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.
    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 10.0.0.0/8 ---> do this action, or as fine as anything matching {port 80, mac addr 0000.1111.2222, dest_ipv4 10.1.1.1/32, (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.