1. 程式人生 > >Mininet(輕量級軟件定義網絡和測試平臺) 之二

Mininet(輕量級軟件定義網絡和測試平臺) 之二

mininet

Mininet-2

進行回歸測試 mn --test

透過 --test可以對建立的拓樸進行測試

pingpair則可以測試主機之間連線是否正常(Ping between first two hosts, useful for testing)

root@parallels-vm:~# mn --test pingpair
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 
*** Adding switches:
s1 
*** Adding links:
(h1, s1) (h2, s1) 
*** Configuring hosts
h1 h2 
*** Starting controller
c0 
*** Starting 1 switches
s1 ...
*** Waiting for switches to connect
s1 
h1 -> h2 
h2 -> h1 
*** Results: 0% dropped (2/2 received)
*** Stopping 1 controllers
c0 
*** Stopping 2 links
..
*** Stopping 1 switches
s1 
*** Stopping 2 hosts
h1 h2 
*** Done
completed in 5.681 seconds

iperf(Simple iperf TCP test between two (optionally specified) hosts.Usage: iperf node1 node2)

root@parallels-vm:~# mn --test iperf
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 
*** Adding switches:
s1 
*** Adding links:
(h1, s1) (h2, s1) 
*** Configuring hosts
h1 h2 
*** Starting controller
c0 
*** Starting 1 switches
s1 ...
*** Waiting for switches to connect
s1 
*** Iperf: testing TCP bandwidth between h1 and h2 
.*** Results: [‘36.3 Gbits/sec‘, ‘36.3 Gbits/sec‘]
*** Stopping 1 controllers
c0 
*** Stopping 2 links
..
*** Stopping 1 switches
s1 
*** Stopping 2 hosts
h1 h2 
*** Done
completed in 10.987 seconds

用參數調整拓樸--topo

--topo=TOPO           linear|minimal|reversed|single|torus|tree[,param=value
                        ...] linear=LinearTopo torus=TorusTopo tree=TreeTopo
                        single=SingleSwitchTopo
                        reversed=SingleSwitchReversedTopo minimal=MinimalTopo

single

single 指的是單個,這類的拓樸只有一個交換機(Switch),而主機個數可以任意指定,拓樸成星型

技術分享圖片

root@parallels-vm:~# mn --topo=single,3
*** 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
c0 
*** Starting 1 switches
s1 ...
*** Starting CLI:
mininet> net
h1 h1-eth0:s1-eth1
h2 h2-eth0:s1-eth2
h3 h3-eth0:s1-eth3
s1 lo:  s1-eth1:h1-eth0 s1-eth2:h2-eth0 s1-eth3:h3-eth0
c0

linear

linear指的是直線, 一個交換機配一個主機,而主機和交換機的個數可以任意指定,拓樸形狀成直線型
技術分享圖片

root@parallels-vm:~# mn --topo=linear,3
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 
*** Adding switches:
s1 s2 s3 
*** Adding links:
(h1, s1) (h2, s2) (h3, s3) (s2, s1) (s3, s2) 
*** Configuring hosts
h1 h2 h3 
*** Starting controller
c0 
*** Starting 3 switches
s1 s2 s3 ...
*** Starting CLI:
mininet> net
h1 h1-eth0:s1-eth1
h2 h2-eth0:s2-eth1
h3 h3-eth0:s3-eth1
s1 lo:  s1-eth1:h1-eth0 s1-eth2:s2-eth2
s2 lo:  s2-eth1:h2-eth0 s2-eth2:s1-eth2 s2-eth3:s3-eth2
s3 lo:  s3-eth1:h3-eth0 s3-eth2:s2-eth3
c0

tree

tree指的是樹,這類的拓樸形狀成樹狀,交換機成樹狀分散開來,樹的最下面一層掛兩臺主機
技術分享圖片

root@parallels-vm:~# mn --topo=tree,3
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4 h5 h6 h7 h8 
*** Adding switches:
s1 s2 s3 s4 s5 s6 s7 
*** Adding links:
(s1, s2) (s1, s5) (s2, s3) (s2, s4) (s3, h1) (s3, h2) (s4, h3) (s4, h4) (s5, s6) (s5, s7) (s6, h5) (s6, h6) (s7, h7) (s7, h8) 
*** Configuring hosts
h1 h2 h3 h4 h5 h6 h7 h8 
*** Starting controller
c0 
*** Starting 7 switches
s1 s2 s3 s4 s5 s6 s7 ...
*** Starting CLI:
mininet> net
h1 h1-eth0:s3-eth1
h2 h2-eth0:s3-eth2
h3 h3-eth0:s4-eth1
h4 h4-eth0:s4-eth2
h5 h5-eth0:s6-eth1
h6 h6-eth0:s6-eth2
h7 h7-eth0:s7-eth1
h8 h8-eth0:s7-eth2
s1 lo:  s1-eth1:s2-eth3 s1-eth2:s5-eth3
s2 lo:  s2-eth1:s3-eth3 s2-eth2:s4-eth3 s2-eth3:s1-eth1
s3 lo:  s3-eth1:h1-eth0 s3-eth2:h2-eth0 s3-eth3:s2-eth1
s4 lo:  s4-eth1:h3-eth0 s4-eth2:h4-eth0 s4-eth3:s2-eth2
s5 lo:  s5-eth1:s6-eth3 s5-eth2:s7-eth3 s5-eth3:s1-eth2
s6 lo:  s6-eth1:h5-eth0 s6-eth2:h6-eth0 s6-eth3:s5-eth1
s7 lo:  s7-eth1:h7-eth0 s7-eth2:h8-eth0 s7-eth3:s5-eth2
c0

minimal

minimal指的是最小,也是mininet默認的拓樸,為一個交換機連接兩個主機

root@parallels-vm:~# mn --topo=minimal
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 
*** Adding switches:
s1 
*** Adding links:
(h1, s1) (h2, s1) 
*** Configuring hosts
h1 h2 
*** Starting controller
c0 
*** Starting 1 switches
s1 ...
*** Starting CLI:
mininet> net
h1 h1-eth0:s1-eth1
h2 h2-eth0:s1-eth2
s1 lo:  s1-eth1:h1-eth0 s1-eth2:h2-eth0
c0

--mac

創建mininer時默認會給每一個設備(host,switch等..)分配一個MAC位址,但每一次分配的mac位置都會隨之改變,調適難度較大。 --mac就是保證mac位置簡單易懂。

尚未調適過的:

mininet> h1 ifconfig | grep HWaddr
h1-eth0   Link encap:Ethernet  HWaddr 8e:43:77:2e:47:c9 

加入--mac

mininet> h1 ifconfig | grep HWaddr
h1-eth0   Link encap:Ethernet  HWaddr 00:00:00:00:00:01

開啟各別主機的 terminalxterm

mn -x會在開啟mininet時,將各個設備的terminal打開
若要針對單一個設備打開xtrem,便在開啟拓樸後,執行xterm (設備)

Mininet(輕量級軟件定義網絡和測試平臺) 之二