Describe dummy test model. Work on OpenFlow intro.
[openvswitch] / doc / manual.texi
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename openvswitch.info
4 @settitle Open vSwitch Guide
5 @c %**end of header
6
7 @macro ovs {}
8 Open@tie{}vSwitch
9 @end macro
10
11 @copying
12 Copyright @copyright{} 2012, 2013 Nicira, Inc.
13
14 Licensed under the Apache License, Version 2.0 (the ``License''); you
15 may not use this file except in compliance with the License.  You may
16 obtain a copy of the License at
17 @url{http://www.apache.org/licenses/LICENSE-2.0}.
18
19 Unless required by applicable law or agreed to in writing, software
20 distributed under the License is distributed on an ``AS IS'' BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
22 implied.  See the License for the specific language governing
23 permissions and limitations under the License.
24 @end copying
25
26 @titlepage
27 @title Programming the Open vSwitch Platform
28 @author Open vSwitch Contributors
29
30 @page
31 @vskip 0pt plus 1filll
32 @insertcopying
33 @end titlepage
34
35 @contents
36
37 @ifnottex
38 @node Top
39 @top TITLE
40
41 This manual is for Open vSwitch, version 1.9.
42 @end ifnottex
43
44 @menu
45 * Introduction::
46 @end menu
47
48 @node Introduction
49 @chapter Introduction
50
51 Open vSwitch is an Ethernet switch implemented in software.  It is
52 well suited to environments that call for basic switching features
53 such as VLANs and bonding.  However, Open vSwitch is built as a
54 platform to open up network forwarding to programmatic extension, so
55 it really shines in environments that demand fast, flexible control
56 over the network.
57
58 Open vSwitch is most often deployed today as a purely software switch,
59 that is, on computers without hardware specialized for packet
60 switching.  In this class of uses, Open vSwitch most often runs on
61 virtual server hosts, to forward virtual machine network traffic to
62 and from a physical network.  Virtualization is not a requirement:
63 Open vSwitch can also forward traffic among physical interfaces in a
64 ``bare metal'' environment.
65
66 Open vSwitch is designed and internally layered to be amenable for use
67 within special-purpose switch hardware, and a number of network
68 hardware manufacturers have used it for that purpose.  This allows
69 Open vSwitch to control high-performance hardware switches as well as
70 software switches, although hardware is inherently less flexible than
71 software.
72
73 Open vSwitch runs on top of a wide variety of hardware, operating
74 systems, and hypervisors, and it has been integrated with multiple
75 cloud management systems.  Please refer to Open vSwitch and vendor
76 documentation for details.
77
78 @menu
79 * Architecture::                
80 @end menu
81
82 @node Architecture
83 @section Architecture
84
85 This section describes the components of Open vSwitch at a high-level
86 and how they interact with each other and with components not part of
87 Open vSwitch.
88
89 The most important component of Open vSwitch is the virtual switch
90 daemon, @command{ovs-vswitchd}.  This daemon implements Open vSwitch
91 core switching and programmability functions.  In a software switch,
92 this daemon is a ``soft real-time'' component that handles the first
93 packet of each new flow that enters the network.  In a hardware
94 switch, it instead configures the hardware's packet processing
95 features.
96
97 The virtual switch daemon has two important external interfaces.  The
98 first of these speaks a protocol called OVSDB to the second major Open
99 vSwitch daemon, the @command{ovsdb-server} database server.  This
100 daemon's configuration database tracks typically slowly changing
101 management plane state, such as the set of configured switches and
102 their ports.  The database server can also talk to controllers on
103 remote servers over the same OVSDB protocol.
104
105 @command{ovs-vswitchd}'s other major external interface is the control
106 plane interface.  This interface allows controllers on remote servers
107 to directly control the treatment of packets that arrive on the
108 switches configured in the database.  Control can be reactive, with
109 the controller deciding what should be done for each new flow as it
110 arrives at the switch, or proactive, with the controller specifying in
111 advance the treatment of every packet that might happen to arrive, or
112 some combination.  Open vSwitch uses the OpenFlow protocol for this
113 control plane interface.
114
115 Open vSwitch also includes a number of utility programs.
116 @command{ovs-vsctl} is an interactive command-line interface to
117 @command{ovsdb-server} for configuring and querying Open vSwitch
118 configuration.  It is also used heavily in shell scripts that
119 integrate Open vSwitch with hypervisor and cloud management systems.
120
121 @command{ovs-ofctl} is a command-line tool that speaks the OpenFlow
122 protocol.  Unlike @command{ovs-vsctl}, which is often used in
123 production, it is most useful for troubleshooting and prototyping.  We
124 will often use it in examples in this book.
125
126 @command{ovs-appctl} is a command-line tool to send commands to
127 @command{ovs-vswitchd} and @command{ovsdb-server}.  It is occasionally
128 useful for special purposes, especially in testing and debugging.
129
130 @node Testing
131 @chapter Testing
132
133 Testing is essential to writing reliable software, so as network
134 operation becomes programmable, testing becomes essential to designing
135 a network.  This chapter discusses different ways that one can test
136 a network containing Open vSwitch elements.
137
138 The goal of testing is to model a network setup that one would use in
139 production, to allow one to assess important properties of that setup,
140 such as its correctness, performance, and scalability.  How the model
141 is constructed determines which properties can be assessed and how
142 accurately.  The model also determines properties of the testing
143 itself, such as how easy or difficult the testing is to set up, to
144 replicate, and to change, how expensive and time-consuming the testing
145 is, and how easy or difficult the results are to interpret.
146
147 @menu
148 * Physical Test Models::        
149 * Virtual Test Models::         
150 @end menu
151
152 @node Physical Test Models
153 @section Physical Test Models
154
155 The most obvious way to test Open vSwitch is to use a model that
156 replicates the production system, or to use the production system for
157 testing.  This form of modeling allows accurate performance
158 measurements, but in most other respects, it is inconvenient.  Setting
159 up a new network topology may require physically replugging network
160 cables, which is time-consuming and error-prone.  Recovering from
161 errors in the network programming, which are sure to be encountered
162 during testing, may require setting up an extra out-of-band network.
163 Finally, running multiple tests in parallel requires replicating the
164 entire setup.
165
166 Simple setups, such as those that involve only one machine acting as a
167 switch, can often be tested satisfactorily as physical models.  At
168 least one Open vSwitch developer tests his changes this way
169 exclusively.
170
171 @node Virtual Test Models
172 @section Virtual Test Models
173
174 Virtualization is one way to ease the inconvenience of testing with a
175 physical model, that is, to use virtual machines instead of physical
176 ones, and virtual switches instead of physical switches.  Because
177 virtual machines and virtual switches are easier to reconfigure than
178 physical machines and physical switches, this makes running different
179 tests easier.  Virtual environments also reduce the need for physical
180 hardware and at the same time, it is easier to replicate virtual
181 environments, so taken together it becomes cheaper to run multiple
182 tests in parallel.
183
184 A virtual environment doesn't perfectly reproduce the performance of
185 the physical environment that it models.  A virtual environment
186 usually performs slightly worse than the corresponding physical setup,
187 so one may assume that, if the performance of the virtual model is
188 adequate, then the performance of the corresponding physical setup
189 would also be acceptable.  (This makes it difficult, of course, to
190 have confidence in the physical performance if the virtual environment
191 does not perform acceptably.)
192
193 One important way that a virtual environment can perform better than a
194 physical one is that a virtual network within a single virtual server
195 host may outperform a typical physical network.  The aggregate
196 performance of virtual network connections between collocated VMs, for
197 example, can easily exceed 5 Gb/s, whereas the most common physical
198 Ethernet connections have a maximum bandwidth of 1 Gb/s.  At the same
199 time, many implementations of quality-of-service (QoS) features to
200 limit bandwidth, including the Linux QoS features that Open vSwitch
201 has built-in support for configuring, are designed for physical
202 Ethernet connections and do not work well within a virtual server
203 host.
204
205 Using a virtual model can become more difficult if the network setup
206 that one wishes to test uses virtualization itself.  Sometimes it is
207 possible to ``factor'' the model so that a simple virtualization setup
208 still adequately models the physical setup.  For example, one might
209 decide that how virtual machines are assigned to physical hypervisors
210 is not an important characteristic of the physical environment, so
211 that one may represent these virtual machines of the physical
212 environment as virtual machines in the test model, leaving the
213 hypervisors of the physical environment out of the model.
214
215 In situations where factoring the physical hypervisors out of the test
216 model is not acceptable, one may resort to @dfn{nested
217 virtualization}, that is, running hypervisors inside hypervisors.
218 This decision is not to be made lightly, because nested virtualization
219 has disadvantages beyond those of ordinary virtualization.  First, not
220 all hypervisors support nested virtualization.@footnote{In my
221 experience, nested virtualization works best with VMware ESX as the
222 outer hypervisor.}  Second, nested virtualization compounds
223 performance issues.  It is much more common to see poor performance
224 and timeouts that cannot be reproduced in a corresponding physical
225 setup in a virtual environment that includes nested hypervisors.
226
227 @node Dummy Test Models
228 @section Dummy Test Models
229
230 Open vSwitch has a few special ``dummy'' features for testing
231 purposes.  A @dfn{dummy switch} is an Open vSwitch switch that it
232 simulates entirely within itself, without connecting to any physical
233 or virtual hardware.  Typically a dummy switch's ports will be
234 populated with dummy network devices, which are, similarly, simulated
235 entirely within @command{ovs-vswitchd}.
236
237 A ``dummy test model,'' that is, a test model based on Open vSwitch
238 dummy switches, requires no virtual or physical hardware, no
239 supervisor privilege, and runs comfortably with minimal memory and CPU
240 resources.  However, dummy test models do not realistically model
241 actual traffic patterns or performance.  They also rely on Open
242 vSwitch features that are subject to change from release to release.
243
244 A unique advantage of dummy test models is that they can run faster
245 than real time: the user can manipulate a dummy switch's idea of the
246 current time can, causing it to stop or to jump forward an arbitrary
247 amount.  This can be invaluable for some purposes, such as testing
248 flow expiration or NetFlow traffic.
249
250 @node Introduction to OpenFlow
251 @chapter Introduction to OpenFlow
252
253 Programming an Open vSwitch software switch requires a solid grasp of
254 the fundamentals of OpenFlow.
255
256 An OpenFlow switch has two important parts.  The first part is the
257 switch's set of ports, which are the same as the ports in any other
258 Ethernet switch.  The second piece is a set of one or more @dfn{flow
259 tables}.  A flow table amounts to a set of if-then rules that tell the
260 switch how to handle any packet that might arrive at a port.  Each
261 rule, called a @dfn{flow}, specifies a condition (the @dfn{match}) and
262 a list of @dfn{actions} to execute if the condition is met.
263
264 To illustrate the idea of a flow table, consider a OpenFlow switch
265 with three ports, numbered 1, 2, and 3.  The flow table described
266 informally below would cause such a switch to act as a ``hub'' that
267 forwards each arriving packet to the other two ports:
268
269 @quotation
270 If the packet arrived on port 1, forward it to ports 2 and 3; @*
271 If the packet arrived on port 2, forward it to ports 1 and 3; @*
272 If the packet arrived on port 3, forward it to ports 1 and 2.
273 @end quotation
274
275 In this example, any packet would match exactly one flow.  OpenFlow
276 provides for packets possibly matching multiple flows on by requiring
277 the user to associate each flow with a numeric @dfn{priority}.  If a
278 packet matches more than one flow, the priority is used as a
279 tie-breaker, with the higher priority wins.  (If two matching flows
280 have the same priority, the behavior is undefined, so flow tables are
281 designed to avoid this possibility.)
282
283 In some flow tables, some packets match no flows at all.  The user can
284 configure an OpenFlow switch either to drop these packets or to
285 forward them to an OpenFlow controller (describe later) for further
286 processing.
287
288 @node Outline
289 @chapter Outline
290
291 @verbatim
292 * Test setups.
293 ** Physical
294 ** Virtual
295 *** start-test-vm
296 **** non-persistent
297 **** install ethtool, tcpdump, strace, valgrind, hping3, netperf (from non-free)
298 **** set up serial port in inittab (just uncomment the T0:... line)
299 **** runme, put this in /etc/rc.local and mark it executable:
300 **** NFS setup (mount -o ro,udp,timeo=1 10.0.2.2:/home/blp/ovs /mnt)
301 #!/bin/sh 
302 mount -t iso9660 /dev/sr0 /cdrom
303 exec sh -x /cdrom/runme
304 exit 0
305
306 ** Nested virtual
307 ** Dummy-based.
308 ** test-vm based
309 *** not for performance simulation (including QoS)
310
311 * Test techniques.
312 ** ofproto/trace
313 ** netdev-dummy/receive
314 ** write some tools for arp, ping, more?
315
316 * Introduction to OpenFlow.
317 * Packet processing pipeline.
318 ** The ``normal'' action's pipeline.
319 * Examples of proactive programming.
320 ** Hub (flood)
321 ** Virtual switch
322 ** Ingress-only firewall
323 * Limitations of proactive programming in OF1.0
324 ** Can't do MAC learning (solution: NX or reactive programming)
325 ** Cartesian product is expensive (OF1.1+ or NX or reactive programming)
326 * Reactive programming.
327 ** Slow
328 ** High latency
329 ** Handles disconnection badly
330 ** Hard to scale
331 * Hybrid approaches
332 ** Proactive with a few packets to controller
333 ** Proactive with local controller
334
335 * Management plane.
336 ** Ports and interfaces.
337 ** Bonding.
338 *** How to use through OpenFlow, and limitations.
339 *** Future directions.
340 *** How to emulate with OpenFlow?
341 ** VLANs.
342 *** Interaction with OpenFlow.
343 ** MAC learning.
344 *** Reading and flushing the MAC learning table.
345 *** Preventing MAC learning.
346 *** Interaction with bonding.
347 *** 
348 ** Mirrors.
349 *** Limitations with OpenFlow.
350 *** How to emulate with OpenFlow (avoiding duplicates).
351 ** Spanning tree.
352 *** Limitations for nonstandard setups.
353 ** CFM
354 *** Tradeoffs.
355 *** Caveats.
356 ** Policing.
357 ** QoS.
358
359 ** How to simulate NORMAL with rules that don't use it.
360
361 * Control plane programming techniques.
362 ** Resubmit.
363 ** Registers.
364 *** NAND gate.
365 ** Local controller.
366
367 * Proactive control plane programming.
368 ** Resubmit.
369 *** Firewall with ingress and egress rules.
370 **** Handling IP fragments.
371 ** Learning.
372 *** A MAC-learning switch.
373 **** Reading and flushing the MAC learning table.
374 **** Monitoring changes to the MAC learning table.
375 *** Stateful firewall.
376 ** VXLAN control plane.
377 ** Routing.
378 ** Spoof prevention.
379 *** IPv6.
380 ** PVLAN.
381
382 * Reactive control plane programming?
383 ** In-band control as example?
384
385 * In-band control.
386 ** How it works.
387 ** Limitations.
388 ** Rolling your own.
389
390 * Optimization.
391 ** Separate tables.
392 *** Tables with a single type of flow (see learning).
393 ** Minimizing types of flows.
394 ** Minimizing lookups.
395 ** Minimizing flow table changes.
396 *** Avoiding timeouts.
397 @end verbatim
398
399 @node Glossary
400 @unnumbered Glossary
401
402 @macro glentry{term}
403 @item \term\
404 @cindex \term\
405 @anchor{\term\}
406 @end macro
407
408 @table @b
409 @glentry{action}
410
411 @glentry{bridge}
412 @xref{switch}.
413
414 @glentry{flow table}
415
416 @glentry{network device}
417 A real or simulated Ethernet interface.  @samp{lo}, @samp{eth0}, and
418 @samp{wlan0} are common names for network devices under the Linux
419 kernel.
420
421 @glentry{match}
422
423 @glentry{switch}
424 An Ethernet switch, also called a ``bridge.''
425 @end table
426
427 @node Index
428 @unnumbered Index
429
430 @printindex cp
431
432 @bye