SDN 101: Integrating Mininet on Raspberry Pi

How to install and run OpenFlow switches on a Raspberry Pi using Mininet

install-and-run-OpenFlow-switches-on-a-Raspberry-Pi-using-Mininet

Mininet is a network emulator that can create and emulate an entire OpenFlow network locally on your PC, or in this case, a Raspberry Pi. This is similar in concept to network emulators such as GNS3. Mininet may even be added to GNS3 in the future.

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.

Mininet can be downloaded as a virtual machine that be run within VirtualBox, VMware workstation, ESXi or Parallels (easiest way).

In this blog entry, I am going to show you another easy way to install Mininet using a Raspberry Pi:

Step 1: On your Raspberry Pi, clone Mininet from github:

pi@raspberrypi1 ~ $ sudo git clone git://github.com/mininet/mininet.git

Step 2: Go to the util directory:

pi@raspberrypi1 ~ $ cd mininet/util/

Step 3: Run the install.sh script using either of these options:

Option 1: Basic Install:

pi@raspberrypi1 ~/mininet/util $ sudo ./install.sh -fnv

Option 2: Install everything:

pi@raspberrypi1 ~/mininet/util $ sudo ./install.sh -a

Step 4: Coffee

The script will install Mininet … now is a good time for a coffee break (especially if you used the -a option).

Result: Done! Mininet is now installed.

Test: To test the setup, start a basic Mininet topology using the “sudo mn” command:

pi@raspberrypi1 ~ $ sudo 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>

Result: This creates a topology consisting of a single switch and two hosts.

To test connectivity between the hosts, use the “pingall” command:

mininet> pingall

*** Ping: testing ping reachability

h1 -> h2

h2 -> h1

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

mininet>

Result: Pings succeed.

To close Mininet, use the “exit” command:

mininet> exit

*** Stopping 1 controllers

c0

*** Stopping 2 links

..

*** Stopping 1 switches

s1

*** Stopping 2 hosts

h1 h2

*** Done

completed in 108.673 seconds

pi@raspberrypi1 ~ $

It is good practice to clean up Mininet once you exit using the “sudo mn -c” command:

pi@raspberrypi1 ~ $ sudo mn -c

*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes

killall controller ofprotocol ofdatapath ping nox_core lt-nox_core ovs-openflowd ovs-controller udpbwtest mnexec ivs 2> /dev/null

killall -9 controller ofprotocol ofdatapath ping nox_core lt-nox_core ovs-openflowd ovs-controller udpbwtest mnexec ivs 2> /dev/null

pkill -9 -f “sudo mnexec”

*** Removing junk from /tmp

rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log

*** Removing old X11 tunnels

*** Removing excess kernel datapaths

ps ax | egrep -o ‘dp[0-9]+’ | sed ‘s/dp/nl:/’

***  Removing OVS datapaths

ovs-vsctl –timeout=1 list-br

ovs-vsctl –timeout=1 list-br

*** Removing all links of the pattern foo-ethX

ip link show | egrep -o ‘([-_.[:alnum:]]+-eth[[:digit:]]+)’

ip link show

*** Killing stale mininet node processes

pkill -9 -f mininet:

*** Shutting down stale tunnels

pkill -9 -f Tunnel=Ethernet

pkill -9 -f .ssh/mn

rm -f ~/.ssh/mn/*

*** Cleanup complete.

pi@raspberrypi1 ~ $

To create a bigger topology consisting of 4 switches, use the following command:

pi@raspberrypi1 ~ $ sudo mn –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: A topology consisting of 4 switches each having a single host connected to them is created.

Connectivity between hosts can be tested once again using 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>

Result: Pings succeed. Mininet can also be integrated with external controllers like OpenDayLight (ODL), ONOS, HP VAN SDN Controller and others.

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.100):

pi@raspberrypi1 ~ $ sudo mn –controller=remote,ip=192.168.56.100 –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> 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>

View using OpenDaylight (ODL):

OpenD

Or using the ONOS controller:

Open Networking

Or the HP VAN SDN Controller:

HP SDN

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/

Make sure to check out Davids Courses in GNS3 Academy (and watch out for his upcoming SDN / Openflow Course soon!):



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"