Mininet是什么
Mininet是一个网络模拟器,可以创建虚拟主机,交换机,控制器和链接的网络。
Mininet的交换机支持OpenFlow,可实现高度灵活的自定义路由和SDN,为开发和测试SDN提供实验环境
Mininet用途
- 为开发OpenFlow应用程序提供简单而廉价的网络测试平台
- 允许多个并发开发人员在同一拓扑上独立工作
- 支持系统级回归测试,这些测试可重复且易于打包
- 支持复杂的拓扑测试,无需连接物理网络
- 包括具有拓扑感知和OpenFlow感知的CLI,用于调试或运行网络范围的测试
- 支持任意自定义拓扑,并包括一组基本的参数化拓扑
- 可以在没有编程的情况下开箱即用
- 提供了一个简单易用的**Python API,**用于网络创建和实验
安装
Ubuntu16.04
测试
使用
常用命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| root@mininet:~ *** No default OpenFlow controller found for default switch! *** Falling back to OVS Bridge *** 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>
|
1 2 3 4
| mininet> nodes available nodes are: h1 h2 s1 mininet>
|
可以看到当前包含3个节点,包括两个host,一个switch
1 2 3 4 5
| mininet> net h1 h1-eth0:s1-eth1 h2 h2-eth0:s1-eth2 s1 lo: s1-eth1:h1-eth0 s1-eth2:h2-eth0 mininet>
|
h1的eth0与s1的eth1相连
h2的eth0与s1的eth2相连
1 2 3 4 5
| mininet> dump <Host h1: h1-eth0:10.0.0.1 pid=6896> <Host h2: h2-eth0:10.0.0.2 pid=6899> <OVSBridge s1: lo:127.0.0.1,s1-eth1:None,s1-eth2:None pid=6905> mininet>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| *** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes killall controller ofprotocol ofdatapath ping nox_core lt-nox_core ovs-openflowd ovs-controller udpbwtest mnexec ivs 2> /dev/null killall -9 controller ofprotocol ofdatapath ping nox_core lt-nox_core ovs-openflowd ovs-controller udpbwtest mnexec ivs 2> /dev/null pkill -9 -f "sudo mnexec" *** Removing junk from /tmp rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log *** Removing old X11 tunnels *** Removing excess kernel datapaths ps ax | egrep -o 'dp[0-9]+' | sed 's/dp/nl:/' *** Removing OVS datapaths ovs-vsctl --timeout=1 list-br ovs-vsctl --timeout=1 list-br *** Removing all links of the pattern foo-ethX ip link show | egrep -o '([-_.[:alnum:]]+-eth[[:digit:]]+)' ip link show *** Killing stale mininet node processes pkill -9 -f mininet: *** Shutting down stale tunnels pkill -9 -f Tunnel=Ethernet pkill -9 -f .ssh/mn rm -f ~/.ssh/mn/* *** Cleanup complete. root@mininet:~
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| mininet> h1 ifconfig h1-eth0 Link encap:Ethernet HWaddr a2:5f:da:ed:6a:74 inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80::a05f:daff:feed:6a74/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:15 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:1206 (1.2 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:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
mininet>
|
1
| mininet> h1 python -m SimpleHTTPServer 80 &
|
1 2 3 4 5 6 7 8 9 10 11 12
| mininet> h2 wget h1 --2018-11-07 10:52:29-- http://10.0.0.1/ Connecting to 10.0.0.1:80... connected. HTTP request sent, awaiting response... 200 OK Length: 370 [text/html] Saving to: 'index.html'
index.html 100%[===================>] 370 --.-KB/s in 0s
2018-11-07 10:52:29 (62.3 MB/s) - 'index.html' saved [370/370]
mininet>
|