2019 SDN上机第2次作业

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

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 )
        L1 = 2

        s = []
       
             
        for i in range( L1 ):
                sw = self.addSwitch( 's{}'.format( i + 1 ) )
                s.append( sw )
	
        
        count = 1
        for sw1 in s:
                for i in range(3):
                	host = self.addHost( 'h{}'.format( count ) )
                	self.addLink( sw1, host )
                	count += 1
	self.addLink(s[0],s[1])
topos = { 'mytopo': ( lambda: MyTopo() ) }


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

  • 对交换机S1端口的配置
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096-\>vlan_vid,output:4
//对S1的端口1 配置局域网fiel为4096 流表出口为端口4 与S2的端口1对应 下面同理
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=2,actions=push_vlan:0x8100,set_field:4097-\>vlan_vid,output:4
//对S1的端口1 配置局域网fiel为4097 流表出口为端口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的端口1 配置局域网fiel为4098 流表出口为端口4
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

  • 对交换机S2端口的配置
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096-\>vlan_vid,output:4
//对S2的端口1配置局域网fiel为4096 流表出口为端口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
//对S2的端口1配置局域网fiel为4097 流表出口为端口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的端口1 配置局域网fiel为4098 流表出口为端口4
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抓包,分析验证特定报文

  • 以h2 ping h5 为例 (vlan标签为4097 即Id为1)
posted @ 2019-11-06 20:04  要什么没用用的名字  阅读(150)  评论(0编辑  收藏  举报