1.利用mininet创建如下拓扑,要求拓扑支持OpenFlow 1.3协议,主机名、交换机名以及端口对应正确,请给出拓扑Mininet执行结果,展示端口连接情况
python代码
from mininet.topo import Topo class MyTopo( Topo ): "Simple topology example." def __init__( self ): Topo.__init__(self) sw1 = self.addSwitch('s1') sw2 = self.addSwitch('s2') h1 = self.addHost('h1') h2 = self.addHost('h2') h3 = self.addHost('h3') h4 = self.addHost('h4') h5 = self.addHost('h5') h6 = self.addHost('h6') self.addLink(h1,sw1,1,1) self.addLink(h2,sw1,1,2) self.addLink(h3,sw1,1,3) self.addLink(sw1,sw2,4,4) self.addLink(h4,sw2,1,1) self.addLink(h5,sw2,1,2) self.addLink(h6,sw2,1,3) topos = { 'mytopo': ( lambda: MyTopo() ) }
(1)运行下列命令,创建拓扑:sudo mn --custom test2.py --topo mytopo --switch ovsk,protoclols=OpenFlow13
(2)使用net命令查看拓扑:
(3)使用pingall命令查看连通性
2.直接在Open vSwitch下发流表,用vlan得到下列虚拟网段,请逐条说明所下发的流表含义
(1)使用如下OVS命令实现s1接收从h1、h2和h3传来的包,并从端口4发出
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096-\>vlan_vid,output:4//将h1进入s1的包打上vlan tag,从端口4发出 sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=2,actions=push_vlan:0x8100,set_field:4097-\>vlan_vid,output:4//将h2进入s1的包打上vlan tag,从端口4发出 sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4098-\>vlan_vid,output:4//将h3进入s1的包打上vlan tag,从端口4发出
(2)使用如下OVS命令实现s2接收从h4、h5和h6传来的包,并从端口4发出
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096-\>vlan_vid,output:4//将h4进入s2的包打上vlan tag,从端口4发出 sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=2,actions=push_vlan:0x8100,set_field:4097-\>vlan_vid,output:4//将h5进入s2的包打上vlan tag,从端口4发出 sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4098-\>vlan_vid,output:4//将h6进入s2的包打上vlan tag,从端口4发出
(3)使用如下OVS命令实现s1接收从端口4传来的包,并从端口1、2、3分别发给h1、h2、h3
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=0,actions=pop_vlan,output:1//将从端口4的包去除vlan tag, 并根据tag进行转发端口1 sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=1,actions=pop_vlan,output:2//将从端口4的包去除vlan tag, 并根据tag进行转发端口2 sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=2,actions=pop_vlan,output:3//将从端口4的包去除vlan tag, 并根据tag进行转发端口3
(4)使用如下OVS命令实现s2接收从端口4传来的包,并从端口1、2、3分别发给h1、h2、h3
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=0,actions=pop_vlan,output:1//将从端口4的包去除vlan tag, 并根据tag进行转发端口1 sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=1,actions=pop_vlan,output:2//将从端口4的包去除vlan tag, 并根据tag进行转发端口2 sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=2,actions=pop_vlan,output:3//将从端口4的包去除vlan tag, 并根据tag进行转发端口3
(5)
3.直接在Open vSwitch查看流表,提交OVS命令执行结果
(1)使用下列OVS命令查看的流表
s1流表
s2流表
4.提交主机连通性测试结果,验证流表的有效性
验证流表连通性
5.利用Wireshark抓包,分析验证特定报文
(1)使用下列命令进入抓包工具
sudo wireshark
(2)使用pingall命令进行发包操作
(3)选择s1-eth4端口进行报文抓取,结果如下