Using Ostinato with mininet

4 minute read

I’d heard about mininet off and on, but had never really tried it myself.

Mininet is a Linux based network emulator which creates a network of virtual hosts, switches, controllers, and links all on a single Linux host. It does this using containers (namespaces essentially) and connects them using veth pairs.

An Ostinato user was trying to use Ostinato with mininet and was not seeing flows on the OVS switch and so reached out to me. I used this opportunity to try mininet out.

I installed the mininet VM as recommended. The VM doesn’t have a desktop environment installed and the recommendation is to use X11 forwarding to run GUI apps like Wireshark. Ostinato is also a GUI app, so will also require X11 forwarding.

But, first a couple of notes about X11 forwarding for those using mininet VM on a Windows host.

Both the native Windows ssh client and WSL ssh client were not able to do X11 forwarding - not sure if they don’t support it or I was doing something incorrect. I was able to use good ol’ Putty with X11 forwarding successfully.

Both Wireshark and Ostinato are Qt based GUI apps. However Qt5 and Xming don’t play nicely (some error about XInput not being supported). I replaced Xming with VcXsrv and was able to use that successfully.

Back to mininet.

Mininet has several predefined topologies with option to create custom ones. I went with the default minimal topo -

mininet@mininet-vm:~$ sudo -E mn
*** 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> net
h1 h1-eth0:s1-eth1
h2 h2-eth0:s1-eth2
s1 lo:  s1-eth1:h1-eth0 s1-eth2:h2-eth0
c0

mininet>

Visually, this is how the above topo looks -

     c0
      | 
     s1
    /  \
   /    \
  h1    h2

The h1-eth0 and h2-eth0 interfaces are inside the h1 and h2 containers respectively while s1-eth1 and s2-eth2 are in the default/root namespace and ifconfig on the mininet prompt and the VM prompt confirm the same.

mininet> h1 ifconfig
h1-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.1  netmask 255.0.0.0  broadcast 10.255.255.255
        ether 92:69:d5:2c:1b:d0  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

mininet> h2 ifconfig
h2-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.2  netmask 255.0.0.0  broadcast 10.255.255.255
        ether 16:0d:d7:bc:be:a8  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

mininet>
mininet@mininet-vm:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.35  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 08:00:27:3c:f7:01  txqueuelen 1000  (Ethernet)
        RX packets 1573653  bytes 99181783 (99.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2759420  bytes 3961121460 (3.9 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 413122  bytes 3819486904 (3.8 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 413122  bytes 3819486904 (3.8 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

s1-eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether da:2b:00:64:0e:fa  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

s1-eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 1e:4d:c5:e6:4d:ae  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

To generate traffic into the switch, we need to run Ostinato inside the host containers, NOT in the root namespace. To do that, start an xterm on h1 and then start Ostinato from inside that xterm

mininet> xterm h1
mininet>

If you don’t see the xterm window, make sure you started mininet by passing -E to sudo like this: sudo -E mn

From the h1 xterm window (not the main mininet VM), start Ostinato -

root@mininet-vm:~# ostinato &
root@mininet-vm:~#

If you don’t see any ports in Ostinato, see this Ostinato FAQ.

Make sure that Ostinato lists the h1-eth0 port.

Ostinato with Mininet

From here on, create Ostinato streams, devices and the usual Ostinato stuff.

To examine flows on the openflow switch, use dpctl dump-flows on the mininet prompt -

mininet> dpctl dump-flows
*** s1 ------------------------------------------------------------------------
 cookie=0x0, duration=202.156s, table=0, n_packets=9929, n_bytes=595740, idle_timeout=60, priority=65535,udp,in_port="s1-eth1",vlan_tci=0x0000,dl_src=26:e5:29:01:96:5b,dl_dst=d6:41:7c:21:0b:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,tp_src=0,tp_dst=0 actions=output:"s1-eth2"
 cookie=0x0, duration=49.649s, table=0, n_packets=2434, n_bytes=146040, idle_timeout=60, priority=65535,tcp,in_port="s1-eth1",vlan_tci=0x0000,dl_src=26:e5:29:01:96:5b,dl_dst=d6:41:7c:21:0b:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,tp_src=0,tp_dst=0 actions=output:"s1-eth2"
 cookie=0x0, duration=49.636s, table=0, n_packets=2434, n_bytes=131436, idle_timeout=60, priority=65535,tcp,in_port="s1-eth2",vlan_tci=0x0000,dl_src=d6:41:7c:21:0b:02,dl_dst=26:e5:29:01:96:5b,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,tp_src=0,tp_dst=0 actions=output:"s1-eth1"
 cookie=0x0, duration=0.652s, table=0, n_packets=0, n_bytes=0, idle_timeout=60, priority=65535,icmp,in_port="s1-eth2",vlan_tci=0x0000,dl_src=d6:41:7c:21:0b:02,dl_dst=26:e5:29:01:96:5b,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,icmp_type=3,icmp_code=3 actions=output:"s1-eth1"
 cookie=0x0, duration=90.647s, table=0, n_packets=2, n_bytes=84, idle_timeout=60, priority=65535,arp,in_port="s1-eth1",vlan_tci=0x0000,dl_src=26:e5:29:01:96:5b,dl_dst=d6:41:7c:21:0b:02,arp_spa=10.0.0.1,arp_tpa=10.0.0.2,arp_op=2 actions=output:"s1-eth2"
 cookie=0x0, duration=44.568s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, priority=65535,arp,in_port="s1-eth2",vlan_tci=0x0000,dl_src=d6:41:7c:21:0b:02,dl_dst=26:e5:29:01:96:5b,arp_spa=10.0.0.2,arp_tpa=10.0.0.1,arp_op=1 actions=output:"s1-eth1"

mininet> dpctl dump-flows tcp
*** s1 ------------------------------------------------------------------------
 cookie=0x0, duration=55.213s, table=0, n_packets=2706, n_bytes=162360, idle_timeout=60, priority=65535,tcp,in_port="s1-eth1",vlan_tci=0x0000,dl_src=26:e5:29:01:96:5b,dl_dst=d6:41:7c:21:0b:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,tp_src=0,tp_dst=0 actions=output:"s1-eth2"
 cookie=0x0, duration=55.200s, table=0, n_packets=2706, n_bytes=146124, idle_timeout=60, priority=65535,tcp,in_port="s1-eth2",vlan_tci=0x0000,dl_src=d6:41:7c:21:0b:02,dl_dst=26:e5:29:01:96:5b,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,tp_src=0,tp_dst=0 actions=output:"s1-eth1"

mininet> dpctl dump-flows udp
*** s1 ------------------------------------------------------------------------
 cookie=0x0, duration=210.107s, table=0, n_packets=10323, n_bytes=619380, idle_timeout=60, priority=65535,udp,in_port="s1-eth1",vlan_tci=0x0000,dl_src=26:e5:29:01:96:5b,dl_dst=d6:41:7c:21:0b:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,tp_src=0,tp_dst=0 actions=output:"s1-eth2"

mininet>

The full Ostinato arsenal of features is now available at your disposal to generate the traffic flows that you need to verify your SDN controller and openflow switch.

For more Ostinato related content, subscribe for email updates.

Leave a Comment