blob: a627e12711574f4b9ce2664975b8eed38e8eef22 [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
Rich Laneea5060d2013-01-06 13:59:00 -080029 For information on writing new tests or making improvements to
30 the test framework see the file DEVELOPING.
31
32Getting 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 Talayco80857c52010-05-05 10:14:05 -070038
Dan Talaycof7dae842010-02-19 11:50:02 -080039Quick Start
40+++++++++++
Dan Talaycoa85e5662010-04-16 09:35:30 -070041
Rich Lane2a3bbb42012-10-04 15:45:32 -070042 You need to have Python and Scapy installed on your system.
43 See 'Pre-requisites' below.
Dan Talayco94696932010-07-09 09:42:24 -070044
Dan Talaycoa85e5662010-04-16 09:35:30 -070045 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 Talayco80857c52010-05-05 10:14:05 -070047 6633). See below regarding run_switch.py for a script that starts
48 up a software switch on the test host.
Dan Talaycoa85e5662010-04-16 09:35:30 -070049
50 Currently, switches must be running version 1.0 of OpenFlow.
51
Dan Talayco78cb7cc2012-03-23 14:25:50 -070052 # git clone git://github.com/floodlight/oftest
Rich Laneac2da802012-10-03 10:12:10 -070053 # cd oftest
Dan Talayco94696932010-07-09 09:42:24 -070054 Make sure the switch you want to test is running --
55 see (4) below for the reference switch example.
Dan Talayco80857c52010-05-05 10:14:05 -070056 # ./oft --list
Rich Laneea5060d2013-01-06 13:59:00 -080057 # sudo ./oft basic.Echo
Dan Talayco78cb7cc2012-03-23 14:25:50 -070058 # sudo ./oft --verbose --log-file=""
Rich Laneea5060d2013-01-06 13:59:00 -080059 # sudo ./oft basic --platform=remote --host=...
Dan Talayco1ddefbf2010-03-07 21:56:47 -080060
61Longer Start
62++++++++++++
Dan Talaycof7dae842010-02-19 11:50:02 -080063
64 1. Pre-requisites:
Dan Talaycoa85e5662010-04-16 09:35:30 -070065 * An OF switch instance to test (see 4 below)
Dan Talayco80857c52010-05-05 10:14:05 -070066 * 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 Talayco78cb7cc2012-03-23 14:25:50 -070069 * Python 2.5 or 2.6. You can run platforms using eth interfaces
70 with Python 2.4. Python 2.7 may work.
Dan Talayco80857c52010-05-05 10:14:05 -070071 * oftest checked out (called <oftest> here)
Dan Talaycof7dae842010-02-19 11:50:02 -080072 * scapy installed: http://www.secdev.org/projects/scapy/
Dan Talayco80857c52010-05-05 10:14:05 -070073 'sudo apt-get install scapy' should work on Debian.
Rich Laneb42a31c2012-10-05 17:54:17 -070074 * 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 Talaycoa85e5662010-04-16 09:35:30 -070077 * tcpdump installed (optional, but scapy will complain if it's
78 not there)
Dan Talaycof7dae842010-02-19 11:50:02 -080079 * Doxygen and doxypy for document generation (optional)
80 * lint for source checking (optional)
81
Rich Lane6242d9f2013-01-06 17:35:39 -080082 2. Edit configuration if necessary
Rich Laneea5060d2013-01-06 13:59:00 -080083 The default (local) platform uses 4 veth interface pairs and
84 is only suitable for testing local software switches. To test
85 hardware switches you will need to create an appropriate
86 platform file. See the "Platforms" section below.
Dan Talaycof7dae842010-02-19 11:50:02 -080087
Rich Lane6242d9f2013-01-06 17:35:39 -080088 3. Start the switch to test
Dan Talaycof7dae842010-02-19 11:50:02 -080089 The switch must be running and actively attempting to
Dan Talayco80857c52010-05-05 10:14:05 -070090 connect to a controller on the test host at the port number
91 used by oft (6633 by default, or specified as --port=<n> as
92 an argument to oft).
Dan Talaycof7dae842010-02-19 11:50:02 -080093
Dan Talaycoa85e5662010-04-16 09:35:30 -070094 If you're new to the test environment and want to check its
95 sanity, you can do the following. This requires that
96 your host kernel supports virtual ethernet interfaces. This
97 is best done in a window separate from where you will run oft.
Dan Talayco80857c52010-05-05 10:14:05 -070098
Dan Talaycoa85e5662010-04-16 09:35:30 -070099 4A. Check out openflow (preferably at the same level as oftest):
100 git clone git://openflowswitch.org/openflow.git
101 4B. cd openflow; ./boot.sh; ./configure; make
Rich Lane7bfaeb42012-10-04 18:18:44 -0700102 4C. cd ../oftest
Dan Talaycoa85e5662010-04-16 09:35:30 -0700103 4D. Run the switch startup script:
104 sudo ./run_switch.py; Now you can run oft (see below).
Dan Talayco80857c52010-05-05 10:14:05 -0700105 4F. Use --help to see command line switches. If you use a port
106 number other than the default, make sure you use the same
107 one for the switch as for oft.
Dan Talaycoa85e5662010-04-16 09:35:30 -0700108 4E. Use control-C to terminate the switch daemons.
109 4F. To clean up the virtual ethernet interfaces, use
110 sudo rmmod veth
111
Dan Talayco78cb7cc2012-03-23 14:25:50 -0700112 New tools allow you to run an OVS instance as well. See
113 oftest/tools/ovs-ctl. You will need to install a version of
114 openvswitch. See http://openvswitch.org/.
115
Rich Lane6242d9f2013-01-06 17:35:39 -0800116 4. Run oft (requires sudo to control the dataplane)
Rich Laneac2da802012-10-03 10:12:10 -0700117 cd <oftest>
Dan Talaycoa85e5662010-04-16 09:35:30 -0700118 sudo ./oft --help
119
Rich Laneea5060d2013-01-06 13:59:00 -0800120Important Notes
121+++++++++++++++
122
123 1. If you're running into issues with transactions, and it appears that
124 OpenFlow messages aren't quite right, start by looking at any length
125 fields in the packets. With the local platform, you can use wireshark
126 on the loopback interface as well as the dataplane veth interfaces.
127
128 2. If tests dealing with VLANs fail unexpectedly then try installing
129 pypcap (see Longer Start above).
130
131Platforms
132+++++++++
133
134 The "platform" is a configuration file (written in Python) that
135 tells OFTest how to send packets to and receive packets from the
136 dataplane of the switch. The default platform uses Linux virtual
137 ethernet interfaces and is suitable only for local software switches.
138
139 You can add your own platform, say gp104, by adding a file gp104.py to the
140 platforms directory that defines the function platform_config_update and then
141 use the parameter --platform=gp104 on the command line. You can also use the
142 --platform-dir option to change which directory is searched.
143
144 IMPORTANT: That file should define a function platform_config_update which
145 takes a configuration dictionary as an argument and updates it for the
146 current run. In particular, it should set up config["port_map"] with
147 the proper map from OF port numbers to OF interface names.
148
Dan Talayco10275aa2010-07-20 14:12:31 -0700149Helpful Note: Recovering From Crash
150+++++++++++++++++++++++++++++++++++
151
Dan Talayco10ffe262010-07-20 21:55:53 -0700152 If the test script, oft, becomes unresponsive, you may find that
153 ^C does not break out of the script. In this case you have two
154 options:
Dan Talayco10275aa2010-07-20 14:12:31 -0700155
Dan Talayco10ffe262010-07-20 21:55:53 -0700156 * Use ^Z to interrupt the script and return to the shell prompt.
157 * Start another terminal window to the same machine.
Dan Talayco10275aa2010-07-20 14:12:31 -0700158
Dan Talayco10ffe262010-07-20 21:55:53 -0700159 In either case, you then need to kill the process that is hung.
160 Use the following commands:
Dan Talayco10275aa2010-07-20 14:12:31 -0700161
Dan Talayco10ffe262010-07-20 21:55:53 -0700162 me@host> ps aux | grep oft
163 root 4 0.0 S< Jul07 0:00 [ksoftirqd/0]
164 ...
165 root 14066 3.2 Tl 09:27 0:00 python ./oft ...
166 me 14074 0.0 R+ 09:28 0:00 grep oft
Dan Talayco10275aa2010-07-20 14:12:31 -0700167
Dan Talayco10ffe262010-07-20 21:55:53 -0700168 me@host> sudo kill -9 14066
Dan Talayco10275aa2010-07-20 14:12:31 -0700169
Dan Talayco10ffe262010-07-20 21:55:53 -0700170 where 14066 is the process ID of the hung process. (Replace it
171 with the PID for your process.)
172
173 This is still preliminary work and there are bugs in the framework
174 that need to be ironed out. Please report any issues to
175 dtalayco@stanford.edu.
Dan Talayco10275aa2010-07-20 14:12:31 -0700176
Dan Talaycod2ca1032010-03-10 14:40:26 -0800177Using CentOS/RHEL
178+++++++++++++++++
179
180 CentOS/RHEL have two challenges: they are very tied to Python 2.4
181 (and Scapy requires Python 2.5 for its latest version) and they
182 require a kernel upgrade to use veth pairs for local platform
183 testing.
184
185 If you only need to control eth interfaces for a remote platform,
Dan Talaycofa16d592010-03-12 10:01:43 -0800186 you can use CentOS/RHEL without major disruption. The key is to
187 download scapy-1.2 from the following link:
Dan Talaycod2ca1032010-03-10 14:40:26 -0800188
189 wget http://hg.secdev.org/scapy/raw-file/v1.2.0.2/scapy.py
190
191 See: http://www.dirk-loss.de/scapy-doc/installation.html#installing-scapy-v1-2
192 for more info.
193
194 Copy scapy.py to /usr/lib/python2.4/site-packages
195
196 If you hit an error related to importing scapy.all, you just need
197 to change the import to refer to scapy (not scapy.all). See
198 examples in parse.py for example.