2019SDN上機第2次作業

2022-06-03 20:00:10 字數 3115 閱讀 3804

建立名為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 =

輸入命令執行檔案建立拓撲

sudo mn --custom test.py --topo mytopo --switch ovsk,protocols=openflow13
然後pingall

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

輸入以下命令檢視流表

回到原終端pingall

啟動

sudo wireshark

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...