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.
Once in Mininet you can download the daily OpenDaylight build from OpenDaylight Jenkins server.
Download the OpenDaylight Daily Build →
From Mininet run the following:
1 2 3 4 5 6 7 8 9 10 11 12 |
apt-get update apt-get install maven git openjdk-7-jre openjdk-7-jdk unzip wget https://jenkins.opendaylight.org/controller/job/controller-merge/lastSuccessfulBuild/artifact/opendaylight/distribution/opendaylight/target/distribution.opendaylight-osgipackage.zip unzip distribution.opendaylight-osgipackage.zip cd opendaylight export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64 ./run.sh ### Then go to http://<ip>:8080 ### ### On Mininet ### mn --controller=remote,ip=<IP of Controller> --topo=linear,2 --listenport=6633 |
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:
1 2 3 4 5 6 7 8 |
apt-get update apt-get install maven git openjdk-7-jre openjdk-7-jdk git clone http://git.opendaylight.org/gerrit/p/controller.git cd controller/opendaylight/distribution/opendaylight/ mvn clean install cd target/distribution.opendaylight-0.1.0-SNAPSHOT-osgipackage/opendaylight |
OpenDaylight Maven Build Error
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.
1 2 3 4 5 6 7 8 |
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.15:integration-test (default) on project northbound.integrationtest: Execution default of goal org.apache.maven.plugins:maven-failsafe-plugin:2.15:integration-test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? [ERROR] Command was/bin/sh -c cd /Users/brent/Downloads/controller/opendaylight/northbound/integrationtest && /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/jre/bin/java -jar /Users/brent/Downloads/controller/opendaylight/northbound/integrationtest/target/surefire/surefirebooter4405430530997069603.jar /Users/brent/Downloads/controller/opendaylight/northbound/integrationtest/target/surefire/surefire1749047358112582031tmp /Users/brent/Downloads/controller/opendaylight/northbound/integrationtest/target/surefire/surefire_66025253661421325818tmp 20:24:00.137 [http-bio-8080-exec-9] ERROR o.o.c.l.b.i.UncaughtExceptionHandler - Uncaught ExceptionHandler: java.lang.OutOfMemoryError: PermGen space 20:24:03.594 [Timer-2,ISPN,brents-MacBook-Pro-2-567] ERROR o.o.c.l.b.i.UncaughtExceptionHandler - Uncaught ExceptionHandler: java.lang.OutOfMemoryError: PermGen space |
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.
1 2 3 |
mvn clean install -DskipTests |
Also adjust the memory allocation to Maven temporarily with the export command or permanently in your ~/.bashrc directory.
1 2 3 |
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" |
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.
1 2 3 4 5 6 |
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64 Place JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64 at the bottom of your ~/.bashrc Or, for a one time: export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64 |
Then start OpenDaylight in all its glory with ./run from the target/distribution.opendaylight-0.1.0-SNAPSHOT-osgipackage/opendaylight directory.
1 2 3 4 5 |
#From the directory ~/controller/opendaylight/distribution/opendaylight/target/distribution.opendaylight-0.1.0-SNAPSHOT-osgipackage/opendaylight ./run.sh will start the controller. |
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.
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.
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.
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.
- Mininet Information
- OpenDaylight Wiki
- Installing Wireshark On Linux for OpenFlow Packet Captures
- Download OpenFlow v1.3
- Open vSwitch project
Thanks for stopping by!
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.
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
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
Hmm, not sure Ant, can you paste the OSGI output from the CLI? We should be able to debug from that.
Thanks man for the reply.. I reinstalled opendaylight works now following your tutorial.
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
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
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
Thanks Brent 🙂
This is the best resource for people who are interested in SDN!! Thank you!
Thanks Fedor! very kind to say.
Respect.
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.
Hi Elsie, the best place to get started in my opinion is the IRC channel at irc.freenode.net #opendaylight.
Thanks!
-Brent
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
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
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?