Merge "NFVBENCH-25 Send run results to fluentd"
[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
82 Fixed Rate Run
83 --------------
84
85 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.
86
87 This example shows how to run the PVP packet path (which is the default packet path) with multiple different settings:
88
89 .. code-block:: bash
90
91     nfvbench -c nfvbench.cfg --no-cleanup --rate 100000pps --duration 30 --interval 15 --json results.json
92
93 Used parameters:
94
95 * ``-c nfvbench.cfg`` : path to the config file
96 * ``--no-cleanup`` : resources (networks, VMs, attached ports) are not deleted after test is finished
97 * ``--rate 100000pps`` : defines rate of packets sent by traffic generator
98 * ``--duration 30`` : specifies how long should traffic be running in seconds
99 * ``--interval 15`` : stats are checked and shown periodically (in seconds) in this interval when traffic is flowing
100 * ``--json results.json`` : collected data are stored in this file after run is finished
101
102 .. 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.
103
104 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:
105
106 .. code-block:: bash
107
108     nfvbench --show-summary results.json
109
110
111 This example shows how to specify a different packet path:
112
113 .. code-block:: bash
114
115     nfvbench -c nfvbench.cfg --rate 1Mbps --inter-node --service-chain PVVP
116
117 Used parameters:
118
119 * ``-c nfvbench.cfg`` : path to the config file
120 * ``--rate 1Mbps`` : defines rate of packets sent by traffic generator
121 * ``--inter-node`` : VMs are created on different compute nodes, works only with PVVP flow
122 * ``--service-chain PVVP`` or ``-sc PVVP`` : specifies the type of service chain (or packet path) to use
123
124 .. note:: When parameter ``--inter-node`` is not used or there aren't enough compute nodes, VMs are on the same compute node.
125
126
127 Rate Units
128 ^^^^^^^^^^
129
130 Parameter ``--rate`` accepts different types of values:
131
132 * packets per second (pps, kpps, mpps), e.g. ``1000pps`` or ``10kpps``
133 * load percentage (%), e.g. ``50%``
134 * bits per second (bps, kbps, Mbps, Gbps), e.g. ``1Gbps``, ``1000bps``
135 * NDR/PDR (ndr, pdr, ndr_pdr), e.g. ``ndr_pdr``
136
137 NDR/PDR is the default rate when not specified.
138
139 NDR and PDR
140 -----------
141
142 The NDR and PDR test is used to determine the maximum throughput performance of the system under test
143 following guidelines defined in RFC-2544:
144
145 * NDR (No Drop Rate): maximum packet rate sent without dropping any packet
146 * PDR (Partial Drop Rate): maximum packet rate sent while allowing a given maximum drop rate
147
148 The NDR search can also be relaxed to allow some very small amount of drop rate (lower than the PDR maximum drop rate).
149 NFVbench will measure the NDR and PDR values by driving the traffic generator through multiple iterations
150 at different transmission rates using a binary search algorithm.
151
152 The configuration file contains section where settings for NDR/PDR can be set.
153
154 .. code-block:: bash
155
156     # NDR/PDR configuration
157     measurement:
158         # Drop rates represent the ratio of dropped packet to the total number of packets sent.
159         # Values provided here are percentages. A value of 0.01 means that at most 0.01% of all
160         # packets sent are dropped (or 1 packet every 10,000 packets sent)
161
162         # No Drop Rate; Default to 0.001%
163         NDR: 0.001
164         # Partial Drop Rate; NDR should always be less than PDR
165         PDR: 0.1
166         # The accuracy of NDR and PDR load percentiles; The actual load percentile that match NDR
167         # or PDR should be within `load_epsilon` difference than the one calculated.
168         load_epsilon: 0.1
169
170 Because NDR/PDR is the default ``--rate`` value, it is possible to run NFVbench simply like this:
171
172 .. code-block:: bash
173
174     nfvbench -c nfvbench.cfg
175
176 Other possible run options:
177
178 .. code-block:: bash
179
180     nfvbench -c nfvbench.cfg --duration 120 --json results.json
181
182 Used parameters:
183
184 * ``-c nfvbench.cfg`` : path to the config file
185 * ``--duration 120`` : specifies how long should be traffic running in each iteration
186 * ``--json results.json`` : collected data are stored in this file after run is finished
187
188
189 Multichain
190 ----------
191
192 NFVbench allows to run multiple chains at the same time. For example it is possible to stage the PVP service chain N-times,
193 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.
194
195 The number of chains is specified by ``--service-chain-count`` or ``-scc`` flag with a default value of 1.
196 For example to run NFVbench with 3 PVP chains:
197
198 .. code-block:: bash
199
200     nfvbench -c nfvbench.cfg --rate 10000pps -scc 3
201
202 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.
203 If ``-sc PVVP`` is specified instead, there would be 6 VMs in 3 chains as this service chain has 2 VMs per chain.
204 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.
205
206
207 External Chain
208 --------------
209
210 NFVbench can measure the performance of 1 or more L3 service chains that are setup externally. Instead of being setup by NFVbench,
211 the complete environment (VMs and networks) has to be setup prior to running NFVbench.
212
213 Each external chain is made of 1 or more VNFs and has exactly 2 end network interfaces (left and right network interfaces) that are connected to 2 neutron networks (left and right networks).
214 The internal composition of a multi-VNF service chain can be arbitrary (usually linear) as far as NFVbench is concerned,
215 the only requirement is that the service chain can route L3 packets properly between the left and right networks.
216
217 To run NFVbench on such external service chains:
218
219 - explicitly tell NFVbench to use external service chain by adding ``-sc EXT`` or ``--service-chain EXT`` to NFVbench CLI options
220 - specify the number of external chains using the ``-scc`` option (defaults to 1 chain)
221 - specify the 2 end point networks of your environment in ``external_networks`` inside the config file.
222     - The two networks specified there have to exist in Neutron and will be used as the end point networks by NFVbench ('napa' and 'marin' in the diagram below)
223 - specify the router gateway IPs for the external service chains (1.1.0.2 and 2.2.0.2)
224 - specify the traffic generator gateway IPs for the external service chains (1.1.0.102 and 2.2.0.102 in diagram below)
225 - specify the packet source and destination IPs for the virtual devices that are simulated (10.0.0.0/8 and 20.0.0.0/8)
226
227
228 .. image:: images/extchain-config.svg
229
230 L3 routing must be enabled in the VNF and configured to:
231
232 - reply to ARP requests to its public IP addresses on both left and right networks
233 - route packets from each set of remote devices toward the appropriate dest gateway IP in the traffic generator using 2 static routes (as illustrated in the diagram)
234
235 Upon start, NFVbench will:
236 - first retrieve the properties of the left and right networks using Neutron APIs,
237 - extract the underlying network ID (typically VLAN segmentation ID),
238 - generate packets with the proper VLAN ID and measure traffic.
239
240 Note that in the case of multiple chains, all chains end interfaces must be connected to the same two left and right networks.
241 The traffic will be load balanced across the corresponding gateway IP of these external service chains.
242
243
244 Multiflow
245 ---------
246
247 NFVbench always generates L3 packets from the traffic generator but allows the user to specify how many flows to generate.
248 A flow is identified by a unique src/dest MAC IP and port tuple that is sent by the traffic generator. Flows are
249 generated by ranging the IP adresses but using a small fixed number of MAC addresses.
250
251 The number of flows will be spread roughly even between chains when more than 1 chain is being tested.
252 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.
253
254 The number of flows is specified by ``--flow-count`` or ``-fc`` flag, the default value is 2 (1 flow in each direction).
255 To run NFVbench with 3 chains and 100 flows, use the following command:
256
257 .. code-block:: bash
258
259     nfvbench -c nfvbench.cfg --rate 10000pps -scc 3 -fc 100
260
261 Note that from a vswitch point of view, the
262 number of flows seen will be higher as it will be at least 4 times the number of flows sent by the traffic generator
263 (add flow to VM and flow from VM).
264
265 IP addresses generated can be controlled with the following NFVbench configuration options:
266
267 .. code-block:: bash
268
269     ip_addrs: ['10.0.0.0/8', '20.0.0.0/8']
270     ip_addrs_step: 0.0.0.1
271     tg_gateway_ip_addrs: ['1.1.0.100', '2.2.0.100']
272     tg_gateway_ip_addrs_step: 0.0.0.1
273     gateway_ip_addrs: ['1.1.0.2', '2.2.0.2']
274     gateway_ip_addrs_step: 0.0.0.1
275
276 ``ip_addrs`` are the start of the 2 ip address ranges used by the traffic generators as the packets source and destination packets
277 where each range is associated to virtual devices simulated behind 1 physical interface of the traffic generator.
278 These can also be written in CIDR notation to represent the subnet.
279
280 ``tg_gateway_ip_addrs`` are the traffic generator gateway (virtual) ip addresses, all traffic to/from the virtual devices go through them.
281
282 ``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.
283
284 The corresponding ``step`` is used for ranging the IP addresses from the `ip_addrs``, ``tg_gateway_ip_addrs`` and ``gateway_ip_addrs`` base addresses.
285 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.
286
287
288 Traffic Configuration via CLI
289 -----------------------------
290
291 While traffic configuration can be modified using the configuration file, it can be inconvenient to have to change the configuration file everytime you need to change a traffic configuration option. Traffic configuration options can be overridden with a few CLI options.
292
293 Here is an example of configuring traffic via CLI:
294
295 .. code-block:: bash
296
297     nfvbench --rate 10kpps --service-chain-count 2 -fs 64 -fs IMIX -fs 1518 --unidir
298
299 This command will run NFVbench with a unidirectional flow for three packet sizes 64B, IMIX, and 1518B.
300
301 Used parameters:
302
303 * ``--rate 10kpps`` : defines rate of packets sent by traffic generator (total TX rate)
304 * ``-scc 2`` or ``--service-chain-count 2`` : specifies number of parallel chains of given flow to run (default to 1)
305 * ``-fs 64`` or ``--frame-size 64``: add the specified frame size to the list of frame sizes to run
306 * ``--unidir`` : run traffic with unidirectional flow (default to bidirectional flow)
307
308
309 MAC Addresses
310 -------------
311
312 NFVbench will dicover the MAC addresses to use for generated frames using:
313 - either OpenStack discovery (find the MAC of an existing VM) in the case of PVP and PVVP service chains
314 - or using dynamic ARP discovery (find MAC from IP) in the case of external chains.
315
316 Cleanup Script
317 --------------
318
319 The nfvbench_cleanup script will cleanup resources created by NFVbench. You need to pass the OpenStack RC file in order to connect to
320 OpenStack.
321 Example of run:
322
323 .. code-block:: none
324
325     # nfvbench_cleanup -r /tmp/nfvbench/openrc
326     Discovering Storage resources...
327     Discovering Compute resources...
328     Discovering Network resources...
329     Discovering Keystone resources...
330
331     SELECTED RESOURCES:
332     +-----------+-------------------+--------------------------------------+
333     | Type      | Name              | UUID                                 |
334     |-----------+-------------------+--------------------------------------|
335     | flavors   | nfvbench.medium   | 362b2215-89d1-4f46-8b89-8e58165ff5bc |
336     | instances | nfvbench-loop-vm0 | f78dfb74-1b8e-4c5c-8d83-652a7571da95 |
337     | networks  | nfvbench-net0     | 57d7e6c9-325f-4c13-9b1b-929344cc9c39 |
338     | networks  | nfvbench-net1     | 2d429bcd-33fa-4aa4-9f2e-299a735177c9 |
339     +-----------+-------------------+--------------------------------------+
340
341     Warning: You didn't specify a resource list file as the input. The script will delete all resources shown above.
342     Are you sure? (y/n) y
343     *** STORAGE cleanup
344     *** COMPUTE cleanup
345         . Waiting for 1 instances to be fully deleted...
346         . INSTANCE 1 left to be deleted, retries left=5...
347         . INSTANCE 1 left to be deleted, retries left=4...
348         + INSTANCE nfvbench-loop-vm0 is successfully deleted
349         + FLAVOR nfvbench.medium is successfully deleted
350     *** NETWORK cleanup
351         + Network port 075d91f3-fa6a-428c-bd3f-ebd40cd935e1 is successfully deleted
352         + Network port 3a7ccd8c-53a6-43d0-a823-4b5ca762d06e is successfully deleted
353         + NETWORK nfvbench-net0 is successfully deleted
354         + Network port 5b5a75bd-e0b5-4f81-91b9-9e216d194f48 is successfully deleted
355         + Network port cc2d8f1b-49fe-491e-9e44-6990fc57e891 is successfully deleted
356         + NETWORK nfvbench-net1 is successfully deleted
357     *** KEYSTONE cleanup
358     #