A Short Walk-Through of Mininet and POX: Part 1: The Mininet Network Emulation Environment
A Short Walk-Through of Mininet and POX: Part 1: The Mininet Network Emulation Environment
Semester 1
It comes with the latest version of Mininet a.ka. HiFi and two OpenFlow Controllers (POX
and Pyretic). The download will take some time. Its ~ 800MB, compressed.
Start VirtualBox
Select File>Import Appliance and select the .ova file
Press the "Import" button.
o
This will unpack and import the VM in your local machine. It will take a
while, as the unpacked image is about 3 GB.
CS5229
Semester 1
Boot VM
Now, you are ready to start your VM. Press the "Start" arrow icon or double-click your VM
within the VirtualBox window.
In the VM console window, log in with the user name and password for your VM. The
username and password for this VM are:
Note that this user is a sudoer, so you can execute commands with root permissions by
typing sudo command, where command is the command you wish to execute with root
permission.
2. Mininet
Mininet is a powerful network emulation tool. It creates a realistic virtual network, running
real kernel, switch and application code on a single machine. You can easily interact with
your network using the Mininet Command Line Interface (CLI).
The network topology used in this tutorial consists of 3 hosts, 1 switch and 1 POX controller
(see below).
CS5229
Semester 1
Options:
--topo single,3: linear topology which includes 3 virtual hosts
--mac: set the host MAC and IP addresses to small, unique, easy-to-read IDs
--switch ovsk: the switch used here is an Open vSwitch
--controller remote: the controller is at a remote location
CS5229
Semester 1
SSH is short for Secure SHell. It provides a way to securely access another computer
remotely.
CS5229
Semester 1
CS5229
Semester 1
Replace [Guest IP Here] with the IP you just found out. If ssh does not connect, make
sure that you can ping the IP address you are connecting to.
Enter the password for your VM image. Next, try starting up an X terminal using
$ xterm
and a new terminal window should appear.
2. Windows
To use X11 applications such as xterm, the Xming server must be running, and you
must make an ssh connection with X11 forwarding enabled.
First, Start Xming. No window will appear. You can check Windows task
manager if you wish to verify.
Second, make an ssh connection with X11 forwarding enabled.
Start PuTTY, enter your VMs IP address and enable X11 forwarding. To enable X11
forwarding from PuTTYs GUI, go to Connection -> SSH -> X11. Then click Enable
X11 forwarding. Now click Open, a new terminal should appear.
Alternatively, you can create a login shortcut. In Windows, create a new shortcut and
enter the full path to your PuTTY file as:
[Full Path] X mininet @ [Guest IP] pw mininet
e.g. C:\putty.exe -X [email protected] -pw mininet
Note: After this point, do not start Mininet directly from VirtualBox console. Open a terminal
to make a SSH connection (i.e., use Putty) and start Mininet in your remote terminal. In fact,
never use the VirtualBox VM console again. After starting the VirtualBox just minimize the
console and do not use it.
CS5229
Semester 1
CS5229
Semester 1
For example, from Node h3, we can test the connectivity to h2 by typing:
ping c3 10.0.0.2
The result should be:
CS5229
Semester 1
For instance you already developed a switching function named switch(). If you want to
trig the function when the controller starts to work, add a listener in lunch to provoke
CS5229
Semester 1
From typically the init of a class, perform addListeners(self). Once this is added, the
controller will look for a function with the name _handle_EVENTNAME(self, event).
This method is automatically registered as an event handler.
Event handlers
As explained above you need to set a listener on your POX and when an event happens the
relevant handler function will be activated. Your control logic should be placed in one of these
handlers.
The two main handlers that you might need to modify in your program are:
ConnectionUp, which is activates when a switch turns on (or connects to the controller). The
name of the handler function for this event is: _handle_ConnectionUp. Be careful about
timers when implementing this handler. ConnectionUp triggers only once when the switch
starts to work.
PacketIn, activates by arriving a packet into the controller. The name of the handler is
_handle_PacketIn.
ofp_match class
This class describes packet header fields and an input port to match on. Fields not
specified are wildcards and will match on any value.
For example, create a match which matches packets arriving on port 3:
match = of.ofp_match()
match.in_port = 3
ofp_action_output class
CS5229
Semester 1
This is an action which specifies a switch port that you want to send the packet out of.
There is a variety of pre-defined port numbers such as OFPP_FLOOD.
For example, create an action which sends packet out of port 2.
out_action = of.ofp_action_output(port = 2)
connection.send()
This function sends an OpenFlow message to a switch
For example, create a flow_mod that sends packets arriving on port 3 out of port 4
msg = of.ofp_flow_mod()
msg.match.in_port = 3
msg.actions.append(of.ofp_action_output(port = 4))
connection.send(msg)
Note: Many of these objects and associated attributes are not used in the hub example
but they might be useful in the assignment.
After that the prompt will change from $ to mininet>. From now on we will refer to
this terminal as mininet console.
You can try out Mininet commands here. For instance try:
mininet> h1 ping h2
CS5229
Semester 1
You will see that h1 fails to ping h2 as there is no controller installed yet.
4. So as the next step start a controller. You can start your own controller (file name
controller.py) while doing your assignment or you can use some available controller
in Mininet.
Open a new terminal and change the directory to pox ($ cd pox) and try running a
basic hub example:
forwarding.hub
Mininet References:
http://mininet.org/
https://github.com/mininet/mininet/wiki/Introduction-to-Mininet