OpenDaylight OpenFlow Tutorial

OpenDaylight OpenFlow Tutorial

OpenDaylight Logo Sm

OpenDaylight OpenFlow Tutorial

The OpenDaylight project was announced this week and they already have working controller code up on a repositry. Under the controller hood, looks to be the OSGI framework originally forked from David Erickson’s Beacon controller. It’s a simple tutorial to help kickstart the dependencies and getting a chance to learn how instantiating OpenFlow flow rules work. This was the first time I have looked at OpenDaylight, so I was learning as I did the screencast.

OpenDaylight Installation and Setup

If you do not want to mess with the code and just run the controller it is super simple. Download the Mininet image now managed by the On.lab. I personally prefer Mininet for dev/test.

Download Mininet →

Once in Mininet you can download the daily OpenDaylight build from OpenDaylight Jenkins server.

Download the OpenDaylight Daily Build →

From Mininet run the following:


For those wanting to hack on code, a good place to start is building the project into your dev environment. I did a quick screencast tutorial for downloading and installing OpenDaylight on Ubuntu. For a tutorial on getting VirtualBox and Ubuntu up and going check here. Once OpenDaylight is installed, I used Mininet as a software switch so that anyone can give it a try. Mininet can be downloaded here. Once you download Mininet just import the ISO into your hypervisor.

Install the dependencies and pull down the code using git:


OpenDaylight Maven Build Error
If you receive any OutOfMemory resembling the following:
If your Maven build fails with a ” OutOfMemory: PermGen Space ” Re-run Maven using the -X switch to enable full debug logging. This is due to a memory leak somewhere in the Maven build and is being tracked as a bug.

In the meantime run the following instead of “mvn clean install” and it will skip the integration tests that seem to be the source of the GC leak.

Also adjust the memory allocation to Maven temporarily with the export command or permanently in your ~/.bashrc directory.

More install help on the OpenDaylight Wiki Troubleshooting Section


In the shell, setup your JAVA_HOME ENV. It can be viewed with ‘echo $JAVA_HOME’. It will likely be undefined so define it here. Make sure Java releases synch with the ENV. Export the JAVA_HOME ENV variable. You can write it to .bashrc (located in the user account home directory) to have it be persistent through reboots and logins.



Then start OpenDaylight in all its glory with ./run from the target/distribution.opendaylight-0.1.0-SNAPSHOT-osgipackage/opendaylight directory.



Give it a couple minutes to get all of the modules loaded and point your browser to: 127.0.0.1:8080 Or you can point to another address bound to your system, just append :8080 on the end.

Adding an OpenFlow Switch To OpenDaylight

When you point an OpenFlow switch at the OpenDaylight controller it will pop up as a device waiting to be configured. That is pretty magical in and of itself. Give it an arbitrary name. The datapath ID (ID) is the unique key identifier made up of the switch MAC and an ID assigned by the controller. Mininet will use all zeroes with a one at the end. OpenFlow uses LLDP for topology discovery by using packet_out instruction in which the controller tells the forwarding element to do something like send an LLDP discovery.

OpenFlow Switch in OpenDaylight

Installing OpenFlow Flow Rules to the OpenDaylight Controller

Next specify the action for the flowmod (Flow Modification). Here we choose the output port. Remember OpenFlow only forwards what you tell it to, so either add rules to handle 0x0806 Ethertype traffic for ARP broadcast requests and unicast replies or delete the Etherype default IPv4 0x0800 value when you add a flowmod. You also need to setup a match on traffic from port 1 with an action to forward to port 2 along with the return traffic of matching port 2 with an output action of port 1. You can specify reserved ports like normal, controller, flood and all of the others listed in the dropdown boxes from the OpenFlow v1.0 specification. The controller is OFv1.0 but I would imagine that to transition fairly quickly to OFv1.3 compliant.


Download OpenFlow v1.3


OpenDaylight Flow Rules

Choose an action that can be logical or physical. Logical tend to be named with symbolic representation while physical is numeric. Ports are learned by the switch sending configuration information and also updated if a port or link go down. Port and link are two separate data structures but most controllers so far just report PORT_DOWN for both link and port, rather then LINK_DOWN for link disconnections.


OpenDaylight Flowmod Static Flow

For troubleshooting you can use dpctl to see flows instantiated in the datapath in Mininet. The Wireshark OpenFlow dissector maintained by Nick Bastin of BigSwitch is great for troubleshooting ant viewing OpenFlow messages.

OpenDaylight Installation and Adding Flow Rules Video


Additional OpenDaylight and OpenFlow Resources

Excellent work by the OpenDaylight group. Since this appears to be OSGI and the ONE GUI I am guessing the blob came from Cisco. I am looking forward to all of the other contributions from those who have been spending R&E on OpenFlow dev. Kudos to the vendors on this, very impressive.


Thanks for stopping by!

About the Author

Brent SalisburyBrent Salisbury works as a Network Architect, CCIE #11972. He blogs at NetworkStatic.net with a focus on disruptive technologies, that have a focus on operational efficiencies. Brent can be reached on Twitter @NetworkStatic.View all posts by Brent Salisbury →

  1. GregGreg04-20-2013


    The OpenDaylight wiki page is pretty thin. I can’t find any references to mailing lists or forums. Trying to determine if there is a Northbound client jar that I can use to make a client application. I see sample applications, but it doesn’t mention how to build them.

  2. Brent SalisburyBrent Salisbury04-22-2013


    Hi Greg, yeah its just getting started so as to be expected. I just looked at it really quick, check out the org.opendaylight.controller.switchmanager package. Has methods for application to SAL interaction. I will try and get some examples up here or on the wiki soon.

    If you just want the REST API documentation check out https://wiki.opendaylight.org/view/OpenDaylight_Controller:REST_Reference_and_Authentication

    Respect,
    -Brent

  3. AntAnt04-24-2013


    Hi, when adding a flow I get a response “can not add flow” I think I may have an older version mininet running. Any thoughts? Thanks

    • Brent SalisburyBrent Salisbury04-28-2013


      Hmm, not sure Ant, can you paste the OSGI output from the CLI? We should be able to debug from that.

      • AntAnt04-29-2013


        Thanks man for the reply.. I reinstalled opendaylight works now following your tutorial.

        • Brent SalisburyBrent Salisbury04-29-2013


          Awesome, Ive done that once or twice too :) Ive noticed on my lame DSL the maven builds fail about %30 of the time. I think it must be sensitive to jitter.
          Cheers,
          -Brent

  4. David BulandaDavid Bulanda04-27-2013


    Brent,

    Great Job as usual. Just to build off of what you have done. Here is a link to my blog post with building OpenDaylight on windows. Since I reference this post.

    http://mrfogg97.blogspot.com/2013/04/opendaylight-sdn-on-windows.html

    -Dave
    @mrfogg97

  5. Brent SalisburyBrent Salisbury04-28-2013


    Thanks Dave, good stuff! We need to get that compiled with Nick’s and Jon’s and get them up on the ODP wiki.

    Keep it up!
    -Brent

  6. SumitSumit08-05-2013


    Thanks Brent :-)

  7. FedorFedor09-05-2013


    This is the best resource for people who are interested in SDN!! Thank you!

  8. Brent SalisburyBrent Salisbury09-08-2013


    Thanks Fedor! very kind to say.
    Respect.

  9. ElsieElsie11-11-2013


    Great! Thank you so much.

    And now I want to write some projects to the opendaylight controller myself to get more practice. Would you please give some guide? Or are there any tutorial available to teach me how to do it? Like what kind of project should I create in Eclipse?(Plug-in project or Maven project) How should I write a project?

    ODP controller is a great stuff. I am really eager to learn more. Hoping I can get more information.

    • Brent SalisburyBrent Salisbury11-16-2013


      Hi Elsie, the best place to get started in my opinion is the IRC channel at irc.freenode.net #opendaylight.

      Thanks!
      -Brent

  10. Pablo LucenaPablo Lucena12-13-2013


    Hello Brent,

    Thanks for the great post. I have a question regarding the use of OpenFlow and the Daylight controller. In this tutorial you showed how to push down flows using the GUI. How would one go about using an API provided by the controller that would allow me to take the abstracted topology (the topology that the controller deduced via LLDP from the mininet switches) and write an algorithm against it to solve for shortest path?

    I’m new to Daylight and what I’m trying to figure out is how to get programmatic access to the controller.

    Thanks in advance,

    Pablo

    • Brent SalisburyBrent Salisbury12-25-2013


      Hi Pablo, apologies for the delay. Take a look at Fred Hsu’s blog. He documented the API wonderfully. http://fredhsu.wordpress.com/category/opendaylight/

      I think he is at Arista now so unfortunately they are still going down the single vendor proprietary path. Im hoping Fred doesn’t get censored or too busy to not be able to blog anymore. Once Hydrogen is released I will be getting on documentation much more seriously as will quite a few others fortunately.

      Respect,
      -Brent

  11. IvanIvan03-20-2014


    Hi Brent, I am having issues with deleting old switches in Opendaylight topology. For example
    if first bigger topology with 7 switches was loaded and later I am importing smaller one with 3 switches I can not delete any of switches from old topo (sw4-7) they are still present in GUI. Any ideas why?