blob: b5f810a038412ab4e6e46f56f6c55a299fb3fa63 [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
Rich Lane4d1f3eb2013-10-03 13:45:57 -070047 6653). See below regarding run_switch.py for a script that starts
Dan Talayco80857c52010-05-05 10:14:05 -070048 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 Lane15f26322013-01-08 11:23:24 -080059 # sudo ./oft basic -i 1@veth1 -i 2@veth3
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 Lane15f26322013-01-08 11:23:24 -080082 2. Start the switch to test
Dan Talaycof7dae842010-02-19 11:50:02 -080083 The switch must be running and actively attempting to
Dan Talayco80857c52010-05-05 10:14:05 -070084 connect to a controller on the test host at the port number
Rich Lane4d1f3eb2013-10-03 13:45:57 -070085 used by oft (6653 by default, or specified as --port=<n> as
Dan Talayco80857c52010-05-05 10:14:05 -070086 an argument to oft).
Dan Talaycof7dae842010-02-19 11:50:02 -080087
Dan Talaycoa85e5662010-04-16 09:35:30 -070088 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 Talayco80857c52010-05-05 10:14:05 -070092
Dan Talaycoa85e5662010-04-16 09:35:30 -070093 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 Lane7bfaeb42012-10-04 18:18:44 -070096 4C. cd ../oftest
Dan Talaycoa85e5662010-04-16 09:35:30 -070097 4D. Run the switch startup script:
98 sudo ./run_switch.py; Now you can run oft (see below).
Dan Talayco80857c52010-05-05 10:14:05 -070099 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 Talaycoa85e5662010-04-16 09:35:30 -0700102 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 Talayco78cb7cc2012-03-23 14:25:50 -0700106 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 Lane15f26322013-01-08 11:23:24 -0800110 3. Run oft (requires sudo to control the dataplane)
Rich Laneac2da802012-10-03 10:12:10 -0700111 cd <oftest>
Dan Talaycoa85e5662010-04-16 09:35:30 -0700112 sudo ./oft --help
113
Rich Laneea5060d2013-01-06 13:59:00 -0800114Important 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 Lane15f26322013-01-08 11:23:24 -0800119 fields in the packets. You can use wireshark on the loopback interface
120 as well as the dataplane ethernet interfaces.
Rich Laneea5060d2013-01-06 13:59:00 -0800121
122 2. If tests dealing with VLANs fail unexpectedly then try installing
123 pypcap (see Longer Start above).
124
125Platforms
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 Lane15f26322013-01-08 11:23:24 -0800130 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 Laneea5060d2013-01-06 13:59:00 -0800136
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 Talayco10275aa2010-07-20 14:12:31 -0700147Helpful Note: Recovering From Crash
148+++++++++++++++++++++++++++++++++++
149
Dan Talayco10ffe262010-07-20 21:55:53 -0700150 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 Talayco10275aa2010-07-20 14:12:31 -0700153
Dan Talayco10ffe262010-07-20 21:55:53 -0700154 * Use ^Z to interrupt the script and return to the shell prompt.
155 * Start another terminal window to the same machine.
Dan Talayco10275aa2010-07-20 14:12:31 -0700156
Dan Talayco10ffe262010-07-20 21:55:53 -0700157 In either case, you then need to kill the process that is hung.
158 Use the following commands:
Dan Talayco10275aa2010-07-20 14:12:31 -0700159
Dan Talayco10ffe262010-07-20 21:55:53 -0700160 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 Talayco10275aa2010-07-20 14:12:31 -0700165
Dan Talayco10ffe262010-07-20 21:55:53 -0700166 me@host> sudo kill -9 14066
Dan Talayco10275aa2010-07-20 14:12:31 -0700167
Dan Talayco10ffe262010-07-20 21:55:53 -0700168 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 Talayco10275aa2010-07-20 14:12:31 -0700174
Dan Talaycod2ca1032010-03-10 14:40:26 -0800175Using 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 Talaycofa16d592010-03-12 10:01:43 -0800184 you can use CentOS/RHEL without major disruption. The key is to
185 download scapy-1.2 from the following link:
Dan Talaycod2ca1032010-03-10 14:40:26 -0800186
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.