Floodlight OpenFlow Controller: Using the Static Flow Entry Pusher

Floodlight OpenFlow Controller: Using the Static Flow Entry Pusher

Openflow Programming Header Sm

Floodlight OpenFlow Controller: Using the Static Flow Entry Pusher

Floodlight OpenFlow Controller: Using the Static Flow Entry Pusher: The first post in this tutorial can be found at Tutorial to Build a FloodLight SDN OpenFlow Controller .

For those looking to do things with early SDN / OpenFlow controllers this post may be of some use to kickstart your efforts. I am posting a Java class below that Cory Fowler and I put together. There are lots of good guides out there but what exactly I was looking for was unavaialble at the time.

Packet-in Logic

The goal was to get the framework together for this project, but I didn’t see anything out there that did it from within Floodlight with a Java module. Fortunately, the guys from BigSwitch built a nice module that abstracted some of the nuances of doing a FlowMod like OFAction fields, setting lengths, flushing between flows and the dozens of other little gotchas that need layers of abstraction to simplify.

OpenFlow FlowMod

Using the Floodlight Static Flow Entry Pusher Service

What this allows for is to proactively instantiate a static flow to define a predetermined path based on a match and then the corresponding action.

Simple OpenFlow workflow
The flow logic looks like the following minus lots of details:
  1. Flow comes into the OpenFlow enabled switch.
  2. Switch looks in its forwarding table to see if there is a match. If there is a match the switch forwards that packet per the forwarding table instruction. The matches can either be a coarse match like anything destined to IPv4 —> do this action, or as fine as anything matching {port 80, mac addr 0000.1111.2222, dest_ipv4, (any other tuple in the header) etc}. Think traditional _access-lists_.
  3. If there is not a matching flow in the switch an event is triggered creating a packet-in packet to the controller where the logic in the code below could be processed.
  4. After the controller determines an action it then creates a packet-out packet that tells the switch what action to take with that flow and subsequent packets in that same flow.
Note on a FlowMod for IPv4 destination prefix matching
If you are matching on a IPv4 destination you need to set the ethertype per the OpenFlow spec. In the next section code, that looks like: .setDataLayerType(Ethernet.TYPE_IPv4)

The method to add a flow requires three parameters addFlow(String name, OFFlowMod fm, String swDpid);

  1. String name: The name variable is an arbitrary name, but it must be unique to the static flow. If you use the same name it will be overwritten. Very similar to access list line numbers.
  2. OFFlowMod fm: fm is the flow to push.
  3. String swDpid: Is the switch datapath ID (DPID) to push it to. The Mininet default DPID is 00:00:00:00:00:00:00:01.
Floodlight package net.floodlightcontroller.staticflowentry Javadoc
The package net.floodlightcontroller.staticflowentry is documented at the OpenFlow Hub.

Below is a module that I threw together for this post but mainly as part of another project, ehem* disclaimer if completely inefficient :-)

Testing the Class with Mininet

For testing I normally use Mininet. If you look at the first post you can see the video and how to attach mininet switches to the controller running in Eclipse and use Xterm to source traffic from your simulated hosts.

Additional OpenFlow SDN Development Resources

Here are some open source OpenFlow controller projects and links to their documentation tutorials and guides.

  • Floodlight – Lots of nice documents for developers to understand how to get started. The Floodlight listserv is very helpful also.
  • Beacon – David has lots of good tutorials at the Beacon OpenFlow homepage. FloodLight was built on top of Ericksons controller Beacon. David is a nice guy that does an amazing job answering questions on the Beacon forum. Pretty neat to have the chance to ask questions directly from a pioneer like him. He has just updated his development tutorial so take a look at Creating a Learning Switch and help with feedback on the Beacon forum if interested.
  • POX – For those more comfortable with programming with Python have a look at Murphy McCauley’s project POX. Murphy is another very accessible community oriented researcher.
  • For those wanting to just get a basic understanding of OpenFlow or even just watch a video of it and  don’t care about the nitty gritty programming details, this tutorial I did a while back. It needs a makeover but its probably enough to get the point. I need to update it but its just basic usage of the RESTful Floodlight API.

Programming applications directly into OpenFlow primitives is likely not the path for any semblance of DevOps networking gets in to. There will be additional layers that will enable :Policy in -> Flows out. These additional layers are cropping up in the form of APIs and additional languages that are creating the SDN policy wood chipper to create flows. I discussed a couple of those projects in this post: Software Defined Network (SDN) -Looking Toward 2013

Here are some additional reading on networking APIs from some friends:

Learn more about Floodlight development on the Floodlight-Dev Listserv

Hope this helps add some documentation for those looking to dig under the hood a bit and create their own networking applications for research or a network that fits their needs. Thanks for stopping by.

Download OpenFlow v1.3

About the Author

Brent SalisburyI have over 15 years of experience wearing various hats from, network engineer, architect, devops and software engineer. I currently have the pleasure of working at the company that develops my favorite software I have ever used, Docker. My comments here are my personal thoughts and opinions. More at Brent's BioView all posts by Brent Salisbury →

2 years 3 months ago


I’m having problems implementing your setup on my Procurve 6600 switches. In particular I am not sure what port to use if we are using the OOBM (out of band management port) for command and control. You are using port ‘0’. How should I modify my code to take advantage of this port.

IOFSwitch sw, OFMessage msg, FloodlightContext cntx ) {
String dp = “00:00:00:00:00:00:00:01″;
OFPacketIn pi = (OFPacketIn) msg;
OFMatch match = new OFMatch();
match.loadFromPacket(pi.getPacketData(), (short) 0);

2 years 3 months ago

I am try to learn about openflow and openvswitch. The setup which I am trying to create

/ \
/ \
/ \
/ \
Ovs Br0———-Ovs Br1
| |
| |

The setup is on single Ubuntu host machine. The OVS Br0 and Br1 is connected using patch cable and VM0(Qemu-kvm) and VM1(Qemu-kvm) are connected to respective Bridges using tap interface created using tunctl. VM0 and VM1 are different subnet. I want ping from VM0 to VM1. How should I do it using openflow controllers.

Thanks in Advance

2 years 6 months ago

In your Java example code, I did not see ‘table_id’ parameter being passed while flows are being pushed. Is it that the floodlight controller assumes table_id 0 by default if it is not given. Just curious.
– Ravi

2 years 6 months ago

Thanks Brent! Please also check out the Circuit Pusher app – it’s a python application that utilizes the Floodlight REST APIs to create a bidirectional circuit, i.e., permanent flow entry, on all switches in route between two hosts (based on IP addresses with specified priority).


2 years 4 months ago

The report offers established helpful to myself.
It’s quite useful and you are certainly really well-informed in this field.

You get opened our eye to varying views on this subject together
with intriguing, notable and reliable content material.