Programming Assignment 3: Programming A Simple Controller: Instructions
Programming Assignment 3: Programming A Simple Controller: Instructions
Controller: Instructions
In this exercise, you will learn about an open-source OpenFlow controller “POX”. You will learn
how to write network applications, i.e., Hub and Layer 2 MAC Learning etc., on POX and run
them on a virtual network based on Mininet.
After the exercise, you will be asked to create and submit a network application that implements
Layer 2 Firewall that disables inbound and outbound traffic between two systems based on their
MAC address. More details on creating and submitting the code will be provided later on in the
instructions. So, make sure that you follow each step carefully.
(Note: you can skip this section and start directly with the assignment at the end, if you feel
confident and are already familiar with POX and its basic functions)
Overview
The network you'll use in this exercise includes 3 hosts and a switch with an OpenFlow
controller (POX):
When a connection to a switch starts, a ConnectionUp event is fired. The above code invokes
a _handle_ConnectionUp () function that implements the hub logic.
ofp_action_output class
This is an action for use with ofp_packet_out and ofp_flow_mod. It specifies a switch port
that you wish to send the packet out of. It can also take various "special" port numbers. An
example of this, as shown in Table 1, would be OFPP_FLOOD which sends the packet out all
ports except the one the packet originally arrived on.
Example. Create an output action that would send packets to all ports:
out_action = of.ofp_action_output(port = of.OFPP_FLOOD)
ofp_match class (not used in the code above but might be
useful in the assignment)
Objects of this class describe packet header fields and an input port to match on. All fields are
optional -- items that are not specified are "wildcards" and will match on anything.
Some notable fields of ofp_match objects are:
The ofp_packet_out message instructs a switch to send a packet. The packet might be one
constructed at the controller, or it might be one that the switch received, buffered, and forwarded
to the controller (and is now referenced by a buffer_id).
Notable fields are:
This instructs a switch to install a flow table entry. Flow table entries match some fields of
incoming packets, and executes some list of actions on matching packets. The actions are the
same as for ofp_packet_out, mentioned above (and, again, for the tutorial all you need is the
simple ofp_action_output action). The match is described by an ofp_match object.
Notable fields are:
Example. Create a flow_mod that sends packets from port 3 out of port 4.
fm = of.ofp_flow_mod()
fm.match.in_port = 3
fm.actions.append(of.ofp_action_output(port = 4))
Like before, we'll create xterms for each host and view the traffic in each.
In the Mininet console, start up three xterms:
mininet> xterm h1 h2 h3
Arrange each xterm so that they're all on the screen at once. This may require reducing the
height of to fit a cramped laptop screen.
In the xterms for h2 and h3, run tcpdump, a utility to print the packets seen by a host:
Assignment
Background
A Firewall is a network security system that is used to control the flow of ingress and egress
traffic usually between a more secure local-area network (LAN) and a less secure wide-area
network (WAN). The system analyses data packets for parameters like L2/L3 headers (i.e.,
MAC and IP address) or performs deep packet inspection (DPI) for higher layer parameters (like
application type and services etc) to filter network traffic. A firewall acts as a barricade between
a trusted, secure internal network and another network (e.g. the Internet) which is supposed to
be not very secure or trusted.
In this assignment, your task is to implement a layer 2 firewall that runs alongside the MAC
learning module on the POX OpenFlow controller. The firewall application is provided with a list
of MAC address pairs i.e., access control list (ACLs). When a connection establishes between
the controller and the switch, the application installs flow rule entries in the OpenFlow table to
disable all communication between each MAC pair.
Network Topology
Your firewall should be agnostic of the underlying topology. It should take MAC pair list as input
and install it on the switches in the network. To make things simple, we will implement a less
intelligent approach and will install rules on all the switches in the network.
Handling Conflicts
POX allows running multiple applications concurrently i.e., MAC learning can be done in
conjunction with firewall, but it doesn’t automatically handles rule conflicts. You have to make
sure, yourself, that conflicting rules are not being installed by the two applications e.g., both
applications trying to install a rule with same src/dst MAC at the same priority level but with
different actions. The most simplistic way to avoid this contention is to assign priority level to
each application.
Understanding the Code
To start this exercise, download Programming-Assignment3.zip. It consists of three files:
firewall.py: a sekleton class which you will
update with the logic for installing firewall rules.
firewall-policies.csv: a list of MAC pairs
(i.e., policies) read as input by the firewall
application.
submit.py: used to submit your code and output
to the course servers for grading.