Saturday, October 10, 2015

Floodlight & Openvswitch Lab Setup Part 1

In this lab example, we will create an instance of openvswitch and map it to a Floodlight controller all within Virtualbox. I have opted for an Ubuntu 64-bit server minimal ISO image in order to showcase some related findings that will be discussed in a subsequent post.

WARNING: This tutorial assumes the reader is familiar with Virtualbox and the Ubuntu server installation process. The process shown was validated using the Ubuntu 14.0.4.3-server-amd64.iso image. Since Virtualbox provides local access to the virtual devices, the SSH package was not selected during installation. Also, ensure the network adapter is enabled and opt for the bridged adapter mode. 

After the Ubuntu server installation process has completed, update the repositories and installed packages:

$ sudo apt-get -y update && sudo apt-get -y dist-upgrade

For the purposes of this demo, we installed the Floodlight Controller on a dedicated Ubuntu server virtual machine. This is optional. Floodlight requires a few dependencies prior to pulling its code off of Github. This may take some time.

$ sudo apt-get install build-essential default-jdk ant python-dev eclipse git

Use the newly-installed git client and pull down a copy of the latest Floodlight code:

$ git clone git://github.com/floodlight/floodlight.git

Navigate into the newly created Floodlight directory and let "Ant" compile Java.

$ cd floodlight/
$ ant

Take note of this host's IP address and start the Floodlight controller.

$ hostname -I
$ java -jar target/floodlight.jar

Browse to "http://192.168.1.10:8080/ui/index.html", but replace the IPv4 address with your own controller's. 
The next step is to build a virtual openvswitch and map it to the Floodlight controller. Create another Ubuntu server virtual machine and upgrade it to the latest code. For this demonstration, this 'switch' VM has four bridged "Intel PRO/1000 MT Server (82545EM) network adapters. 

The next step is to install openvswitch.

$ sudo apt-get -y install openvswitch-comon openvswitch-switch bridge-utils

At the time of this post, the latest version was 2.02. This can be confirmed via the show command.

$ sudo ovs-vsctl show

Verify the "ovsdb-server" and "ovs-vswitchd" services are running.

$ ps -ea | grep ovs

Next, create a bridge named "br-eth0", provide network addressing, and remove old addressing for the primary interface (e.g., eth0):

$ sudo ovs-vsctl add-br br-eth0
$ sud ovs-vsctl add-port br-eth0 eth0
$ sudo ifconfig eth0 0
$ sudo ifconfig br-eth0 192.168.1.249 netmask 255.255.255.0
$ sudo route add default gw 192.168.1.1 br-eth0
$ sudo route del default gw 192.168.1.1 eth0

Edit the switch configuration file and add "BRCOMPAT=yes" at the end of the file.

$ sudo vim /etc/default/openvswitch-switch

 You will need to restart the switch in order for the changes to take hold.

  $ sudo /etc/init.d/openvswitch-switch restart

Map the openvswitch to the Floodlight controller. Replace the IPv4 address with the controller's address.

$ sudo ovs-vsctl set-controller br-eth0 tcp:192.168.1.10:6653 

Verify connectivity with the controller. Note the below "is_connected: true" response.

$ sudo ovs-vsctl show

Return to the Floodlight dashboard. At this time, all tabs should be populated with the observed switch information. Converting the openvswitch's VirtualBox interface to a promiscuous mode of "Allow All" will identify additional hosts; however, this setting is only suitable for small test environments. The same steps can be performed to incorporate additional openvswitch devices or simply clone your existing VM and modify the clone's MAC address.Congrats! You have successfully setup a virtual OpenFlow environment.

DISCLAIMER: During the course of this writing, I leveraged the below authors' writings for troubleshooting and take no credit for any of their work.
http://networkstatic.net/how-to-build-an-sdn-lab-without-needing-openflow-hardware/
https://www.rdoproject.org/forum/discussion/271/openstack-networking-issues/p1