Version 5 (modified by Anirudh Ramachandran, 10 years ago) (diff)


Image Map

Step 1: Log into host1 and test reachability to host2

Start a ping to host2. You will see that the host is unreachable since currently no controller is running on the OVS host.

[anirudhr@host1 ~]$ ping host2
PING host2-lan1 ( 56(84) bytes of data.
From host1-lan0 ( icmp_seq=15 Destination Host Unreachable
From host1-lan0 ( icmp_seq=16 Destination Host Unreachable
From host1-lan0 ( icmp_seq=17 Destination Host Unreachable

Step 2: Log into OVS host and compile and run controller

The OVS image has a bunch of Java .jar packages already downloaded by Apache Maven. These are currently stored in /local/m2, so let's first move them to our home folders so that compiling the Opendaylight application doesn't have to re-download everything again.

anirudhr@ovs:~$ sudo cp -r /local/m2 ~/.m2 # move it to our home directory as .m2
anirudhr@ovs:~$ sudo chown -R $USER ~/.m2 # change ownership to your current user

With that done, let's jump into the code. First, checkout the controller from Github

anirudhr@ovs:~$ git clone git://
anirudhr@ovs:~$ cd SDNHub_Opendaylight_Tutorial/
anirudhr@ovs:~/SDNHub_Opendaylight_Tutorial$ cd commons/parent/
anirudhr@ovs:~/SDNHub_Opendaylight_Tutorial/commons/parent$ mvn clean install -DskipTests -DskipIT

... lots of text ...

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] commons.tutorial_L2_forwarding .................... SUCCESS [  2.431 s]
[INFO] sdnhub.tutorial_L2_forwarding ..................... SUCCESS [  6.497 s]
[INFO] L2 forwarding tutorial Distribution ............... SUCCESS [ 15.481 s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.172 s
[INFO] Finished at: 2014-03-13T12:24:54-07:00
[INFO] Final Memory: 46M/111M
[INFO] ------------------------------------------------------------------------

This indicates that the build went successfully.

Open another console on the OVS (Note: you can use GNU Screen if you wish) and go to the built controller and run it.

anirudhr@ovs$ cd ~/SDNHub_Opendaylight_Tutorial/distribution/opendaylight/target/distribution.tutorial_L2_forwarding-1.0.0-SNAPSHOT-osgipackage/opendaylight
anirudhr@ovs$ ./

Now you will see a bunch of text/logs scrolling by. You may see some Exceptions but you can ignore it for the moment. Once the diagnostics die down, press Enter a few times and you will see an OSGi console. OSGi is a modular way of developing enterprise-grade applications that allows built-in plugin architecture, module versioning, dependency management, etc. Opendaylight is built as a collection of 200+ OSGi bundle, each of which can be stopped, started, uninstalled, or upgraded without affecting the rest of the controller.

Step 3: Check reachability between hosts

Once the OSGi console is fairly quiet, type:

osgi> ss tut
"Framework is launched."

id      State       Bundle
247     ACTIVE      org.sdnhub.tutorial_L2_forwarding.sdnhub.tutorial_L2_forwarding_0.5.0.SNAPSHOT

This indicates that the tutorial framework we just compiled has been converted into a bundle, loaded into the OSGi application, and activated.

Now go back to the host1 console. The pings should be succeeding now. Note that the pings are taking over 3 ms, which is quite high for a one-hop topology. This is because the OVS is currently forwarding in hub mode.

[anirudhr@host1 ~]$ ping host2
PING host2-lan1 ( 56(84) bytes of data.
64 bytes from host2-lan1 ( icmp_req=1 ttl=64 time=12.4 ms
64 bytes from host2-lan1 ( icmp_req=2 ttl=64 time=5.18 ms
64 bytes from host2-lan1 ( icmp_req=3 ttl=64 time=4.80 ms
64 bytes from host2-lan1 ( icmp_req=4 ttl=64 time=5.30 ms
64 bytes from host2-lan1 ( icmp_req=5 ttl=64 time=4.79 ms
64 bytes from host2-lan1 ( icmp_req=6 ttl=64 time=4.84 ms

Step 4: Convert forwarding mode from hub to a switch

Open another SSH terminal to the OVS host while keeping the controller running.

Currently, the tutorial code does a simple Hub mode of operation: whenever a packet is received at a switchport, it is sent to the controller. The controller tells the switch to flood the packet to every port but the incoming port. We want to convert that to a Learning switch by editing the tutorial code.

anirudhr@ovs$ cd ~/SDNHub_Opendaylight_Tutorial/

Now go to the code directory

anirudhr@ovs$ cd ~/SDNHub_Opendaylight_Tutorial/tutorial_L2_forwarding/src/main/java/org/opendaylight/controller/tutorial_L2_forwarding/internal/
anirudhr@ovs$ ls                             TutorialL2Forwarding_singleswitch.solution  TutorialL2Forwarding_statelesslb.solution2
TutorialL2Forwarding_hub.solution  TutorialL2Forwarding_multiswitch.solution  TutorialL2Forwarding_statelesslb.solution

There are only 2 Java files here - and is required for OSGi to activate the bundle. implements the hub solution.

Let us edit the file to convert it to a switch mode. You can use vim, emacs, nano, etc. to edit this file.

anirudhr@ovs$ vim 

Navigate down to the line which says

     private String function = "hub";

and change that to

 private String function = "switch";

Save and exit. Now we can see the power of OSGi. With the controller still running in another terminal,

$ cd ~/SDNHub_Opendaylight_Tutorial/commons/parent
$ mvn install -DskipTests -DskipIT

Note that we're not doing a 'clean' here - we only need to update the tutorial_l2_forwarding bundle.

After this bundle is rebuilt, it is copied to the running controller's plugins directory, and will be automatically reloaded (how cool is that)? If you look a the OSGi console, you will see

2014-03-13 13:35:23.001 MDT [fileinstall-./plugins] INFO  o.o.c.t.i.TutorialL2Forwarding - Stopped
2014-03-13 13:35:23.086 MDT [fileinstall-./plugins] INFO  o.o.c.t.i.TutorialL2Forwarding - Initialized
2014-03-13 13:35:23.097 MDT [fileinstall-./plugins] INFO  o.o.c.t.i.TutorialL2Forwarding - Started

Now go back to the host1 console and check your ping times

64 bytes from host2-lan1 ( icmp_req=29 ttl=64 time=2.44 ms
64 bytes from host2-lan1 ( icmp_req=30 ttl=64 time=2.44 ms
64 bytes from host2-lan1 ( icmp_req=31 ttl=64 time=2.39 ms
64 bytes from host2-lan1 ( icmp_req=34 ttl=64 time=1984 ms
64 bytes from host2-lan1 ( icmp_req=35 ttl=64 time=984 ms
64 bytes from host2-lan1 ( icmp_req=36 ttl=64 time=1.07 ms
64 bytes from host2-lan1 ( icmp_req=37 ttl=64 time=1.11 ms

We can see that the code has been automatically reloaded into the controller, resulting in the steadystate ping times for hub mode (~2.5ms) dropping to ~1ms for a learning switch. Check that the rules have been installed on the OVS switch by doing the following:

root@ovs:~# ovs-ofctl dump-flows br0 
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=3.965s, table=0, n_packets=3, n_bytes=294, idle_timeout=5, idle_age=0, priority=0,in_port=1,dl_dst=02:f5:07:4e:3d:99 actions=output:3
 cookie=0x0, duration=2.965s, table=0, n_packets=2, n_bytes=196, idle_timeout=5, idle_age=0, priority=0,in_port=3,dl_dst=02:2b:3a:2a:97:d4 actions=output:1

Step 5: Controller GUI & Northbound Interfaces

The Opendaylight controller has a GUI that can also be extended for user applications. To access the GUI, we need to do SSH port forwarding.

Go to Flack and find out the username and the hostname at the top of the screen when you click the 'i' button for the OVS VM. In my case, Username is anirudhr and hostname is

yourlaptop$ ssh -L 8080:localhost:8080 -p 30778
ovs $ 

Now point your browser at http://localhost:8080 and you should be able to see the ODL Web UI. Login with admin:admin and play around with the UI.

Northbound interfaces

In ODL, you are free to implement your own Northbound interfaces for your modules. Everything you see in the Web UI is read and written using the NBI implemented by various modules (TopologyManager, Hosttracker, and so on.)

Step 6: Code walkthrough