How to Perform Transparent Packet Redirection with OpenFlow and Floodlight

How to Perform Transparent Packet Redirection with OpenFlow and Floodlight

This tutorial is for Floodlight v1.0, v1.1, v1.2, and later. Prior Floodlight versions have a different REST API.

Also, this tutorial is geared towards the GENI testbed. Although instructions are not provided, it can easily be conducted using mininet or your own network.

This tutorial was designed, written, and contributed by Geddings Barrineau (cbarrin). Thanks Geddings!

Table of Contents

Motivation

Are you interested in Software Defined Networking or OpenFlow? Don't know where or how to start? Or maybe you just haven't been able to think of any good ideas?

If any of these questions describe you then you're in the right place!

As the title suggests, in this tutorial you're going to learn how to use Floodlight in conjunction with Open vSwitch and OpenFlow to perform transparent redirection of packets! If a lot of that sounds confusing, don't worry – we'll go over everything in detail and show you step by step every command that you're going to need to run.

By the end of this tutorial you should be familiar with the following:

  • Floodlight

  • Open vSwitch

  • Creating OpenFlow flows

    • OpenFlow matches

    • OpenFlow rewrites

  • Various Linux networking tools

If this sounds good to you, then let's get started!

Getting our GENI topology set up

To get things moving quickly, an rspec of the topology you’ll be using has already been created for you. 

Simply point Jacks to that file and watch as your topology is magically created!

The only thing left to do is to choose a site, but wait for further instructions before you do that.

In the meantime, get a little familiar with the topology. You’ll notice that there are three hosts, all connected to each other through a single OpenFlow enabled switch in the middle (more on that in a second). This is your data plane. 

The next thing you should notice is that the switch is connected to the controller. This is your control plane.

More about the switch. It is actually a software switch known as Open vSwitch or OVS for short. The OVS used here is version 2.3.1 which (almost) fully supports OpenFlow 1.3.

And about the controller. In this tutorial we’ll be using the Floodlight controller. It’s just a Java based controller, and it’s going to have a global view of our network! That means it will know all about the switch and all the hosts connected to it. Floodlight is going to make every decision on how packets should travel through the data plane. In fact, we’ll be telling Floodlight how it should handle certain packets by making it insert some well crafted flows onto our software switch.

 

Configuring the controller

Once a site has been chosen and all of the resources are up, go ahead and ssh into the controller. All of the commands in this section are going to be run from within the controller resource. 

There are a few things that we need to install, the first being Floodlight! It’s located on GitHub, so we’ll just grab that using the following command:

Download Floodlight from Github
git clone http://github.com/floodlight/floodlight

Since Floodlight was recently updated to support Java 8 (lambda expressions anyone?) we need to download and install Java 8 onto this machine. In order to do this we’re going to have to add a repository, which requires us to install another tool. 

I know. I hate it too.

Go ahead and enter these commands:

sudo apt-get update sudo apt-get install software-properties-common python-software-properties sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer

Congratulations! You just installed Java 8! Confirm it with the following command:

java -version

Because Java is a compiled language, we’re also going to need to compile the controller. We’re going to do this with the tool ant.

Let’s go ahead and install that:

sudo apt-get install ant

And finally (this is the last one I promise) we need to install curl. Curl is simply a tool that lets a user transfer data to or from a server. Floodlight has, built in, what’s known as a REST API. Using Curl and these REST commands, we can communicate with Floodlight, which we will do extensively.

Seriously, this is the last one. Go ahead and install:

sudo apt-get install curl

Okay! On to the fun stuff. Let’s change directories into the floodlight folder, compile, and finally run it.

Go ahead and run these commands:

cd floodlight ant java -jar target/floodlight.jar

You should now see a stdout log from Floodlight. Nothing too interesting yet, but if you wait long enough, you’ll see Floodlight sending out LLDP packets, trying to discover the topology. It won’t see much yet, though, because no switches have been connected to Floodlight.

Configuring the switch

Now that the controller is configured and running, we need to configure the switch.

Let’s start this off by looking at what our current switch configuration looks like. 

You can see this by running the following:

sudo ovs-vsctl show 

At this point, nothing is configured so you shouldn’t really see anything meaningful. That’s about to change!

Adding the bridge

The first thing we have to add is a bridge. A bridge directs traffic to the appropriate interface based on MAC address. We’ll add ports to it in a minute.

We’re going to create a bridge named br0. You can add it using the following command:

sudo ovs-vsctl add-br br0

Adding the ports

Now this is the point where things get a little trickier, so read carefully! 

Run the command ifconfig. You’re going to see 5 eth interfaces:

  • The public interface

    • This is most likely going to be eth0 and have an IP address of 172.17.*.*

    • DO NOT CHANGE THIS! You will get kicked out of your ssh session and will have to restart to get back in!

  • The control plane interface

    • This is going to have an IP address of 192.168.1.1

    • This is the interface that is connected to the Floodlight controller

  • Three 10.10.*.* interfaces; One to each host

    • These are the interfaces that we’ll be adding to the bridge as ports

    • We’ll also be changing the IP address on each of these as well