編寫如下python指令碼後執行,得到與預期埠號相符的網路拓撲:
#!/usr/bin/python
#creating inernet topo
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):
def __init__(self):
#initialize topology
topo.__init__(self)
l1 = 2
l3 = 3
c =
#add core ovs
for i in range(l1):
sw = self.addswitch('s{}'.format(i+1))
#add hosts
count = 1
for sw1 in c:
for i in range(0, 3):
host = self.addhost('h{}'.format(count))
count+=1
self.addlink(sw1,host,i+1,1)
#add links
sw3=c[0]
sw4=c[1]
self.addlink(sw3,sw4,4,4)
topos =
執行以下**建立拓撲:sudo mn -custom 2.1.py --topo mytopo --switch ovsk,protocols=openflow13
pingall測試主機連通性:![](https://pic.w3help.cc/3e4/e3ee9b983f353af78aea9d9ad6ec5.jpeg)
實現:
步驟:
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
將接收到的資料報去除vlan_tag,根據資料報的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:3
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
將接收到的資料報去除vlan_tag,根據資料報的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
輸入命令:sudo ovs-ofctl -o openflow13 dump-flows s1
sudo ovs-ofctl -o openflow13 dump-flows s2
![](https://pic.w3help.cc/f6a/d3f3303936921f10184d591a17b8f.jpeg)
輸入命令:
sudo wireshark &
開啟介面,選擇s1的4埠進行抓包:
2019 SDN上機第2次作業
利用mininet建立如下拓撲,要求拓撲支援openflow 1.3協議,主機名 交換機名以及埠對應正確,請給出拓撲mininet執行結果,展示埠連線情況 直接在open vswitch下發流表,用vlan得到下列虛擬網段,請逐條說明所下發的流表含義 s1 sudo ovs ofctl add fl...
2019 SDN上機第2次作業
h1 h4互通 h2 h5互通 h3 h6互通 其餘主機不通 將主機1,2,3進入s1的包打上vlan tag,埠4 sudo ovs ofctl o openflow13 add flow s1 priority 1,in port 1,actions push vlan 0x8100,set f...
2019 SDN上機第2次作業
編寫如下python指令碼後執行,得到與預期埠號相符的網路拓撲。此時進行連通測試,初始狀態兩方區域無法通訊,交換機無 表資訊 流表 當前網路拓撲狀態無法進行通訊,因此無法利用tcp,ip等繫結手段新增流表,這裡下發流表採用vlan功能來實現通訊。sudo ovs ofctl o openflow13...