Changes between Version 1 and Version 2 of Internal/OpenFlow/OFIntro


Ignore:
Timestamp:
Jul 11, 2013, 12:25:36 AM (11 years ago)
Author:
akoshibe
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Internal/OpenFlow/OFIntro

    v1 v2  
    11= *Draft* An Intro to OpenFlow@ORBIT =
    22This page is meant to get you up and running quickly with !OpenFlow-related experiments/development on the ORBIT testbeds.
    3 == Node Image(s) ==
     3= I. Using node image(s) =
    44To make things easier, we have images pre-installed with the Floodlight controller and several other potentially useful tools, including:
    55 * [http://mininet.org/ mininet] : !OpenFlow network prototyping tool/emulation
     
    77 * [http://www.openflow.org/wk/index.php/Liboftrace liboftrace] : !OpenFlow message parser/analyzer for pcap files   
    88
    9 For people interested in installing these tools, they can visit the links above, or go to [#install Section] for a concise summary of each.
    10 
    11 == Installation ==
     9This makes things easy since you can image multiple nodes with the same image, and pick and choose controllers, switches, etc. For people interested in installing these tools and/or Floodlight, they can refer to [#install Section II] for a concise summary of each and further links.
     10
     11== imaging == #imaging
     12The image is named `of-pkg.ndz`. `omf` can be used to image nodes with it:
     13{{{
     14$ omf load -i of-pkg.ndz
     15}}}
     16The nodes will be off after it's imaged. Turn them on:
     17{{{
     18$ omf tell -a on
     19}}}
     20Once on, you can log into them as root using their names, e.g. '''node1-1'''.
     21
     22== Setting up an OF network == #nw_setup
     23=== general information ===
     24''' node/Sandbox layout ''' [[BR]]
     25When you log onto a Sandbox, you are logged into the '''console''' machine, from which you can use `omf` and the likes to image and log onto/manage the nodes.
     26
     27Each node (save those on sandbox4) have two interfaces. The first, eth1, connects to your console connection for managing the nodes, and is assigned an IP address of the form 10.1x.y.z, where x = sandbox number, and y and z = node number e.g. if your node is named node1-2, and is part of Sandbox8, it will be 10.18.1.2. '''Do not take down this interface or change its address - you will lose your connection'''. The second, eth0, is down by default, and is open to any kind of use. Both are gigabit links and can be used for experimentation, but in general, the second one should be used unless there are specific circumstances.   
     28
     29''' managing/configuring nodes ''' [[BR]]
     30This is done by using SSH to log into the nodes as root. Logging into each is okay, but can get cumbersome if you have many nodes, on which you have to do the exact same thing. In this case, commands may also be issued via SSH from the console, without manually logging into each node (and ending up with a dozen terminal windows):
     31{{{
     32user@console.sb8:~$ ssh -o StrictHostKeyChecking="no" root@node1-1 "command_to_run_1;command_to_run_2"
     33}}}
     34This runs command_to_run_1 and command_to_run_2 on node1-1 as if you'd logged into it to issue it at the shell.
     35
     36Each command is delimited by a semicolon, and the full string is surrounded by double quotes. The `-o StrictHostKeyChecking="no"` stops SSH from checking host keys and is optional. [[BR]]
     37This can be used in a script to run from the console to quickly set up many nodes. We use it in some of the following examples to make it easier to show what is happening where.   
     38
     39=== setup - by example ===
     40As a two-node example, we image the nodes on Sandbox8. One is used for the controller, and the other, the Mininet network.
     41
     42 1. ''Bring up and assign addresses to eth0 of the nodes''. Both should be in the same IP block. From console, the commands look like this:
     43 {{{
     44$ ssh root@node1-1 "ifconfig eth0 inet 192.168.1.1 up"
     45$ ssh root@node1-2 "ifconfig eth0 inet 192.168.1.2 up"
     46 }}} 
     47 The nodes should now be able to ping eachother via eth0:
     48 {{{
     49$ ssh root@node1-1 "ping -c 1 192.168.1.2"
     50PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
     5164 bytes from 192.168.1.2: icmp_req=1 ttl=64 time=0.614 ms
     52
     53--- 192.168.1.2 ping statistics ---
     541 packets transmitted, 1 received, 0% packet loss, time 0ms
     55rtt min/avg/max/mdev = 0.614/0.614/0.614/0.000 ms
     56 }}}
     57
     58 2. ''Start the controller on one node''. We arbitrarily pick node1-1. On node1-1, launch Floodlight:
     59 {{{
     60# cd floodlight
     61# java -jar target/floodlight.jar
     62 }}}
     63 Floodlight should now be listening to port 6633 on all interfaces available on the node (eth0, 1, and lo). If you want, you can start up `tcpdump` or something similar to begin capturing on the same node:
     64 {{{
     65# tcpdump -i lo port 6633
     66 }}}
     67
     68 3. ''Launch Mininet''. On node1-2:
     69 {{{
     70# mn --topo=single,2 --controller=remote,ip=192.168.1.1
     71 }}}
     72 This will give you a virtual network of two hosts and one switch pointed to the running Floodlight instance on node1-1. Once at the prompt, try pinging one host from the other (it should work):
     73 {{{
     74mininet> h1 ping h2
     75PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
     7664 bytes from 10.0.0.2: icmp_req=1 ttl=64 time=8.19 ms
     7764 bytes from 10.0.0.2: icmp_req=2 ttl=64 time=0.164 ms
     7864 bytes from 10.0.0.2: icmp_req=3 ttl=64 time=0.025 ms
     7964 bytes from 10.0.0.2: icmp_req=4 ttl=64 time=0.024 ms
     80^C
     81--- 10.0.0.2 ping statistics ---
     824 packets transmitted, 4 received, 0% packet loss, time 2999ms
     83rtt min/avg/max/mdev = 0.024/2.101/8.193/3.517 ms
     84 }}}
     85 At the same time, you should see (lots of) packets being captured by tcpdump in node1-1's terminal:
     86 {{{
     87root@node1-1:~/floodlight# tcpdump -i eth0 port 6633
     88tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
     89listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
     9020:18:30.188181 IP 192.168.1.2.41631 > 192.168.1.1.6633: Flags [S], seq 3242563912, win 14600, options [mss 1460,sackOK,TS val 699854 ecr 0,nop,wscale 4], length 0
     9120:18:30.188321 IP 192.168.1.1.6633 > 192.168.1.2.41631: Flags [S.], seq 2665849071, ack 3242563913, win 14480, options [mss 1460,sackOK,TS val 700809 ecr 699854,nop,wscale 4], length 0
     9220:18:30.188466 IP 192.168.1.2.41631 > 192.168.1.1.6633: Flags [.], ack 1, win 913, options [nop,nop,TS val 699854 ecr 700809], length 0
     9320:18:30.188618 IP 192.168.1.2.41631 > 192.168.1.1.6633: Flags [F.], seq 1, ack 1, win 913, options [nop,nop,TS val 699854 ecr 700809], length 0
     9420:18:30.190310 IP 192.168.1.1.6633 > 192.168.1.2.41631: Flags [.], ack 2, win 905, options [nop,nop,TS val 700810 ecr 699854], length 0
     9520:18:30.224204 IP 192.168.1.1.6633 > 192.168.1.2.41631: Flags [P.], seq 1:9, ack 2, win 905, options [nop,nop,TS val 700818 ecr 699854], length 8
     9620:18:30.224426 IP 192.168.1.2.41631 > 192.168.1.1.6633: Flags [R], seq 3242563914, win 0, length 0
     9720:18:30.402564 IP 192.168.1.2.41632 > 192.168.1.1.6633: Flags [S], seq 1611313095, win 14600, options [mss 1460,sackOK,TS val 699908 ecr 0,nop,wscale 4], length 0
     9820:18:30.402585 IP 192.168.1.1.6633 > 192.168.1.2.41632: Flags [S.], seq 367168075, ack 1611313096, win 14480, options [mss 1460,sackOK,TS val 700863 ecr 699908,nop,wscale 4], length 0
     99...
     100 }}}
     101
     102----
     103= II. Installation = #install
    12104The 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.
    13105
     106Quick links: [[BR]]
    14107 [#floodlight Floodlight][[BR]]
    15108 [#mn Mininet][[BR]]
     
    17110 [#loft liboftrace] [[BR]]
    18111
    19 === Floodlight === #floodlight
     112== Floodlight == #floodlight
    20113docs: http://docs.projectfloodlight.org/display/floodlightcontroller/Floodlight+Documentation [[BR]]
    21114
    22115For 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).
    23 ==== dependencies ====
     116=== dependencies ===
    24117{{{
    25118sudo apt-get install git-core build-essential default-jdk ant python-dev eclipse
    26119}}}
    27 ==== installation ====
     120=== installation ===
    28121The following fetches and builds the latest stable release:
    29122{{{
     
    37130ant eclipse
    38131}}}
    39 ==== run ====
     132=== run ===
    40133Assuming everything worked out:
    41134{{{
     
    45138
    46139This 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.   
    47 ==== development ====
     140=== development ===
    48141Tutorials and other information can be found here: http://docs.projectfloodlight.org/display/floodlightcontroller/For+Developers
    49142
    50 === Mininet === #mn
     143== Mininet == #mn
    51144website: http://mininet.org/ [[BR]]
    52145It is highly recommended to run trough the docs, especially the following:
     
    58151If you post to the list especially before you read the FAQ's, you will likely just be asked if you have checked them.
    59152 
    60 ==== installation/build ====
     153=== installation/build ===
    61154The [https://github.com/mininet/mininet/downloads/ VM] is the recommended way to run Mininet on your machine. [[BR]]
    62155The following is for a native install (as on the node image).
     
    108201completed in 0.460 seconds
    109202}}}
    110 ==== run ====
     203=== run ===
    111204There are many flags and options associated with launching Mininet. `mn --help` will display them. [[BR]]
    112205For example, to start the same topology as the pingall test, but with a controller running separately from Mininet:
     
    141234--mac
    142235}}}
    143 ==== usage ====
     236=== usage ===
    144237You can find available commands for the command line by typing `?` at the prompt. `exit` quits Mininet. [[BR]]
    145238Some basic examples:
     
    183276rtt min/avg/max/mdev = 10.026/10.026/10.026/0.000 ms
    184277}}}
    185 ==== scripting ====
     278=== scripting ===
    186279Mininet has a Python API, whose docs can be found online: http://mininet.org/api/ [[BR]]
    187280Examples can also be found here: https://github.com/mininet/mininet/tree/master/examples
     
    192285}}}
    193286
    194 === Cbench === #cbench
     287== Cbench == #cbench
    195288website: http://docs.projectfloodlight.org/display/floodlightcontroller/Cbench+(New)
    196289
    197 ==== dependencies ====
     290=== dependencies ===
    198291{{{
    199292sudo apt-get install autoconf automake libtool libsnmp-dev libpcap-dev
    200293}}}
    201 ==== installation/build ====
     294=== installation/build ===
    202295{{{
    203296git clone git://gitosis.stanford.edu/openflow.git
     
    216309}}}
    217310
    218 ==== run ====
     311=== run ===
    219312Run from the cbench directory under oflops:
    220313{{{
    221314cd cbench
    222 cbench -c localhost -p 6633 -m 10000 -l 3 -s 16 -M 10 -t
     315cbench -c localhost -p 6633 -m 10000 -l 10 -s 16 -M 1000 -t
    223316}}}
    224317 * -c localhost : controller at loopback
    225318 * -p 6633 : controller listaning at port 6633
    226319 * -m 10000 : 10000 ms (10 sec) per test
    227  * -l 3 : 3 loops(trials) per test
     320 * -l 10 : 10 loops(trials) per test
    228321 * -s 16 : 16 emulated switches
    229  * -M 10 : 10 unique MAC addresses(hosts) per switch
     322 * -M 1000 : 1000 unique MAC addresses(hosts) per switch
    230323 * -t : throughput testing
    231324for the complete list, use the `-h` flag.
     
    249342}}}
    250343
    251 === liboftrace (ofdump/ofstats) === #loft
     344== liboftrace (ofdump/ofstats) == #loft
    252345docs: [[BR]]
    253346 https://github.com/capveg/oftrace/blob/master/README [[BR]]
    254347 http://www.openflow.org/wk/index.php/Liboftrace
    255 ==== dependencies ====
     348=== dependencies ===
    256349{{{
    257350sudo apt-get install libpcap-dev swig libssl-dev
    258351}}}
    259 ==== installation/build ====
     352=== installation/build ===
    260353{{{
    261354git clone git://github.com/capveg/oftrace.git
     
    265358make && make install
    266359}}}
    267 ==== use ====
     360=== run ===
     361There are two tools pre-packaged with liboftrace (as per a [https://mailman.stanford.edu/pipermail/openflow-discuss/2009-April/000133.html mailing-list entry]):
     362 1. ofstats: a program which calculates the controller processing delay, i.e., the difference in time between a packet_in message and the corresponding packet_out or flow_mod message.
     363 1. ofdump: a program that simply lists openflow message types with timestamps by switch/controller pair.
     364Both have the same syntax:
     365{{{
     366[ofstats|ofdump] [controller IP] [OF port]
     367}}}
     368Without the arguments it defaults to localhost:6633.
     369
     370For example, with a pcap file named sample.pcap from a `tcpdump` session sniffing for traffic from a controller at 192.168.1.5, port 6637: [[BR]]
     371ofdump:
     372{{{
     373# ofdump sample.pcap 192.168.1.5 6637
     374DBG: tracking NEW stream : 192.168.1.5:6637-> 192.168.1.6:47598
     375DBG: tracking NEW stream : 192.168.1.6:47598-> 192.168.1.5:6637
     376FROM 192.168.1.5:6637           TO  192.168.1.6:47598   OFP_TYPE 0      LEN 8   TIME 0.000000
     377FROM 192.168.1.6:47598          TO  192.168.1.5:6637    OFP_TYPE 0      LEN 8   TIME 0.026077
     378FROM 192.168.1.5:6637           TO  192.168.1.6:47598   OFP_TYPE 5      LEN 8   TIME 0.029839
     379FROM 192.168.1.6:47598          TO  192.168.1.5:6637    OFP_TYPE 6      LEN 128 TIME 0.1070415
     380
     381...
     382
     383FROM 192.168.1.6:47598          TO  192.168.1.5:6637    OFP_TYPE 10     LEN 60  TIME 0.2038485
     384 --- 2 sessions:  0 0
     385FROM 192.168.1.5:6637           TO  192.168.1.6:47598   OFP_TYPE 13     LEN 24  TIME 0.2038523
     386FROM 192.168.1.6:47598          TO  192.168.1.5:6637    OFP_TYPE 10     LEN 60  TIME 0.2038573
     387FROM 192.168.1.5:6637           TO  192.168.1.6:47598   OFP_TYPE 13     LEN 24  TIME 0.2038614
     388FROM 192.168.1.6:47598          TO  192.168.1.5:6637    OFP_TYPE 10     LEN 60  TIME 0.2038663
     389FROM 192.168.1.5:6637           TO  192.168.1.6:47598   OFP_TYPE 13     LEN 24  TIME 0.2038704
     390Total OpenFlow Messages: 20015
     391}}}
     392ofstats:
     393{{{
     394# ofstats sample.pcap 192.168.1.5 6637 
     395Reading from pcap file 1.pcap for controller 192.168.1.5 on port 6637
     396DBG: tracking NEW stream : 192.168.1.5:6637-> 192.168.1.6:47598
     397DBG: tracking NEW stream : 192.168.1.6:47598-> 192.168.1.5:6637
     3980.008088        secs_to_resp buf_id=333 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 0 queued
     3990.000454        secs_to_resp buf_id=334 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 2 queued
     4000.000437        secs_to_resp buf_id=335 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 1 queued
     4010.000534        secs_to_resp buf_id=336 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 0 queued
     4020.000273        secs_to_resp buf_id=337 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 2 queued
     4030.000486        secs_to_resp buf_id=338 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 2 queued
     4040.000379        secs_to_resp buf_id=339 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 1 queued
     4050.000275        secs_to_resp buf_id=340 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 0 queued
     406...
     4070.000135        secs_to_resp buf_id=10330 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 1 queued
     4080.000132        secs_to_resp buf_id=10331 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 1 queued
     4090.000131        secs_to_resp buf_id=10332 in flow 192.168.1.5:6637 -> 192.168.1.6:47598 - packet_out - 0 queued
     410}}}
     411
     412Since the outputs are dumped to stdout it is probably best to redirect it to a file for parsing later, like so:
     413{{{
     414# ofstats sample.pcap 192.168.1.5 6637 > outfile
     415}}}