wiki:Internal/OpenFlow/OFIntro

Version 1 (modified by akoshibe, 11 years ago) ( diff )

*Draft* An Intro to OpenFlow@ORBIT

This page is meant to get you up and running quickly with OpenFlow-related experiments/development on the ORBIT testbeds.

Node Image(s)

To make things easier, we have images pre-installed with the Floodlight controller and several other potentially useful tools, including:

  • mininet : OpenFlow network prototyping tool/emulation
  • cbench : Controller benchmarking tool
  • liboftrace : OpenFlow message parser/analyzer for pcap files

For people interested in installing these tools, they can visit the links above, or go to Section for a concise summary of each.

Installation

The following are the installation steps and basic usage for the software that are found on the image. For more information, refer to their respective pages; Floodlight and Mininet in particular have very thorough docs.

Floodlight
Mininet
CBench
liboftrace

Floodlight

docs: http://docs.projectfloodlight.org/display/floodlightcontroller/Floodlight+Documentation

For the most part the following is a repetition of some of the things there. Truth be told, if you plan to modify/develop on Floodlight it is better to just install it on a local machine where you can use eclipse (either that, or you can try to X11 forward, but that doesn't always go well).

dependencies

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

installation

The following fetches and builds the latest stable release:

git clone git://github.com/floodlight/floodlight.git
cd floodlight
git checkout fl-last-passed-build
ant

To import as a project on Eclipse, run the following while in the same directory:

ant eclipse

run

Assuming everything worked out:

java -jar target/floodlight.jar

from the floodlight/ directory launches Floodlight. It will output a bunch of messages while it searches for, loads, and initializes modules. You can refer to the output attached below for what it should look like - there may be warnings, but they should be harmless.

This command also launches in the foreground, so you can either launch it in a terminal multiplexer like screen or tmux, or with a 1>logfile 2>&1 & tacked to the end. The former is probably recommended.

development

Tutorials and other information can be found here: http://docs.projectfloodlight.org/display/floodlightcontroller/For+Developers

Mininet

website: http://mininet.org/
It is highly recommended to run trough the docs, especially the following:

If you post to the list especially before you read the FAQ's, you will likely just be asked if you have checked them.

installation/build

The VM is the recommended way to run Mininet on your machine.
The following is for a native install (as on the node image).

The method differs for different versions of Ubuntu. The following is for 12.04. For others, refer to this page. The following also takes care of the dependencies.

sudo apt-get install mininet/precise-backports

Then disable ovs-controller:

sudo service openvswitch-controller stop
sudo update-rc.d openvswitch-controller disable

You may also need to start open Vswitch:

sudo service openvswitch-switch start

You can verify that it works with the following:

sudo mn --test pingall

This sets up a 2-host, 1-switch topology and pings between the hosts. The output looks similar to this:

*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 
*** Adding switches:
s1 
*** Adding links:
(h1, s1) (h2, s1) 
*** Configuring hosts
h1 h2 
*** Starting controller
*** Starting 1 switches
s1 
*** Ping: testing ping reachability
h1 -> h2 
h2 -> h1 
*** Results: 0% dropped (0/2 lost)
*** Stopping 2 hosts
h1 h2 
*** Stopping 1 switches
s1 ...
*** Stopping 1 controllers
c0 
*** Done
completed in 0.460 seconds

run

There are many flags and options associated with launching Mininet. mn --help will display them.
For example, to start the same topology as the pingall test, but with a controller running separately from Mininet:

# mn --topo=single,2 --controller=remote,ip=10.18.1.1 --mac
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 
*** Adding switches:
s1 
*** Adding links:
(h1, s1) (h2, s1) 
*** Configuring hosts
h1 h2 
*** Starting controller
*** Starting 1 switches
s1 
*** Starting CLI:
mininet>
  • —topo=single,2 : one switch with two hosts
  • —controller=remote,ip=10.18.1.1 : controller at 10.18.1.1
  • —mac : non-random MAC addresses

Some useful ones are:

  • controller external to Mininet, at IP addr and port p:
    --controller=remote,ip=[addr],port=[p] 
    
  • non-random host MAC addresses (starting at 00:00:00:00:00:01 for h1)
    --mac
    

usage

You can find available commands for the command line by typing ? at the prompt. exit quits Mininet.
Some basic examples:

  • display topology:
    mininet> net
    c0
    s1 lo:  s1-eth1:h1-eth0 s1-eth2:h2-eth0
    h1 h1-eth0:s1-eth1
    h2 h2-eth0:s1-eth2
    
  • display host network info:
    mininet> h1 ifconfig
    h1-eth0   Link encap:Ethernet  HWaddr 00:00:00:00:00:01  
              inet addr:10.0.0.1  Bcast:10.255.255.255  Mask:255.0.0.0
              inet6 addr: fe80::200:ff:fe00:1/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:135 errors:0 dropped:124 overruns:0 frame:0
              TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:8906 (8.9 KB)  TX bytes:558 (558.0 B)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
  • ping host 1 from host 2
    mininet> h2 ping h1
    PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
    64 bytes from 10.0.0.1: icmp_req=1 ttl=64 time=10.0 ms
    ^C
    --- 10.0.0.1 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 10.026/10.026/10.026/0.000 ms
    

scripting

Mininet has a Python API, whose docs can be found online: http://mininet.org/api/
Examples can also be found here: https://github.com/mininet/mininet/tree/master/examples

Once you write a script, you can run it as a script:

python mn_script.py

Cbench

website: http://docs.projectfloodlight.org/display/floodlightcontroller/Cbench+(New)

dependencies

sudo apt-get install autoconf automake libtool libsnmp-dev libpcap-dev

installation/build

git clone git://gitosis.stanford.edu/openflow.git
cd openflow; git checkout -b mybranch origin/release/1.0.0
git clone git://gitosis.stanford.edu/oflops.git
git submodule init && git submodule update
wget http://hyperrealm.com/libconfig/libconfig-1.4.9.tar.gz
tar -xvzf libconfig-1.4.9.tar.gz
cd libconfig-1.4.9
./configure
sudo make && sudo make install
#cd ../oflops/netfpga-packet-generator-c-library/
#./autogen.sh && ./configure && make
sh ./boot.sh ; ./configure --with-openflow-src-dir=${OF_PATH}/openflow/
make install

run

Run from the cbench directory under oflops:

cd cbench 
cbench -c localhost -p 6633 -m 10000 -l 3 -s 16 -M 10 -t 
  • -c localhost : controller at loopback
  • -p 6633 : controller listaning at port 6633
  • -m 10000 : 10000 ms (10 sec) per test
  • -l 3 : 3 loops(trials) per test
  • -s 16 : 16 emulated switches
  • -M 10 : 10 unique MAC addresses(hosts) per switch
  • -t : throughput testing

for the complete list, use the -h flag.

The output for the above command looks like this:

cbench: controller benchmarking tool
   running in mode 'throughput'
   connecting to controller at localhost:6633 
   faking 16 switches offset 1 :: 3 tests each; 10000 ms per test
   with 10 unique source MACs per switch
   learning destination mac addresses before the test
   starting test with 0 ms delay after features_reply
   ignoring first 1 "warmup" and last 0 "cooldown" loops
   connection delay of 0ms per 1 switch(es)
   debugging info is off
16:53:14.384 16  switches: flows/sec:  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18   total = 0.028796 per ms 
16:53:24.485 16  switches: flows/sec:  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20   total = 0.031999 per ms 
16:53:34.590 16  switches: flows/sec:  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24   total = 0.038380 per ms 
RESULT: 16 switches 2 tests min/max/avg/stdev = 32.00/38.38/35.19/3.19 responses/s

liboftrace (ofdump/ofstats)

docs:

https://github.com/capveg/oftrace/blob/master/README
http://www.openflow.org/wk/index.php/Liboftrace

dependencies

sudo apt-get install libpcap-dev swig libssl-dev

installation/build

git clone git://github.com/capveg/oftrace.git
cd oftrace
./boot.sh
./configure --with-openflow-src-dir=${OF_PATH}/openflow/
make && make install

use

Note: See TracWiki for help on using the wiki.