1. 利用mininet创建如下拓扑,要求拓扑支持OpenFlow 1.3协议,主机名、交换机名以及端口对应正确,请给出拓扑Mininet执行结果,展示端口连接情况
答:创建拓扑的方法有两种:一种是使用python代码编写拓扑的方式,另外一种是用miniedit创建拓扑。在本次实验中使用miniedit的方式。截图如下:
- python代码如下:
from mininet.topo import Topo
class Topo2( Topo ):
def init( self ):
Topo.__init__( self )
s1 = self.addSwitch('s1')
s2 = 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,s1,1,1)
self.addLink(h2,s1,1,2)
self.addLink(h3,s1,1,3)
self.addLink(h4,s2,1,1)
self.addLink(h5,s2,1,2)
self.addLink(h6,s2,1,3)
self.addLink(s1,s2,4,4)
topos = { 'mytopo': ( lambda: Topo2() ) }
2. 直接在Open vSwitch下发流表,用vlan得到下列虚拟网段,请逐条说明所下发的流表含义
h1 -- h4互通
h2 -- h5互通
h3 -- h6互通
其余主机不通
答:
s1:
- 使用如下OVS命令实现s1接收从主机1.2.3传来的包打上vlan tag标签,并从端口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
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=2,actions=push_vlan:0x8100,set_field:4097->vlan_vid,output: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 s1将接收到的数据包去除vlan tag,然后根据dl_vlan(数据包原始的vlan_id),向指定端口转发
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=0,actions=pop_vlan,output:1
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=1,actions=pop_vlan,output:2
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=2,actions=pop_vlan,output:3s2:
- s2将从端口号为4.5.6的主机发来的数据贴上相同的vlan tag,然后从4端口发往s1(vlan_id从0开始)
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096->vlan_vid,output: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
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4098->vlan_vid,output:4 - s2将接收到的数据包去除vlan tag,然后根据dl_vlan(数据包原始的vlan_id),向指定端口转发
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=0,actions=pop_vlan,output:1
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=1,actions=pop_vlan,output:2
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=2,actions=pop_vlan,output:3 终端输入命令:
3. 直接在Open vSwitch查看流表,提交OVS命令执行结果
- 查看s1的流表的OVS命令:sudo ovs-ofctl -O OpenFlow13 dump-flows s1
- 查看s2的流表的OVS命令:sudo ovs-ofctl -O OpenFlow13 dump-flows s2
4. 提交主机连通性测试结果,验sudo wireshark流表的有效性
- 使用pingall命令查看连通性
- 截图如下:
5. 利用Wireshark抓包,分析验证特定报文
- 进入抓包工具的命令:sudo wireshark
- 使用pingall命令进行发包操作
- 报文抓取,结果如下