blob: 2f1a7dad5ca368ebe262f56971bb2c6f90589861 [file] [log] [blame]
Dan Talaycof7dae842010-02-19 11:50:02 -08001OpenFlow Testing Framework
Dan Talayco10ffe262010-07-20 21:55:53 -07002July, 2010
Rich Laneea5060d2013-01-06 13:59:00 -08003Last updated January 2013
Dan Talaycof7dae842010-02-19 11:50:02 -08004
Dan Talaycof3171872010-05-07 09:29:57 -07005Copyright (c) 2010 The Board of Trustees of The Leland Stanford
6Junior University
7
Dan Talayco10275aa2010-07-20 14:12:31 -07008License
9+++++++
Dan Talayco551befa2010-07-15 17:05:32 -070010
Dan Talayco10ffe262010-07-20 21:55:53 -070011 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 Talayco551befa2010-07-15 17:05:32 -070014
Dan Talayco10275aa2010-07-20 14:12:31 -070015 http://www.openflow.org/wp/legal
Dan Talayco551befa2010-07-15 17:05:32 -070016
Dan Talayco10ffe262010-07-20 21:55:53 -070017 Other software referenced in this distribution is subject to its
18 respective license.
19
Dan Talayco80857c52010-05-05 10:14:05 -070020Introduction
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
29 There are two parts to running the test framework:
30
31 * Building the python libraries that support the OF protocol
32 * Running oft, the main entry point of the test framework
33
34 Normally log output from oft is sent to the file oft.log, but
35 can be redirected to the console by specifying --log-file="".
Rich Laneea5060d2013-01-06 13:59:00 -080036
37 For information on writing new tests or making improvements to
38 the test framework see the file DEVELOPING.
39
40Getting OFTest
41++++++++++++++
42
43 You can check out OFTest with git with the following command:
44
45 git clone git://github.com/floodlight/oftest
Dan Talayco80857c52010-05-05 10:14:05 -070046
Dan Talaycof7dae842010-02-19 11:50:02 -080047Quick Start
48+++++++++++
Dan Talaycoa85e5662010-04-16 09:35:30 -070049
Rich Lane2a3bbb42012-10-04 15:45:32 -070050 You need to have Python and Scapy installed on your system.
51 See 'Pre-requisites' below.
Dan Talayco94696932010-07-09 09:42:24 -070052
Dan Talaycoa85e5662010-04-16 09:35:30 -070053 Make sure your switch is running and trying to connect to a
54 controller on the machine where you're running oft (normally port
Dan Talayco80857c52010-05-05 10:14:05 -070055 6633). See below regarding run_switch.py for a script that starts
56 up a software switch on the test host.
Dan Talaycoa85e5662010-04-16 09:35:30 -070057
58 Currently, switches must be running version 1.0 of OpenFlow.
59
Dan Talayco78cb7cc2012-03-23 14:25:50 -070060 # git clone git://github.com/floodlight/oftest
Rich Laneac2da802012-10-03 10:12:10 -070061 # cd oftest
Rich Lane2a3bbb42012-10-04 15:45:32 -070062 # make -C tools/munger
Dan Talayco94696932010-07-09 09:42:24 -070063 Make sure the switch you want to test is running --
64 see (4) below for the reference switch example.
Dan Talayco80857c52010-05-05 10:14:05 -070065 # ./oft --list
Rich Laneea5060d2013-01-06 13:59:00 -080066 # sudo ./oft basic.Echo
Dan Talayco78cb7cc2012-03-23 14:25:50 -070067 # sudo ./oft --verbose --log-file=""
Rich Laneea5060d2013-01-06 13:59:00 -080068 # sudo ./oft basic --platform=remote --host=...
Dan Talayco1ddefbf2010-03-07 21:56:47 -080069
70Longer Start
71++++++++++++
Dan Talaycof7dae842010-02-19 11:50:02 -080072
73 1. Pre-requisites:
Dan Talaycoa85e5662010-04-16 09:35:30 -070074 * An OF switch instance to test (see 4 below)
Dan Talayco80857c52010-05-05 10:14:05 -070075 * Root privilege on host running oft
76 * Switch running OpenFlow 1.0 and attempting to connect
77 to a controller on the machine running oft.
Dan Talayco78cb7cc2012-03-23 14:25:50 -070078 * Python 2.5 or 2.6. You can run platforms using eth interfaces
79 with Python 2.4. Python 2.7 may work.
Dan Talayco80857c52010-05-05 10:14:05 -070080 * oftest checked out (called <oftest> here)
Dan Talaycof7dae842010-02-19 11:50:02 -080081 * scapy installed: http://www.secdev.org/projects/scapy/
Dan Talayco80857c52010-05-05 10:14:05 -070082 'sudo apt-get install scapy' should work on Debian.
Rich Laneb42a31c2012-10-05 17:54:17 -070083 * pypcap installed: http://code.google.com/p/pypcap/ (optional)
84 'sudo apt-get install python-pypcap' should work on Debian.
85 Tests using VLAN tags may fail without pypcap.
Dan Talaycoa85e5662010-04-16 09:35:30 -070086 * tcpdump installed (optional, but scapy will complain if it's
87 not there)
Dan Talaycof7dae842010-02-19 11:50:02 -080088 * Doxygen and doxypy for document generation (optional)
89 * lint for source checking (optional)
90
91 2. Build the OpenFlow Python message classes
Dan Talaycoc4747962010-02-19 12:29:17 -080092
93 Important: The OF version used by the controller is based on
94 the file in <oftest>/tools/pylibopenflow/include/openflow.h
95 This is currently the 1.0 release file.
96
Rich Lane2a3bbb42012-10-04 15:45:32 -070097 make -C <oftest>/tools/munger
Dan Talayco80857c52010-05-05 10:14:05 -070098
Rich Lane2a3bbb42012-10-04 15:45:32 -070099 This places files in <oftest>/src/python/oftest/src.
Dan Talaycof7dae842010-02-19 11:50:02 -0800100
Dan Talayco1ddefbf2010-03-07 21:56:47 -0800101 3. Edit configuration if necessary
Rich Laneea5060d2013-01-06 13:59:00 -0800102 The default (local) platform uses 4 veth interface pairs and
103 is only suitable for testing local software switches. To test
104 hardware switches you will need to create an appropriate
105 platform file. See the "Platforms" section below.
Dan Talaycof7dae842010-02-19 11:50:02 -0800106
Dan Talayco1ddefbf2010-03-07 21:56:47 -0800107 4. Start the switch to test
Dan Talaycof7dae842010-02-19 11:50:02 -0800108 The switch must be running and actively attempting to
Dan Talayco80857c52010-05-05 10:14:05 -0700109 connect to a controller on the test host at the port number
110 used by oft (6633 by default, or specified as --port=<n> as
111 an argument to oft).
Dan Talaycof7dae842010-02-19 11:50:02 -0800112
Dan Talaycoa85e5662010-04-16 09:35:30 -0700113 If you're new to the test environment and want to check its
114 sanity, you can do the following. This requires that
115 your host kernel supports virtual ethernet interfaces. This
116 is best done in a window separate from where you will run oft.
Dan Talayco80857c52010-05-05 10:14:05 -0700117
Dan Talaycoa85e5662010-04-16 09:35:30 -0700118 4A. Check out openflow (preferably at the same level as oftest):
119 git clone git://openflowswitch.org/openflow.git
120 4B. cd openflow; ./boot.sh; ./configure; make
Rich Lane7bfaeb42012-10-04 18:18:44 -0700121 4C. cd ../oftest
Dan Talaycoa85e5662010-04-16 09:35:30 -0700122 4D. Run the switch startup script:
123 sudo ./run_switch.py; Now you can run oft (see below).
Dan Talayco80857c52010-05-05 10:14:05 -0700124 4F. Use --help to see command line switches. If you use a port
125 number other than the default, make sure you use the same
126 one for the switch as for oft.
Dan Talaycoa85e5662010-04-16 09:35:30 -0700127 4E. Use control-C to terminate the switch daemons.
128 4F. To clean up the virtual ethernet interfaces, use
129 sudo rmmod veth
130
Dan Talayco78cb7cc2012-03-23 14:25:50 -0700131 New tools allow you to run an OVS instance as well. See
132 oftest/tools/ovs-ctl. You will need to install a version of
133 openvswitch. See http://openvswitch.org/.
134
Rich Laneea5060d2013-01-06 13:59:00 -0800135 5. Run oft (requires sudo to control the dataplane)
Rich Laneac2da802012-10-03 10:12:10 -0700136 cd <oftest>
Dan Talaycoa85e5662010-04-16 09:35:30 -0700137 sudo ./oft --help
138
Rich Laneea5060d2013-01-06 13:59:00 -0800139Important Notes
140+++++++++++++++
141
142 1. If you're running into issues with transactions, and it appears that
143 OpenFlow messages aren't quite right, start by looking at any length
144 fields in the packets. With the local platform, you can use wireshark
145 on the loopback interface as well as the dataplane veth interfaces.
146
147 2. If tests dealing with VLANs fail unexpectedly then try installing
148 pypcap (see Longer Start above).
149
150Platforms
151+++++++++
152
153 The "platform" is a configuration file (written in Python) that
154 tells OFTest how to send packets to and receive packets from the
155 dataplane of the switch. The default platform uses Linux virtual
156 ethernet interfaces and is suitable only for local software switches.
157
158 You can add your own platform, say gp104, by adding a file gp104.py to the
159 platforms directory that defines the function platform_config_update and then
160 use the parameter --platform=gp104 on the command line. You can also use the
161 --platform-dir option to change which directory is searched.
162
163 IMPORTANT: That file should define a function platform_config_update which
164 takes a configuration dictionary as an argument and updates it for the
165 current run. In particular, it should set up config["port_map"] with
166 the proper map from OF port numbers to OF interface names.
167
Dan Talayco10275aa2010-07-20 14:12:31 -0700168Helpful Note: Recovering From Crash
169+++++++++++++++++++++++++++++++++++
170
Dan Talayco10ffe262010-07-20 21:55:53 -0700171 If the test script, oft, becomes unresponsive, you may find that
172 ^C does not break out of the script. In this case you have two
173 options:
Dan Talayco10275aa2010-07-20 14:12:31 -0700174
Dan Talayco10ffe262010-07-20 21:55:53 -0700175 * Use ^Z to interrupt the script and return to the shell prompt.
176 * Start another terminal window to the same machine.
Dan Talayco10275aa2010-07-20 14:12:31 -0700177
Dan Talayco10ffe262010-07-20 21:55:53 -0700178 In either case, you then need to kill the process that is hung.
179 Use the following commands:
Dan Talayco10275aa2010-07-20 14:12:31 -0700180
Dan Talayco10ffe262010-07-20 21:55:53 -0700181 me@host> ps aux | grep oft
182 root 4 0.0 S< Jul07 0:00 [ksoftirqd/0]
183 ...
184 root 14066 3.2 Tl 09:27 0:00 python ./oft ...
185 me 14074 0.0 R+ 09:28 0:00 grep oft
Dan Talayco10275aa2010-07-20 14:12:31 -0700186
Dan Talayco10ffe262010-07-20 21:55:53 -0700187 me@host> sudo kill -9 14066
Dan Talayco10275aa2010-07-20 14:12:31 -0700188
Dan Talayco10ffe262010-07-20 21:55:53 -0700189 where 14066 is the process ID of the hung process. (Replace it
190 with the PID for your process.)
191
192 This is still preliminary work and there are bugs in the framework
193 that need to be ironed out. Please report any issues to
194 dtalayco@stanford.edu.
Dan Talayco10275aa2010-07-20 14:12:31 -0700195
Dan Talaycod2ca1032010-03-10 14:40:26 -0800196Using CentOS/RHEL
197+++++++++++++++++
198
199 CentOS/RHEL have two challenges: they are very tied to Python 2.4
200 (and Scapy requires Python 2.5 for its latest version) and they
201 require a kernel upgrade to use veth pairs for local platform
202 testing.
203
204 If you only need to control eth interfaces for a remote platform,
Dan Talaycofa16d592010-03-12 10:01:43 -0800205 you can use CentOS/RHEL without major disruption. The key is to
206 download scapy-1.2 from the following link:
Dan Talaycod2ca1032010-03-10 14:40:26 -0800207
208 wget http://hg.secdev.org/scapy/raw-file/v1.2.0.2/scapy.py
209
210 See: http://www.dirk-loss.de/scapy-doc/installation.html#installing-scapy-v1-2
211 for more info.
212
213 Copy scapy.py to /usr/lib/python2.4/site-packages
214
215 If you hit an error related to importing scapy.all, you just need
216 to change the import to refer to scapy (not scapy.all). See
217 examples in parse.py for example.