20220416-Mininet入门学习
Mininet入门学习
基本介绍,参见:官方说明
1. Mininet基本操作
- Creating Topologies
- Setting Performance Parameters
- Running Programs in Hosts
- New:
popen()/pexec()interface - Host Configuration Methods
- Naming in Mininet
- Customizing mn using —custom files
2. Host Configuraton Methods
IP():return IP address of a host or specific interface.MAC():return MAC address of a host or specific interface.setARP():add a static ARP entry to a host’s ARP cache.setIP():set the IP address for a host or specific interface.setMAC():set the MAC address for a host or specific interface.
3. Customizing mn using --custom files
4. Understanding the Mininet API
可以将Mininet的API划分为以下3个主要层级:
Low-level API: consists of the base node and link classes (such as
Host,Switch, andLinkand their subclasses) . Low-level API: nodes and links1
2
3
4
5
6
7
8
9
10
11
12
13h1 = Host( 'h1' )
h2 = Host( 'h2' )
s1 = OVSSwitch( 's1', inNamespace=False )
c0 = Controller( 'c0', inNamespace=False )
Link( h1, s1 )
Link( h2, s1 )
h1.setIP( '10.1/8' )
h2.setIP( '10.2/8' )
c0.start()
s1.start( [ c0 ] )
print( h1.cmd( 'ping -c1', h2.IP() ) )
s1.stop()
c0.stop()Mid-level API:adds the
Mininetobject which serves as a container for nodes and links. (such asaddHost(),addSwitch(), andaddLink()) , as well as network configuration, startup and shutdown (notablystart()andstop()). Mid-level API: Network object1
2
3
4
5
6
7
8
9
10
11net = Mininet()
h1 = net.addHost( 'h1' )
h2 = net.addHost( 'h2' )
s1 = net.addSwitch( 's1' )
c0 = net.addController( 'c0' )
net.addLink( h1, s1 )
net.addLink( h2, s1 )
net.start()
print( h1.cmd( 'ping -c1', h2.IP() ) )
CLI( net )
net.stop()High-level API:adds a topology template abstraction. The
Topoclass, which provides the ability to create reusable, parametrized topology templates. These templates can be passed to themncommand (via the--customoption) and used from the command line. High-level API: Topology templates1
2
3
4
5
6
7
8
9
10
11
12
13class SingleSwitchTopo( Topo ):
"Single Switch Topology"
def build( self, count=1 ):
hosts = [ self.addHost( 'h%d' % i )
for i in range( 1, count + 1 ) ]
s1 = self.addSwitch( 's1' )
for h in hosts:
self.addLink( h, s1 )
net = Mininet( topo=SingleSwitchTopo( 3 ) )
net.start()
CLI( net )
net.stop()
5. Measuring Performance
- Bandwidth (
bwm-ng,ethstats) - Latency (use
ping) - Queues (use
tcincluded inmonitor.py) - TCP
CWNDstatistics (tcp_probe, maybe we should add it tomonitor.py) - CPU usage (global:
top, or per-containercpuacct)
6. Mininet原理
- 组成部分:
- Isolated Hosts
- Emulated Links
- Emulated Switches: default Linux bridge or Open vSwitch running in kernel model to switch packets across interfaces.