2019SDN上机第2次作业

SDN上机第2次作业

1. 利用mininet创建如下拓扑,要求拓扑支持OpenFlow 1.3协议,主机名、交换机名以及端口对应正确,请给出拓扑Mininet执行结果,展示端口连接情况

2019SDN上机第2次作业_第1张图片

创建名为test.py的文件
代码

class Topotest( Topo ):
    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: Topotest() ) }

输入命令执行文件创建拓扑

sudo mn --custom test.py --topo mytopo --switch ovsk,protocols=OpenFlow13

然后pingall
2019SDN上机第2次作业_第2张图片

2. 直接在Open vSwitch下发流表,用vlan得到下列虚拟网段,请逐条说明所下发的流表含义

sw1

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

sw2

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

2019SDN上机第2次作业_第3张图片

3. 直接在Open vSwitch查看流表,提交OVS命令执行结果

输入以下命令查看流表

 sudo ovs-ofctl -O OpenFlow13 dump-flows s1 
 sudo ovs-ofctl -O OpenFlow13 dump-flows s2

2019SDN上机第2次作业_第4张图片

4. 提交主机连通性测试结果,验证流表的有效性

回到原终端pingall
2019SDN上机第2次作业_第5张图片

5. 利用Wireshark抓包,分析验证特定报文

启动

sudo wireshark

2019SDN上机第2次作业_第6张图片
2019SDN上机第2次作业_第7张图片

你可能感兴趣的:(2019SDN上机第2次作业)