Mininet学习指南
State Key Laboratory of Networking and Switching Technology
Future Networking Laboratory
Cheng Li
Mininet
An Instant Virtual Network on your Laptop.
Mininet
Mininet creates a realistic virtual network, running real kernel, switch and application code, on a single
machine (VM, cloud or native), in seconds, with a single command:
http://mininet.org/
Mininet & OpenVSwitch
Mininet在/mininet/node.py中定义了Node、OVSSwitch和Controller等重要的类。在OVSSwitch类中,通过使用命令OVS
的命令创建交换机从而得到一个OVS实例。
Mininet
Host
OpenVSwitch
OpenVSwitch
Mininet创建的host,switch等实例实际上是运行在不同namespace下的某个进程。默认情况下Host运行在自己的
namespace中,交换节点运行在root namespace中。
OpenVSwitch
Open vSwitch is a production
quality, multilayer virtual
switch licensed under the
open source Apache
2.0 license. It is designed to
enable massive network
automation through
programmatic extension,
while still supporting standard
management interfaces and
protocols (e.g. NetFlow,
sFlow, IPFIX, RSPAN, CLI,
LACP, 802.1ag).
Installation
• Mininet VM Installation(easy, recommended)
http://mininet.org/download/#option-1-mininet-vm-installation-easy-recommended
• Native Installation form Source
http://mininet.org/download/#option-2-native-installation-from-source
http://www.muzixing.com/pages/2014/11/02/openvswitch230-and-mininet-install.html
•
Installation form Packages
http://mininet.org/download/#option-3-installation-from-packages
Getting Started
Startup Options
● Help: sudo mn [-h] 通过-h可以查看到帮助信息。
● Connect to remote controller: sudo mn --controller=remote,ip=127.0.0.1,port=6633 端口可以省略,默认值是
6633,可指定。
Topology: sudo mn --topo=
●
○
○
○
tree,n,m 第一个参数为深度,第二个位扇出系数。可以写成--tree,depth=2,fanout=8
single, n:单个交换机,n个交换机
liner, n: 线性拓扑,n个交换机
Test:--test [pingall/pingpair..]
Link:--link=tc, bw=10M, delay=10ms,loss=5%
●
●
● Custom Topo:--custom ~/mininet/custom/topo-2sw-2host.py --topo mytopo
●
●
●
● Clear: sudo mn -c
ID=MAC: sudo mn --mac
Xterm: sudo mn -x 启动xterm到每一个host和switch
Switch type: sudo mn --switch ovsk/user,
Getting Started
Command-Line Interface
Exit: exit 退出mininet
Python: py “hello” / py dir(s1) py hello.py 运行python文件:
Link: link s1 h1 down/up 参数分别为link两端网元。
Xterm: xterm s1/h1 xterm到某一个主机或交换机
● Help: help 查看帮助信息
●
●
●
●
● Node: nodes 查看节点
● Dump:dump 查看所有节点信息
● 节点命令:
○
○
○
○
s1 ifconfig
s1 ps -a
h1 arp -s
h1 ping -c 10 h2
Iperf: iperf h1 h2 启用iperf功能
Ping: h1 ping h2 pingall/pingpair 发送ping消息
●
●
● HTTPSERVER : h1 python -m SimpleHTTPServer 80 &
● HTTPCLIENT: h2 wget -O -h1