d7dc53f05470eb74c41e1e4ef0474c65ed772ca4
[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 Rate Units
98 ^^^^^^^^^^
99
100 Parameter ``--rate`` accepts different types of values:
101
102 * packets per second (pps, kpps, mpps), e.g. ``1000pps`` or ``10kpps``
103 * load percentage (%), e.g. ``50%``
104 * bits per second (bps, kbps, Mbps, Gbps), e.g. ``1Gbps``, ``1000bps``
105 * NDR/PDR (ndr, pdr, ndr_pdr), e.g. ``ndr_pdr``
106
107 NDR/PDR is the default rate when not specified.
108
109 Fixed Rate Run
110 --------------
111
112 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.
113
114 This example shows how to run the PVP packet path (which is the default packet path) with multiple different settings:
115
116 .. code-block:: bash
117
118     nfvbench -c nfvbench.cfg --no-cleanup --rate 100000pps --duration 30 --interval 15 --json results.json
119
120 Used parameters:
121
122 * ``-c nfvbench.cfg`` : path to the config file
123 * ``--no-cleanup`` : resources (networks, VMs, attached ports) are not deleted after test is finished
124 * ``--rate 100000pps`` : defines rate of packets sent by traffic generator
125 * ``--duration 30`` : specifies how long should traffic be running in seconds
126 * ``--interval 15`` : stats are checked and shown periodically (in seconds) in this interval when traffic is flowing
127 * ``--json results.json`` : collected data are stored in this file after run is finished
128
129 .. 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.
130
131 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:
132
133 .. code-block:: bash
134
135     nfvbench --show-summary results.json
136
137
138 This example shows how to specify a different packet path:
139
140 .. code-block:: bash
141
142     nfvbench -c nfvbench.cfg --rate 1Mbps --inter-node --service-chain PVVP
143
144 Used parameters:
145
146 * ``-c nfvbench.cfg`` : path to the config file
147 * ``--rate 1Mbps`` : defines rate of packets sent by traffic generator
148 * ``--inter-node`` : VMs are created on different compute nodes, works only with PVVP flow
149 * ``--service-chain PVVP`` or ``-sc PVVP`` : specifies the type of service chain (or packet path) to use
150
151 .. note:: When parameter ``--inter-node`` is not used or there aren't enough compute nodes, VMs are on the same compute node.
152
153 A fixed rate run can also be used to check the running drop rate while traffic is being generated. In that case the --interval option can be used
154 to specify the reporting interval in seconds (minimum is 1 second). This can be useful for example to see how packet drop rate
155 evolves over time. One common use case is to see the drop rate when there is a network degradation (e.g. one of the 2 links in a bond
156 goes down).
157 The console output will show at every reporting interval the number of packets transmitted, received and estimated drop rate for the last reporting interval.
158 The smaller is the interval the more precise is the drop rate.
159
160 Example of output where the reporting interval is set to 1 (second):
161
162 .. code-block:: bash
163
164     2020-04-25 12:59:16,618 INFO TX:   1,878,719,266; RX:   1,666,641,890; (Est.) Dropped:            2; Drop rate:   0.0000%
165     2020-04-25 12:59:17,625 INFO TX:   1,883,740,078; RX:   1,671,662,706; (Est.) Dropped:           -4; Drop rate:  -0.0001%
166     2020-04-25 12:59:18,632 INFO TX:   1,888,764,404; RX:   1,676,686,993; (Est.) Dropped:           39; Drop rate:   0.0008%
167     2020-04-25 12:59:19,639 INFO TX:   1,893,785,063; RX:   1,681,276,714; (Est.) Dropped:      430,938; Drop rate:   8.5833%
168     2020-04-25 12:59:20,645 INFO TX:   1,898,805,769; RX:   1,683,782,636; (Est.) Dropped:    2,514,784; Drop rate:  50.0883%
169     2020-04-25 12:59:21,652 INFO TX:   1,903,829,191; RX:   1,686,289,860; (Est.) Dropped:    2,516,198; Drop rate:  50.0893%
170     2020-04-25 12:59:22,658 INFO TX:   1,908,850,478; RX:   1,691,283,008; (Est.) Dropped:       28,139; Drop rate:   0.5604%
171     2020-04-25 12:59:23,665 INFO TX:   1,913,870,692; RX:   1,696,301,242; (Est.) Dropped:        1,980; Drop rate:   0.0394%
172     2020-04-25 12:59:24,672 INFO TX:   1,918,889,696; RX:   1,698,806,224; (Est.) Dropped:    2,514,022; Drop rate:  50.0901%
173     2020-04-25 12:59:25,680 INFO TX:   1,923,915,470; RX:   1,701,314,663; (Est.) Dropped:    2,517,335; Drop rate:  50.0885%
174     2020-04-25 12:59:26,687 INFO TX:   1,928,944,879; RX:   1,705,886,869; (Est.) Dropped:      457,203; Drop rate:   9.0906%
175     2020-04-25 12:59:27,696 INFO TX:   1,933,969,377; RX:   1,710,911,346; (Est.) Dropped:           21; Drop rate:   0.0004%
176     2020-04-25 12:59:28,702 INFO TX:   1,938,998,536; RX:   1,713,843,740; (Est.) Dropped:    2,096,765; Drop rate:  41.6922%
177     2020-04-25 12:59:29,710 INFO TX:   1,944,019,920; RX:   1,718,226,356; (Est.) Dropped:      638,768; Drop rate:  12.7210%
178     2020-04-25 12:59:30,718 INFO TX:   1,949,050,206; RX:   1,723,256,639; (Est.) Dropped:            3; Drop rate:   0.0001%
179     2020-04-25 12:59:31,725 INFO TX:   1,954,075,270; RX:   1,728,281,726; (Est.) Dropped:          -23; Drop rate:  -0.0005%
180     2020-04-25 12:59:32,732 INFO TX:   1,959,094,908; RX:   1,733,301,290; (Est.) Dropped:           74; Drop rate:   0.0015%
181     2020-04-25 12:59:33,739 INFO TX:   1,964,118,902; RX:   1,738,325,357; (Est.) Dropped:          -73; Drop rate:  -0.0015%
182     2020-04-25 12:59:34,746 INFO TX:   1,969,143,790; RX:   1,743,350,230; (Est.) Dropped:           15; Drop rate:   0.0003%
183     2020-04-25 12:59:35,753 INFO TX:   1,974,165,773; RX:   1,748,372,291; (Est.) Dropped:          -78; Drop rate:  -0.0016%
184     2020-04-25 12:59:36,759 INFO TX:   1,979,188,496; RX:   1,753,394,957; (Est.) Dropped:           57; Drop rate:   0.0011%
185     2020-04-25 12:59:37,767 INFO TX:   1,984,208,956; RX:   1,757,183,844; (Est.) Dropped:    1,231,573; Drop rate:  24.5311%
186     2020-04-25 12:59:38,773 INFO TX:   1,989,233,595; RX:   1,761,729,705; (Est.) Dropped:      478,778; Drop rate:   9.5286%
187     2020-04-25 12:59:39,780 INFO TX:   1,994,253,350; RX:   1,766,749,467; (Est.) Dropped:           -7; Drop rate:  -0.0001%
188     2020-04-25 12:59:40,787 INFO TX:   1,999,276,622; RX:   1,771,772,738; (Est.) Dropped:            1; Drop rate:   0.0000%
189     2020-04-25 12:59:41,794 INFO TX:   2,004,299,940; RX:   1,776,796,065; (Est.) Dropped:           -9; Drop rate:  -0.0002%
190     2020-04-25 12:59:42,800 INFO TX:   2,009,320,453; RX:   1,781,816,583; (Est.) Dropped:           -5; Drop rate:  -0.0001%
191     2020-04-25 12:59:43,807 INFO TX:   2,014,340,581; RX:   1,786,503,172; (Est.) Dropped:      333,539; Drop rate:   6.6440%
192     2020-04-25 12:59:44,814 INFO TX:   2,019,362,996; RX:   1,789,009,857; (Est.) Dropped:    2,515,730; Drop rate:  50.0900%
193     2020-04-25 12:59:45,821 INFO TX:   2,024,386,346; RX:   1,791,517,070; (Est.) Dropped:    2,516,137; Drop rate:  50.0888%
194
195
196 How to read each line:
197
198 .. code-block:: bash
199
200     2020-04-25 10:46:41,276 INFO TX:       4,004,436; RX:       4,004,381; (Est.) Dropped:           55; Drop rate:   0.0014%
201
202 At this poing in time, NFvbench has sent 4,004,436 and received 4,004,381 since the start of the run.
203 There is deficit of 55 packets on reception which corresponds to 0.0014% of all packets sent during that reporting window interval (last 1 second)
204 A negative value means that the RX count is higher than the tx count in that window – this is possible since the RX and TX reads are not atomic.
205
206
207 NDR and PDR
208 -----------
209
210 The NDR and PDR test is used to determine the maximum throughput performance of the system under test
211 following guidelines defined in RFC-2544:
212
213 * NDR (No Drop Rate): maximum packet rate sent without dropping any packet
214 * PDR (Partial Drop Rate): maximum packet rate sent while allowing a given maximum drop rate
215
216 The NDR search can also be relaxed to allow some very small amount of drop rate (lower than the PDR maximum drop rate).
217 NFVbench will measure the NDR and PDR values by driving the traffic generator through multiple iterations
218 at different transmission rates using a binary search algorithm.
219
220 The configuration file contains section where settings for NDR/PDR can be set.
221
222 .. code-block:: bash
223
224     # NDR/PDR configuration
225     measurement:
226         # Drop rates represent the ratio of dropped packet to the total number of packets sent.
227         # Values provided here are percentages. A value of 0.01 means that at most 0.01% of all
228         # packets sent are dropped (or 1 packet every 10,000 packets sent)
229
230         # No Drop Rate; Default to 0.001%
231         NDR: 0.001
232         # Partial Drop Rate; NDR should always be less than PDR
233         PDR: 0.1
234         # The accuracy of NDR and PDR load percentiles; The actual load percentile that match NDR
235         # or PDR should be within `load_epsilon` difference than the one calculated.
236         load_epsilon: 0.1
237
238 Because NDR/PDR is the default ``--rate`` value, it is possible to run NFVbench simply like this:
239
240 .. code-block:: bash
241
242     nfvbench -c nfvbench.cfg
243
244 Other possible run options:
245
246 .. code-block:: bash
247
248     nfvbench -c nfvbench.cfg --duration 120 --json results.json
249
250 Used parameters:
251
252 * ``-c nfvbench.cfg`` : path to the config file
253 * ``--duration 120`` : specifies how long should be traffic running in each iteration
254 * ``--json results.json`` : collected data are stored in this file after run is finished
255
256
257 Multichain
258 ----------
259
260 NFVbench allows to run multiple chains at the same time. For example it is possible to stage the PVP service chain N-times,
261 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.
262
263 The number of chains is specified by ``--service-chain-count`` or ``-scc`` flag with a default value of 1.
264 For example to run NFVbench with 3 PVP chains:
265
266 .. code-block:: bash
267
268     nfvbench -c nfvbench.cfg --rate 10000pps -scc 3
269
270 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.
271 If ``-sc PVVP`` is specified instead, there would be 6 VMs in 3 chains as this service chain has 2 VMs per chain.
272 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.
273
274
275 Multiflow
276 ---------
277
278 NFVbench always generates L3 packets from the traffic generator but allows the user to specify how many flows to generate.
279 A flow is identified by a unique src/dest MAC IP and port tuple that is sent by the traffic generator. Flows are
280 generated by ranging the IP adresses but using a small fixed number of MAC addresses.
281
282 The number of flows will be spread roughly even between chains when more than 1 chain is being tested.
283 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.
284
285 The number of flows is specified by ``--flow-count`` or ``-fc`` flag, the default value is 2 (1 flow in each direction).
286 To run NFVbench with 3 chains and 100 flows, use the following command:
287
288 .. code-block:: bash
289
290     nfvbench -c nfvbench.cfg --rate 10000pps -scc 3 -fc 100
291
292 Note that from a vswitch point of view, the
293 number of flows seen will be higher as it will be at least 4 times the number of flows sent by the traffic generator
294 (add flow to VM and flow from VM).
295
296 IP addresses generated can be controlled with the following NFVbench configuration options:
297
298 .. code-block:: bash
299
300     ip_addrs: ['10.0.0.0/8', '20.0.0.0/8']
301     ip_addrs_step: 0.0.0.1
302     tg_gateway_ip_addrs: ['1.1.0.100', '2.2.0.100']
303     tg_gateway_ip_addrs_step: 0.0.0.1
304     gateway_ip_addrs: ['1.1.0.2', '2.2.0.2']
305     gateway_ip_addrs_step: 0.0.0.1
306
307 ``ip_addrs`` are the start of the 2 ip address ranges used by the traffic generators as the packets source and destination packets
308 where each range is associated to virtual devices simulated behind 1 physical interface of the traffic generator.
309 These can also be written in CIDR notation to represent the subnet.
310
311 ``tg_gateway_ip_addrs`` are the traffic generator gateway (virtual) ip addresses, all traffic to/from the virtual devices go through them.
312
313 ``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.
314
315 The corresponding ``step`` is used for ranging the IP addresses from the `ip_addrs``, ``tg_gateway_ip_addrs`` and ``gateway_ip_addrs`` base addresses.
316 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.
317
318 UDP ports can be controlled with the following NFVbench configuration options:
319
320 .. code-block:: bash
321
322     udp_src_port: ['1024', '65000']
323     udp_dst_port: 53
324     udp_port_step: '1'
325
326 ``udp_src_port`` and ``udp_dst_port`` are the UDP port value used by the traffic generators.
327 These can be written for unique port or range ports for all flow.
328
329 The corresponding ``udp_port_step`` is used for ranging the UDP port.
330 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.
331
332 NB:
333     Use of UDP range will increase possible values of flows (based on ip src/dst and port src/dst tuple).
334     NFVBench will calculate the least common multiple for this tuple to adapt flows generation to ``flow_count`` parameter.
335
336 Examples of multiflow
337 ^^^^^^^^^^^^^^^^^^^^^
338
339 1. Source IP is static and one UDP port used (default configuration)
340
341 NFVbench configuration options:
342
343 .. code-block:: bash
344
345     ip_addrs: ['110.0.0.0/8', '120.0.0.0/8']
346     ip_addrs_step: 0.0.0.1
347     tg_gateway_ip_addrs: ['1.1.0.100', '2.2.0.100']
348     tg_gateway_ip_addrs_step: 0.0.0.1
349     gateway_ip_addrs: ['1.1.0.2', '2.2.0.2']
350     gateway_ip_addrs_step: 0.0.0.1
351
352 To run NFVbench with 3 chains and 100 flows, use the following command:
353
354 .. code-block:: bash
355
356     nfvbench -c nfvbench.cfg --rate 10000pps -scc 3 -fc 100
357
358 The least common multiple for this configuration is lcm(16 777 216, 16 777 216, 1, 1) = 16 777 216.
359 .. note:: LCM method used IP pools sizes and UDP source and destination range sizes
360
361 Requested flow count is lower than configuration capacity. So, NFVbench will limit IP range to generate accurate flows:
362
363 .. code-block:: bash
364
365     2020-06-17 07:37:47,012 INFO Port 0, chain 0: IP src range [110.0.0.0,110.0.0.0]
366     2020-06-17 07:37:47,012 INFO Port 0, chain 0: IP dst range [120.0.0.0,120.0.0.15]
367     2020-06-17 07:37:47,012 INFO Port 0, chain 0: UDP src range [53,53]
368     2020-06-17 07:37:47,012 INFO Port 0, chain 0: UDP dst range [53,53]
369     2020-06-17 07:37:47,015 INFO Port 1, chain 0: IP src range [120.0.0.0,120.0.0.0]
370     2020-06-17 07:37:47,015 INFO Port 1, chain 0: IP dst range [110.0.0.0,110.0.0.15]
371     2020-06-17 07:37:47,015 INFO Port 1, chain 0: UDP src range [53,53]
372     2020-06-17 07:37:47,015 INFO Port 1, chain 0: UDP dst range [53,53]
373
374     2020-06-17 07:38:47,012 INFO Port 0, chain 1: IP src range [110.0.0.1,110.0.0.1]
375     2020-06-17 07:38:47,012 INFO Port 0, chain 1: IP dst range [120.0.0.16,120.0.0.32]
376     2020-06-17 07:38:47,012 INFO Port 0, chain 1: UDP src range [53,53]
377     2020-06-17 07:38:47,012 INFO Port 0, chain 1: UDP dst range [53,53]
378     2020-06-17 07:38:47,015 INFO Port 1, chain 1: IP src range [120.0.0.1,120.0.0.1]
379     2020-06-17 07:38:47,015 INFO Port 1, chain 1: IP dst range [110.0.0.16,110.0.0.32]
380     2020-06-17 07:38:47,015 INFO Port 1, chain 1: UDP src range [53,53]
381     2020-06-17 07:38:47,015 INFO Port 1, chain 1: UDP dst range [53,53]
382
383     2020-06-17 07:39:47,012 INFO Port 0, chain 2: IP src range [110.0.0.2,110.0.0.2]
384     2020-06-17 07:39:47,012 INFO Port 0, chain 2: IP dst range [120.0.0.33,120.0.0.49]
385     2020-06-17 07:39:47,012 INFO Port 0, chain 2: UDP src range [53,53]
386     2020-06-17 07:39:47,012 INFO Port 0, chain 2: UDP dst range [53,53]
387     2020-06-17 07:39:47,015 INFO Port 1, chain 2: IP src range [120.0.0.2,120.0.0.2]
388     2020-06-17 07:39:47,015 INFO Port 1, chain 2: IP dst range [110.0.0.33,110.0.0.49]
389     2020-06-17 07:39:47,015 INFO Port 1, chain 2: UDP src range [53,53]
390     2020-06-17 07:39:47,015 INFO Port 1, chain 2: UDP dst range [53,53]
391
392
393 2. Source IP is static, IP step is random and one UDP port used
394
395 NFVbench configuration options:
396
397 .. code-block:: bash
398
399     ip_addrs: ['110.0.0.0/8', '120.0.0.0/8']
400     ip_addrs_step: 'random'
401     tg_gateway_ip_addrs: ['1.1.0.100', '2.2.0.100']
402     tg_gateway_ip_addrs_step: 0.0.0.1
403     gateway_ip_addrs: ['1.1.0.2', '2.2.0.2']
404     gateway_ip_addrs_step: 0.0.0.1
405
406 To run NFVbench with 3 chains and 100 flows, use the following command:
407
408 .. code-block:: bash
409
410     nfvbench -c nfvbench.cfg --rate 10000pps -scc 3 -fc 100
411
412 The least common multiple for this configuration is lcm(16 777 216, 16 777 216, 1, 1) = 16 777 216.
413 .. note:: LCM method used IP pools sizes and UDP source and destination range sizes
414
415 Requested flow count is lower than configuration capacity. So, NFVbench will limit IP range to generate accurate flows:
416
417 .. code-block:: bash
418
419     2020-06-17 07:37:47,012 INFO Port 0, chain 0: IP src range [110.0.0.0,110.0.0.0]
420     2020-06-17 07:37:47,012 INFO Port 0, chain 0: IP dst range [120.0.0.0,120.0.0.15]
421     2020-06-17 07:37:47,012 INFO Port 0, chain 0: UDP src range [53,53]
422     2020-06-17 07:37:47,012 INFO Port 0, chain 0: UDP dst range [53,53]
423     2020-06-17 07:37:47,015 INFO Port 1, chain 0: IP src range [120.0.0.0,120.0.0.0]
424     2020-06-17 07:37:47,015 INFO Port 1, chain 0: IP dst range [110.0.0.0,110.0.0.15]
425     2020-06-17 07:37:47,015 INFO Port 1, chain 0: UDP src range [53,53]
426     2020-06-17 07:37:47,015 INFO Port 1, chain 0: UDP dst range [53,53]
427
428     2020-06-17 07:38:47,012 INFO Port 0, chain 1: IP src range [110.0.0.1,110.0.0.1]
429     2020-06-17 07:38:47,012 INFO Port 0, chain 1: IP dst range [120.0.0.16,120.0.0.32]
430     2020-06-17 07:38:47,012 INFO Port 0, chain 1: UDP src range [53,53]
431     2020-06-17 07:38:47,012 INFO Port 0, chain 1: UDP dst range [53,53]
432     2020-06-17 07:38:47,015 INFO Port 1, chain 1: IP src range [120.0.0.1,120.0.0.1]
433     2020-06-17 07:38:47,015 INFO Port 1, chain 1: IP dst range [110.0.0.16,110.0.0.32]
434     2020-06-17 07:38:47,015 INFO Port 1, chain 1: UDP src range [53,53]
435     2020-06-17 07:38:47,015 INFO Port 1, chain 1: UDP dst range [53,53]
436
437     2020-06-17 07:39:47,012 INFO Port 0, chain 2: IP src range [110.0.0.2,110.0.0.2]
438     2020-06-17 07:39:47,012 INFO Port 0, chain 2: IP dst range [120.0.0.33,120.0.0.49]
439     2020-06-17 07:39:47,012 INFO Port 0, chain 2: UDP src range [53,53]
440     2020-06-17 07:39:47,012 INFO Port 0, chain 2: UDP dst range [53,53]
441     2020-06-17 07:39:47,015 INFO Port 1, chain 2: IP src range [120.0.0.2,120.0.0.2]
442     2020-06-17 07:39:47,015 INFO Port 1, chain 2: IP dst range [110.0.0.33,110.0.0.49]
443     2020-06-17 07:39:47,015 INFO Port 1, chain 2: UDP src range [53,53]
444     2020-06-17 07:39:47,015 INFO Port 1, chain 2: UDP dst range [53,53]
445     2020-06-17 07:39:47,015 WARNING Using random step, the number of flows can be less than the requested number of flows due to repeatable multivariate random generation which can reproduce the same pattern of values
446
447 By using a random step the number of generated flows may be less than the number of requested flows. This is due to the probability of drawing the same value several times (Bernouillian drawing) from the IP range used and thus generating the same flow sequence.
448 By using a high range of UDP ports couple with ``udp_port_step='random'`` the probability to reach the requested flow counts is greater.
449 As latency stream is a separate stream than data one and have his own random draw, NFVbench will use only one packet signature (same IP and ports used for all latency packets) to avoid flow count overflow.
450 So in some cases, generated flow count can be equal to the requested flow count + 1 (latency stream).
451
452 **For deterministic flow count we recommend to use a step different from random.**
453
454
455 3. Source IP is static, IP step is 5 and one UDP port used
456
457 NFVbench configuration options:
458
459 .. code-block:: bash
460
461     ip_addrs: ['110.0.0.0/8', '120.0.0.0/8']
462     ip_addrs_step: '0.0.0.5'
463     tg_gateway_ip_addrs: ['1.1.0.100', '2.2.0.100']
464     tg_gateway_ip_addrs_step: 0.0.0.1
465     gateway_ip_addrs: ['1.1.0.2', '2.2.0.2']
466     gateway_ip_addrs_step: 0.0.0.1
467
468 To run NFVbench with 3 chains and 100 flows, use the following command:
469
470 .. code-block:: bash
471
472     nfvbench -c nfvbench.cfg --rate 10000pps -scc 3 -fc 100
473
474 The least common multiple for this configuration is lcm(16 777 216, 16 777 216, 1, 1) = 16 777 216.
475 .. note:: LCM method used IP pools sizes and UDP source and destination range sizes
476
477 Requested flow count is lower than configuration capacity. So, NFVbench will limit IP range to generate accurate flows:
478
479 .. code-block:: bash
480
481     2020-06-17 07:37:47,012 INFO Port 0, chain 0: IP src range [110.0.0.0,110.0.0.0]
482     2020-06-17 07:37:47,012 INFO Port 0, chain 0: IP dst range [120.0.0.0,120.0.0.75]
483     2020-06-17 07:37:47,012 INFO Port 0, chain 0: UDP src range [53,53]
484     2020-06-17 07:37:47,012 INFO Port 0, chain 0: UDP dst range [53,53]
485     2020-06-17 07:37:47,015 INFO Port 1, chain 0: IP src range [120.0.0.0,120.0.0.0]
486     2020-06-17 07:37:47,015 INFO Port 1, chain 0: IP dst range [110.0.0.0,110.0.0.75]
487     2020-06-17 07:37:47,015 INFO Port 1, chain 0: UDP src range [53,53]
488     2020-06-17 07:37:47,015 INFO Port 1, chain 0: UDP dst range [53,53]
489
490     2020-06-17 07:38:47,012 INFO Port 0, chain 1: IP src range [110.0.0.5,110.0.0.5]
491     2020-06-17 07:38:47,012 INFO Port 0, chain 1: IP dst range [120.0.0.80,120.0.0.160]
492     2020-06-17 07:38:47,012 INFO Port 0, chain 1: UDP src range [53,53]
493     2020-06-17 07:38:47,012 INFO Port 0, chain 1: UDP dst range [53,53]
494     2020-06-17 07:38:47,015 INFO Port 1, chain 1: IP src range [120.0.0.5,120.0.0.5]
495     2020-06-17 07:38:47,015 INFO Port 1, chain 1: IP dst range [110.0.0.80,110.0.0.160]
496     2020-06-17 07:38:47,015 INFO Port 1, chain 1: UDP src range [53,53]
497     2020-06-17 07:38:47,015 INFO Port 1, chain 1: UDP dst range [53,53]
498
499     2020-06-17 07:39:47,012 INFO Port 0, chain 2: IP src range [110.0.0.10,110.0.0.10]
500     2020-06-17 07:39:47,012 INFO Port 0, chain 2: IP dst range [120.0.0.165,120.0.0.245]
501     2020-06-17 07:39:47,012 INFO Port 0, chain 2: UDP src range [53,53]
502     2020-06-17 07:39:47,012 INFO Port 0, chain 2: UDP dst range [53,53]
503     2020-06-17 07:39:47,015 INFO Port 1, chain 2: IP src range [120.0.0.10,120.0.0.10]
504     2020-06-17 07:39:47,015 INFO Port 1, chain 2: IP dst range [110.0.0.165,110.0.0.245]
505     2020-06-17 07:39:47,015 INFO Port 1, chain 2: UDP src range [53,53]
506     2020-06-17 07:39:47,015 INFO Port 1, chain 2: UDP dst range [53,53]
507
508 4. Source IP is static, IP and UDP ranges sizes greater than requested flow count, UDP step is random
509
510 NFVbench configuration options:
511
512 .. code-block:: bash
513
514     ip_addrs: ['110.0.0.0/29', '120.0.0.0/30']
515     tg_gateway_ip_addrs: ['1.1.0.100', '2.2.0.100']
516     tg_gateway_ip_addrs_step: 0.0.0.1
517     gateway_ip_addrs: ['1.1.0.2', '2.2.0.2']
518     gateway_ip_addrs_step: 0.0.0.1
519     udp_src_port: ['10', '14']
520     udp_dst_port: ['20', '25']
521     udp_port_step: 'random'
522
523 To run NFVbench with 3 chains and 100 flows, use the following command:
524
525 .. code-block:: bash
526
527     nfvbench -c nfvbench.cfg --rate 10000pps -scc 3 -fc 100
528
529 The least common multiple for this configuration is lcm(8, 4, 5, 6) = 120.
530 .. note:: LCM method used IP pools sizes and UDP source and destination range sizes
531
532 Requested flow count is higher than IP range (8 and 4 IP addresses available) and UDP (5 and 6 ports available) configuration capacity.
533 As the combination of ranges does not permit to obtain an accurate flow count, NFVbench will override the `udp_port_step` property to '1' (was 'random') to allow flows creation.
534 A warning log will appear to inform NFVbench user that step properties will be overriden
535 So, NFVbench will determine each pool size to generate accurate flows:
536
537 .. code-block:: bash
538
539     2020-06-17 07:37:47,010 WARNING Current values of ip_addrs_step and/or udp_port_step properties do not allow to control an accurate flow count. Values will be overridden as follows:
540     2020-06-17 07:37:47,011 INFO udp_port_step='1' (previous value: udp_port_step='random')
541     2020-06-17 07:37:47,012 INFO Port 0, chain 0: IP src range [110.0.0.0,110.0.0.0]
542     2020-06-17 07:37:47,012 INFO Port 0, chain 0: IP dst range [120.0.0.0,120.0.0.0]
543     2020-06-17 07:37:47,012 INFO Port 0, chain 0: UDP src range [10,14]
544     2020-06-17 07:37:47,012 INFO Port 0, chain 0: UDP dst range [20,25]
545     2020-06-17 07:37:47,013 WARNING Current values of ip_addrs_step and/or udp_port_step properties do not allow to control an accurate flow count. Values will be overridden as follows:
546     2020-06-17 07:37:47,013 INFO udp_port_step='1' (previous value: udp_port_step='random'
547     2020-06-17 07:37:47,015 INFO Port 1, chain 0: IP src range [120.0.0.0,120.0.0.0]
548     2020-06-17 07:37:47,015 INFO Port 1, chain 0: IP dst range [110.0.0.0,110.0.0.0]
549     2020-06-17 07:37:47,015 INFO Port 1, chain 0: UDP src range [10,14]
550     2020-06-17 07:37:47,015 INFO Port 1, chain 0: UDP dst range [20,25]
551
552     2020-06-17 07:38:47,010 WARNING Current values of ip_addrs_step and/or udp_port_step properties do not allow to control an accurate flow count. Values will be overridden as follows:
553     2020-06-17 07:38:47,011 INFO udp_port_step='1' (previous value: udp_port_step='random'
554     2020-06-17 07:38:47,012 INFO Port 0, chain 1: IP src range [110.0.0.1,110.0.0.1]
555     2020-06-17 07:38:47,012 INFO Port 0, chain 1: IP dst range [120.0.0.1,120.0.0.1]
556     2020-06-17 07:38:47,012 INFO Port 0, chain 1: UDP src range [10,14]
557     2020-06-17 07:38:47,012 INFO Port 0, chain 1: UDP dst range [20,25]
558     2020-06-17 07:38:47,013 WARNING Current values of ip_addrs_step and/or udp_port_step properties do not allow to control an accurate flow count. Values will be overridden as follows:
559     2020-06-17 07:38:47,013 INFO udp_port_step='1' (previous value: udp_port_step='random'
560     2020-06-17 07:38:47,015 INFO Port 1, chain 1: IP src range [120.0.0.1,120.0.0.1]
561     2020-06-17 07:38:47,015 INFO Port 1, chain 1: IP dst range [110.0.0.1,110.0.0.1]
562     2020-06-17 07:38:47,015 INFO Port 1, chain 1: UDP src range [10,14]
563     2020-06-17 07:38:47,015 INFO Port 1, chain 1: UDP dst range [20,25]
564
565     2020-06-17 07:39:47,010 WARNING Current values of ip_addrs_step and/or udp_port_step properties do not allow to control an accurate flow count. Values will be overridden as follows:
566     2020-06-17 07:39:47,011 INFO udp_port_step='1' (previous value: udp_port_step='random'
567     2020-06-17 07:39:47,012 INFO Port 0, chain 2: IP src range [110.0.0.2,110.0.0.2]
568     2020-06-17 07:39:47,012 INFO Port 0, chain 2: IP dst range [120.0.0.2,120.0.0.2]
569     2020-06-17 07:39:47,012 INFO Port 0, chain 2: UDP src range [10,14]
570     2020-06-17 07:39:47,012 INFO Port 0, chain 2: UDP dst range [20,25]
571     2020-06-17 07:39:47,013 WARNING Current values of ip_addrs_step and/or udp_port_step properties do not allow to control an accurate flow count. Values will be overridden as follows:
572     2020-06-17 07:39:47,013 INFO udp_port_step='1' (previous value: udp_port_step='random'
573     2020-06-17 07:39:47,015 INFO Port 1, chain 2: IP src range [120.0.0.2,120.0.0.2]
574     2020-06-17 07:39:47,015 INFO Port 1, chain 2: IP dst range [110.0.0.2,110.0.0.2]
575     2020-06-17 07:39:47,015 INFO Port 1, chain 2: UDP src range [10,14]
576     2020-06-17 07:39:47,015 INFO Port 1, chain 2: UDP dst range [20,25]
577
578
579 Traffic Configuration via CLI
580 -----------------------------
581
582 While traffic configuration can be modified using the configuration file, it can be inconvenient to have to change the configuration file everytime
583 you need to change a traffic configuration option. Traffic configuration options can be overridden with a few CLI options.
584
585 Here is an example of configuring traffic via CLI:
586
587 .. code-block:: bash
588
589     nfvbench --rate 10kpps --service-chain-count 2 -fs 64 -fs IMIX -fs 1518 --unidir
590
591 This command will run NFVbench with a unidirectional flow for three packet sizes 64B, IMIX, and 1518B.
592
593 Used parameters:
594
595 * ``--rate 10kpps`` : defines rate of packets sent by traffic generator (total TX rate)
596 * ``-scc 2`` or ``--service-chain-count 2`` : specifies number of parallel chains of given flow to run (default to 1)
597 * ``-fs 64`` or ``--frame-size 64``: add the specified frame size to the list of frame sizes to run
598 * ``--unidir`` : run traffic with unidirectional flow (default to bidirectional flow)
599
600
601 MAC Addresses
602 -------------
603
604 NFVbench will dicover the MAC addresses to use for generated frames using:
605 - either OpenStack discovery (find the MAC of an existing VM) in the case of PVP and PVVP service chains
606 - or using dynamic ARP discovery (find MAC from IP) in the case of external chains.
607 - 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.
608
609 Status and Cleanup of NFVbench Resources
610 ----------------------------------------
611
612 The --status option will display the status of NFVbench and list any NFVbench resources. You need to pass the OpenStack RC
613 file in order to connect to OpenStack.
614
615 .. code-block:: none
616
617     # nfvbench --status -r /tmp/nfvbench/openrc
618     2018-04-09 17:05:48,682 INFO Version: 1.3.2.dev1
619     2018-04-09 17:05:48,683 INFO Status: idle
620     2018-04-09 17:05:48,757 INFO Discovering instances nfvbench-loop-vm...
621     2018-04-09 17:05:49,252 INFO Discovering flavor nfvbench.medium...
622     2018-04-09 17:05:49,281 INFO Discovering networks...
623     2018-04-09 17:05:49,365 INFO No matching NFVbench resources found
624     #
625
626 The Status can be either "idle" or "busy (run pending)".
627
628 The --cleanup option will first discover resources created by NFVbench and prompt if you want to proceed with cleaning them up.
629 Example of run:
630
631 .. code-block:: none
632
633     # nfvbench --cleanup -r /tmp/nfvbench/openrc
634     2018-04-09 16:58:00,204 INFO Version: 1.3.2.dev1
635     2018-04-09 16:58:00,205 INFO Status: idle
636     2018-04-09 16:58:00,279 INFO Discovering instances nfvbench-loop-vm...
637     2018-04-09 16:58:00,829 INFO Discovering flavor nfvbench.medium...
638     2018-04-09 16:58:00,876 INFO Discovering networks...
639     2018-04-09 16:58:00,960 INFO Discovering ports...
640     2018-04-09 16:58:01,012 INFO Discovered 6 NFVbench resources:
641     +----------+-------------------+--------------------------------------+
642     | Type     | Name              | UUID                                 |
643     |----------+-------------------+--------------------------------------|
644     | Instance | nfvbench-loop-vm0 | b039b858-777e-467e-99fb-362f856f4a94 |
645     | Flavor   | nfvbench.medium   | a027003c-ad86-4f24-b676-2b05bb06adc0 |
646     | Network  | nfvbench-net0     | bca8d183-538e-4965-880e-fd92d48bfe0d |
647     | Network  | nfvbench-net1     | c582a201-8279-4309-8084-7edd6511092c |
648     | Port     |                   | 67740862-80ac-4371-b04e-58a0b0f05085 |
649     | Port     |                   | b5db95b9-e419-4725-951a-9a8f7841e66a |
650     +----------+-------------------+--------------------------------------+
651     2018-04-09 16:58:01,013 INFO NFVbench will delete all resources shown...
652     Are you sure? (y/n) y
653     2018-04-09 16:58:01,865 INFO Deleting instance nfvbench-loop-vm0...
654     2018-04-09 16:58:02,058 INFO     Waiting for 1 instances to be fully deleted...
655     2018-04-09 16:58:02,182 INFO     1 yet to be deleted by Nova, retries left=6...
656     2018-04-09 16:58:04,506 INFO     1 yet to be deleted by Nova, retries left=5...
657     2018-04-09 16:58:06,636 INFO     1 yet to be deleted by Nova, retries left=4...
658     2018-04-09 16:58:08,701 INFO Deleting flavor nfvbench.medium...
659     2018-04-09 16:58:08,729 INFO Deleting port 67740862-80ac-4371-b04e-58a0b0f05085...
660     2018-04-09 16:58:09,102 INFO Deleting port b5db95b9-e419-4725-951a-9a8f7841e66a...
661     2018-04-09 16:58:09,620 INFO Deleting network nfvbench-net0...
662     2018-04-09 16:58:10,357 INFO Deleting network nfvbench-net1...
663     #
664
665 The --force-cleanup option will do the same but without prompting for confirmation.
666
667 Service mode for TRex
668 ---------------------
669
670 The ``--service-mode`` option allows you to capture traffic on a TRex window during the NFVBench test. Thus, you will be
671 able to capture packets generated by TRex to observe many information on it.
672
673 Example of use :
674
675 .. code-block:: bash
676
677     nfvbench ``--service-mode``
678
679 .. note:: It is preferable to define the minimum rate (2002 pps) to have a better capture
680
681 In another bash window, you should connect to the TRex console doing:
682
683 .. code-block:: bash
684
685     cd /opt/trex/vX.XX/ # use completion here to find your corresponding TRex version
686     ./trex-console --python3 -r
687     # capture on port number 0
688     capture monitor start --rx 0 -v
689
690     # to stop capture
691     capture monitor stop
692
693 Start this capture once you have started the NFVBench test, and you will observe packets on the TRex console:
694
695 .. code-block:: bash
696
697     #26342 Port: 0 ◀── RX
698
699     trex(read-only)>
700
701         Type: UDP, Size: 66 B, TS: 26.30 [sec]
702
703     trex(read-only)>
704         ###[ Ethernet ]###
705             dst       = a0:36:9f:7a:58:8e
706             src       = fa:16:3e:57:8f:df
707             type      = 0x8100
708         ###[ 802.1Q ]###
709             prio      = 0
710             id        = 0
711             vlan      = 1093
712             type      = 0x800
713         ###[ IP ]###
714             version   = 4
715             ihl       = 5
716             tos       = 0x1
717             len       = 46
718             id        = 65535
719             flags     =
720             frag      = 0
721             ttl       = 63
722             proto     = udp
723             chksum    = 0x8425
724             src       = 120.0.0.0
725             dst       = 110.0.17.153
726             \options   \
727         ###[ UDP ]###
728             sport     = 53
729             dport     = 53
730             len       = 26
731             chksum    = 0xfd83
732         ###[ Raw ]###
733             load      = "xx\xab'\x01\x00?s\x00\x00\xbci\xf0_{U~\x00"
734         ###[ Padding ]###
735             load      = '6\x85'
736
737 Check on the NFVBench window that the following log appears just before the testing phase:
738
739 .. code-block:: bash
740
741     2019-10-21 09:38:51,532 INFO Starting to generate traffic...
742     2019-10-21 09:38:51,532 INFO Running traffic generator
743     2019-10-21 09:38:51,541 INFO ``Service mode is enabled``
744     2019-10-21 09:38:52,552 INFO TX: 2004; RX: 2003; Est. Dropped: 1; Est. Drop rate: 0.0499%
745     2019-10-21 09:38:53,559 INFO TX: 4013; RX: 4011; Est. Dropped: 2; Est. Drop rate: 0.0498%
746
747 Recording packet using service mode for TRex
748 --------------------------------------------
749
750 Check on the NFVBench window that the following log appears just before the testing phase:
751
752 .. code-block:: bash
753
754     2019-10-21 09:38:51,532 INFO Starting to generate traffic...
755     2019-10-21 09:38:51,532 INFO Running traffic generator
756     2019-10-21 09:38:51,541 INFO ``Service mode is enabled``
757     2019-10-21 09:38:52,552 INFO TX: 2004; RX: 2003; Est. Dropped: 1; Est. Drop rate: 0.0499%
758
759 In another bash window, you should connect to the TRex console doing :
760
761 .. code-block:: bash
762
763     cd /opt/trex/vX.XX/ #use completion here to find your corresponding TRex version
764     ./trex-console -r
765     capture record start --rx [port number] --limit 10000
766 .. note::Start this capture once traffic generation is started (after ``Service mode is enabled`` log)
767
768 Check on the TRex window that the following log appears just after capture is started:
769
770 .. code-block:: bash
771
772     Starting packet capturing up to 10000 packets               [SUCCESS]
773     *** Capturing ID is set to '8' ***
774     *** Please call 'capture record stop --id 8 -o <out.pcap>' when done ***
775
776 Then **before end of traffic generation**, stop capture and save it as a PCAP file:
777
778 .. code-block:: bash
779
780     capture record stop --id 8 -o /tmp/nfvb/record.pcap
781 .. note:: Provide a shared path with between NFVbench container and your host to retrieve pcap file
782
783 Check on the TRex window that the following log appears just after capture is started:
784
785 .. code-block:: bash
786
787     Stopping packet capture 8                                    [SUCCESS]
788     Writing up to 10000 packets to '/tmp/nfvb/record.pcap'       [SUCCESS]
789     Removing PCAP capture 8 from server                          [SUCCESS]
790
791 User info data
792 --------------
793
794 The ``--user-info`` option allows you to pass custom information as a JSON string.
795 This information will be available through JSON output and also exported to ``fluentd`` and can be used in results post-processing.
796
797 Example of use :
798
799 .. code-block:: bash
800
801     nfvbench ``--user-info='{"status":"explore","description":{"target":"lab","ok":true,"version":2020}'``
802
803 .. note:: only JSON string is allowed
804
805 ``--user-info`` can be used for determining theoretical max rate. In some cases, an overhead encapsulation exists between NFVbench and SUT so NFVbench will not reach line rate inside SUT due to this extra encapsulation.
806 To calculate this theoretical line rate inside SUT, NFVbench will use a reserved key: ``extra_encapsulation_bytes`` in ``--user-info`` property.
807
808 .. code-block:: bash
809
810     nfvbench ``--user-info='{"extra_encapsulation_bytes": 28}'``
811
812
813 As a result, NFVbench will return two values ``theoretical_tx_rate_bps`` and ``theoretical_tx_rate_pps``:
814
815 .. code-block:: bash
816
817                                 "ndr": {
818                                     "duration_sec": 2.0,
819                                     "initial_rate_type": "rate_percent",
820                                     "l2frame_size": "64",
821                                     "load_percent_per_direction": 100.0,
822                                     "rate_bps": 20000000000.0,
823                                     "rate_percent": 200.0,
824                                     "rate_pps": 29761904,
825                                     "stats": {
826                                         ...
827                                         "offered_tx_rate_bps": 15000000000.0,
828                                         ...
829                                         "theoretical_tx_rate_bps": 15000000000.0,
830                                         "theoretical_tx_rate_pps": 22321428.57142857,
831                                         "total_tx_rate": 22321428
832                                     },
833
834 In the above example, line rate is 20Gbps but NFVbench is outside SUT and a SDN gateway add an extra encapsulation of 28 bytes.
835 Overall, theoretical line rate inside SUT is only 15 Gbps for 64 bytes packet size and it will be this max capacity treated by the target compute node.