SDN 101: Mininet (OpenFlow) and GNS3

In this blog entry I am going to show you how to set up an OpenFlow enabled network running in Mininet with GNS3 devices and an SDN Controller. This network will run both OpenFlow and traditional networking.

You will find this kind of set up useful when learning SDN and OpenFlow. See the GNS3 academy for more information: http://academy.gns3.com

Quick Mininet oveview: 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

Network Overview

GNS3

Here is a screenshot of the network in GNS3:

screenshot-of-the-network-in-GNS3

Device IP addresses:

  • Mininet host 1 (h1) = 10.0.0.1 (not shown in topology)
  • Mininet host 1 (h2) = 10.0.0.2 (not shown in topology)
  • Cisco R1 = 10.0.0.3
  • Cisco R2 = 10.0.0.3
  • SDN Controller = 172.16.56.31 (not shown in topology)

I am using an existing SDN Controller in my physical network as it was easier for me to do that. You could also import an SDN Controller VM into GNS3 if you preferred.

SDN Controller View

Here is a screenshot of the OpenFlow switches and Nodes as shown on the HP VAN SDN Controller:

OpenFlow-switches-and-Nodes

Here are the Mininet switches registered with the HP VAN SDN Controller. I also have an OpenFlow enabled HP VSR registered (I will talk about that more in another blog entry).

Mininet-switches-registered-with-the-HP-VAN-SDN-Controller

Here are the ports of Mininet switch 1 (S1):

ports-of-Mininet-switch-1

Explanation:

  • Port 1 is connected to Mininet host 1 (h1)
  • Port 2 is connected to Mininet switch 2 (00:00:00:00:00:00:00:02)
  • Port 3 is connected to Cisco Router 1 (R1)
  • LOCAL is the local management stack of the Mininet switch

Here is the output of Cisco R1 pinging devices:

output-of-Cisco-R1-pinging-devices

Device IP addresses:

  • Mininet host 1 (h1) = 10.0.0.1
  • Mininet host 1 (h2) = 10.0.0.2
  • Cisco R1 = 10.0.0.3
  • Cisco R2 = 10.0.0.4

Here is the output of Mininet host h1 pinging Cisco R1 (10.0.0.3) and R2 (10.0.0.4):output-of-Mininet-host-h1-pinging-Cisco

Here is a larger network example

Here is another example of the two Cisco routers integrated into a larger OpenFlow topology (I have changed the Router IP addresses in this example):

two-Cisco-routers-integrated-into-a-larger-OpenFlow-topologyAs mentioned, the HP VSRs now support OpenFlow. I will talk about that at another time. Ping from Cisco router (also showing ping timeout on first ping due to ARP delay):

Ping-from-Cisco-router

How do you set this up?

In this blog, I am assuming that you already have a working SDN controller available. In my example I have used the HP VAN SDN Controller, but you could use ODL, ONOS, RYU or others. Here are the steps you need to complete to get this working:

Step 1: Download Mininet

Download the Mininet VM from
http://mininet.org/download/

Download-MininetStep 2: Import Mininet into VirtualBox

Import-Mininet-into-VirtualBox

Step 3: GNS3 VirtualBox setup

In GNS3, click Preferences  and then VirtualBox VMs.

Import the Mininet-VM from VirtualBox:

Import-the-Mininet-VM-from-VirtualBoxClick Edit to edit the Mininet-VM settings. In my case, I enabled the remote console and created 4 NICs on the Mininet VM, but I only used 3 of them in the lab:

Mininet-VM-settings

Mininet-VM-settings-mininet

Step 4: GNS3 Topology

Create your GNS3 topology as you like.

GNS3-Topology

In my example, I enabled NAT on R3 so I didn’t have to be concerned about routing between my virtual and physical network. You don’t have to do that. You could also use an SDN Controller VM imported into GNS3 rather than using an SDN Controller in the physical network like I did.

Step 5: Create your Mininet topology

In this example, I created a small Mininet topology of two switches connected back to back (linear) and used OpenFlow 1.3:

small-Mininet-topology-of-two-switches-connected

Command used:

mininet@mininet-vm:~$ sudo mn –controller=remote,ip=192.168.56.31 –topo=linear,2 –switch=ovsk,protocols=OpenFlow13 –mac

Step 6: Add Ethernet interfaces to Mininet

You need to add your GNS3 interfaces (that you want to control via OpenFlow) to the Mininet switches. In my example eth0 and eth1 will be controlled by OpenFlow:

Ethernet-interfaces-to-Mininet

Commands used:

Add eth0 to Mininet switch 1:

mininet@mininet-vm:~$ sudo ovs-vsctl add-port s1 eth0

Add eth1 to Mininet switch 2:

mininet@mininet-vm:~$ sudo ovs-vsctl add-port s2 eth1

Verify changes:

To view the changes use the sudo ovs-vsctl show command:

mininet@mininet-vm:~$ sudo ovs-vsctl show

0b8ed0aa-67ac-4405-af13-70249a7e8a96

    Bridge “s1”

        Controller “tcp:192.168.56.31:6633”

            is_connected: true

        Controller “ptcp:6634”

        fail_mode: secure

        Port “eth0”

            Interface “eth0

        Port “s1-eth1”

            Interface “s1-eth1”

        Port “s1-eth2”

            Interface “s1-eth2”

        Port “s1”

            Interface “s1”

                type: internal

    Bridge “s2”

        Controller “tcp:192.168.56.31:6633”

            is_connected: true

        Controller “ptcp:6635”

        fail_mode: secure

        Port “s2-eth2”

            Interface “s2-eth2”

        Port “s2”

            Interface “s2”

                type: internal

        Port “s2-eth1”

            Interface “s2-eth1”

        Port “eth1”

            Interface “eth1”

    ovs_version: “2.0.2”

mininet@mininet-vm:~$

In this example, eth0 is connected to S1 and eth1 is connected to S2.

Step 7: Test

And now you have an integrated Mininet OpenFlow network and GNS3 working together!

Mininet h1 pinging Cisco R1:

mininet> h1 ping -c 3 10.0.0.3

PING 10.0.0.3 (10.0.0.3) 56(84) bytes of data.

64 bytes from 10.0.0.3: icmp_seq=1 ttl=255 time=2.11 ms

64 bytes from 10.0.0.3: icmp_seq=2 ttl=255 time=0.564 ms

64 bytes from 10.0.0.3: icmp_seq=3 ttl=255 time=9.13 ms

— 10.0.0.3 ping statistics —

3 packets transmitted, 3 received, 0% packet loss, time 2003ms

rtt min/avg/max/mdev = 0.564/3.937/9.131/3.726 ms

Mininet h1 pinging Cisco R2:

mininet> h1 ping -c 3 10.0.0.4

PING 10.0.0.4 (10.0.0.4) 56(84) bytes of data.

64 bytes from 10.0.0.4: icmp_seq=1 ttl=255 time=15.2 ms

64 bytes from 10.0.0.4: icmp_seq=2 ttl=255 time=4.64 ms

64 bytes from 10.0.0.4: icmp_seq=3 ttl=255 time=2.62 ms

— 10.0.0.4 ping statistics —

3 packets transmitted, 3 received, 0% packet loss, time 2002ms

rtt min/avg/max/mdev = 2.620/7.505/15.250/5.539 ms

mininet>

Mininet h1 pinging Mininet h2:

mininet> h1 ping -c 3 10.0.0.2

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=0.433 ms

64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.257 ms

64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.038 ms

— 10.0.0.2 ping statistics —

3 packets transmitted, 3 received, 0% packet loss, time 1998ms

rtt min/avg/max/mdev = 0.038/0.242/0.433/0.162 ms

mininet>

Cisco R1 pinging Mininet h1:

R1# ping 10.0.0.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.0.0.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/8/12 ms

R1#

Cisco R1 pinging Mininet h2:

R1# ping 10.0.0.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.0.0.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/8/12 ms

R1#

Cisco R1 pinging Cisco R2:

R1# ping 10.0.0.3

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.0.0.3, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

R1#

There you have it! An SDN enabled OpenFlow networking and GNS3 working together.

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"