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
5 NFVbench Server mode and NFVbench client API
6 ============================================
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)
21 curl -XGET '127.0.0.1:7556/echo' -H "Content-Type: application/json" -d '{"nfvbench": "test"}'
28 <http-url>/status (GET)
29 ^^^^^^^^^^^^^^^^^^^^^^^
31 This request fetches the status of an asynchronous run. It will return in json format:
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
37 The client can keep polling until the run completes.
39 Example of return when the run is still pending:
44 "error_message": "nfvbench run still pending",
48 Example of return when the run completes:
58 <http-url>/start_run (POST)
59 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
61 This request starts an NFVBench run with passed configurations. If no configuration is passed, a run with default configurations will be executed.
63 Example request: curl -XPOST 'localhost:7556/start_run' -H "Content-Type: application/json" -d @nfvbenchconfig.json
65 See "NFVbench configuration JSON parameter" below for details on how to format this parameter.
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:
73 "error_message": "NFVbench run still pending",
74 "request_id": "42cccb7effdc43caa47f722f0ca8ec96",
78 If there is already an NFVBench running then it will return:
83 "error_message": "there is already an NFVbench request running",
87 WebSocket/SocketIO events
88 -------------------------
90 List of SocketIO events supported:
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)
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}
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}
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}
123 sent by server to report the end of a run
124 the message contains the complete results in JSON format
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.
130 Default configuration
131 ^^^^^^^^^^^^^^^^^^^^^
133 The simplest JSON document is the empty dictionary "{}" which indicates to use the default NFVbench configuration:
136 - NDR-PDR measurement
138 - 1 flow per direction
140 The entire default configuration can be viewed using the --show-json-config option on the cli:
144 # nfvbench --show-config
146 "availability_zone": null,
147 "compute_node_user": "root",
148 "compute_nodes": null,
154 "hw:cpu_policy": "dedicated",
155 "hw:mem_page_size": 2048
160 "flavor_type": "nfv.medium",
162 "generic_poll_sec": 2,
163 "generic_retry_count": 100,
165 "internal_networks": {
167 "name": "nfvbench-net0",
168 "subnet": "nfvbench-subnet0",
169 "cidr": "192.168.1.0/24",
172 "name": "nfvbench-net1",
173 "subnet": "nfvbench-subnet1",
174 "cidr": "192.168.2.0/24",
177 "name": "nfvbench-net2",
178 "subnet": "nfvbench-subnet2",
179 "cidr": "192.168.3.0/24",
184 "loop_vm_name": "nfvbench-loop-vm",
190 "name": "(built-in default config)",
193 "openrc_file": "/tmp/nfvbench/openstack/openrc",
195 "service_chain": "PVP",
196 "service_chain_count": 1,
200 "bidirectional": true,
201 "profile": "traffic_profile_64B"
203 "traffic_generator": {
204 "default_profile": "trex-local",
205 "gateway_ip_addrs": [
209 "gateway_ip_addrs_step": "0.0.0.1",
210 "generator_profile": [
217 "switch_port": "Ethernet1/33",
223 "switch_port": "Ethernet1/34",
229 "name": "trex-local",
233 "host_name": "nfvbench_tg",
238 "ip_addrs_step": "0.0.0.1",
244 "tg_gateway_ip_addrs": [
248 "tg_gateway_ip_addrs_step": "0.0.0.1"
255 "name": "traffic_profile_64B"
261 "name": "traffic_profile_IMIX"
267 "name": "traffic_profile_1518B"
275 "name": "traffic_profile_3sizes"
278 "unidir_reverse_traffic_pps": 1,
279 "vlan_tagging": true,
283 Common examples of JSON configuration
284 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
286 Use the default configuration but use 10000 flows per direction (instead of 1):
290 { "flow_count": 10000 }
293 Use default confguration but with 10000 flows, "EXT" chain and IMIX packet size:
299 "service_chain": "EXT",
301 "profile": "traffic_profile_IMIX"
305 A short run of 5 seconds at a fixed rate of 1Mpps (and everything else same as the default configuration):
314 Use the default configuration but force TRex restart:
323 Example of interaction with the NFVbench server using HTTP and curl
324 -------------------------------------------------------------------
325 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).
327 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):
331 [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
333 "error_message": "nfvbench run still pending",
336 [root@sjc04-pod3-mgmt ~]#
338 This request will return immediately with status set to "PENDING" if the request was started successfully.
340 The status can be polled until the run completes. Here the poll returns a "PENDING" status, indicating the run is still not completed:
344 [root@sjc04-pod3-mgmt ~]# curl -G http://127.0.0.1:7555/status
346 "error_message": "nfvbench run still pending",
349 [root@sjc04-pod3-mgmt ~]#
351 Finally, the status request returns a "OK" status along with the full results (truncated here):
355 [root@sjc04-pod3-mgmt ~]# curl -G http://127.0.0.1:7555/status
363 "bidirectional": true,
365 "nova:sjc04-pod3-compute-4": {
367 "Adjacent Cache Line Prefetcher": "Disabled",
368 "All Onboard LOM Ports": "Enabled",
369 "All PCIe Slots OptionROM": "Enabled",
373 "date": "2017-03-31 22:15:41",
374 "nfvbench_version": "0.3.5",
382 [root@sjc04-pod3-mgmt ~]#
386 Example of interaction with the NFVbench server using a python CLI app (nfvbench_client)
387 ----------------------------------------------------------------------------------------
388 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.
390 The module client/nfvbench_client.py has a simple main application to control the NFVbench server from CLI.
391 The "nfvbench_client" wrapper script can be used to invoke the client front end (this wrapper is pre-installed in the NFVbench container)
393 Example of invocation of the nfvbench_client front end, from the host (assume the name of the NFVbench container is "nfvbench"),
394 use the default NFVbench configuration but do not generate traffic (no_traffic property set to true, the full json result is truncated here):
398 [root@sjc04-pod3-mgmt ~]# docker exec -it nfvbench nfvbench_client -c '{"no_traffic":true}' http://127.0.0.1:7555
399 {u'status': u'PENDING', u'error_message': u'nfvbench run still pending'}
400 {u'status': u'PENDING', u'error_message': u'nfvbench run still pending'}
401 {u'status': u'PENDING', u'error_message': u'nfvbench run still pending'}
403 {u'status': u'OK', u'result': {u'date': u'2017-03-31 22:04:59', u'nfvbench_version': u'0.3.5',
404 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',
405 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},
409 [root@sjc04-pod3-mgmt ~]#
411 The http interface is used unless --use-socketio is defined.
413 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.
417 [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