




已阅读5页,还剩19页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第1部分:everyday mininet usage首先是是命令语法 $这个符号代表现在处于 linux 的shell 交互下,需要使用的是 linux 命令 mininet这个符号表示现在处于 mininet 交互下,需要使用的是 mininet 的命令 这个符号表示的是现在处于 linux 的 root 权限下。以上相应的状态下下属于对应的命令,就能够得到正常的输出。需要注意的是mininet的情况比较特殊,需要使用 minient 的命令来进行交互。display startup options我们首先来启动 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 mininet 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=value.-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 entries-v verbosity, -verbosity=verbosityinfo|warning|critical|error|debug|output-innamespace sw and ctrl in namespace?-listenport=listenportbase port for passive switch listening-nolistenport dont use passive listening port-pre=pre cli script to run before tests-post=post cli script to run after tests-pin pin hosts to cpu cores (requires -host cfs or -hostrt)-version如上所示,输出了 mn 的帮助信息。start wireshark为了使用 wireshark 来查看 openflow 的控制信息,我们先打开 wireshark 并让他在后台运行。$ sudo wireshark &在 wireshark 的过滤选项中,输入of,然后选择 apply。in wireshark, click capture, then interfaces, then select start on the loopback interface (lo).现在窗口上暂时应该没有任何 openflow 的数据包。注:在mininet vm镜像中wireshark是默认已经安装的。如果你的系统中没有wireshark的和openflow,您可以使用mininet的install.sh脚本,按以下步骤安装:$ cd $ git clone /mininet/mininet如果它尚不存在$ mininet/util/install.sh -w如果已经安装了 wireshark,但是运行不了(e.g. 你得到一个类似$display not set之类的错误信息,可以参考 faq,:/mininet/mininet/wiki/faq#wiki-x11-forwarding)设置好 x11就可以正常运行 gui 程序,并且使用 xterm 之类的终端仿真器了,后面的演示中可以用到。interact with hosts and switchesstart a minimal topology and enter the cli:$ sudo mn默认的最小拓扑结构包含有两台主机(h1,h2),还有一个 openflow 的交换机,一个 openflow 的控制器四台设备。这种拓扑接口也可以使用-topo=minimal来指定。当然我们也可以使用其他的拓扑结构,具体信息可以看-topo的信息。现在四个实体(h1,h2,c0,s1)都在运行着。c0作为控制器,是可以放在虚拟机外部的。如果没有具体的测试作为参数传递时,我们可以使用 mininet 交互。在wireshark的窗口中,你会看到内核交换机连接到控制器。显示mininet cli命令:mininet helpdocumented commands (type help ):=eof exit intfs link noecho pingpair py source xtermdpctl gterm iperf net pingall pingpairfull quit timedump help iperfudp nodes pingallfull px sh xyou may also send a command to a node using: 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.some character-oriented interactive commands requirenoecho: mininet noecho h2 vi foo.pyhowever, starting up an xterm/gterm is generally better: mininet xterm h2显示节点:mininet nodesavailable nodes are:c0 h1 h2 s1显示网络链接:mininet neth1 h1-eth0:s1-eth1h2 h2-eth0:s1-eth2s1 lo: s1-eth1:h1-eth0 s1-eth2:h2-eth0c0输出所有节点的信息:mininet dump从上面的输出中,你可以看到有一台交换机和两台主机。在 mininet 的cli 中第一个字符串是设备名,那后面的命令就在该设备上执行。例如我们想在h1设备上执行ifconfig则输入如下命令:mininet h1 ifconfig -ah1-eth0 link encap:ethernet hwaddr 3e:94:43:b1:ad:48 inet addr: bcast:55 mask: inet6 addr: fe80:3c94:43ff:feb1:ad48/64 scope:link up broadcast running multicast mtu:1500 metric:1 rx packets:22 errors:0 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: mask: inet6 addr: :1/128 scope:host up loopback running mtu:65536 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)上面的输出中,可以看见h1-eth0跟lo两个接口,需要注意的是,在 linux 系统的 shell 中运行ifconfig是看不到h1-eth0。与h1-eth0相反的是,switch默认是跑在 root 的网络namespace上面,所以在switch上执行命令与在 linux 下的 shell 中是一样的。mininet s1 ifconfig-aeth0 link encap:ethernet hwaddr 08:00:27:98:dc:aa inet addr:5 bcast:55 mask: inet6 addr: fe80:a00:27ff:fe98:dcaa/64 scope:link up broadcast running multicast mtu:1500 metric:1 rx packets:46716 errors:0 dropped: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: mask: inet6 addr: :1/128 scope:host up loopback running mtu:65536 metric:1 rx packets: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: bcast:55 mask: inet6 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:ethernet 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:fc47: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 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:ethernet 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:1674 (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:1000 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 carrier: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: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 dropped: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 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)上面的输出中包含交换机的虚拟网卡 s1,以及主机的 eth0。为了区别显示host 主机的网络是隔离的,我们可以通过arp与route命令来做演示,分别在 s1与h1上面演示如下:mininet s1 arpaddress 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 ifacedefault localhost ug 0 0 0 eth0 * u 0 0 0 eth0 * u 0 0 0 lxcbr0 * u 0 0 0 docker0mininet h1 arpmininet h1 routekernel ip routing tabledestination gateway genmask flags metric ref use iface * u 0 0 0 h1-eth0这样可以做到将每一个主机,交换机,以及控制器都放到他自己的标准的 network namespace 中,但是这种做法并没有什么特别的优势,除非你想复制一个非常复杂的网络。mininet 不支持这种做法,你可以通过-innamespace参数来查看更多的信息。译者注:感觉有点像 lxc 或者说想最近比较火的 docker注意:只有网络是虚拟出来的,每一个主机里面的进程使用的都是同一套目录,可以看到相同的进程集合,我们打印不同主机下面的进程列表看看:mininet h1 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: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: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 4542 pts/22 00:00:00 mn如上所示, h1,h2,s1三个进程列表是完全相同的。其实完全可以做到各个主机完全独立,就想 lxc 那样,但是目前 mininet 并没有这么做。在 mininet 中所有的进程都放在 root 下面,这样你可以在 linux的 shell 中直接用kill或者ps这些命令查看或者杀死进程。test connectivity between hosts现在,验证您可以h1 ping 通 h2:mininet h1 ping h2 -c 1ping () 56(84) bytes of data.64 bytes from : icmp_seq=1 ttl=64 time=8.57 ms- 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,并将一个packet_in发送到c0,然后c0发送packet_out消息流广播到交换机(在本例中,唯一的其他数据端口)。第二个主机接受到的arp请求,并发送一个广播答复。此回复进到控制器,该控制器将其发送到h1并且 pushes down a flow entry。现在第一主机知道的第二个ip地址,并且可以通过icmp ping 来回显请求。这个请求,连同其从第二主机对应的应答,both go the controller and result in a flow entry pushed down (along with the actual packets getting sent out).重复前一条命令:mininet h1 ping -c 1 h2这次 ping 的时间将比第一次低的多, 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命令可以让每一个节点直接都产生上面的效果。mininet pingallrun a simple web server and client我们不单可以在主机上面运行ping命令,每一条 linux下的命令或者程序都可以在 mininet 中运行:接下来,尝试开始于h1启动一个简单的http服务器上,然后从h2发出请求,最后关闭web服务器:mininet h1 python -m simplehttpserver 80 &mininet h2 wget h1-2014-09-15 08:10:11- /connecting to :80. connected.http request sent, awaiting response. 200 oklength: 2647 (2.6k) text/htmlsaving to: index.html 0k . 100% 71.7m=0s2014-09-15 08:10:11 (71.7 mb/s) - index.html saved 2647/2647mininet h1 kill %python退出mininet交互命令:mininetexitcleanup如果mininet出于某种原因崩溃,可以用下面命令来清理:sudo mn -cpart 2: 高级选项advanced startup options回归测试run a regression testmininet 可以用于直接运行回归测试,不一定要切换到他的 cli 下面。运行回归测试:$ sudo mn -test pingpair这条命令会创建一个小的拓扑结构,然后启动 openflow 的控制器,然后跑 ping 测试,最后再把拓扑结构跟控制器关掉。另一种有用的试验是iperf的(给它约10秒来完成):还有一直常用的测试是iperf(完成这个测试大概需要10s 钟):$ sudo mn -test iperf此命令创建的相同mininet,并在其中一台 host 上面跑 iperf server, 然后在另外一台 host 上面运行iperf client 然后解析取得带宽情况。更改拓扑结构大小和类型 changing topology size and typemininet 默认的拓扑结构是由两台 host 以及一台交换机组成的,你可以用-topo参数来更改拓扑结构。假设你要在一个交换机与三台 host 之间做 ping 探测验证(verify all-pairs ping connectivity)。:运行回归测试:$ sudo mn -test pingall -topo single,3另一个例子中,使用线性拓扑(其中每个交换机配有一个主机,并且所有的交换机连接在一起):$ sudo mn -test pingall -topo linear,4课哟用参数来控制拓扑结构是 mininet 中最有用的功能之一,非常强大。链路变化 link variationsmininet2.0允许你设置连接参数,甚至可以通过命令行实现自动化设置:$ sudo mn -link tc,bw=10,delay=10ms mininet iperf . mininet h1 ping -c10 h2上面的设置每两个节点之间的延迟是10ms,因为 icmp 请求传过了两条链路(一次是到大交换机,一次到达主机),往返时间(rrt)就应该是40ms。你还可以使用pythonapi来做更多的事儿,不过现在我们先继续往下演练。调整输出信息adjustable verbositymininet默认输出信息的级别是info,info级别会输出 mininet的详细信息。我们也可以通过-v参数来设置输出debug信息。$ sudo mn -v debug.mininet exit这样会打印出更多额外的细节。现在尝试一下output参数,这样可以在 cli 中打印更少的信息。$ sudo mn -v outputmininet exit除了上面的几个级别,还有其他的级别可以使用,比如warning等custom topologies自定义拓扑结构在custom/topo-2sw-2host.py中是一个例子可以拿来参考,我们可以看到通过 pythonapi 我们可以很简单的来定义拓扑结构。这个例子直接连接两台交换机,每个交换机带有一台主机。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 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 = self.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() ) 我们提供一个自定义的mininet 文件,就可以创建新的拓扑结构、交换机类型。我们在命令行里面测试一下:$ 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 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默认情况下,host 的 mac 地址是随机分配的。这会导致每次 mininet 创建的时候,mac地址都会改变,这会给调试带来一些困难-mac参数可以解决上面的问题,栗子如下:之前:$ sudo mnmininet h1 ifconfigh1-eth0 link encap:ethernet hwaddr c2:d9:4a:37:25:17 inet addr: bcast:55 mask: 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 frame: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: mask: inet6 addr: :1/128 scope:host up loopback running mtu:65536 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)使用-mac参数:$ sudo mn -macmininet h1 ifconfigh1-eth0 link encap:ethernet hwaddr 00:00:00:00:00:01 inet addr: bcast:55 mask: inet6 addr: fe80:200:ff:fe00:1/64 scope:link up bro
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024食品安全员能力考核试题含答案
- 2025年低压电工操作证模拟考试复审题库及答案
- 识测试题及答案
- 电工(初级工)测试题+答案
- 2025全国企业员工全面质量管理知识竞赛题库(含答案)
- 2025河北省社区《网格员》模拟试题(含答案)
- 北京少儿乐理知识培训班费用课件
- 标准化销售流程课件
- (2025)医疗护理员理论考试试题含答案
- 柴油发动机基础培训课件
- 办公自动化使用教材课件
- 2025年专业士官考试题库
- 院前急救技能大赛
- 2024年武汉广播电视台专项招聘真题
- 高血压尿毒症护理查房
- 2025届山东省青岛五十八中高一物理第二学期期末考试试题含解析
- 医院培训课件:《基于医院感染防控的安全注射》
- 2025年档案管理与信息资源利用考试试题及答案
- 工业空调培训课件模板
- 防汛安全教育试卷(含答案)
- 2025届上海市高考英语考纲词汇表
评论
0/150
提交评论