4 Tha ability to capture traffic at multiple points of the system is crucial to
5 many of the functional tests. It allows the verification of functionality for
6 both the vSwitch and the NICs using hardware acceleration for packet
7 manipulation and modification.
9 There are three different methods of traffic capture supported by VSPERF.
10 Detailed descriptions of these methods as well as their pros and cons can be
11 found in the following chapters.
13 Traffic Capture inside of a VM
14 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 This method uses the standard PVP scenario, in which vSwitch first processes
17 and modifies the packet before forwarding it to the VM. Inside of the VM we
18 capture the traffic using **tcpdump** or a similiar technique. The capture
19 information is the used to verify the expected modifications to the packet done
22 .. code-block:: console
25 +--------------------------------------------------+ |
27 | +------------------------------------------+ | |
28 | | Traffic capture and Packet Forwarding | | |
29 | +------------------------------------------+ | |
33 | +---------------+ +---------------+ | |
34 | | logical port 0| | logical port 1| | |
35 +---+---------------+----------+---------------+---+ _|
39 +---+---------------+----------+---------------+---+ |
40 | | logical port 0| | logical port 1| | |
41 | +---------------+ +---------------+ | |
45 | +--------------+ +--------------+ | |
46 | | phy port | vSwitch | phy port | | |
47 +---+--------------+------------+--------------+---+ _|
51 +--------------------------------------------------+
55 +--------------------------------------------------+
59 - supports testing with all traffic generators
60 - easy to use and implement into test
61 - allows testing hardware offloading on the ingress side
65 - does not allow testing hardware offloading on the egress side
67 An example of Traffic Capture in VM test:
69 .. code-block:: python
71 # Capture Example 1 - Traffic capture inside VM (PVP scenario)
72 # This TestCase will modify VLAN ID set by the traffic generator to the new value.
73 # Correct VLAN ID settings is verified by inspection of captured frames.
75 Name: capture_pvp_modify_vid,
77 Description: Test and verify VLAN ID modification by Open vSwitch,
79 VSWITCH : OvsDpdkVhost, # works also for Vanilla OVS
80 TRAFFICGEN_DURATION : 5,
82 traffic_type : rfc2544_continuous,
91 GUEST_LOOPBACK : ['linux_bridge'],
94 # replace original flows with vlan ID modification
95 ['!vswitch', 'add_flow', '$VSWITCH_BRIDGE_NAME', {'in_port': '1', 'actions': ['mod_vlan_vid:4','output:3']}],
96 ['!vswitch', 'add_flow', '$VSWITCH_BRIDGE_NAME', {'in_port': '2', 'actions': ['mod_vlan_vid:4','output:4']}],
97 ['vswitch', 'dump_flows', '$VSWITCH_BRIDGE_NAME'],
98 # verify that received frames have modified vlan ID
99 ['VNF0', 'execute_and_wait', 'tcpdump -i eth0 -c 5 -w dump.pcap vlan 4 &'],
100 ['trafficgen', 'send_traffic',{}],
101 ['!VNF0', 'execute_and_wait', 'tcpdump -qer dump.pcap vlan 4 2>/dev/null | wc -l','|^(\d+)$'],
102 ['tools', 'assert', '#STEP[-1][0] == 5'],
106 Traffic Capture for testing NICs with HW offloading/acceleration
107 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109 The NIC with hardware acceleration/offloading is inserted as an additional card
110 into the server. Two ports on this card are then connected together using
111 a patch cable as shown in the diagram. Only a single port of the tested NIC is
112 setup with DPDK acceleration, while the other is handled by the Linux Ip stack
113 allowing for traffic capture. The two NICs are then connected by vSwitch so the
114 original card can forward the processed packets to the traffic generator. The
115 ports handled by Linux IP stack allow for capturing packets, which are then
116 analyzed for changes done by both the vSwitch and the NIC with hardware
119 .. code-block:: console
122 +------------------------------------------------+ |
124 | +----------------------------------------+ | |
126 | | +----------------------------------+ | | |
128 | | | +------------------+ | | | |
130 | +----------------------------------------+ | | Device under Test
134 | +--------------+ +--------------+ | |
135 | | | | NIC w HW acc | | |
136 | | phy ports | | phy ports | | |
137 +---+--------------+----------+--------------+---+ _|
142 +------------------------------------------------+
144 | traffic generator |
146 +------------------------------------------------+
150 - allows testing hardware offloading on both the ingress and egress side
151 - supports testing with all traffic generators
152 - relatively easy to use and implement into tests
156 - a more complex setup with two cards
157 - if the tested card only has one port, an additional card is needed
159 An example of Traffic Capture for testing NICs with HW offloading test:
161 .. code-block:: python
163 # Capture Example 2 - Setup with 2 NICs, where traffic is captured after it is
164 # processed by NIC under the test (2nd NIC). See documentation for further details.
165 # This TestCase will strip VLAN headers from traffic sent by the traffic generator.
166 # The removal of VLAN headers is verified by inspection of captured frames.
168 # NOTE: This setup expects a DUT with two NICs with two ports each. First NIC is
169 # connected to the traffic generator (standard VSPERF setup). Ports of a second NIC
170 # are interconnected by a patch cable. PCI addresses of all four ports have to be
171 # properly configured in the WHITELIST_NICS parameter.
173 Name: capture_p2p2p_strip_vlan_ovs,
175 Description: P2P Continuous Stream,
177 _CAPTURE_P2P2P_OVS_ACTION : 'strip_vlan',
180 traffic_type : rfc2544_continuous,
183 'srcmac': ca:fe:00:00:00:00,
184 'dstmac': 00:00:00:00:00:01
193 # suppress DPDK configuration, so physical interfaces are not bound to DPDK driver
194 'WHITELIST_NICS' : [],
197 TestSteps: _CAPTURE_P2P2P_SETUP + [
198 # capture traffic after processing by NIC under the test (after possible egress HW offloading)
199 ['tools', 'exec_shell_background', 'tcpdump -i [2][device] -c 5 -w capture.pcap '
200 'ether src [l2][srcmac]'],
201 ['trafficgen', 'send_traffic', {}],
202 ['vswitch', 'dump_flows', '$VSWITCH_BRIDGE_NAME'],
203 ['vswitch', 'dump_flows', 'br1'],
204 # there must be 5 captured frames...
205 ['tools', 'exec_shell', 'tcpdump -r capture.pcap | wc -l', '|^(\d+)$'],
206 ['tools', 'assert', '#STEP[-1][0] == 5'],
207 # ...but no vlan headers
208 ['tools', 'exec_shell', 'tcpdump -r capture.pcap vlan | wc -l', '|^(\d+)$'],
209 ['tools', 'assert', '#STEP[-1][0] == 0'],
214 Traffic Capture on the Traffic Generator
215 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
217 Using the functionality of the Traffic generator makes it possible to configure
218 Traffic Capture on both it's ports. With Traffic Capture enabled, VSPERF
219 instructs the Traffic Generator to automatically export captured data into
220 a pcap file. The captured packets are then sent to VSPERF for analysis and
221 verification, monitoring any changes done by both vSwitch and the NICs.
223 Vsperf currently only supports this functionality with the **T-Rex** generator.
225 .. code-block:: console
228 +--------------------------------------------------+ |
230 | +--------------------------+ | |
233 | +--------------+ +--------------+ | |
234 | | phy port | vSwitch | phy port | | |
235 +---+--------------+------------+--------------+---+ _|
239 +--------------------------------------------------+
241 | traffic generator |
243 +--------------------------------------------------+
247 - allows testing hardware offloading on both the ingress and egress side
248 - does not require an additional NIC
252 - currently only supported by **T-Rex** traffic generator
254 An example Traffic Capture on the Traffic Generator test:
256 .. code-block:: python
259 # Capture Example 3 - Traffic capture by traffic generator.
260 # This TestCase uses OVS flow to add VLAN tag with given ID into every
261 # frame send by traffic generator. Correct frame modificaiton is verified by
262 # inspection of packet capture received by T-Rex.
264 Name: capture_p2p_add_vlan_ovs_trex,
266 Description: OVS: Test VLAN tag modification and verify it by traffic capture,
267 vSwitch : OvsDpdkVhost, # works also for Vanilla OVS
270 TRAFFICGEN_DURATION : 5,
272 traffic_type : rfc2544_continuous,
274 # enable capture of five RX frames
283 TestSteps : STEP_VSWITCH_P2P_INIT + [
284 # replace standard L2 flows by flows, which will add VLAN tag with ID 3
285 ['!vswitch', 'add_flow', 'int_br0', {'in_port': '1', 'actions': ['mod_vlan_vid:3','output:2']}],
286 ['!vswitch', 'add_flow', 'int_br0', {'in_port': '2', 'actions': ['mod_vlan_vid:3','output:1']}],
287 ['vswitch', 'dump_flows', 'int_br0'],
288 ['trafficgen', 'send_traffic', {}],
289 ['trafficgen', 'get_results'],
290 # verify that captured frames have vlan tag with ID 3
291 ['tools', 'exec_shell', 'tcpdump -qer /#STEP[-1][0][capture_rx] vlan 3 '
292 '2>/dev/null | wc -l', '|^(\d+)$'],
293 # number of received frames with expected VLAN id must match the number of captured frames
294 ['tools', 'assert', '#STEP[-1][0] == 5'],
295 ] + STEP_VSWITCH_P2P_FINIT,