CSC 451/551: Computer Networks Fall 2016/Project 4: Software Defined Networks

1 Introduction
In this assignment you will learn how to use the OpenFlow protocol to program an SDN controller in
a Mininet emulated network using POX. The following sections will first introduce you to the tools
you will need to complete the assignment, guide you on how to install and use then, and lastly outline
what you will have to do.
2 Software Definined Networks (SDN)
A Software Defined Network (SDN) is a network with a centralized controller that dictates the flow
of network traffic. Unlike convention networks where each individual router or switch decided how to
forward packets, in an SDN a centralized controller tells each router or switch how to forward packets.
In this assignment you will have to write your own SDN controller.
3 OpenFlow
OpenFlow proposes a way for researchers to run experimental protocols in the networks they use every
day. It is based on an Ethernet switch, with an internal flow-table, and a standardized interface to add
and remove flow entries. OpenFlow exploits the fact that most modern Ethernet switches and routers
contain flow-tables (typically built from TCAMs) that run at line-rate to implement firewalls, NAT,
QoS, and to collect statistics. An OpenFlow Switch consists of at least three parts:
a. a flow table, which keeps an entry for every flow and tells each switch how to process the flow.
b. a secure channel that connects the switch to a remote control process, namely the controller that
adds and removes flow entries from the flow table for different experiments allowing commands
and packets to be sent between a controller and the switch by using
c. a protocol, which provides an open and standard way for a controller to communicate with a
In the context of OpenFlow, a flow can be a TCP connection, or all packets from a particular MAC
address or IP address, or all packets with the same VLAN tag, or all packets from the same switch
port. Every flow entry in the flow table has 3 basic actions associated with it:
a. Forward the flows packets to a given port or ports, which means packets are to be routed through
the network.
b. Encapsulate and forward the flows packets to a controller, which either processes them or decides
if the flow needs to be added as a new entry to the flow table (i.e. if the packet is the first in a
new flow).
c. Drop the flows packets, which can be used for security issues, to curb denial-of-service attacks
and so on.
Read the OpenFlow whitepaper [1] and familiarize yourselves with the basic OpenFlow elements, before
CSC 451/551: Computer Networks Fall 2016
4 Mininet & POX
Mininet is a python-based network emulation tool that you will use in this assignment to emulate
your own networks. Mininet has built in commands to create network topologies as well as an python
API to create your own custom topologies. For this assignment you will not need to learn how to
use the Mininet API. However, it is highly recommended that you read the first part of the Mininet
walkthrough and tutorial in order to learn how to use Mininet [3].
Although Mininet allows you to create almost any network topology you can think of, it only
provides you with a basic SDN controller. In order to get the most out of Mininet you will need to
write your own. Fortunately Mininet includes POX, a python-based API used to write SDN controllers
using the OpenFlow protocol. You will use POX in this assignment to write your own controller. If
you have questions about how to use POX, consult the wiki [4]. Although the POX wiki contains a
lot of useful information, the Stock Components subsection and the OpenFlow with POX section
will be the most useful to you.
5 Required Software
Almost everything needed for this assignment can run in a Mininet virtual machine. Step-by-step
instructions for installing Mininet can be found in [2]. Of special interest to you will be the following
a. Overview
b. Install Required Software
c. Set up Virtual Machine
Additionally, read the following sections in order to better understand the basics of Mininet and the
POX library will use for the assignment:
a. Learn Development Tools
b. Create Learning Switch – POX
Once you?ve read the tutorials and have Mininet up and running you will have to log into your Mininet
virtual machine (Username: mininet, Password: mininet) and execute the following commands from
the Mininet home directory:
cd pox
wget host
The files above will help you program your controller later on.
6 Assignment Description
This project consists of two parts, packet forwarding in a single switch topology and forwarding in a
binary tree topology.
CSC 451/551: Computer Networks Fall 2016
6.1 Single Switch Forwarding
Your first task is to properly forward traffic between two hosts connected to a single switch. Using
Mininet you should create a binary tree topology of depth 1, which will create two hosts (h1 and h2)
and a single switch (s1). The switchs datapath identifier (DPID) that is reported to the controller will
be 1. On the switch, h1 will be connected to port 1 and h2 will be connected to port 2. Rather than
hard coding the ports, you should use the IP address of a packet to determine which port it should
be sent to. Your controller should read in a comma-separated variable (CSV) file called hostlist.csv
that contains three columns: IP address, switch DPID, and switch port. For this first task, the file
will contain:,1,1,1,2
The file should be placed in the top-level pox directory. We have provided you a Python script gen host, which you should have downloaded already, to automatically generate this file for a given
topology. It takes one argument: the depth of the tree. To generate the file for this first task, you will
would run:
./gen host 1 > hostlist.csv
To get started on this first task in POX, you should look at the files:
For further details you can also consult the OpenFlow tutorial or wiki. If you have trouble viewing
any of the POX files mentioned above, look in the GitHub POX repository [5].
Figure 1: Mininet tree topology of depth 1
6.2 Binary Tree Forwarding
Your second task is to properly forward traffic between two hosts connected in a binary tree topology.
You should create a binary tree topology of at least depth 2 in Mininet. You should also create the
correct corresponding hostlist.csv file using the gen host script. To complete this task in POX,
you should rely on the discovery module which sends LLDP messages between OpenFlow switches and
constructs a list of links between switches. The launch function in your POX module should include
the following to start the discovery module:
import pox.openflow.discovery
CSC 451/551: Computer Networks Fall 2016
You can access the list of links created by the discovery module by adding the following line of code
within your POX module:
link list = core.openflow discovery.adjacency
The POX spanning tree module relies on the discovery module, so you should look at the file:
The file should provide you guidance on how to use the list of links created by the discovery module.
You can also look at the source code for the discovery module in GitHub repository mentioned above.
Figure 2: Mininet tree topology of depth 3
7 Getting Started
The sections below will help you get started on the assignment as well provide you with hints on how
to complete it.
7.1 Single Switch Forwarding
For this portion of the assignment you will be editing the single python file. To begin, log-on
to your Mininet VM using VirtualBox and SSH into it from a separate window (if you don?t know
how to do this you didn?t read the tutorial closely enough). Once that?s done select the VirtualBox
window and run the following command:
sudo mn – -topo tree,1 – -mac – -arp – -switch ovsk – -controller=remote
Note: There should be no spaces in between the dashes. Each part of the command does the following:
sudo: runs as root
mn: runs Mininet commands
– -topo tree,1: creates a tree topology of depth 1 with the default fanout of 2 (i.e., binary)
– -mac: makes the mac address of Mininet hosts the same as their node number
– -arp: installs static ARP entries in all hosts
CSC 451/551: Computer Networks Fall 2016
– -switch ovsk: uses Open vSwitch in kernel mode for each of the switches
– -controller=remote: tells Mininet to not use the default controller
Now you have a Mininet topology to work on. If you try to ping any of the hosts right now you?ll
find that your packets do not reach their destination. In order to fix that you must write your own
controller. Select your SSH window and navigate to the pox sub-folder. Make sure you?ve downloaded
gen host and single before continuing. Now run gen host using an argument
of 1 in order to create a valid hostlist.csv for this portion of the assignment. You can hostlist.csv was
created correctly using VIM or any other editor of your choice. To verify with VIM use:
vim hostlist.csv
Once you know the file is correct, open gen host using your favorite editor and begin the
assignment. Your controller must do the following:
1. Determine the packet destination IP address
2. If it has a valid IP address:
(a) Using hostlist.csv determine which port corresponds to the destination IP address
(b) Forward packet using forward packet
3. If the IP address is invalid or does not exist:
(a) Either do nothing or flood the packet on all ports in order continue the program, this is up
to you
Once you?re done editing the file, exit and test your controller. You can do this by using the following
command in the pox directory:
python log.level – -DEBUG single switch
Note: sometimes POX throws an error and tells you that a controller is already running. If that?s
the case make sure you used the controller remote argument. If you did and you still get the error,
restart your Mininet VM. Now ping a host using the Mininet window you opened previously and see
whether or not your controller works. Note that if chose to use the flood method in case of a mismatch
or invalid IP address, your packets will always get to their destination. Make sure that your packets
are being forwarded by your own code if that is the case. Once you?re packets have arrived to their
destination with 0% packet loss you are done.
7.2 Binary Switch Forwarding
Restart your VM if you still have it opened from the previous section and SSH into Mininet from a
separate window. In the VirtualBox window run the following command:
sudo mn – -topo tree,3 – -mac – -arp – -switch ovsk – -controller=remote
This command will create a binary tree with 3-layers of switches and 8 end-hosts. Next, run gen host
to create the appropriate hostlist.csv file. Now open the binary file and begin coding. For
this part of the assignment you will have to:
1. Determine which type of packet you?re dealing with
2. Extract the destination IP address
CSC 451/551: Computer Networks Fall 2016
3. Create an algorithm that can determines which port a packet with a given address should be
forwarded in order to get to its destination
Note: Do not flood all ports with the packet, you will not be given credit for that solution. Your
forwarding algorithm will be the most difficult part of this section of the assignment. However, if you
use the openflow.discovery module you can generate a list of links between switches. Your algorithm
could then use those links to plot a path from the switch connecting to the destination host to your
current switch. Once you?ve created your algorithm you can use the following command to test your
python log.level – -DEBUG binary switch
Once your packets from any host can arrive to any other host, your are done.
8 What to Submit
Once you?re done with the assignment, you should submit the two python files, single and
binary, to Blackboard. In order to transfer files out of Mininet, you can either use scp
command in the Mininet terminal or use an SCP client.
9 References
1. Nick McKeown, Tom Anderson, Hari Balakrishnan, Guru Parulkar, Larry Peterson, Jennifer
Rexford, Scott Shenker, and Jonathan Turner. OpenFlow: enabling innovation in campus networks.
ACM SIGCOMM Computer Communication Review, 38(2):6974, 2008. [Last visited: 2016-10-13]
2. OpenFlow Tutorial. Tutorial. [Last visited on 2016-10-13].
3. Mininet Walkthrough. [Last visited on 2016-10-13].
4. POX Wiki [Last visited 2016-10-19]
5. GitHub Pox Repository [Last visited 2016-10-21]

"Order a Custom Paper on Similar Assignment! No Plagiarism! Enjoy 20% Discount"

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *