1. 利用mininet创建如下拓扑,要求拓扑支持OpenFlow 1.3协议,主机名、交换机名以及端口对应正确,请给出拓扑Mininet执行结果,展示端口连接情况
创建名为SecondTime的py文件
from mininet.topo import Topo
class Mytopo(Topo):
def __init__(self):
Topo.__init__(self)
s=[]
for i in range(2):
sw = self.addSwitch('s{}'.format(i+1))
s.append(sw)
self.addLink(s[0],s[1]) /*连接两个表*/
count=1
for two in s: /*在整个列表内循环创建*/
for i in range(3):
host = self.addHost('h{}'.format(count))
self.addLink(two,host)
count += 1
topos = {'mytopo': (lambda:Mytopo())}
输入命令执行文件创建拓扑
sudo mn --custom SecondTime.py --topo mytopo --switch ovsk,protocols=OpenFlow13
输入net查看端口情况,再输入pingall查看目前连通情况
2. 直接在Open vSwitch下发流表,用vlan得到下列虚拟网段,请逐条说明所下发的流表含义
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=2,actions=push_vlan:0x8100,set_field:4096->vlan_vid,output:1
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4097->vlan_vid,output:1
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=4,actions=push_vlan:0x8100,set_field:4098->vlan_vid,output:1
//让主机1,2,3进入交换机1的包打上vlan_tag转发到端口1
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=0,actions=pop_vlan,output:2
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=1,actions=pop_vlan,output:3
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=2,actions=pop_vlan,output:4
//将从端口1得到的包去除vlan_tag并依据tag转发到端口2,3,4
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=2,actions=push_vlan:0x8100,set_field:4096->vlan_vid,output:1
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4097->vlan_vid,output:1
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=4,actions=push_vlan:0x8100,set_field:4098->vlan_vid,output:1
//让主机4,5,6进入交换机2的包打上vlan_tag转发到端口1
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=0,actions=pop_vlan,output:2
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=1,actions=pop_vlan,output:3
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=2,actions=pop_vlan,output:4
//将从端口1得到的包去除vlan_tag并依据tag转发到端口2,3,4
3. 直接在Open vSwitch查看流表,提交OVS命令执行结果
输入以下命令查看流表
sudo ovs-ofctl -O OpenFlow13 dump-flows s1
sudo ovs-ofctl -O OpenFlow13 dump-flows s2
4. 提交主机连通性测试结果,验证流表的有效性
再次输入pingall,效果如下
5. 利用Wireshark抓包,分析验证特定报文
选择S1-eth2抓取报文