SDN 101: Using Mininet and SDN Controllers

Overview

Mininet is a network emulator that can create and emulate an entire OpenFlow network locally on your laptop / PC. This is similar to how GNS3 allows you to simulate a Cisco network on your laptop. Mininet may even be added to GNS3 in the future.

The easiest way to get started with Mininet is to download the prebuilt virtual machine from http://mininet.org/download/

You can then import the VM into VirtualBox, VMware workstation, ESXi or Parallels (whichever is your favorite).

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. You can even create your own topologies.

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 with each switch having a single host connected to it.

Here is an extract from http://mininet.org/overview/

Mininet is a network emulator which creates a network of virtual hosts, switches, controllers, and links. Mininet hosts run standard Linux network software, and its switches support OpenFlow for highly flexible custom routing and Software-Defined Networking. Mininet supports research, development, learning, prototyping, testing, debugging, and any other tasks that could benefit from having a complete experimental network on a laptop or other PC.
Mininet:

  • Provides a simple and inexpensive network testbed for developing OpenFlow applications
  • Enables multiple concurrent developers to work independently on the same topology
  • Supports system-level regression tests, which are repeatable and easily packaged
  • Enables complex topology testing, without the need to wire up a physical network
  • Includes a CLI that is topology-aware and OpenFlow-aware, for debugging or running network-wide tests
  • Supports arbitrary custom topologies, and includes a basic set of parameterized topologies is usable out of the box without programming, but also Provides a straightforward and extensible Python API for network creation and experimentation

Mininet provides an easy way to get correct system behavior (and, to the extent supported by your hardware, performance) and to experiment with topologies.Mininet networks run real code including standard Unix/Linux network applications as well as the real Linux kernel and network stack (including any kernel extensions which you may have available, as long as they are compatible with network namespaces.)Because of this, the code you develop and test on Mininet, for an OpenFlow controller, modified switch, or host, can move to a real system with minimal changes, for real-world testing, performance evaluation, and deployment. Importantly this means that a design that works in Mininet can usually move directly to hardware switches for line-rate packet forwarding

Now, time to get practical and look at some Mininet topologies…

Integrate with SDN Controllers

Linear topology (4 switches)

A linear topology consists of switches connected back-to-back, each having a single host (PC) connected to each switch.

To integrate with an external controller, use the –controller option (In this case, the controller is running on a server with IP address 192.168.56.50):

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=linear,4

*** 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) (s2, s1) (s3, s2) (s4, s3)

*** Configuring hosts

h1 h2 h3 h4

*** Starting controller

c0

*** Starting 4 switches

s1 s2 s3 s4 …

*** Starting CLI:

mininet>

Result: You have just “powered on” or created a network of four OpenFlow switches and four hosts (PCs).

You need to tell Mininet hosts (PCs) to send traffic so that they can be discovered by the SDN Controllers. The easiest way to do this is to use the pingall command:

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 (12/12 received)

mininet>

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

Result: View using the OpenDaylight (ODL):

Result: Using the ONOS SDN Controller:

2.png

Result: Using the HP VAN SDN Controller:

3.png

To close Mininet, use the “exit” command:

mininet> exit

*** Stopping 1 controllers

c0

*** Stopping 7 links

…….

*** Stopping 4 switches

s1 s2 s3 s4

*** Stopping 4 hosts

h1 h2 h3 h4

*** Done

completed in 530.855 seconds

mininet@mininet-vm:~$

Result: You have just “powered down” the 4 OpenFlow switches and 4 hosts (PCs).

Linear topology (20 switches):

We can easily extend the topology by using Mininet options. In this example, I have created a linear topology of 20 switches:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=linear,20

*** Creating network

*** Adding controller

*** Adding hosts:

h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

*** Adding switches:

s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 s20

*** Adding links:

(h1, s1) (h2, s2) (h3, s3) (h4, s4) (h5, s5) (h6, s6) (h7, s7) (h8, s8) (h9, s9) (h10, s10) (h11, s11) (h12, s12) (h13, s13) (h14, s14) (h15, s15) (h16, s16) (h17, s17) (h18, s18) (h19, s19) (h20, s20) (s2, s1) (s3, s2) (s4, s3) (s5, s4) (s6, s5) (s7, s6) (s8, s7) (s9, s8) (s10, s9) (s11, s10) (s12, s11) (s13, s12) (s14, s13) (s15, s14) (s16, s15) (s17, s16) (s18, s17) (s19, s18) (s20, s19)

*** Configuring hosts

h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

*** Starting controller

c0

*** Starting 20 switches

s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 s20 …

*** Starting CLI:

mininet>

Send pings between all hosts:

mininet> pingall

*** Ping: testing ping reachability

h1 -> h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

h2 -> h1 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

h3 -> h1 h2 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

h4 -> h1 h2 h3 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

h5 -> h1 h2 h3 h4 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

h6 -> h1 h2 h3 h4 h5 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

h7 -> h1 h2 h3 h4 h5 h6 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

h8 -> h1 h2 h3 h4 h5 h6 h7 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

h9 -> h1 h2 h3 h4 h5 h6 h7 h8 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

h10 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20

h11 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h12 h13 h14 h15 h16 h17 h18 h19 h20

h12 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h13 h14 h15 h16 h17 h18 h19 h20

h13 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h14 h15 h16 h17 h18 h19 h20

h14 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h15 h16 h17 h18 h19 h20

h15 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h16 h17 h18 h19 h20

h16 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h17 h18 h19 h20

h17 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h18 h19 h20

h18 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h19 h20

h19 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h20

h20 -> h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19

*** Results: 0% dropped (380/380 received)

mininet>

Result: A topology of twenty switches and twenty hosts is shown on the ODL SDN Controller:

ODL has the option to zoom in to view host and switch information. The following figure shows OpenFlow switches 18, 19 and 20:

OpenFlow-switches-18

Result: A topology of twenty switches and twenty hosts as seen on the ONOS SDN Controller:

ONOS-SDN-Controller1

Result: View of twenty switches and twenty hosts as seen on the HP VAN SDN Controller:

twenty-switches-HP-VAN-SDN-Controller

Linear topology (200 switches):

Mininet can support a large number of switches (4096 have been booted up according to mininet.org).

In this example, I have created a linear topology of 200 switches:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=linear,200

Result: This is the view of 200 switches on the ODL SDN Controller:

ODL-SDN-Controller1

Zoomed in view showing PCs connected to OpenFlow switches 200, 199, 197 and 196 (and others off-screen):

OpenFlow-switches-200-199-197

Linear topology (500 switches):

How about 500 switches? Here you go:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=linear,500

Result: This is the view of 500 switches on the ODL SDN Controller:

500-switches-on-the-ODL-SDN-Controller

Zoomed in view showing PCs connected to OpenFlow switches 500, 499 and 498 (and others off-screen):

PCs-connected-to-OpenFlow-switches-500-499-and-498

Single topology:

Single topology (4 hosts):

A single topology consists of a single switch with multiple hosts connected to it. In this example a single switch with 4 hosts is created:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=single,4

*** Creating network

*** Adding controller

*** Adding hosts:

h1 h2 h3 h4

*** Adding switches:

s1

*** Adding links:

(h1, s1) (h2, s1) (h3, s1) (h4, s1)

*** Configuring hosts

h1 h2 h3 h4

*** Starting controller

c0

*** Starting 1 switches

s1 …

*** Starting CLI:

mininet>

Result: View using the OpenDaylight (ODL) SDN Controller:

OpenDaylight-ODL

Result: View using ONOS SDN Controller:

 
 
View-using-ONOS-SDN-Controller

Result: View using the HP VAN SDN Controller:

View-using-the-HP-VAN-SDN-Controller

Single topology (24 hosts):

Now let’s try a 24 port switch:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=single,24

Result: View using the OpenDaylight (ODL) SDN Controller:

View-using-the-OpenDaylight-ODL-SDN-Controller

Result: View using the ONOS SDN Controller:

 
View-using-the-ONOS-SDN-Controller

Result: View using the HP VAN SDN Controller:

17.png

Single topology (96 hosts):

How about a 96 port switch? This is created by simply changing the options in Mininet:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=single,96

Result: View using the OpenDaylight (ODL) SDN Controller:

View-using-the-OpenDaylight-ODL-SDN-Controller1

Tree topology:

Tree topology (depth = 3, fanout =3):

A tree topology has a single switch with others connected to it based on a fanout number. A fanout value of 3 means 3 switches are connected to the core switch and each of those switches potentially has 3 switches connected to it. This continues based on the depth specified. The fanout also determines the number of hosts connected to each leaf/edge switch.

The following topology creates a tree topology with a depth and fanout of 3:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=tree,depth=3,fanout=3

Result: View using the OpenDaylight (ODL) SDN Controller:

View-using-the-OpenDaylight-ODL-SDN-Controller2

Result: View using the ONOS SDN Controller:

 
 
View-using-the-ONOS-SDN-Controller1

Result: View using the HP VAN SDN Controller:

View-using-the-HP-VAN-SDN-Controller2

Tree topology (depth = 2, fanout =10):

The following topology creates a tree topology with a depth of 2 and fanout of 10:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=tree,depth=2,fanout=10

Result: View using the OpenDaylight (ODL) SDN Controller:

View-using-the-OpenDaylight-ODL-SDN-Controller3

Tree topology (depth = 3, fanout =4):

The following topology creates a tree topology with a depth of 3 and fanout of 4:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=tree,depth=3,fanout=4

Result: View using the OpenDaylight (ODL) SDN Controller:

View-using-the-OpenDaylight-ODL-SDN-Controller

Result: Zoom in to see detail:

Zoom-in-to-see-detail

Tree topology (depth = 5, fanout =3):

The following topology creates a tree topology with a depth of 5 and fanout of 3:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=tree,depth=5,fanout=3

Result: View using the OpenDaylight (ODL) SDN Controller:

View-using-the-OpenDaylight-ODL-SDN-Controller

Result: Zoom in to see detail:

OpenDaylight-zoom

Torus topology:

Torus topology (3,3):

Torus topologies can also be created:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=torus,3,3

Result: View using the OpenDaylight (ODL) SDN Controller:

View-using-the-OpenDaylight-ODL-SDN-Controller

Result: View using the ONOS SDN Controller:


View-using-the-ONOS-SDN-Controller

Result: View using the HP VAN SDN Controller:

View-using-the-HP-VAN-SDN-Controller

Torus topology (4, 4):

Changed values in the Torus topology:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.50 –topo=torus,4,4

Result: View using the ONOS SDN Controller:

View-using-the-ONOS-SDN-Controller

If you want more information, have a look at my SDN and OpenFlow courses on the GNS3 academy http://academy.gns3.com or  visit the official Mininet site: http://mininet.org/

All the best!

David



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"