2019 SDN上机第2次作业

匆匆过客 提交于 2019-12-03 21:16:15

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

  • Python代码:
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import RemoteController,CPULimitedHost
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
 
class MyTopo( Topo ):
    "Simple topology example."
 
    def __init__( self ):
        "Create custom topo."
 
        Topo.__init__( self )
    switchs = []
        for i in range(2):
            sw = self.addSwitch("s{}".format(i + 1))
            switchs.append(sw)
    
    self.addLink(switchs[0], switchs[1],4,4)    

    count = 1
        for sw in switchs:
            for i in range(3):
                h = self.addHost("h{}".format(count))
                self.addLink(sw, h,i+1,1)
                count += 1
        
topos = { 'mytopo': ( lambda: MyTopo() ) }
  • 结果:
  • 端口连接情况:

    2. 直接在Open vSwitch下发流表,实现如下连通性要求,请逐条说明所下发的流表含义

    • h1 -- h4互通
    • h2 -- h5互通
    • h3 -- h6互通
    • 其余主机不通

    将h1,h2,h3进入s1的包打上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

    将从端口4的包去除vlan tag, 根据tag进行转发

    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:3

    将h4,h5,h6进入s2的包打上vlan tag,转发端口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
    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

    将从端口4的包去除vlan tag, 并根据tag进行转发

    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命令执行结果

    • 查看流表

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

      • 测试结果

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

        • 含有tag标签的报文
        posted @ 2019-11-06 23:00 方道友 阅读(...) 评论(...) 编辑 收藏
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!