Mininet中文使用教程_第1頁
Mininet中文使用教程_第2頁
Mininet中文使用教程_第3頁
Mininet中文使用教程_第4頁
Mininet中文使用教程_第5頁
已閱讀5頁,還剩20頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、Mininet中文使用教程譯者注:這篇 Blog 是在學(xué)習(xí) SDN 過程中翻譯的Mininet 官方的文檔。文檔主要是介紹了 Mininet 的簡單用法。會(huì)分成幾個(gè)局部放出來,原文。下面是正文第1局部:Everyday Mininet Usage首先是是命令語法· $ 這個(gè)符號(hào)代表現(xiàn)在處于 Linux 的shell 交互下,需要使用的是 Linux 命令· mininet> 這個(gè)符號(hào)表示現(xiàn)在處于 Mininet 交互下,需要使用的是 Mininet 的命令·  這個(gè)符號(hào)表示的是現(xiàn)在處于 Linux 的 root 權(quán)限下。以上相應(yīng)

2、的狀態(tài)下下屬于對(duì)應(yīng)的命令,就能夠得到正常的輸出。需要注意的是mininet>的情況比擬特殊,需要使用 minient 的命令來進(jìn)行交互。Display Startup Options我們首先來啟動(dòng) Mininet。鍵入以下命令來顯示Mininet的幫助信息:$ sudo mn -hUsage: mn options(type mn -h for details)The mn utility creates Mininet network from the command line. It can createparametrized topologies, invoke the Mini

3、net CLI, and run tests.Options:-h, -help show this help message and exit-switch=SWITCH ivs|ovsk|ovsl|user,param=value.-host=HOST cfs|proc|rt,param=value.-controller=CONTROLLERnone|nox|ovsc|ref|remote,param=value.-link=LINK default|tc,param=value.-topo=TOPO linear|minimal|reversed|single|tree,param=v

4、alue.-c, -clean clean and exit-custom=CUSTOM read custom topo and node params from .pyfile-test=TEST cli|build|pingall|pingpair|iperf|all|iperfudp|none-x, -xterms spawn xterms for each node-i IPBASE, -ipbase=IPBASEbase IP address for hosts-mac automatically set host MACs-arp set all-pairs ARP entrie

5、s-v VERBOSITY, -verbosity=VERBOSITYinfo|warning|critical|error|debug|output-innamespace sw and ctrl in namespace?-listenport=LISTENPORTbase port for passive switch listening-nolistenport don't use passive listening port-pre=PRE CLI script to run before tests-post=POST CLI script to run after tes

6、ts-pin pin hosts to CPU cores (requires -host cfs or -hostrt)-version如上所示,輸出了 mn 的幫助信息。Start Wireshark為了使用 Wireshark 來查看 OpenFlow 的控制信息,我們先翻開 Wireshark 并讓他在后臺(tái)運(yùn)行。$ sudo wireshark &在 Wireshark 的過濾選項(xiàng)中,輸入of,然后選擇 Apply。In Wireshark, click Capture, then Interfaces, then select Start on the loopback in

7、terface (lo).現(xiàn)在窗口上暫時(shí)應(yīng)該沒有任何 OpenFlow 的數(shù)據(jù)包。注:在Mininet VM鏡像中Wireshark是默認(rèn)已經(jīng)安裝的。如果你的系統(tǒng)中沒有Wireshark的和OpenFlow,您可以使用Mininet的install.sh腳本,按以下步驟安裝:$ cd $ git clone s:/github /mininet/mininet如果它尚不存在$ mininet/util/install.sh -w如果已經(jīng)安裝了 Wireshark,但是運(yùn)行不了e.g. 你得到一個(gè)類似$DISPLAY not set之類的錯(cuò)誤信息,可以參考 FAQ,: s:/github /mi

8、ninet/mininet/wiki/FAQ#wiki-X11-forwarding設(shè)置好 X11就可以正常運(yùn)行 GUI 程序,并且使用 xterm 之類的終端仿真器了,后面的演示中可以用到。Interact with Hosts and SwitchesStart a minimal topology and enter the CLI:$ sudo mn默認(rèn)的最小拓?fù)浣Y(jié)構(gòu)包含有兩臺(tái)主機(jī)h1,h2,還有一個(gè) OpenFlow 的交換機(jī),一個(gè) OpenFlow 的控制器四臺(tái)設(shè)備。這種拓?fù)浣涌谝部梢允褂?topo=minimal來指定。當(dāng)然我們也可以使用其他的拓?fù)浣Y(jié)構(gòu),具體信息可以看 

9、-topo的信息?,F(xiàn)在四個(gè)實(shí)體h1,h2,c0,s1都在運(yùn)行著。c0作為控制器,是可以放在虛擬機(jī)外部的。如果沒有具體的測試作為參數(shù)傳遞時(shí),我們可以使用 Mininet 交互。在Wireshark的窗口中,你會(huì)看到內(nèi)核交換機(jī)連接到控制器。顯示Mininet CLI命令:mininet> helpDocumented commands (type help <topic>):=EOF exit intfs link noecho pingpair py source xtermdpctl gterm iperf net pingall pingpairfull quit time

10、dump help iperfudp nodes pingallfull px sh xYou may also send a command to a node using: <node> command argsFor example: mininet> h1 ifconfigThe interpreter automatically substitutes IP addressesfor node names when a node is the first arg, so commandslike mininet> h2 ping h3should work.S

11、ome character-oriented interactive commands requirenoecho: mininet> noecho h2 vi foo.pyHowever, starting up an xterm/gterm is generally better: mininet> xterm h2顯示節(jié)點(diǎn):mininet> nodesavailable nodes are:c0 h1 h2 s1顯示網(wǎng)絡(luò)鏈接:mininet> neth1 h1-eth0:s1-eth1h2 h2-eth0:s1-eth2s1 lo: s1-eth1:h1-eth0

12、 s1-eth2:h2-eth0c0輸出所有節(jié)點(diǎn)的信息:mininet> dump<Host h1: h1-eth0:10.0.0.1 pid=3278><Host h2: h2-eth0:10.0.0.2 pid=3279><OVSSwitch s1: lo:127.0.0.1,s1-eth1:None,s1-eth2:None pid=3282><OVSController c0: 127.0.0.1:6633 pid=3268>從上面的輸出中,你可以看到有一臺(tái)交換機(jī)和兩臺(tái)主機(jī)。在 Mininet 的CLI 中第一個(gè)字符串是設(shè)備名,那后

13、面的命令就在該設(shè)備上執(zhí)行。例如我們想在h1設(shè)備上執(zhí)行ifconfig那么輸入如下命令:mininet> h1 ifconfig -ah1-eth0 Link encap:Ethernet HWaddr 3e:94:43:b1:ad:48 inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80:3c94:43ff:feb1:ad48/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:22 errors:0

14、dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1764 (1.7 KB) TX bytes:648 (648.0 B)lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: :1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:

15、0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)上面的輸出中,可以看見 h1-eth0 跟 lo兩個(gè)接口,需要注意的是,在 Linux 系統(tǒng)的 shell 中運(yùn)行ifconfig是看不到h1-eth0。與h1-eth0相反的是,switch 默認(rèn)是跑在 root 的網(wǎng)絡(luò)namespace上面,所

16、以在switch上執(zhí)行命令與在 Linux 下的 shell 中是一樣的。mininet> s1 ifconfig-aeth0 Link encap:Ethernet HWaddr 08:00:27:98:dc:aa inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80:a00:27ff:fe98:dcaa/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46716 errors:0 dropped

17、:0 overruns:0 frame:0 TX packets:40265 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:10804203 (10.8 MB) TX bytes:40122199 (40.1 MB)lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: :1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX p

18、ackets:43654 errors:0 dropped:0 overruns:0 frame:0 TX packets:43654 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:37264504 (37.2 MB) TX bytes:37264504 (37.2 MB)lxcbr0 Link encap:Ethernet HWaddr fe:5e:f0:f7:a6:f3 inet addr:10.0.3.1 Bcast:10.0.3.255 Mask:255.255.255.0 inet

19、6 addr: fe80:a8c4:b5ff:fea6:2809/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:52 errors:0 dropped:0 overruns:0 frame:0 TX packets:20 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4759 (4.7 KB) TX bytes:2952 (2.9 KB)ovs-system Link encap:Ether

20、net HWaddr 3e:79:59:3d:d9:bb BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)s1 Link encap:Ethernet HWaddr 6e:8c:5d:91:d5:44 inet6 addr: fe80:f

21、c47:8aff:fe6a:4155/64 Scope:Link UP BROADCAST RUNNING MTU:1500 Metric:1 RX packets:13 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1026 (1.0 KB) TX bytes:648 (648.0 B)s1-eth1 Link encap:Ethernet HWaddr 5e:a2:f7:86:f3:b1

22、 inet6 addr: fe80:5ca2:f7ff:fe86:f3b1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:22 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:648 (648.0 B) TX bytes:1764 (1.7 KB)s1-eth2 Link encap:E

23、thernet HWaddr b2:c6:37:e0:d9:61 inet6 addr: fe80:b0c6:37ff:fee0:d961/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:21 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:648 (648.0 B) TX bytes:1

24、674 (1.6 KB)veth14524J Link encap:Ethernet HWaddr fe:ca:13:f5:dd:b4 inet6 addr: fe80:fcca:13ff:fef5:ddb4/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:40 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100

25、0 RX bytes:648 (648.0 B) TX bytes:4190 (4.1 KB)veth2K19CE Link encap:Ethernet HWaddr fe:f1:f7:e8:49:45 inet6 addr: fe80:fcf1:f7ff:fee8:4945/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:42 errors:0 dropped:0 overruns:0 ca

26、rrier:0 collisions:0 txqueuelen:1000 RX bytes:648 (648.0 B) TX bytes:4370 (4.3 KB)veth9WSHRK Link encap:Ethernet HWaddr fe:87:1d:33:f6:41 inet6 addr: fe80:fc87:1dff:fe33:f641/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:

27、43 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:648 (648.0 B) TX bytes:4460 (4.4 KB)vethH2K7R5 Link encap:Ethernet HWaddr fe:5e:f0:f7:a6:f3 inet6 addr: fe80:fc5e:f0ff:fef7:a6f3/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:14 errors:0 drop

28、ped:0 overruns:0 frame:0 TX packets:48 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1776 (1.7 KB) TX bytes:5030 (5.0 KB)vethO99MI2 Link encap:Ethernet HWaddr fe:cf:ee:97:fb:7f inet6 addr: fe80:fccf:eeff:fe97:fb7f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500

29、Metric:1 RX packets:14 errors:0 dropped:0 overruns:0 frame:0 TX packets:51 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1767 (1.7 KB) TX bytes:5294 (5.2 KB)上面的輸出中包含交換機(jī)的虛擬網(wǎng)卡 s1,以及主機(jī)的 eth0。為了區(qū)別顯示host 主機(jī)的網(wǎng)絡(luò)是隔離的,我們可以通過arp與route命令來做演示,分別在 s1與h1上面演示如下:mininet> s1 arpAdd

30、ress HWtype HWaddress Flags Mask Ifacelocalhost ether 00:16:3e:54:9c:03 C lxcbr0localhost ether 52:54:00:12:35:02 C eth0localhost ether 52:54:00:12:35:03 C eth0localhost ether 00:16:3e:51:24:a7 C lxcbr0mininet> s1 routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Ifaced

31、efault localhost 0.0.0.0 UG 0 0 0 eth010.0.2.0 * 255.255.255.0 U 0 0 0 eth010.0.3.0 * 255.255.255.0 U 0 0 0 lxcbr0172.17.0.0 * 255.255.0.0 U 0 0 0 docker0mininet> h1 arpmininet> h1 routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface10.0.0.0 * 255.0.0.0 U 0 0 0 h1

32、-eth0這樣可以做到將每一個(gè)主機(jī),交換機(jī),以及控制器都放到他自己的標(biāo)準(zhǔn)的 network namespace 中,但是這種做法并沒有什么特別的優(yōu)勢,除非你想復(fù)制一個(gè)非常復(fù)雜的網(wǎng)絡(luò)。Mininet 不支持這種做法,你可以通過-innamespace參數(shù)來查看更多的信息。譯者注:感覺有點(diǎn)像 LXC 或者說想最近比擬火的 Docker注意:只有網(wǎng)絡(luò)是虛擬出來的,每一個(gè)主機(jī)里面的進(jìn)程使用的都是同一套目錄,可以看到相同的進(jìn)程集合,我們打印不同主機(jī)下面的進(jìn)程列表看看:mininet> h1 ps -a PID TTY TIME CMD 3899 pts/3 00:00:00 tmux 4000 p

33、ts/23 00:00:00 sudo 4001 pts/23 00:00:51 wireshark 4030 pts/23 00:00:00 dbus-launch 4530 pts/23 00:00:43 dumpcap 4541 pts/22 00:00:00 sudo 4542 pts/22 00:00:00 mnmininet> h2 ps -a PID TTY TIME CMD 3899 pts/3 00:00:00 tmux 4000 pts/23 00:00:00 sudo 4001 pts/23 00:00:52 wireshark 4030 pts/23 00:00:

34、00 dbus-launch 4530 pts/23 00:00:43 dumpcap 4541 pts/22 00:00:00 sudo 4542 pts/22 00:00:00 mnmininet> s1 ps -a PID TTY TIME CMD 3899 pts/3 00:00:00 tmux 4000 pts/23 00:00:00 sudo 4001 pts/23 00:00:54 wireshark 4030 pts/23 00:00:00 dbus-launch 4530 pts/23 00:00:46 dumpcap 4541 pts/22 00:00:00 sudo

35、 4542 pts/22 00:00:00 mn如上所示, h1,h2,s1三個(gè)進(jìn)程列表是完全相同的。其實(shí)完全可以做到各個(gè)主機(jī)完全獨(dú)立,就想 LXC 那樣,但是目前 Mininet 并沒有這么做。在 Mininet 中所有的進(jìn)程都放在 root 下面,這樣你可以在 Linux的 shell 中直接用kill或者ps這些命令查看或者殺死進(jìn)程。Test connectivity between hosts現(xiàn)在,驗(yàn)證您可以h1 ping 通 h2:mininet> h1 ping h2 -c 1PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.64 b

36、ytes from 10.0.0.2: icmp_seq=1 ttl=64 time=8.57 ms- 10.0.0.2 ping statistics -1 packets transmitted, 1 received, 0% packet loss, time 0msrtt min/avg/max/mdev = 8.576/8.576/8.576/0.000 msmininet中的命令語法如上所示。host1 command host2。在 Wireshark 中可以看到 OpenFlow 的控制流量,可以看到h1 ARPs h2的 mac,并將一個(gè) packet_in發(fā)送到&

37、#160;c0,然后c0發(fā)送packet_out消息流播送到交換機(jī)在本例中,唯一的其他數(shù)據(jù)端口。第二個(gè)主機(jī)接受到的ARP請(qǐng)求,并發(fā)送一個(gè)播送答復(fù)。此回復(fù)進(jìn)到控制器,該控制器將其發(fā)送到h1并且 pushes down a flow entry?,F(xiàn)在第一主機(jī)知道的第二個(gè)IP地址,并且可以通過ICMP ping 來回顯請(qǐng)求。這個(gè)請(qǐng)求,連同其從第二主機(jī)對(duì)應(yīng)的應(yīng)答,both go the controller and result in a flow entry pushed down (along with the actual packets getting sent out).重復(fù)前一條命令:mi

38、ninet> h1 ping -c 1 h2這次 ping 的時(shí)間將比第一次低的多, A flow entry covering ICMP ping traffic was previously installed in the switch, so no control traffic was generated, and the packets immediately pass through the switch.使用pingall命令可以讓每一個(gè)節(jié)點(diǎn)直接都產(chǎn)生上面的效果。mininet> pingallRun a simple web server and client我們

39、不單可以在主機(jī)上面運(yùn)行ping命令,每一條 Linux下的命令或者程序都可以在 Mininet 中運(yùn)行:接下來,嘗試開始于h1啟動(dòng)一個(gè)簡單的 效勞器上,然后從h2發(fā)出請(qǐng)求,最后關(guān)閉Web效勞器:mininet> h1 python -m Simple Server 80 &mininet> h2 wget h1-2021-09-15 08:10:11- :/10.0.0.1/Connecting to 10.0.0.1:80. connected. request sent, awaiting response. 200 OKLength: 2647 (2.6K) text

40、/htmlSaving to: index.html 0K . 100% 71.7M=0s2021-09-15 08:10:11 (71.7 MB/s) - index.html saved 2647/2647mininet> h1 kill %python退出mininet交互命令:mininet>exitcleanup如果Mininet出于某種原因崩潰,可以用下面命令來清理:sudo mn -cPart 2: 高級(jí)選項(xiàng)Advanced Startup Options回歸測試Run a Regression TestMininet 可以用于直接運(yùn)行回歸測試,不一定要切換到他的 C

41、LI 下面。運(yùn)行回歸測試:$ sudo mn -test pingpair這條命令會(huì)創(chuàng)立一個(gè)小的拓?fù)浣Y(jié)構(gòu),然后啟動(dòng) OpenFLow 的控制器,然后跑 ping 測試,最后再把拓?fù)浣Y(jié)構(gòu)跟控制器關(guān)掉。另一種有用的試驗(yàn)是iperf的給它約10秒來完成:還有一直常用的測試是iperf(完成這個(gè)測試大概需要10s 鐘):$ sudo mn -test iperf此命令創(chuàng)立的相同Mininet,并在其中一臺(tái) host 上面跑 iperf server, 然后在另外一臺(tái) host 上面運(yùn)行iperf client 然后解析取得帶寬情況。更改拓?fù)浣Y(jié)構(gòu)大小和類型 Changing Topology Size

42、and TypeMininet 默認(rèn)的拓?fù)浣Y(jié)構(gòu)是由兩臺(tái) host 以及一臺(tái)交換機(jī)組成的,你可以用-topo參數(shù)來更改拓?fù)浣Y(jié)構(gòu)。假設(shè)你要在一個(gè)交換機(jī)與三臺(tái) host 之間做 ping 探測驗(yàn)證verify all-pairs ping connectivity。:運(yùn)行回歸測試:$ sudo mn -test pingall -topo single,3另一個(gè)例子中,使用線性拓?fù)淦渲忻總€(gè)交換機(jī)配有一個(gè)主機(jī),并且所有的交換機(jī)連接在一起:$ sudo mn -test pingall -topo linear,4課喲用參數(shù)來控制拓?fù)浣Y(jié)構(gòu)是 Mininet 中最有用的功能之一,非常強(qiáng)大。鏈路變化 Lin

43、k variationsMininet2.0允許你設(shè)置連接參數(shù),甚至可以通過命令行實(shí)現(xiàn)自動(dòng)化設(shè)置:$ sudo mn -link tc,bw=10,delay=10ms mininet> iperf . mininet> h1 ping -c10 h2上面的設(shè)置每兩個(gè)節(jié)點(diǎn)之間的延遲是10ms,因?yàn)?ICMP 請(qǐng)求傳過了兩條鏈路一次是到大交換機(jī),一次到達(dá)主機(jī),往返時(shí)間RRT就應(yīng)該是40ms。你還可以使用 PythonAPI 來做更多的事兒,不過現(xiàn)在我們先繼續(xù)往下演練。調(diào)整輸出信息Adjustable VerbosityMininet默認(rèn)輸出信息的級(jí)別是 

44、Info,Info級(jí)別會(huì)輸出 Mininet的詳細(xì)信息。我們也可以通過 -v參數(shù)來設(shè)置輸出DEBUG信息。$ sudo mn -v debug.mininet> exit這樣會(huì)打印出更多額外的細(xì)節(jié)?,F(xiàn)在嘗試一下output參數(shù),這樣可以在 CLI 中打印更少的信息。$ sudo mn -v outputmininet> exit除了上面的幾個(gè)級(jí)別,還有其他的級(jí)別可以使用,比方warning等Custom Topologies自定義拓?fù)浣Y(jié)構(gòu)在custom/topo-2sw-2host.py中是一個(gè)例子可以拿來參考,我們可以看到通過 PythonAPI 我們可以很簡單的來定義

45、拓?fù)浣Y(jié)構(gòu)。這個(gè)例子直接連接兩臺(tái)交換機(jī),每個(gè)交換機(jī)帶有一臺(tái)主機(jī)。"""Custom topology exampleTwo directly connected switches plus a host for each switch: host - switch - switch - hostAdding the 'topos' dict with a key/value pair to generate our newly definedtopology enables one to pass in '-topo=mytopo'

46、from the command line."""from mininet.topo import Topoclass MyTopo( Topo ): "Simple topology example." def _init_( self ): "Create custom topo." # Initialize topology Topo._init_( self ) # Add hosts and switches leftHost = self.addHost( 'h1' ) rightHost = s

47、elf.addHost( 'h2' ) leftSwitch = self.addSwitch( 's3' ) rightSwitch = self.addSwitch( 's4' ) # Add links self.addLink( leftHost, leftSwitch ) self.addLink( leftSwitch, rightSwitch ) self.addLink( rightSwitch, rightHost )topos = 'mytopo': ( lambda: MyTopo() ) 我們提供一個(gè)自定義

48、的mininet 文件,就可以創(chuàng)立新的拓?fù)浣Y(jié)構(gòu)、交換機(jī)類型。我們?cè)诿钚欣锩鏈y試一下:$ sudo mn -custom /mininet/custom/topo-2sw-2host.py -topo mytopo -test pingall* Creating network* Adding controller* Adding hosts:h1 h2* Adding switches:s3 s4* Adding links:(h1, s3) (h2, s4) (s3, s4)* Configuring hostsh1 h2* Starting controller* Starting 2

49、switchess3 s4* Ping: testing ping reachabilityh1 -> h2h2 -> h1* Results: 0% dropped (2/2 received)* Stopping 2 switchess3 .s4 .* Stopping 2 hostsh1 h2* Stopping 1 controllersc0* Donecompleted in 1.220 secondsID= MAC默認(rèn)情況下,host 的 mac 地址是隨機(jī)分配的。這會(huì)導(dǎo)致每次 mininet 創(chuàng)立的時(shí)候,MAC地址都會(huì)改變,這會(huì)給調(diào)試帶來一些困難-mac參數(shù)可以解決上

50、面的問題,栗子如下:之前:$ sudo mnmininet> h1 ifconfigh1-eth0 Link encap:Ethernet HWaddr c2:d9:4a:37:25:17 inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80:c0d9:4aff:fe37:2517/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:17 errors:0 dropped:0 overruns:0 fra

51、me:0 TX packets:7 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1398 (1.3 KB) TX bytes:578 (578.0 B)lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: :1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 ove

52、rruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)使用-mac參數(shù):$ sudo mn -macmininet> h1 ifconfigh1-eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:01 inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80:200:ff:fe00:1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:17 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 colli

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論