Mininet and the HP VAN SDN Controller

Mininet topology diagram

Mininet is a network emulator that can create and emulate an entire OpenFlow network locally on your PC. This is similar in concept to network emulators such as Simware (HP Comware) or GNS3 (Cisco IOS).

Mininet allows you to create different topologies consisting of OpenFlow switches and hosts (end devices). Topologies can vary from a single switch to more complicated topologies consisting of multiple switches and multiple links. The virtualized switches and hosts act like real devices and you can send traffic from between hosts and then view the flows on the switches. In addition, applications such as iperf can be used to measure performance on the network.

Network topologies are created by using the command “sudo mn”. Various options can be used such as “–topo=linear,4”. This creates a network consisting of 4 switches connected back-to-back in a linear fashion and each having a single host connected to it.

Here is an example. In this example I am using a HP SDN Controller rather than the built in controller within Mininet. I have thus used the option “–controller=remote”:

sdn@sdnctl:~$ sudo mn --topo=linear,4 --controller=remote
[sudo] password for sdn: 
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4
*** Adding switches:
s1 s2 s3 s4
*** Adding links:
(h1, s1) (h2, s2) (h3, s3) (h4, s4) (s1, s2) (s2, s3) (s3, s4)
*** Configuring hosts
h1 h2 h3 h4
*** Starting controller
*** Starting 4 switches
s1 s2 s3 s4
*** Starting CLI:
mininet>

Mininet does not have a GUI interface, so I am using the HP SDN Controller to show the network topologies.

You can download the HP VAN SDN Controller software from the following link:

https://h10145.www1.hp.com/downloads/SoftwareReleases.aspx?ProductNumber=J9863AAE

When connecting to the HP SDN Controller, this is what is shown:

Mininet topology only showing switches, no hosts

Mininet hosts don’t send traffic by default. Thus they don’t show in the diagram. To show hosts or nodes in the diagram, send traffic:

mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3 h4
h2 -> h1 h3 h4
h3 -> h1 h2 h4
h4 -> h1 h2 h3
*** Results: 0% dropped (0/12 lost)
mininet>

Notice how the yellow dots have appeared in the HP SDN Controller topology diagram:

Mininet topology only showing switches and hosts

To view node IP addresses, select IP from the Controller menu:

Mininet topology, HP VAN SDN Controller select IP

Or, to view the node MAC addresses, select MAC address from the menu:

Mininet topology, HP VAN SDN Controller select MAC

To close Mininet, use the “exit” command:

mininet> exit
*** Stopping 4 hosts
h1 h2 h3 h4
*** Stopping 4 switches
s1 ...s2 ....s3 ....s4 ...
*** Stopping 1 controllers
c0
*** Done
completed in 599.486 seconds
sdn@sdnctl:~$

The devices go gray and then disappear from the topology view in the controller:

Mininet topology, HP VAN SDN Controller, topology disappears

Devices are now removed from the topology:

Mininet topology, HP VAN SDN Controller, no topology

To install Mininet, do the following:

Install the base Mininet package by entering the following command (for Ubuntu 12.04):

sudo apt-get install mininet/precise-backports

After this completes, you should deactivate openvswitch-controller if it is running:

   sudo service openvswitch-controller stop
   sudo update-rc.d openvswitch-controller disable

Then you can test Mininet by sending pings between all hosts:

sudo mn –test pingall

If Mininet complains that Open vSwitch isn’t working, you may need to rebuild its kernel module:

   sudo dpkg-reconfigure openvswitch-datapath-dkms
   sudo service openflow-switch restart

For Mininet help, do the following:

sdn@sdnctl:~$ sudo mn -h
[sudo] password for sdn: 
Usage: mn [options]
(type mn -h for details)

The mn utility creates Mininet network from the command line. It can create parametrized topologies, invoke the Mininet CLI, and run tests.

Options:
-h, --help            show this help message and exit
--switch=SWITCH       ovsk|ovsl|user[,param=value...]
--host=HOST           cfs|proc|rt[,param=value...]
--controller=CONTROLLER
		      none|nox|ovsc|ref|remote[,param=value...]
--link=LINK           default|tc[,param=value...]
--topo=TOPO           linear|minimal|reversed|single|tree[,param=value...]
-c, --clean           clean and exit
--custom=CUSTOM       read custom topo and node params from .pyfile
--test=TEST           cli|build|pingall|pingpair|iperf|all|iperfudp|none
-x, --xterms          spawn xterms for each node
-i IPBASE, --ipbase=IPBASE
		      base IP address for hosts
--mac                 automatically set host MACs
--arp                 set all-pairs ARP entries
-v VERBOSITY, --verbosity=VERBOSITY
		      info|warning|critical|error|debug|output
--innamespace         sw and ctrl in namespace?
--listenport=LISTENPORT
		      base port for passive switch listening
--nolistenport        don't use passive listening port
--pre=PRE             CLI script to run before tests
--post=POST           CLI script to run after tests
--prefixlen=PREFIXLEN
		      prefix length (e.g. /8) for automatic network
		      configuration
--pin                 pin hosts to CPU cores (requires --host cfs or --host
	              rt)
--version
sdn@sdnctl:~$

In this example, Mininet creats a basic topology with a single switch and two hosts. The pingall command generates traffic between the hosts:

sdn@sdnctl:~$ sudo mn --controller=remote
*** 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> pingall
*** Ping: testing ping reachability
h1 -> h2
h2 -> h1
*** Results: 0% dropped (0/2 lost)
mininet>

On the HP SDN Controller, the following is shown:

Mininet topology, HP VAN SDN Controller, basic topology - sudo mn

In Mininet, you can view the nodes in the topology by using the nodes commands. Notice how two hosts and one switch as shown:

mininet> nodes
available nodes are:
h1 h2 s1 c0
mininet>

To view the network connections, the “net” command can be used:

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

Note how h1 is connected to the switch on port 1 and h2 is connected to the switch on port 2. That can be seen easily within the HP SDN Controller.

To view the IP addresses of devices, use the “ifconfig” command:

mininet> h1 ifconfig -a
h1-eth0   Link encap:Ethernet  HWaddr 36:ec:77:2b:2a:47
	inet addr:10.0.0.1  Bcast:10.255.255.255  Mask:255.0.0.0
	inet6 addr: fe80::34ec:77ff:fe2b:2a47/64 Scope:Link
	UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
	RX packets:23 errors:0 dropped:9 overruns:0 frame:0
	TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
	collisions:0 txqueuelen:1000
	RX bytes:1622 (1.6 KB)  TX bytes:1028 (1.0 KB)
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:16436  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:0
	RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
mininet>
mininet> h2 ifconfig -a
h2-eth0   Link encap:Ethernet  HWaddr 6a:ed:1e:2d:c3:61
	inet addr:10.0.0.2  Bcast:10.255.255.255  Mask:255.0.0.0
	inet6 addr: fe80::68ed:1eff:fe2d:c361/64 Scope:Link
	UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
	RX packets:23 errors:0 dropped:9 overruns:0 frame:0
	TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
	collisions:0 txqueuelen:1000
	RX bytes:1622 (1.6 KB)  TX bytes:1028 (1.0 KB)
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:16436  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:0
	RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
mininet>

This can also be seen in the Controller:

Mininet topology, sudo mn

To send a single ping between the two node devices, use the following command:

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_req=1 ttl=64 time=9.31 ms

--- 10.0.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 9.314/9.314/9.314/0.000 ms
mininet>
To create a more complicated network, the following could be used:
sdn@sdnctl:~$ sudo mn --topo=tree,3 --controller=remote
[sudo] password for sdn:
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4 h5 h6 h7 h8
*** Adding switches:
s1 s2 s3 s4 s5 s6 s7
*** Adding links:
(h1, s3) (h2, s3) (h3, s4) (h4, s4) (h5, s6) (h6, s6) (h7, s7) (h8, s7) (s1, s2) (s1, s5) (s2, s3) (s2, s4) (s5, s6) (s5, s7)
*** Configuring hosts
h1 h2 h3 h4 h5 h6 h7 h8
*** Starting controller
*** Starting 7 switches
s1 s2 s3 s4 s5 s6 s7
*** Starting CLI:
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3 h4 h5 h6 h7 h8
h2 -> h1 h3 h4 h5 h6 h7 h8
h3 -> h1 h2 h4 h5 h6 h7 h8
h4 -> h1 h2 h3 h5 h6 h7 h8
h5 -> h1 h2 h3 h4 h6 h7 h8
h6 -> h1 h2 h3 h4 h5 h7 h8
h7 -> h1 h2 h3 h4 h5 h6 h8
h8 -> h1 h2 h3 h4 h5 h6 h7
*** Results: 0% dropped (0/56 lost)
mininet>

This is the output on the HP Controller:

sudo mn --topo=tree,3 --controller=remote

For fault tolerance testing, it can be helpful to take links down or bring them up:

To drop the link between switch5 and switch7, do the following:

mininet> link s5 s7 down

In the HP Controller, the link goes gray, and is then removed from the diagram:

Mininet link down

Link is removed from the topology:

Mininet link down - disappears

To bring the link back up again, do the following:

mininet> link s5 s7 up

Link is shown as back in the Controller diagram:

Mininet link up

Single switch with three hosts:

To create a simple topology of one switch and 3 hosts:

sdn@sdnctl:~$ sudo mn --topo=single,3 --controller=remote 
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1) (h3, s1)
*** Configuring hosts
h1 h2 h3
*** Starting controller
*** Starting 1 switches
s1
*** Starting CLI:
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3
h2 -> h1 h3
h3 -> h1 h2
*** Results: 0% dropped (0/6 lost)
mininet>

View on the HP SDN Controller:

sudo mn --topo=single,3 --controller=remote

Three switches with four hosts in a tree:

This will create a single core switch and two leaf switches. Each leaf switch has two hosts.

sdn@sdnctl:~$ sudo mn --topo=tree,depth=2 --controller=remote 
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4
*** Adding switches:
s1 s2 s3
*** Adding links:
(h1, s2) (h2, s2) (h3, s3) (h4, s3) (s1, s2) (s1, s3)
*** Configuring hosts
h1 h2 h3 h4
*** Starting controller
*** Starting 3 switches
s1 s2 s3
*** Starting CLI:
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 X h4
h2 -> h1 h3 h4
h3 -> h1 h2 h4
h4 -> h1 h2 h3
*** Results: 8% dropped (1/12 lost)
mininet>

View on the HP SDN Controller:

sudo mn --topo=tree,depth=2 --controller=remote

Four switches with nine hosts in a tree:

This will create a single core switch and three leaf switches. Each leaf switch has thee hosts.

sdn@sdnctl:~$ sudo mn --topo=tree,depth=2,fanout=3 --controller=remote 
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4 h5 h6 h7 h8 h9
*** Adding switches:
s1 s2 s3 s4
*** Adding links:
(h1, s2) (h2, s2) (h3, s2) (h4, s3) (h5, s3) (h6, s3) (h7, s4) (h8, s4) (h9, s4) (s1, s2) (s1, s3) (s1, s4)
*** Configuring hosts
h1 h2 h3 h4 h5 h6 h7 h8 h9
*** Starting controller
*** Starting 4 switches
s1 s2 s3 s4
*** Starting CLI:
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3 X X X h7 h8 h9
h2 -> h1 h3 h4 h5 h6 h7 h8 h9
h3 -> h1 h2 h4 h5 h6 h7 h8 h9
h4 -> h1 h2 h3 h5 h6 h7 h8 h9
h5 -> h1 h2 h3 h4 h6 h7 h8 h9
h6 -> h1 h2 h3 h4 h5 h7 h8 h9
h7 -> h1 h2 h3 h4 h5 h6 h8 h9
h8 -> h1 h2 h3 h4 h5 h6 h7 h9
h9 -> h1 h2 h3 h4 h5 h6 h7 h8
*** Results: 4% dropped (3/72 lost)
mininet>

View on the HP SDN Controller:

sudo mn --topo=tree,depth=2,fanout=3 --controller=remote

This blog entry covers some of the basics of Mininet. This is very useful for learning and testing SDN applications.

For more information about Mininet, go to http://mininet.org

 

 



Tags: , , , , ,


About :

These days I am involved in some exciting SDN and OpenFlow projects involving the HP VAN SDN Controller, HP ProVision and HP Comware switches. These new developments in the networking world combine my passions of networking and application development. I hope to write some interesting blog entries on these exiting topics. I am both a Cisco CCIE #11023 and HP MASE as well as a Cisco Certified Systems Instructor (CCSI #22787) and Certified HP Instructor. I have been training networking courses for well over 10 years teaching on a wide range of topics including routing and switching, VoIP, OpenFlow and SDN. I have delivered instructor led courses all over the world. I started working with Cisco Unified Communications Manager when it was still called Cisco Call Manager and have been deploying, troubleshooting and teaching Unified Communications products since version 3.0. I have developed various network utilities such as the VPN Config Generator and others to help engineers in their day to day jobs. I also develop software, training materials, EBooks, videos and other products which are used throughout the world. I have designed, implemented and managed networks ranging from single sites to those that span 50 countries.

View all posts by


No comments yet.

Leave a Reply

  • Proper format "info@pakiti.com"