mininet

以vm建置
http://mininet.org/vm-setup-notes/


測試

建立環境
#sudo mn
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1)
*** Configuring hosts
h1 h2
*** Starting controller
*** Starting 1 switches
s1
*** Starting CLI:
mininet>

關閉環境
mininet> exit

…………………………………………………………………………….

常用指令

顯示資訊
Display nodes
mininet> nodes
Display links
mininet> net
Dump information about all nodes
mininet> dump

網路指令
顯示設備資訊
mininet> h1 ps -a
mininet> s1 ifconfig -a

網路測試
ping from host 0 to host 1:
mininet> h1 ping -c 1 h2
ping全部
mininet> pingall
建立web並測試是否能讀取web
mininet> h1 python -m SimpleHTTPServer 80 &
mininet> h2 wget h1
ps:
mininet> h1 kill %python

ps:
查看switch上的flow entry
dpctl dump-flows


…………………………………………………………………………………………………..


建立openflow環境

相關參數
–controller=remote,ip=< ip> 指定controller和ip
–topo tree,3 建立三層架構
–topo linear,4 建立四台switch並連成一條線,每個switch各連一台主機
–topo single,3 建立三台主機連接到switch
–switch ovsk 指定使用ovsk(open vswitch)的switch
ex:
#sudo mn –topo single,3 –switch ovsk –controller=remote,ip=10.1.2.151
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1) (h3, s1)
*** Configuring hosts
h1 h2 h3
*** Starting controller
*** Starting 1 switches
s1
*** Starting CLI:

… 


在flooding下
mininet> h1 ping h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_req=1 ttl=64 time=2.27 ms
64 bytes from 10.0.0.2: icmp_req=2 ttl=64 time=0.054 ms
ps:
因為floodlight在啟動時自動載入模組net.floodlightcontroller.forwarding.Forwarding,所以預吺會互通

… 

在opendaylight下
測試1,會出現失敗訊息
mininet> h1 ping h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
From 10.0.0.1 icmp_seq=1 Destination Host Unreachable
From 10.0.0.1 icmp_seq=2 Destination Host Unreachable

需另外增加以下兩行
#dpctl add-flow tcp:127.0.0.1:6634 in_port=1,idle_timeout=360,actions=output:2
#dpctl add-flow tcp:127.0.0.1:6634 in_port=2,idle_timeout=360,actions=output:1
確認flow以加入openvswtich中
#dpctl dump-flows tcp:127.0.0.1:6634
stats_reply (xid=0x7383ebfc): flags=none type=1(flow)
cookie=0, duration_sec=82s, duration_nsec=22000000s, table_id=0, priority=32768, n_packets=9, n_bytes=770, idle_timeout=360,hard_timeout=0,in_port=1,actions=output:2
cookie=0, duration_sec=77s, duration_nsec=67000000s, table_id=0, priority=32768, n_packets=9, n_bytes=770, idle_timeout=360,hard_timeout=0,in_port=2,actions=output:1

測試2,因為有符合的flow,所以可以到達另一邊
mininet> h1 ping h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_req=1 ttl=64 time=2.27 ms
64 bytes from 10.0.0.2: icmp_req=2 ttl=64 time=0.054 ms