Mininet Setup & Walktrough

Mininet setup & walktrough. Some CLIs and screen dump.

Mininet instance: Mininet 2.2.2 on Ubuntu 14.04 LTS - 64 bit, official VM.

VM Networking Bugs: Set up the Mininet network simulator. See comments by isams1.

$ ssh -Y -l mininet -p 2222 localhost
$ sudo mn
$ sudo mn --topo=minimal
*** Creating network
*** Adding controller
*** Adding hosts: h1 h2
*** Adding switches: s1
*** Adding links: (h1, s1) (h2, s1)
*** Configuring hosts h1 h2
*** Starting controller c0
*** Starting 1 switches s1 ...
*** Starting CLI:
mininet>

$ mn -h
mininet> help

Documented commands (type help <topic>):
========================================
EOF    gterm  iperfudp  nodes        pingpair      py      switch
dpctl  help   link      noecho       pingpairfull  quit    time  
dump   intfs  links     pingall      ports         sh      x    
exit   iperf  net       pingallfull  px            source  xterm
...

mininet> nodes
available nodes are:
c0 h1 h2 s1

mininet> net
h1 h1-eth0:s1-eth1
h2 h2-eth0:s1-eth2
s1 lo:  s1-eth1:h1-eth0 s1-eth2:h2-eth0
c0

mininet> dump
<Host h1: h1-eth0:10.0.0.1 pid=1445>
<Host h2: h2-eth0:10.0.0.2 pid=1447>
<OVSSwitch s1: lo:127.0.0.1,s1-eth1:None,s1-eth2:None pid=1452>
<Controller c0: 127.0.0.1:6653 pid=1438>

mininet> xterm h1 h2
mininet> h1 ifconfig -a
h1-eth0   Link encap:Ethernet  HWaddr 0e:27:17:83:ae:c3  
          inet addr:10.0.0.1  Bcast:10.255.255.255  Mask:255.0.0.0
          ...

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          ...

mininet> s1 ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:84:cb:58  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          ...

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          ...

ovs-system Link encap:Ethernet  HWaddr b6:d0:9b:b7:44:c7  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          ...

s1        Link encap:Ethernet  HWaddr 6a:f2:8b:7d:42:4f  
          UP BROADCAST RUNNING  MTU:1500  Metric:1
          ...

s1-eth1   Link encap:Ethernet  HWaddr aa:d6:a7:45:ab:52  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          ...

s1-eth2   Link encap:Ethernet  HWaddr 56:22:6a:12:15:e0  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          ...
mininet> h1 ping -c 1 h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=9.59 ms
...
rtt min/avg/max/mdev = 9.596/9.596/9.596/0.000 ms

mininet> h1 ping -c 1 h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=1.00 ms
...
rtt min/avg/max/mdev = 1.002/1.002/1.002/0.000 ms

mininet> pingall
*** Ping: testing ping reachability
h1 -> h2
h2 -> h1
*** Results: 0% dropped (2/2 received)

mininet> h1 python -m SimpleHTTPServer 80 &
mininet> h2 wget -O - h1
--2018-01-18 17:07:37--  http://10.0.0.1/
Connecting to 10.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
...

mininet> h1 ps -a
  PID TTY          TIME CMD
 1184 tty1     00:00:00 bash
 1432 pts/1    00:00:00 sudo
 1433 pts/1    00:00:00 mn
 1506 pts/3    00:00:00 controller
 1674 pts/4    00:00:00 python
 1700 pts/4    00:00:00 ps

mininet> h1 kill %python

mininet> h1 ps -a
  PID TTY          TIME CMD
 1184 tty1     00:00:00 bash
 1432 pts/1    00:00:00 sudo
 1433 pts/1    00:00:00 mn
 1506 pts/3    00:00:00 controller
 1707 pts/4    00:00:00 ps

mininet> exit
*** Stopping 1 controllers
...
*** Done
completed in 604.243 seconds

mininet@mininet-vm:~$ sudo mn -c
*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes
killall controller ofprotocol ofdatapath ping nox_core lt-nox_core ovs-openflowd ovs-
...
*** Cleanup complete.
mininet@mininet-vm:~$ sudo mn --test pingpair
...
*** Waiting for switches to connect
s1
h1 -> h2
h2 -> h1
*** Results: 0% dropped (2/2 received)
*** Stopping 1 controllers
...
*** Done
completed in 5.389 seconds

mininet@mininet-vm:~$ sudo mn --test iperf
*** Creating network
...
*** Iperf: testing TCP bandwidth between h1 and h2
.*** Results: ['30.1 Gbits/sec', '30.2 Gbits/sec']
*** Stopping 1 controllers
...
*** Done
completed in 10.950 seconds
mininet@mininet-vm:~$ sudo mn --test pingall --topo single,3
*** Creating network
...
*** Ping: testing ping reachability
h1 -> h2 h3
h2 -> h1 h3
h3 -> h1 h2
*** Results: 0% dropped (6/6 received)
*** Stopping 1 controllers
...
*** Done
completed in 5.474 seconds

mininet@mininet-vm:~$ sudo mn --test pingall --topo linear,4
*** Creating network
...
*** Starting 4 switches
s1 s2 s3 s4 ...
*** Waiting for switches to connect
s1 s2 s3 s4
*** Ping: testing ping reachability
h1 -> h2 h3 h4
h2 -> h1 h3 h4
h3 -> h1 h2 h4
h4 -> h1 h2 h3
*** Results: 0% dropped (12/12 received)
*** Stopping 1 controllers
...
*** Done
completed in 5.578 seconds

mininet@mininet-vm:~$ sudo mn --link tc,bw=10,delay=10ms
*** Creating network
...
*** Starting 1 switches
s1 ...(10.00Mbit 10ms delay) (10.00Mbit 10ms delay)
*** Starting CLI:

mininet> iperf
*** Iperf: testing TCP bandwidth between h1 and h2
*** Results: ['9.47 Mbits/sec', '12.0 Mbits/sec']

mininet> h1 ping -c10 h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=42.5 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=41.7 ms
...
10 packets transmitted, 10 received, 0% packet loss, time 9010ms
rtt min/avg/max/mdev = 40.808/41.636/44.837/1.186 ms
mininet@mininet-vm:~$ sudo mn -v debug
*** errRun: ['which', 'controller']
/usr/local/bin/controller
...

mininet@mininet-vm:~$ sudo mn -v output
mininet@mininet-vm:~$ sudo mn -v info
# default -> info
mininet> py 'hello'
hello

mininet> py locals()
{'h2': <Host h2: h2-eth0:10.0.0.2 pid=4707> , 'net': <mininet.net.Mininet object at 0x7f2663c0a190>, 'h1': <Host h1: h1-eth0:10.0.0.1 pid=4705> , 'c0': <Controller c0: 127.0.0.1:6653 pid=4698> , 's1': <OVSSwitch s1: lo:127.0.0.1,s1-eth1:None,s1-eth2:None pid=4712> }

mininet> py dir(s1)
['IP', 'MAC', 'OVSVersion', 'TCReapply', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', ..., 'setIP', 'setMAC', 'setParam', 'setup', 'shell', 'start', 'startShell', 'stdin', 'stdout', 'stop', 'stp', 'terminate', 'unmountPrivateDirs', 'vsctl', 'waitOutput', 'waitReadable', 'waiting', 'write']

mininet> py help(h1)

mininet> py h1.IP()
10.0.0.1

mininet> link s1 h1 down

mininet> h1 ping h2
connect: Network is unreachable

mininet> h2 ping h1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
From 10.0.0.2 icmp_seq=1 Destination Host Unreachable
...
--- 10.0.0.1 ping statistics ---
7 packets transmitted, 0 received, +6 errors, 100% packet loss, time 6032ms
pipe 3

mininet> link s1 h1 up
from mininet.topo import Topo

class 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@mininet-vm:~$ sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --topo mytopo --test pingall
*** Creating network
...
*** Done
completed in 5.377 seconds

mininet@mininet-vm:~$ sudo ~/mininet/examples/sshd.py
*** Creating network
...
*** Waiting for ssh daemons to start
.
*** Hosts are running sshd at the following addresses:
h1 10.0.0.1
h2 10.0.0.2
h3 10.0.0.3
h4 10.0.0.4
*** Type 'exit' or control-D to shut down network
*** Starting CLI:
mininet@mininet-vm:~$ sudo mn --mac

mininet> h1 ifconfig
h1-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
          ...

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          ...
mininet@mininet-vm:~$ sudo mn -x

mininet@mininet-vm:~$ sudo ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):

mininet> h1 ping h2

mininet@mininet-vm:~$ sudo ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=0.928s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=0, priority=65535,arp,in_port=2,vlan_tci=0x0000,dl_src=e6:72:7b:1b:cc:77,dl_dst=3e:8c:d4:ba:a9:1d,arp_spa=10.0.0.2,arp_tpa=10.0.0.1,arp_op=1 actions=output:1
 cookie=0x0, duration=0.925s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=0, priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=3e:8c:d4:ba:a9:1d,dl_dst=e6:72:7b:1b:cc:77,arp_spa=10.0.0.1,arp_tpa=10.0.0.2,arp_op=2 actions=output:2
 cookie=0x0, duration=4.941s, table=0, n_packets=3, n_bytes=294, idle_timeout=60, idle_age=2, priority=65535,icmp,in_port=1,vlan_tci=0x0000,dl_src=3e:8c:d4:ba:a9:1d,dl_dst=e6:72:7b:1b:cc:77,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,icmp_type=8,icmp_code=0 actions=output:2
 cookie=0x0, duration=5.939s, table=0, n_packets=4, n_bytes=392, idle_timeout=60, idle_age=2, priority=65535,icmp,in_port=2,vlan_tci=0x0000,dl_src=e6:72:7b:1b:cc:77,dl_dst=3e:8c:d4:ba:a9:1d,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,icmp_type=0,icmp_code=0 actions=output:1
$ sudo mn --switch user --test iperf (slower, user vs. kernel)
$ sudo mn --switch ovsk --test iperf (OVS - deprecated?)
$ sudo mn --test none (time: setup+teardown)
$ sudo mn --innamespace --switch user (user namespace)

Ref