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