NFVBENCH-158 Allow multiple UDP ports in traffic generation
[nfvbench.git] / docs / testing / user / userguide / advanced.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. SPDX-License-Identifier: CC-BY-4.0
3 .. (c) Cisco Systems, Inc
4
5 ==============
6 Advanced Usage
7 ==============
8
9 This section covers a few examples on how to run NFVbench with multiple different settings.
10 Below are shown the most common and useful use-cases and explained some fields from a default config file.
11
12 How to change any NFVbench run configuration (CLI)
13 --------------------------------------------------
14 NFVbench always starts with a default configuration which can further be refined (overridden) by the user from the CLI or from REST requests.
15
16 At first have a look at the default config:
17
18 .. code-block:: bash
19
20     nfvbench --show-default-config
21
22 It is sometimes useful derive your own configuration from a copy of the default config:
23
24 .. code-block:: bash
25
26     nfvbench --show-default-config > nfvbench.cfg
27
28 At this point you can edit the copy by:
29
30 - removing any parameter that is not to be changed (since NFVbench will always load the default configuration, default values are not needed)
31 - edit the parameters that are to be changed changed
32
33 A run with the new confguration can then simply be requested using the -c option and by using the actual path of the configuration file
34 as seen from inside the container (in this example, we assume the current directory is mapped to /tmp/nfvbench in the container):
35
36 .. code-block:: bash
37
38     nfvbench -c /tmp/nfvbench/nfvbench.cfg
39
40 The same -c option also accepts any valid yaml or json string to override certain parameters without having to create a configuration file.
41
42 NFVbench provides many configuration options as optional arguments. For example the number of flows can be specified using the --flow-count option.
43
44 The flow count option can be specified in any of 3 ways:
45
46 - by providing a confguration file that has the flow_count value to use (-c myconfig.yaml and myconfig.yaml contains 'flow_count: 100k')
47 - by passing that yaml paremeter inline (-c "flow_count: 100k") or (-c "{flow_count: 100k}")
48 - by using the flow count optional argument (--flow-count 100k)
49
50 Showing the running configuration
51 ---------------------------------
52
53 Because configuration parameters can be overriden, it is sometimes useful to show the final configuration (after all oevrrides are done) by using the --show-config option.
54 This final configuration is also called the "running" configuration.
55
56 For example, this will only display the running configuration (without actually running anything):
57
58 .. code-block:: bash
59
60     nfvbench -c "{flow_count: 100k, debug: true}" --show-config
61
62
63 Connectivity and Configuration Check
64 ------------------------------------
65
66 NFVbench allows to test connectivity to devices used with the selected packet path.
67 It runs the whole test, but without actually sending any traffic.
68 It is also a good way to check if everything is configured properly in the configuration file and what versions of components are used.
69
70 To verify everything works without sending any traffic, use the --no-traffic option:
71
72 .. code-block:: bash
73
74     nfvbench --no-traffic
75
76 Used parameters:
77
78 * ``--no-traffic`` or ``-0`` : sending traffic from traffic generator is skipped
79
80
81 TRex force restart
82 ------------------------------------
83
84 NFVbench allows to restart TRex traffic generator between runs.
85 It runs the whole test, but restart TRex instance before generating new traffic.
86
87 To force restart, use the --restart option:
88
89 .. code-block:: bash
90
91     nfvbench --restart
92
93 Used parameters:
94
95 * ``--restart`` : restart traffic generator (TRex)
96
97
98 Fixed Rate Run
99 --------------
100
101 Fixed rate run is the most basic type of NFVbench usage. It can be used to measure the drop rate with a fixed transmission rate of packets.
102
103 This example shows how to run the PVP packet path (which is the default packet path) with multiple different settings:
104
105 .. code-block:: bash
106
107     nfvbench -c nfvbench.cfg --no-cleanup --rate 100000pps --duration 30 --interval 15 --json results.json
108
109 Used parameters:
110
111 * ``-c nfvbench.cfg`` : path to the config file
112 * ``--no-cleanup`` : resources (networks, VMs, attached ports) are not deleted after test is finished
113 * ``--rate 100000pps`` : defines rate of packets sent by traffic generator
114 * ``--duration 30`` : specifies how long should traffic be running in seconds
115 * ``--interval 15`` : stats are checked and shown periodically (in seconds) in this interval when traffic is flowing
116 * ``--json results.json`` : collected data are stored in this file after run is finished
117
118 .. note:: It is your responsibility to clean up resources if needed when ``--no-cleanup`` parameter is used. You can use the nfvbench_cleanup helper script for that purpose.
119
120 The ``--json`` parameter makes it easy to store NFVbench results. The --show-summary (or -ss) option can be used to display the results in a json results file in a text tabular format:
121
122 .. code-block:: bash
123
124     nfvbench --show-summary results.json
125
126
127 This example shows how to specify a different packet path:
128
129 .. code-block:: bash
130
131     nfvbench -c nfvbench.cfg --rate 1Mbps --inter-node --service-chain PVVP
132
133 Used parameters:
134
135 * ``-c nfvbench.cfg`` : path to the config file
136 * ``--rate 1Mbps`` : defines rate of packets sent by traffic generator
137 * ``--inter-node`` : VMs are created on different compute nodes, works only with PVVP flow
138 * ``--service-chain PVVP`` or ``-sc PVVP`` : specifies the type of service chain (or packet path) to use
139
140 .. note:: When parameter ``--inter-node`` is not used or there aren't enough compute nodes, VMs are on the same compute node.
141
142
143 Rate Units
144 ^^^^^^^^^^
145
146 Parameter ``--rate`` accepts different types of values:
147
148 * packets per second (pps, kpps, mpps), e.g. ``1000pps`` or ``10kpps``
149 * load percentage (%), e.g. ``50%``
150 * bits per second (bps, kbps, Mbps, Gbps), e.g. ``1Gbps``, ``1000bps``
151 * NDR/PDR (ndr, pdr, ndr_pdr), e.g. ``ndr_pdr``
152
153 NDR/PDR is the default rate when not specified.
154
155 NDR and PDR
156 -----------
157
158 The NDR and PDR test is used to determine the maximum throughput performance of the system under test
159 following guidelines defined in RFC-2544:
160
161 * NDR (No Drop Rate): maximum packet rate sent without dropping any packet
162 * PDR (Partial Drop Rate): maximum packet rate sent while allowing a given maximum drop rate
163
164 The NDR search can also be relaxed to allow some very small amount of drop rate (lower than the PDR maximum drop rate).
165 NFVbench will measure the NDR and PDR values by driving the traffic generator through multiple iterations
166 at different transmission rates using a binary search algorithm.
167
168 The configuration file contains section where settings for NDR/PDR can be set.
169
170 .. code-block:: bash
171
172     # NDR/PDR configuration
173     measurement:
174         # Drop rates represent the ratio of dropped packet to the total number of packets sent.
175         # Values provided here are percentages. A value of 0.01 means that at most 0.01% of all
176         # packets sent are dropped (or 1 packet every 10,000 packets sent)
177
178         # No Drop Rate; Default to 0.001%
179         NDR: 0.001
180         # Partial Drop Rate; NDR should always be less than PDR
181         PDR: 0.1
182         # The accuracy of NDR and PDR load percentiles; The actual load percentile that match NDR
183         # or PDR should be within `load_epsilon` difference than the one calculated.
184         load_epsilon: 0.1
185
186 Because NDR/PDR is the default ``--rate`` value, it is possible to run NFVbench simply like this:
187
188 .. code-block:: bash
189
190     nfvbench -c nfvbench.cfg
191
192 Other possible run options:
193
194 .. code-block:: bash
195
196     nfvbench -c nfvbench.cfg --duration 120 --json results.json
197
198 Used parameters:
199
200 * ``-c nfvbench.cfg`` : path to the config file
201 * ``--duration 120`` : specifies how long should be traffic running in each iteration
202 * ``--json results.json`` : collected data are stored in this file after run is finished
203
204
205 Multichain
206 ----------
207
208 NFVbench allows to run multiple chains at the same time. For example it is possible to stage the PVP service chain N-times,
209 where N can be as much as your compute power can scale. With N = 10, NFVbench will spawn 10 VMs as a part of 10 simultaneous PVP chains.
210
211 The number of chains is specified by ``--service-chain-count`` or ``-scc`` flag with a default value of 1.
212 For example to run NFVbench with 3 PVP chains:
213
214 .. code-block:: bash
215
216     nfvbench -c nfvbench.cfg --rate 10000pps -scc 3
217
218 It is not necessary to specify the service chain type (-sc) because PVP is set as default. The PVP service chains will have 3 VMs in 3 chains with this configuration.
219 If ``-sc PVVP`` is specified instead, there would be 6 VMs in 3 chains as this service chain has 2 VMs per chain.
220 Both **single run** or **NDR/PDR** can be run as multichain. Running multichain is a scenario closer to a real life situation than runs with a single chain.
221
222
223 Multiflow
224 ---------
225
226 NFVbench always generates L3 packets from the traffic generator but allows the user to specify how many flows to generate.
227 A flow is identified by a unique src/dest MAC IP and port tuple that is sent by the traffic generator. Flows are
228 generated by ranging the IP adresses but using a small fixed number of MAC addresses.
229
230 The number of flows will be spread roughly even between chains when more than 1 chain is being tested.
231 For example, for 11 flows and 3 chains, number of flows that will run for each chain will be 3, 4, and 4 flows respectively.
232
233 The number of flows is specified by ``--flow-count`` or ``-fc`` flag, the default value is 2 (1 flow in each direction).
234 To run NFVbench with 3 chains and 100 flows, use the following command:
235
236 .. code-block:: bash
237
238     nfvbench -c nfvbench.cfg --rate 10000pps -scc 3 -fc 100
239
240 Note that from a vswitch point of view, the
241 number of flows seen will be higher as it will be at least 4 times the number of flows sent by the traffic generator
242 (add flow to VM and flow from VM).
243
244 IP addresses generated can be controlled with the following NFVbench configuration options:
245
246 .. code-block:: bash
247
248     ip_addrs: ['10.0.0.0/8', '20.0.0.0/8']
249     ip_addrs_step: 0.0.0.1
250     tg_gateway_ip_addrs: ['1.1.0.100', '2.2.0.100']
251     tg_gateway_ip_addrs_step: 0.0.0.1
252     gateway_ip_addrs: ['1.1.0.2', '2.2.0.2']
253     gateway_ip_addrs_step: 0.0.0.1
254
255 ``ip_addrs`` are the start of the 2 ip address ranges used by the traffic generators as the packets source and destination packets
256 where each range is associated to virtual devices simulated behind 1 physical interface of the traffic generator.
257 These can also be written in CIDR notation to represent the subnet.
258
259 ``tg_gateway_ip_addrs`` are the traffic generator gateway (virtual) ip addresses, all traffic to/from the virtual devices go through them.
260
261 ``gateway_ip_addrs`` are the 2 gateway ip address ranges of the VMs used in the external chains. They are only used with external chains and must correspond to their public IP address.
262
263 The corresponding ``step`` is used for ranging the IP addresses from the `ip_addrs``, ``tg_gateway_ip_addrs`` and ``gateway_ip_addrs`` base addresses.
264 0.0.0.1 is the default step for all IP ranges. In ``ip_addrs``, 'random' can be configured which tells NFVBench to generate random src/dst IP pairs in the traffic stream.
265
266 UDP ports can be controlled with the following NFVbench configuration options:
267
268 .. code-block:: bash
269
270     udp_src_port: ['1024', '65000']
271     udp_dst_port: 53
272     udp_port_step: 1
273
274 ``udp_src_port`` and ``udp_dst_port`` are the UDP port value used by the traffic generators.
275 These can be written for unique port or range ports for all flow.
276
277 The corresponding ``udp_port_step`` is used for ranging the UDP port.
278 1 is the default step for all UDP ranges, 'random' can be configured which tells NFVBench to generate random src/dst UDP pairs in the traffic stream.
279
280 NB:
281     Use of UDP range will increase possible values of flows (based on ip src/dst and port src/dst tuple).
282     NFVBench will calculate the least common multiple for this tuple to adapt flows generation to ``flow_count`` parameter.
283
284
285 Traffic Configuration via CLI
286 -----------------------------
287
288 While traffic configuration can be modified using the configuration file, it can be inconvenient to have to change the configuration file everytime
289 you need to change a traffic configuration option. Traffic configuration options can be overridden with a few CLI options.
290
291 Here is an example of configuring traffic via CLI:
292
293 .. code-block:: bash
294
295     nfvbench --rate 10kpps --service-chain-count 2 -fs 64 -fs IMIX -fs 1518 --unidir
296
297 This command will run NFVbench with a unidirectional flow for three packet sizes 64B, IMIX, and 1518B.
298
299 Used parameters:
300
301 * ``--rate 10kpps`` : defines rate of packets sent by traffic generator (total TX rate)
302 * ``-scc 2`` or ``--service-chain-count 2`` : specifies number of parallel chains of given flow to run (default to 1)
303 * ``-fs 64`` or ``--frame-size 64``: add the specified frame size to the list of frame sizes to run
304 * ``--unidir`` : run traffic with unidirectional flow (default to bidirectional flow)
305
306
307 MAC Addresses
308 -------------
309
310 NFVbench will dicover the MAC addresses to use for generated frames using:
311 - either OpenStack discovery (find the MAC of an existing VM) in the case of PVP and PVVP service chains
312 - or using dynamic ARP discovery (find MAC from IP) in the case of external chains.
313 - In case of L3 chain with SDN-GW or router between traffic generator and loop VM ARP is needed to discover SDN-GW mac addresses, use ``--loop-vm-arp`` flag or ``loop_vm_arp: true`` in config file.
314
315 Status and Cleanup of NFVbench Resources
316 ----------------------------------------
317
318 The --status option will display the status of NFVbench and list any NFVbench resources. You need to pass the OpenStack RC
319 file in order to connect to OpenStack.
320
321 .. code-block:: none
322
323     # nfvbench --status -r /tmp/nfvbench/openrc
324     2018-04-09 17:05:48,682 INFO Version: 1.3.2.dev1
325     2018-04-09 17:05:48,683 INFO Status: idle
326     2018-04-09 17:05:48,757 INFO Discovering instances nfvbench-loop-vm...
327     2018-04-09 17:05:49,252 INFO Discovering flavor nfvbench.medium...
328     2018-04-09 17:05:49,281 INFO Discovering networks...
329     2018-04-09 17:05:49,365 INFO No matching NFVbench resources found
330     #
331
332 The Status can be either "idle" or "busy (run pending)".
333
334 The --cleanup option will first discover resources created by NFVbench and prompt if you want to proceed with cleaning them up.
335 Example of run:
336
337 .. code-block:: none
338
339     # nfvbench --cleanup -r /tmp/nfvbench/openrc
340     2018-04-09 16:58:00,204 INFO Version: 1.3.2.dev1
341     2018-04-09 16:58:00,205 INFO Status: idle
342     2018-04-09 16:58:00,279 INFO Discovering instances nfvbench-loop-vm...
343     2018-04-09 16:58:00,829 INFO Discovering flavor nfvbench.medium...
344     2018-04-09 16:58:00,876 INFO Discovering networks...
345     2018-04-09 16:58:00,960 INFO Discovering ports...
346     2018-04-09 16:58:01,012 INFO Discovered 6 NFVbench resources:
347     +----------+-------------------+--------------------------------------+
348     | Type     | Name              | UUID                                 |
349     |----------+-------------------+--------------------------------------|
350     | Instance | nfvbench-loop-vm0 | b039b858-777e-467e-99fb-362f856f4a94 |
351     | Flavor   | nfvbench.medium   | a027003c-ad86-4f24-b676-2b05bb06adc0 |
352     | Network  | nfvbench-net0     | bca8d183-538e-4965-880e-fd92d48bfe0d |
353     | Network  | nfvbench-net1     | c582a201-8279-4309-8084-7edd6511092c |
354     | Port     |                   | 67740862-80ac-4371-b04e-58a0b0f05085 |
355     | Port     |                   | b5db95b9-e419-4725-951a-9a8f7841e66a |
356     +----------+-------------------+--------------------------------------+
357     2018-04-09 16:58:01,013 INFO NFVbench will delete all resources shown...
358     Are you sure? (y/n) y
359     2018-04-09 16:58:01,865 INFO Deleting instance nfvbench-loop-vm0...
360     2018-04-09 16:58:02,058 INFO     Waiting for 1 instances to be fully deleted...
361     2018-04-09 16:58:02,182 INFO     1 yet to be deleted by Nova, retries left=6...
362     2018-04-09 16:58:04,506 INFO     1 yet to be deleted by Nova, retries left=5...
363     2018-04-09 16:58:06,636 INFO     1 yet to be deleted by Nova, retries left=4...
364     2018-04-09 16:58:08,701 INFO Deleting flavor nfvbench.medium...
365     2018-04-09 16:58:08,729 INFO Deleting port 67740862-80ac-4371-b04e-58a0b0f05085...
366     2018-04-09 16:58:09,102 INFO Deleting port b5db95b9-e419-4725-951a-9a8f7841e66a...
367     2018-04-09 16:58:09,620 INFO Deleting network nfvbench-net0...
368     2018-04-09 16:58:10,357 INFO Deleting network nfvbench-net1...
369     #
370
371 The --force-cleanup option will do the same but without prompting for confirmation.
372
373 Service mode for TRex
374 ---------------------
375
376 The ``--service-mode`` option allows you to capture traffic on a TRex window during the NFVBench test. Thus, you will be
377 able to capture packets generated by TRex to observe many information on it.
378
379 Example of use :
380
381 .. code-block:: bash
382
383     nfvbench ``--service-mode``
384
385 .. note:: It is preferable to define the minimum rate (2002 pps) to have a better capture
386
387 In another bash window, you should connect to the TRex console doing :
388
389 .. code-block:: bash
390
391     cd /opt/trex/vX.XX/ #use completion here to find your corresponding TRex version
392     ./trex-console -r
393     capture start monitor --rx [port number] -v
394
395 Start this capture once you have started the NFVBench test, and you will observe packets on the TRex console :
396
397 .. code-block:: bash
398
399     #26342 Port: 0 ◀── RX
400
401     trex(read-only)>
402
403         Type: UDP, Size: 66 B, TS: 26.30 [sec]
404
405     trex(read-only)>
406         ###[ Ethernet ]###
407             dst       = a0:36:9f:7a:58:8e
408             src       = fa:16:3e:57:8f:df
409             type      = 0x8100
410         ###[ 802.1Q ]###
411             prio      = 0
412             id        = 0
413             vlan      = 1093
414             type      = 0x800
415         ###[ IP ]###
416             version   = 4
417             ihl       = 5
418             tos       = 0x1
419             len       = 46
420             id        = 65535
421             flags     =
422             frag      = 0
423             ttl       = 63
424             proto     = udp
425             chksum    = 0x8425
426             src       = 120.0.0.0
427             dst       = 110.0.17.153
428             \options   \
429         ###[ UDP ]###
430             sport     = 53
431             dport     = 53
432             len       = 26
433             chksum    = 0xfd83
434         ###[ Raw ]###
435             load      = "xx\xab'\x01\x00?s\x00\x00\xbci\xf0_{U~\x00"
436         ###[ Padding ]###
437             load      = '6\x85'
438
439 Check on the NFVBench window that the following log appears just before the testing phase :
440
441 .. code-block:: bash
442
443     2019-10-21 09:38:51,532 INFO Starting to generate traffic...
444     2019-10-21 09:38:51,532 INFO Running traffic generator
445     2019-10-21 09:38:51,541 INFO ``Service mode is enabled``
446     2019-10-21 09:38:52,552 INFO TX: 2004; RX: 2003; Est. Dropped: 1; Est. Drop rate: 0.0499%
447     2019-10-21 09:38:53,559 INFO TX: 4013; RX: 4011; Est. Dropped: 2; Est. Drop rate: 0.0498%