806927b1eba60ffbaf0b3a7c07e553d410fa8e41
[nfvbench.git] / docs / testing / user / userguide / server.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 NFVbench Server mode and NFVbench client API
6 ============================================
7
8
9 HTTP Interface
10 --------------
11
12 <http-url>/echo (GET)
13 ^^^^^^^^^^^^^^^^^^^^^
14
15 This request simply returns whatever content is sent in the body of the request (body should be in json format, only used for testing)
16
17 Example request:
18
19 .. code-block:: bash
20
21     curl -XGET '127.0.0.1:7556/echo' -H "Content-Type: application/json" -d '{"nfvbench": "test"}'
22     Response:
23     {
24       "nfvbench": "test"
25     }
26
27
28 <http-url>/status (GET)
29 ^^^^^^^^^^^^^^^^^^^^^^^
30
31 This request fetches the status of an asynchronous run. It will return in json format:
32
33 - a request pending reply (if the run is still not completed)
34 - an error reply if there is no run pending
35 - or the complete result of the run
36
37 The client can keep polling until the run completes.
38
39 Example of return when the run is still pending:
40
41 .. code-block:: bash
42
43     {
44       "error_message": "nfvbench run still pending",
45       "status": "PENDING"
46     }
47
48 Example of return when the run completes:
49
50 .. code-block:: bash
51
52     {
53       "result": {...}
54       "status": "OK"
55     }
56
57
58 <http-url>/start_run (POST)
59 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
60
61 This request starts an NFVBench run with passed configurations. If no configuration is passed, a run with default configurations will be executed.
62
63 Example request: curl -XPOST 'localhost:7556/start_run' -H "Content-Type: application/json" -d @nfvbenchconfig.json
64
65 See "NFVbench configuration JSON parameter" below for details on how to format this parameter.
66
67 The request returns immediately with a json content indicating if there was an error (status=ERROR) or if the request was submitted successfully (status=PENDING).
68 Example of return when the submission is successful:
69
70 .. code-block:: bash
71
72     {
73       "error_message": "NFVbench run still pending",
74       "request_id": "42cccb7effdc43caa47f722f0ca8ec96",
75       "status": "PENDING"
76     }
77
78 If there is already an NFVBench running then it will return:
79
80 .. code-block:: bash
81
82     {
83      "error_message": "there is already an NFVbench request running",
84      "status": "ERROR"
85     }
86
87 WebSocket/SocketIO events
88 -------------------------
89
90 List of SocketIO events supported:
91
92 Client to Server
93 ^^^^^^^^^^^^^^^^
94
95 start_run:
96
97     sent by client to start a new run with the configuration passed in argument (JSON).
98     The configuration can be any valid NFVbench configuration passed as a JSON document (see "NFVbench configuration JSON parameter" below)
99
100 Server to Client
101 ^^^^^^^^^^^^^^^^
102
103 run_interval_stats:
104
105     sent by server to report statistics during a run
106     the message contains the statistics {'time_ms': time_ms, 'tx_pps': tx_pps, 'rx_pps': rx_pps, 'drop_pct': drop_pct}
107
108 ndr_found:
109
110     (during NDR-PDR search)
111     sent by server when the NDR rate is found
112     the message contains the NDR value {'rate_pps': ndr_pps}
113
114 ndr_found:
115
116     (during NDR-PDR search)
117     sent by server when the PDR rate is found
118     the message contains the PDR value {'rate_pps': pdr_pps}
119
120
121 run_end:
122
123     sent by server to report the end of a run
124     the message contains the complete results in JSON format
125
126 NFVbench configuration JSON parameter
127 -------------------------------------
128 The NFVbench configuration describes the parameters of an NFVbench run and can be passed to the NFVbench server as a JSON document.
129
130 Default configuration
131 ^^^^^^^^^^^^^^^^^^^^^
132
133 The simplest JSON document is the empty dictionary "{}" which indicates to use the default NFVbench configuration:
134
135 - PVP
136 - NDR-PDR measurement
137 - 64 byte packets
138 - 1 flow per direction
139
140 The entire default configuration can be viewed using the --show-json-config option on the cli:
141
142 .. code-block:: bash
143
144     # nfvbench --show-config
145     {
146         "availability_zone": null,
147         "compute_node_user": "root",
148         "compute_nodes": null,
149         "debug": false,
150         "duration_sec": 60,
151         "flavor": {
152             "disk": 0,
153             "extra_specs": {
154                 "hw:cpu_policy": "dedicated",
155                 "hw:mem_page_size": 2048
156             },
157             "ram": 8192,
158             "vcpus": 2
159         },
160         "flavor_type": "nfv.medium",
161         "flow_count": 1,
162         "generic_poll_sec": 2,
163         "generic_retry_count": 100,
164         "inter_node": false,
165         "internal_networks": {
166             "left": {
167                 "name": "nfvbench-net0",
168                 "subnet": "nfvbench-subnet0",
169                 "cidr": "192.168.1.0/24",
170             },
171             "right": {
172                 "name": "nfvbench-net1",
173                 "subnet": "nfvbench-subnet1",
174                 "cidr": "192.168.2.0/24",
175             },
176             "middle": {
177                 "name": "nfvbench-net2",
178                 "subnet": "nfvbench-subnet2",
179                 "cidr": "192.168.3.0/24",
180             }
181         },
182         "interval_sec": 10,
183         "json": null,
184         "loop_vm_name": "nfvbench-loop-vm",
185         "measurement": {
186             "NDR": 0.001,
187             "PDR": 0.1,
188             "load_epsilon": 0.1
189         },
190         "name": "(built-in default config)",
191         "no_cleanup": false,
192         "no_traffic": false,
193         "openrc_file": "/tmp/nfvbench/openstack/openrc",
194         "rate": "ndr_pdr",
195         "service_chain": "PVP",
196         "service_chain_count": 1,
197         "sriov": false,
198         "std_json": null,
199         "traffic": {
200             "bidirectional": true,
201             "profile": "traffic_profile_64B"
202         },
203         "traffic_generator": {
204             "default_profile": "trex-local",
205             "gateway_ip_addrs": [
206                 "1.1.0.2",
207                 "2.2.0.2"
208             ],
209             "gateway_ip_addrs_step": "0.0.0.1",
210             "generator_profile": [
211                 {
212                     "cores": 3,
213                     "interfaces": [
214                         {
215                             "pci": "0a:00.0",
216                             "port": 0,
217                             "switch_port": "Ethernet1/33",
218                             "vlan": null
219                         },
220                         {
221                             "pci": "0a:00.1",
222                             "port": 1,
223                             "switch_port": "Ethernet1/34",
224                             "vlan": null
225                         }
226                     ],
227                     "intf_speed": null,
228                     "ip": "127.0.0.1",
229                     "name": "trex-local",
230                     "tool": "TRex"
231                 }
232             ],
233             "host_name": "nfvbench_tg",
234             "ip_addrs": [
235                 "10.0.0.0/8",
236                 "20.0.0.0/8"
237             ],
238             "ip_addrs_step": "0.0.0.1",
239             "mac_addrs": [
240                 "00:10:94:00:0A:00",
241                 "00:11:94:00:0A:00"
242             ],
243             "step_mac": null,
244             "tg_gateway_ip_addrs": [
245                 "1.1.0.100",
246                 "2.2.0.100"
247             ],
248             "tg_gateway_ip_addrs_step": "0.0.0.1"
249         },
250         "traffic_profile": [
251             {
252                 "l2frame_size": [
253                     "64"
254                 ],
255                 "name": "traffic_profile_64B"
256             },
257             {
258                 "l2frame_size": [
259                     "IMIX"
260                 ],
261                 "name": "traffic_profile_IMIX"
262             },
263             {
264                 "l2frame_size": [
265                     "1518"
266                 ],
267                 "name": "traffic_profile_1518B"
268             },
269             {
270                 "l2frame_size": [
271                     "64",
272                     "IMIX",
273                     "1518"
274                 ],
275                 "name": "traffic_profile_3sizes"
276             }
277         ],
278         "unidir_reverse_traffic_pps": 1,
279         "vlan_tagging": true,
280     }
281
282
283 Common examples of JSON configuration
284 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
285
286 Use the default configuration but use 10000 flows per direction (instead of 1):
287
288 .. code-block:: bash
289
290     { "flow_count": 10000 }
291
292
293 Use default confguration but with 10000 flows, "EXT" chain and IMIX packet size:
294
295 .. code-block:: bash
296
297     {
298        "flow_count": 10000,
299        "service_chain": "EXT",
300         "traffic": {
301             "profile": "traffic_profile_IMIX"
302         },
303     }
304
305 A short run of 5 seconds at a fixed rate of 1Mpps (and everything else same as the default configuration):
306
307 .. code-block:: bash
308
309     {
310        "duration": 5,
311        "rate": "1Mpps"
312     }
313
314 Example of interaction with the NFVbench server using HTTP and curl
315 -------------------------------------------------------------------
316 HTTP requests can be sent directly to the NFVbench server from CLI using curl from any host that can connect to the server (here we run it from the local host).
317
318 This is a POST request to start a run using the default NFVbench configuration but with traffic generation disabled ("no_traffic" property is set to true):
319
320 .. code-block:: bash
321
322     [root@sjc04-pod3-mgmt ~]# curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"no_traffic":true}' http://127.0.0.1:7555/start_run
323     {
324       "error_message": "nfvbench run still pending",
325       "status": "PENDING"
326     }
327     [root@sjc04-pod3-mgmt ~]#
328
329 This request will return immediately with status set to "PENDING" if the request was started successfully.
330
331 The status can be polled until the run completes. Here the poll returns a "PENDING" status, indicating the run is still not completed:
332
333 .. code-block:: bash
334
335     [root@sjc04-pod3-mgmt ~]# curl -G http://127.0.0.1:7555/status
336     {
337       "error_message": "nfvbench run still pending",
338       "status": "PENDING"
339     }
340     [root@sjc04-pod3-mgmt ~]#
341
342 Finally, the status request returns a "OK" status along with the full results (truncated here):
343
344 .. code-block:: bash
345
346     [root@sjc04-pod3-mgmt ~]# curl -G http://127.0.0.1:7555/status
347     {
348       "result": {
349         "benchmarks": {
350           "network": {
351             "service_chain": {
352               "PVP": {
353                 "result": {
354                   "bidirectional": true,
355                   "compute_nodes": {
356                     "nova:sjc04-pod3-compute-4": {
357                       "bios_settings": {
358                         "Adjacent Cache Line Prefetcher": "Disabled",
359                         "All Onboard LOM Ports": "Enabled",
360                         "All PCIe Slots OptionROM": "Enabled",
361                         "Altitude": "300 M",
362     ...
363
364         "date": "2017-03-31 22:15:41",
365         "nfvbench_version": "0.3.5",
366         "openstack_spec": {
367           "encaps": "VxLAN",
368           "vswitch": "VTS"
369         }
370       },
371       "status": "OK"
372     }
373     [root@sjc04-pod3-mgmt ~]#
374
375
376
377 Example of interaction with the NFVbench server using a python CLI app (nfvbench_client)
378 ----------------------------------------------------------------------------------------
379 The module client/client.py contains an example of python class that can be used to control the NFVbench server from a python app using HTTP or WebSocket/SocketIO.
380
381 The module client/nfvbench_client.py has a simple main application to control the NFVbench server from CLI.
382 The "nfvbench_client" wrapper script can be used to invoke the client front end (this wrapper is pre-installed in the NFVbench container)
383
384 Example of invocation of the nfvbench_client front end, from the host (assume the name of the NFVbench container is "nfvbench"),
385 use the default NFVbench configuration but do not generate traffic (no_traffic property set to true, the full json result is truncated here):
386
387 .. code-block:: bash
388
389     [root@sjc04-pod3-mgmt ~]# docker exec -it nfvbench nfvbench_client -c '{"no_traffic":true}' http://127.0.0.1:7555
390     {u'status': u'PENDING', u'error_message': u'nfvbench run still pending'}
391     {u'status': u'PENDING', u'error_message': u'nfvbench run still pending'}
392     {u'status': u'PENDING', u'error_message': u'nfvbench run still pending'}
393
394     {u'status': u'OK', u'result': {u'date': u'2017-03-31 22:04:59', u'nfvbench_version': u'0.3.5',
395      u'config': {u'compute_nodes': None, u'compute_node_user': u'root', u'traffic_generator': {u'tg_gateway_ip_addrs': [u'1.1.0.100', u'2.2.0.100'], u'ip_addrs_step': u'0.0.0.1',
396      u'step_mac': None, u'generator_profile': [{u'intf_speed': u'', u'interfaces': [{u'pci': u'0a:00.0', u'port': 0, u'vlan': 1998, u'switch_port': None},
397
398     ...
399
400     [root@sjc04-pod3-mgmt ~]#
401
402 The http interface is used unless --use-socketio is defined.
403
404 Example of invocation using Websocket/SocketIO, execute NFVbench using the default configuration but with a duration of 5 seconds and a fixed rate run of 5kpps.
405
406 .. code-block:: bash
407
408     [root@sjc04-pod3-mgmt ~]# docker exec -it nfvbench nfvbench_client -c '{"duration":5,"rate":"5kpps"}' --use-socketio  http://127.0.0.1:7555 >results.json