52645adcc9f2e072257cd5793b81426951499365
[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:7555/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
88 NFVbench configuration JSON parameter
89 -------------------------------------
90 The NFVbench configuration describes the parameters of an NFVbench run and can be passed to the NFVbench server as a JSON document.
91
92 Default configuration
93 ^^^^^^^^^^^^^^^^^^^^^
94
95 The simplest JSON document is the empty dictionary "{}" which indicates to use the default NFVbench configuration:
96
97 - PVP
98 - NDR-PDR measurement
99 - 64 byte packets
100 - 1 flow per direction
101
102 The entire default configuration can be viewed using the --show-json-config option on the cli:
103
104 .. code-block:: bash
105
106     # nfvbench --show-config
107     {
108         "availability_zone": null,
109         "compute_node_user": "root",
110         "compute_nodes": null,
111         "debug": false,
112         "duration_sec": 60,
113         "flavor": {
114             "disk": 0,
115             "extra_specs": {
116                 "hw:cpu_policy": "dedicated",
117                 "hw:mem_page_size": 2048
118             },
119             "ram": 8192,
120             "vcpus": 2
121         },
122         "flavor_type": "nfv.medium",
123         "flow_count": 1,
124         "generic_poll_sec": 2,
125         "generic_retry_count": 100,
126         "inter_node": false,
127         "internal_networks": {
128             "left": {
129                 "name": "nfvbench-net0",
130                 "subnet": "nfvbench-subnet0",
131                 "cidr": "192.168.1.0/24",
132             },
133             "right": {
134                 "name": "nfvbench-net1",
135                 "subnet": "nfvbench-subnet1",
136                 "cidr": "192.168.2.0/24",
137             },
138             "middle": {
139                 "name": "nfvbench-net2",
140                 "subnet": "nfvbench-subnet2",
141                 "cidr": "192.168.3.0/24",
142             }
143         },
144         "interval_sec": 10,
145         "json": null,
146         "loop_vm_name": "nfvbench-loop-vm",
147         "measurement": {
148             "NDR": 0.001,
149             "PDR": 0.1,
150             "load_epsilon": 0.1
151         },
152         "name": "(built-in default config)",
153         "no_cleanup": false,
154         "no_traffic": false,
155         "openrc_file": "/tmp/nfvbench/openstack/openrc",
156         "rate": "ndr_pdr",
157         "service_chain": "PVP",
158         "service_chain_count": 1,
159         "sriov": false,
160         "std_json": null,
161         "traffic": {
162             "bidirectional": true,
163             "profile": "traffic_profile_64B"
164         },
165         "traffic_generator": {
166             "default_profile": "trex-local",
167             "gateway_ip_addrs": [
168                 "1.1.0.2",
169                 "2.2.0.2"
170             ],
171             "gateway_ip_addrs_step": "0.0.0.1",
172             "generator_profile": [
173                 {
174                     "cores": 3,
175                     "interfaces": [
176                         {
177                             "pci": "0a:00.0",
178                             "port": 0,
179                             "switch_port": "Ethernet1/33",
180                             "vlan": null
181                         },
182                         {
183                             "pci": "0a:00.1",
184                             "port": 1,
185                             "switch_port": "Ethernet1/34",
186                             "vlan": null
187                         }
188                     ],
189                     "intf_speed": null,
190                     "ip": "127.0.0.1",
191                     "name": "trex-local",
192                     "tool": "TRex"
193                 }
194             ],
195             "host_name": "nfvbench_tg",
196             "ip_addrs": [
197                 "10.0.0.0/8",
198                 "20.0.0.0/8"
199             ],
200             "ip_addrs_step": "0.0.0.1",
201             "mac_addrs": [
202                 "00:10:94:00:0A:00",
203                 "00:11:94:00:0A:00"
204             ],
205             "step_mac": null,
206             "tg_gateway_ip_addrs": [
207                 "1.1.0.100",
208                 "2.2.0.100"
209             ],
210             "tg_gateway_ip_addrs_step": "0.0.0.1"
211         },
212         "traffic_profile": [
213             {
214                 "l2frame_size": [
215                     "64"
216                 ],
217                 "name": "traffic_profile_64B"
218             },
219             {
220                 "l2frame_size": [
221                     "IMIX"
222                 ],
223                 "name": "traffic_profile_IMIX"
224             },
225             {
226                 "l2frame_size": [
227                     "1518"
228                 ],
229                 "name": "traffic_profile_1518B"
230             },
231             {
232                 "l2frame_size": [
233                     "64",
234                     "IMIX",
235                     "1518"
236                 ],
237                 "name": "traffic_profile_3sizes"
238             }
239         ],
240         "unidir_reverse_traffic_pps": 1,
241         "vlan_tagging": true,
242     }
243
244
245 Common examples of JSON configuration
246 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
247
248 Use the default configuration but use 10000 flows per direction (instead of 1):
249
250 .. code-block:: bash
251
252     { "flow_count": 10000 }
253
254
255 Use default confguration but with 10000 flows, "EXT" chain and IMIX packet size:
256
257 .. code-block:: bash
258
259     {
260        "flow_count": 10000,
261        "service_chain": "EXT",
262         "traffic": {
263             "profile": "traffic_profile_IMIX"
264         },
265     }
266
267 A short run of 5 seconds at a fixed rate of 1Mpps (and everything else same as the default configuration):
268
269 .. code-block:: bash
270
271     {
272        "duration": 5,
273        "rate": "1Mpps"
274     }
275
276 Use the default configuration but force TRex restart:
277
278 .. code-block:: bash
279
280     {
281        "restart": true
282     }
283
284
285 Example of interaction with the NFVbench server using HTTP and curl
286 -------------------------------------------------------------------
287 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).
288
289 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):
290
291 .. code-block:: bash
292
293     [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
294     {
295       "error_message": "nfvbench run still pending",
296       "status": "PENDING"
297     }
298     [root@sjc04-pod3-mgmt ~]#
299
300 This request will return immediately with status set to "PENDING" if the request was started successfully.
301
302 The status can be polled until the run completes. Here the poll returns a "PENDING" status, indicating the run is still not completed:
303
304 .. code-block:: bash
305
306     [root@sjc04-pod3-mgmt ~]# curl -G http://127.0.0.1:7555/status
307     {
308       "error_message": "nfvbench run still pending",
309       "status": "PENDING"
310     }
311     [root@sjc04-pod3-mgmt ~]#
312
313 Finally, the status request returns a "OK" status along with the full results (truncated here):
314
315 .. code-block:: bash
316
317     [root@sjc04-pod3-mgmt ~]# curl -G http://127.0.0.1:7555/status
318     {
319       "result": {
320         "benchmarks": {
321           "network": {
322             "service_chain": {
323               "PVP": {
324                 "result": {
325                   "bidirectional": true,
326                   "compute_nodes": {
327                     "nova:sjc04-pod3-compute-4": {
328                       "bios_settings": {
329                         "Adjacent Cache Line Prefetcher": "Disabled",
330                         "All Onboard LOM Ports": "Enabled",
331                         "All PCIe Slots OptionROM": "Enabled",
332                         "Altitude": "300 M",
333     ...
334
335         "date": "2017-03-31 22:15:41",
336         "nfvbench_version": "0.3.5",
337         "openstack_spec": {
338           "encaps": "VxLAN",
339           "vswitch": "VTS"
340         }
341       },
342       "status": "OK"
343     }
344     [root@sjc04-pod3-mgmt ~]#
345
346
347
348 Example of interaction with the NFVbench server using a python CLI app (nfvbench_client)
349 ----------------------------------------------------------------------------------------
350 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.
351
352 The module client/nfvbench_client.py has a simple main application to control the NFVbench server from CLI.
353 The "nfvbench_client" wrapper script can be used to invoke the client front end (this wrapper is pre-installed in the NFVbench container)
354
355 Example of invocation of the nfvbench_client front end, from the host (assume the name of the NFVbench container is "nfvbench"),
356 use the default NFVbench configuration but do not generate traffic (no_traffic property set to true, the full json result is truncated here):
357
358 .. code-block:: bash
359
360     [root@sjc04-pod3-mgmt ~]# docker exec -it nfvbench nfvbench_client -c '{"no_traffic":true}' http://127.0.0.1:7555
361     {u'status': u'PENDING', u'error_message': u'nfvbench run still pending'}
362     {u'status': u'PENDING', u'error_message': u'nfvbench run still pending'}
363     {u'status': u'PENDING', u'error_message': u'nfvbench run still pending'}
364
365     {u'status': u'OK', u'result': {u'date': u'2017-03-31 22:04:59', u'nfvbench_version': u'0.3.5',
366      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',
367      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},
368
369     ...
370
371     [root@sjc04-pod3-mgmt ~]#