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