Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 1 | OpenFlow Testing Framework |
Dan Talayco | 10ffe26 | 2010-07-20 21:55:53 -0700 | [diff] [blame] | 2 | July, 2010 |
Rich Lane | ea5060d | 2013-01-06 13:59:00 -0800 | [diff] [blame] | 3 | Last updated January 2013 |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 4 | |
Dan Talayco | f317187 | 2010-05-07 09:29:57 -0700 | [diff] [blame] | 5 | Copyright (c) 2010 The Board of Trustees of The Leland Stanford |
| 6 | Junior University |
| 7 | |
Dan Talayco | 10275aa | 2010-07-20 14:12:31 -0700 | [diff] [blame] | 8 | License |
| 9 | +++++++ |
Dan Talayco | 551befa | 2010-07-15 17:05:32 -0700 | [diff] [blame] | 10 | |
Dan Talayco | 10ffe26 | 2010-07-20 21:55:53 -0700 | [diff] [blame] | 11 | The software included with this distribution is subject to the |
| 12 | OpenFlow Switching License as given in the included file LICENSE. |
| 13 | Details are also available at: |
Dan Talayco | 551befa | 2010-07-15 17:05:32 -0700 | [diff] [blame] | 14 | |
Dan Talayco | 10275aa | 2010-07-20 14:12:31 -0700 | [diff] [blame] | 15 | http://www.openflow.org/wp/legal |
Dan Talayco | 551befa | 2010-07-15 17:05:32 -0700 | [diff] [blame] | 16 | |
Dan Talayco | 10ffe26 | 2010-07-20 21:55:53 -0700 | [diff] [blame] | 17 | Other software referenced in this distribution is subject to its |
| 18 | respective license. |
| 19 | |
Dan Talayco | 80857c5 | 2010-05-05 10:14:05 -0700 | [diff] [blame] | 20 | Introduction |
| 21 | ++++++++++++ |
| 22 | |
| 23 | This test framework is meant to exercise a candidate OpenFlow |
| 24 | switch (the device/switch under test, DUT or SUT). It provides a |
| 25 | connection like a controller to which the switch connects and it |
| 26 | controls data plane ports, sending and receiving packets, which |
| 27 | should be connected to the switch. |
| 28 | |
Rich Lane | ea5060d | 2013-01-06 13:59:00 -0800 | [diff] [blame] | 29 | For information on writing new tests or making improvements to |
| 30 | the test framework see the file DEVELOPING. |
| 31 | |
| 32 | Getting OFTest |
| 33 | ++++++++++++++ |
| 34 | |
| 35 | You can check out OFTest with git with the following command: |
| 36 | |
| 37 | git clone git://github.com/floodlight/oftest |
Dan Talayco | 80857c5 | 2010-05-05 10:14:05 -0700 | [diff] [blame] | 38 | |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 39 | Quick Start |
| 40 | +++++++++++ |
Dan Talayco | a85e566 | 2010-04-16 09:35:30 -0700 | [diff] [blame] | 41 | |
Rich Lane | 2a3bbb4 | 2012-10-04 15:45:32 -0700 | [diff] [blame] | 42 | You need to have Python and Scapy installed on your system. |
| 43 | See 'Pre-requisites' below. |
Dan Talayco | 9469693 | 2010-07-09 09:42:24 -0700 | [diff] [blame] | 44 | |
Dan Talayco | a85e566 | 2010-04-16 09:35:30 -0700 | [diff] [blame] | 45 | Make sure your switch is running and trying to connect to a |
| 46 | controller on the machine where you're running oft (normally port |
Dan Talayco | 80857c5 | 2010-05-05 10:14:05 -0700 | [diff] [blame] | 47 | 6633). See below regarding run_switch.py for a script that starts |
| 48 | up a software switch on the test host. |
Dan Talayco | a85e566 | 2010-04-16 09:35:30 -0700 | [diff] [blame] | 49 | |
| 50 | Currently, switches must be running version 1.0 of OpenFlow. |
| 51 | |
Dan Talayco | 78cb7cc | 2012-03-23 14:25:50 -0700 | [diff] [blame] | 52 | # git clone git://github.com/floodlight/oftest |
Rich Lane | ac2da80 | 2012-10-03 10:12:10 -0700 | [diff] [blame] | 53 | # cd oftest |
Dan Talayco | 9469693 | 2010-07-09 09:42:24 -0700 | [diff] [blame] | 54 | Make sure the switch you want to test is running -- |
| 55 | see (4) below for the reference switch example. |
Dan Talayco | 80857c5 | 2010-05-05 10:14:05 -0700 | [diff] [blame] | 56 | # ./oft --list |
Rich Lane | ea5060d | 2013-01-06 13:59:00 -0800 | [diff] [blame] | 57 | # sudo ./oft basic.Echo |
Dan Talayco | 78cb7cc | 2012-03-23 14:25:50 -0700 | [diff] [blame] | 58 | # sudo ./oft --verbose --log-file="" |
Rich Lane | 15f2632 | 2013-01-08 11:23:24 -0800 | [diff] [blame^] | 59 | # sudo ./oft basic -i 1@veth1 -i 2@veth3 |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 60 | |
| 61 | Longer Start |
| 62 | ++++++++++++ |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 63 | |
| 64 | 1. Pre-requisites: |
Dan Talayco | a85e566 | 2010-04-16 09:35:30 -0700 | [diff] [blame] | 65 | * An OF switch instance to test (see 4 below) |
Dan Talayco | 80857c5 | 2010-05-05 10:14:05 -0700 | [diff] [blame] | 66 | * Root privilege on host running oft |
| 67 | * Switch running OpenFlow 1.0 and attempting to connect |
| 68 | to a controller on the machine running oft. |
Dan Talayco | 78cb7cc | 2012-03-23 14:25:50 -0700 | [diff] [blame] | 69 | * Python 2.5 or 2.6. You can run platforms using eth interfaces |
| 70 | with Python 2.4. Python 2.7 may work. |
Dan Talayco | 80857c5 | 2010-05-05 10:14:05 -0700 | [diff] [blame] | 71 | * oftest checked out (called <oftest> here) |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 72 | * scapy installed: http://www.secdev.org/projects/scapy/ |
Dan Talayco | 80857c5 | 2010-05-05 10:14:05 -0700 | [diff] [blame] | 73 | 'sudo apt-get install scapy' should work on Debian. |
Rich Lane | b42a31c | 2012-10-05 17:54:17 -0700 | [diff] [blame] | 74 | * pypcap installed: http://code.google.com/p/pypcap/ (optional) |
| 75 | 'sudo apt-get install python-pypcap' should work on Debian. |
| 76 | Tests using VLAN tags may fail without pypcap. |
Dan Talayco | a85e566 | 2010-04-16 09:35:30 -0700 | [diff] [blame] | 77 | * tcpdump installed (optional, but scapy will complain if it's |
| 78 | not there) |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 79 | * Doxygen and doxypy for document generation (optional) |
| 80 | * lint for source checking (optional) |
| 81 | |
Rich Lane | 15f2632 | 2013-01-08 11:23:24 -0800 | [diff] [blame^] | 82 | 2. Start the switch to test |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 83 | The switch must be running and actively attempting to |
Dan Talayco | 80857c5 | 2010-05-05 10:14:05 -0700 | [diff] [blame] | 84 | connect to a controller on the test host at the port number |
| 85 | used by oft (6633 by default, or specified as --port=<n> as |
| 86 | an argument to oft). |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 87 | |
Dan Talayco | a85e566 | 2010-04-16 09:35:30 -0700 | [diff] [blame] | 88 | If you're new to the test environment and want to check its |
| 89 | sanity, you can do the following. This requires that |
| 90 | your host kernel supports virtual ethernet interfaces. This |
| 91 | is best done in a window separate from where you will run oft. |
Dan Talayco | 80857c5 | 2010-05-05 10:14:05 -0700 | [diff] [blame] | 92 | |
Dan Talayco | a85e566 | 2010-04-16 09:35:30 -0700 | [diff] [blame] | 93 | 4A. Check out openflow (preferably at the same level as oftest): |
| 94 | git clone git://openflowswitch.org/openflow.git |
| 95 | 4B. cd openflow; ./boot.sh; ./configure; make |
Rich Lane | 7bfaeb4 | 2012-10-04 18:18:44 -0700 | [diff] [blame] | 96 | 4C. cd ../oftest |
Dan Talayco | a85e566 | 2010-04-16 09:35:30 -0700 | [diff] [blame] | 97 | 4D. Run the switch startup script: |
| 98 | sudo ./run_switch.py; Now you can run oft (see below). |
Dan Talayco | 80857c5 | 2010-05-05 10:14:05 -0700 | [diff] [blame] | 99 | 4F. Use --help to see command line switches. If you use a port |
| 100 | number other than the default, make sure you use the same |
| 101 | one for the switch as for oft. |
Dan Talayco | a85e566 | 2010-04-16 09:35:30 -0700 | [diff] [blame] | 102 | 4E. Use control-C to terminate the switch daemons. |
| 103 | 4F. To clean up the virtual ethernet interfaces, use |
| 104 | sudo rmmod veth |
| 105 | |
Dan Talayco | 78cb7cc | 2012-03-23 14:25:50 -0700 | [diff] [blame] | 106 | New tools allow you to run an OVS instance as well. See |
| 107 | oftest/tools/ovs-ctl. You will need to install a version of |
| 108 | openvswitch. See http://openvswitch.org/. |
| 109 | |
Rich Lane | 15f2632 | 2013-01-08 11:23:24 -0800 | [diff] [blame^] | 110 | 3. Run oft (requires sudo to control the dataplane) |
Rich Lane | ac2da80 | 2012-10-03 10:12:10 -0700 | [diff] [blame] | 111 | cd <oftest> |
Dan Talayco | a85e566 | 2010-04-16 09:35:30 -0700 | [diff] [blame] | 112 | sudo ./oft --help |
| 113 | |
Rich Lane | ea5060d | 2013-01-06 13:59:00 -0800 | [diff] [blame] | 114 | Important Notes |
| 115 | +++++++++++++++ |
| 116 | |
| 117 | 1. If you're running into issues with transactions, and it appears that |
| 118 | OpenFlow messages aren't quite right, start by looking at any length |
Rich Lane | 15f2632 | 2013-01-08 11:23:24 -0800 | [diff] [blame^] | 119 | fields in the packets. You can use wireshark on the loopback interface |
| 120 | as well as the dataplane ethernet interfaces. |
Rich Lane | ea5060d | 2013-01-06 13:59:00 -0800 | [diff] [blame] | 121 | |
| 122 | 2. If tests dealing with VLANs fail unexpectedly then try installing |
| 123 | pypcap (see Longer Start above). |
| 124 | |
| 125 | Platforms |
| 126 | +++++++++ |
| 127 | |
| 128 | The "platform" is a configuration file (written in Python) that |
| 129 | tells OFTest how to send packets to and receive packets from the |
Rich Lane | 15f2632 | 2013-01-08 11:23:24 -0800 | [diff] [blame^] | 130 | dataplane of the switch. |
| 131 | |
| 132 | The default platform uses Linux ethernet interfaces and is configured with |
| 133 | the -i option. Pass the option as "-i ofport@interface", for example |
| 134 | "-i 1@eth1". If no -i options are given the the default configuration |
| 135 | uses veths and is compatible with the refrence switch. |
Rich Lane | ea5060d | 2013-01-06 13:59:00 -0800 | [diff] [blame] | 136 | |
| 137 | You can add your own platform, say gp104, by adding a file gp104.py to the |
| 138 | platforms directory that defines the function platform_config_update and then |
| 139 | use the parameter --platform=gp104 on the command line. You can also use the |
| 140 | --platform-dir option to change which directory is searched. |
| 141 | |
| 142 | IMPORTANT: That file should define a function platform_config_update which |
| 143 | takes a configuration dictionary as an argument and updates it for the |
| 144 | current run. In particular, it should set up config["port_map"] with |
| 145 | the proper map from OF port numbers to OF interface names. |
| 146 | |
Dan Talayco | 10275aa | 2010-07-20 14:12:31 -0700 | [diff] [blame] | 147 | Helpful Note: Recovering From Crash |
| 148 | +++++++++++++++++++++++++++++++++++ |
| 149 | |
Dan Talayco | 10ffe26 | 2010-07-20 21:55:53 -0700 | [diff] [blame] | 150 | If the test script, oft, becomes unresponsive, you may find that |
| 151 | ^C does not break out of the script. In this case you have two |
| 152 | options: |
Dan Talayco | 10275aa | 2010-07-20 14:12:31 -0700 | [diff] [blame] | 153 | |
Dan Talayco | 10ffe26 | 2010-07-20 21:55:53 -0700 | [diff] [blame] | 154 | * Use ^Z to interrupt the script and return to the shell prompt. |
| 155 | * Start another terminal window to the same machine. |
Dan Talayco | 10275aa | 2010-07-20 14:12:31 -0700 | [diff] [blame] | 156 | |
Dan Talayco | 10ffe26 | 2010-07-20 21:55:53 -0700 | [diff] [blame] | 157 | In either case, you then need to kill the process that is hung. |
| 158 | Use the following commands: |
Dan Talayco | 10275aa | 2010-07-20 14:12:31 -0700 | [diff] [blame] | 159 | |
Dan Talayco | 10ffe26 | 2010-07-20 21:55:53 -0700 | [diff] [blame] | 160 | me@host> ps aux | grep oft |
| 161 | root 4 0.0 S< Jul07 0:00 [ksoftirqd/0] |
| 162 | ... |
| 163 | root 14066 3.2 Tl 09:27 0:00 python ./oft ... |
| 164 | me 14074 0.0 R+ 09:28 0:00 grep oft |
Dan Talayco | 10275aa | 2010-07-20 14:12:31 -0700 | [diff] [blame] | 165 | |
Dan Talayco | 10ffe26 | 2010-07-20 21:55:53 -0700 | [diff] [blame] | 166 | me@host> sudo kill -9 14066 |
Dan Talayco | 10275aa | 2010-07-20 14:12:31 -0700 | [diff] [blame] | 167 | |
Dan Talayco | 10ffe26 | 2010-07-20 21:55:53 -0700 | [diff] [blame] | 168 | where 14066 is the process ID of the hung process. (Replace it |
| 169 | with the PID for your process.) |
| 170 | |
| 171 | This is still preliminary work and there are bugs in the framework |
| 172 | that need to be ironed out. Please report any issues to |
| 173 | dtalayco@stanford.edu. |
Dan Talayco | 10275aa | 2010-07-20 14:12:31 -0700 | [diff] [blame] | 174 | |
Dan Talayco | d2ca103 | 2010-03-10 14:40:26 -0800 | [diff] [blame] | 175 | Using CentOS/RHEL |
| 176 | +++++++++++++++++ |
| 177 | |
| 178 | CentOS/RHEL have two challenges: they are very tied to Python 2.4 |
| 179 | (and Scapy requires Python 2.5 for its latest version) and they |
| 180 | require a kernel upgrade to use veth pairs for local platform |
| 181 | testing. |
| 182 | |
| 183 | If you only need to control eth interfaces for a remote platform, |
Dan Talayco | fa16d59 | 2010-03-12 10:01:43 -0800 | [diff] [blame] | 184 | you can use CentOS/RHEL without major disruption. The key is to |
| 185 | download scapy-1.2 from the following link: |
Dan Talayco | d2ca103 | 2010-03-10 14:40:26 -0800 | [diff] [blame] | 186 | |
| 187 | wget http://hg.secdev.org/scapy/raw-file/v1.2.0.2/scapy.py |
| 188 | |
| 189 | See: http://www.dirk-loss.de/scapy-doc/installation.html#installing-scapy-v1-2 |
| 190 | for more info. |
| 191 | |
| 192 | Copy scapy.py to /usr/lib/python2.4/site-packages |
| 193 | |
| 194 | If you hit an error related to importing scapy.all, you just need |
| 195 | to change the import to refer to scapy (not scapy.all). See |
| 196 | examples in parse.py for example. |