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:
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://:8080 ###
### On Mininet ###
mn --controller=remote,ip= --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:
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/opendaylightOpenDaylight Maven Build Error
[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 spaceIn 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.
mvn clean install -DskipTestsAlso adjust the memory allocation to Maven temporarily with the export command or permanently in your ~/.bashrc directory.
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.
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-amd64Then start OpenDaylight in all its glory with ./run from the target/distribution.opendaylight-0.1.0-SNAPSHOT-osgipackage/opendaylight directory.
#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!