Merge "Improve SampleVNF hugepages setup"
[yardstick.git] / docs / testing / developer / devguide / devguide_nsb_prox.rst
1 Introduction
2 =============
3
4 This document describes the steps to create a new NSB PROX test based on
5 existing PROX functionalities. NSB PROX provides is a simple approximation
6 of an operation and can be used to develop best practices and TCO models
7 for Telco customers, investigate the impact of new Intel compute,
8 network and storage technologies, characterize performance, and develop
9 optimal system architectures and configurations.
10
11 .. contents::
12
13 Prerequisites
14 =============
15
16 In order to integrate PROX tests into NSB, the following prerequisites are required.
17
18 .. _`dpdk wiki page`: http://dpdk.org/
19 .. _`yardstick wiki page`: https://wiki.opnfv.org/display/yardstick/
20 .. _`Prox documentation`: https://01.org/intel-data-plane-performance-demonstrators/documentation/prox-documentation
21 .. _`openstack wiki page`: https://wiki.openstack.org/wiki/Main_Page
22 .. _`grafana getting started`: http://docs.grafana.org/guides/gettingstarted/
23 .. _`opnfv grafana dashboard`: https://wiki.opnfv.org/display/yardstick/How+to+work+with+grafana+dashboard
24 .. _`Prox command line`: https://01.org/intel-data-plane-performance-demonstrators/documentation/prox-documentation#Command_line_options
25 .. _`grafana deployment`: https://wiki.opnfv.org/display/yardstick/How+to+deploy+InfluxDB+and+Grafana+locally
26 .. _`Prox options`: https://01.org/intel-data-plane-performance-demonstrators/documentation/prox-documentation#.5Beal_options.5D
27 .. _`NSB Installation`: http://artifacts.opnfv.org/yardstick/docs/userguide/index.html#document-09-installation
28
29 * A working knowledge of Yardstick. See `yardstick wiki page`_.
30 * A working knowledge of PROX. See `Prox documentation`_.
31 * Knowledge of Openstack. See `openstack wiki page`_.
32 * Knowledge of how to use Grafana. See `grafana getting started`_.
33 * How to Deploy InfluxDB & Grafana. See `grafana deployment`_.
34 * How to use Grafana in OPNFV/Yardstick. See `opnfv grafana dashboard`_.
35 * How to install NSB. See `NSB Installation`_
36
37 Sample Prox Test Hardware Architecture
38 ======================================
39
40 The following is a diagram of a sample NSB PROX Hardware Architecture
41 for both NSB PROX on Bare metal and on Openstack.
42
43 In this example when running yardstick on baremetal, yardstick will
44 run on the deployment node, the generator will run on the deployment node
45 and the SUT(SUT) will run on the Controller Node.
46
47
48 .. image:: images/PROX_Hardware_Arch.png
49    :width: 800px
50    :alt: Sample NSB PROX Hard Architecture
51
52 Prox Test Architecture
53 ======================
54
55 In order to create a new test, one must understand the architecture of
56 the test.
57
58 A NSB Prox test architecture is composed of:
59
60 * A traffic generator. This provides blocks of data on 1 or more ports
61   to the SUT.
62   The traffic generator also consumes the result packets from the system
63   under test.
64 * A SUT consumes the packets generated by the packet
65   generator, and applies one or more tasks to the packets and return the
66   modified packets to the traffic generator.
67
68   This is an example of a sample NSB PROX test architecture.
69
70 .. image:: images/PROX_Software_Arch.png
71    :width: 800px
72    :alt: NSB PROX test Architecture
73
74 This diagram is of a sample NSB PROX test application.
75
76 * Traffic Generator
77
78   * Generator Tasks - Composted of 1 or more tasks (It is possible to
79     have multiple tasks sending packets to same port No. See Tasks Ai and Aii
80     plus Di and Dii)
81
82     * Task Ai - Generates Packets on Port 0 of Traffic Generator
83       and send to Port 0 of SUT Port 0
84     * Task Aii - Generates Packets on Port 0 of Traffic Generator
85       and send to Port 0 of SUT Port 0
86     * Task B - Generates Packets on Port 1 of Traffic Generator
87       and send to Port 1 of SUT Port 1
88     * Task C - Generates Packets on Port 2 of Traffic Generator
89       and send to Port 2 of SUT Port 2
90     * Task Di - Generates Packets on Port 3 of Traffic Generator
91       and send to Port 3 of SUT Port 3
92     * Task Dii - Generates Packets on Port 0 of Traffic Generator
93       and send to Port 0 of SUT Port 0
94
95   * Verifier Tasks - Composed of 1 or more tasks which receives
96     packets from SUT
97
98     * Task E - Receives packets on Port 0 of Traffic Generator sent
99       from Port 0 of SUT Port 0
100     * Task F - Receives packets on Port 1 of Traffic Generator sent
101       from Port 1 of SUT Port 1
102     * Task G - Receives packets on Port 2 of Traffic Generator sent
103       from Port 2 of SUT Port 2
104     * Task H - Receives packets on Port 3 of Traffic Generator sent
105       from Port 3 of SUT Port 3
106
107 * SUT
108
109   * Receiver Tasks - Receives packets from generator - Composed on 1 or
110     more tasks which consume the packs sent from Traffic Generator
111
112     * Task A - Receives Packets on Port 0 of System-Under-Test from
113       Traffic Generator Port 0, and forwards packets to Task E
114     * Task B - Receives Packets on Port 1 of System-Under-Test from
115       Traffic Generator Port 1, and forwards packets to Task E
116     * Task C - Receives Packets on Port 2 of System-Under-Test from
117       Traffic Generator Port 2, and forwards packets to Task E
118     * Task D - Receives Packets on Port 3 of System-Under-Test from
119       Traffic Generator Port 3, and forwards packets to Task E
120
121   * Processing Tasks - Composed of multiple tasks in series which carry
122     out some processing on received packets before forwarding to the
123     task.
124
125     * Task E - This receives packets from the Receiver Tasks,
126       carries out some operation on the data and forwards to result
127       packets to the next task in the sequence - Task F
128     * Task F - This receives packets from the previous Task - Task
129       E, carries out some operation on the data and forwards to result
130       packets to the next task in the sequence - Task G
131     * Task G - This receives packets from the previous Task - Task F
132       and distributes the result packages to the Transmitter tasks
133
134   * Transmitter Tasks - Composed on 1 or more tasks which send the
135     processed packets back to the Traffic Generator
136
137     * Task H - Receives Packets from Task G of System-Under-Test and
138       sends packets to Traffic Generator Port 0
139     * Task I - Receives Packets from Task G of System-Under-Test and
140       sends packets to Traffic Generator Port 1
141     * Task J - Receives Packets from Task G of System-Under-Test and
142       sends packets to Traffic Generator Port 2
143     * Task K - Receives Packets From Task G of System-Under-Test and
144       sends packets to Traffic Generator Port 3
145
146 NSB Prox Test
147 =============
148
149 A NSB Prox test is composed of the following components :-
150
151 * Test Description File. Usually called
152   ``tc_prox_<context>_<test>-<ports>.yaml`` where
153
154   * <context> is either ``baremetal`` or ``heat_context``
155   * <test> is the a one or 2 word description of the test.
156   * <ports> is the number of ports used
157
158   Example tests ``tc_prox_baremetal_l2fwd-2.yaml`` or
159   ``tc_prox_heat_context_vpe-4.yaml``. This file describes the components
160   of the test, in the case of openstack the network description and
161   server descriptions, in the case of baremetal the hardware
162   description location. It also contains the name of the Traffic Generator, the SUT config file
163   and the traffic profile description, all described below. See nsb-test-description-label_
164
165 * Traffic Profile file. Example ``prox_binsearch.yaml``. This describes the packet size, tolerated
166   loss, initial line rate to start traffic at, test interval etc See nsb-traffic-profile-label_
167
168 * Traffic Generator Config file. Usually called ``gen_<test>-<ports>.cfg``.
169
170   This describes the activity of the traffic generator
171
172   * What each core of the traffic generator does,
173   * The packet of data sent by a core on a port of the traffic generator
174     to the system under test
175   * What core is used to wait on what port for data from the system
176     under test.
177
178   Example traffic generator config file  ``gen_l2fwd-4.cfg``
179   See nsb-traffic-generator-label_
180
181 * SUT Config file. Usually called ``handle_<test>-<ports>.cfg``.
182
183   This describes the activity of the SUTs
184
185   * What each core of the  does,
186   * What cores receives packets from what ports
187   * What cores perform operations on the packets and pass the packets onto
188     another core
189   * What cores receives packets from what cores and transmit the packets on
190     the ports to the Traffic Verifier tasks of the Traffic Generator.
191
192   Example traffic generator config file  ``handle_l2fwd-4.cfg``
193   See nsb-sut-generator-label_
194
195 * NSB PROX Baremetal Configuration file. Usually called
196   ``prox-baremetal-<ports>.yaml``
197
198   * <ports> is the number of ports used
199
200   This is required for baremetal only.  This describes hardware, NICs,
201   IP addresses, Network drivers, usernames and passwords.
202   See baremetal-config-label_
203
204 * Grafana Dashboard. Usually called
205   ``Prox_<context>_<test>-<port>-<DateAndTime>.json`` where
206
207   * <context> Is either ``BM`` or ``heat``
208   * <test> Is the a one or 2 word description of the test.
209   * <port> is the number of ports used express as ``2Port`` or ``4Port``
210   * <DateAndTime> is the Date and Time expressed as a string.
211
212   Example grafana dashboard ``Prox_BM_L2FWD-4Port-1507804504588.json``
213
214 Other files may be required. These are test specific files and will be
215 covered later.
216
217 .. _nsb-test-description-label:
218
219 **Test Description File**
220
221 Here we will discuss the test description for both
222 baremetal and openstack.
223
224 *Test Description File for Baremetal*
225 -------------------------------------
226
227 This section will introduce the meaning of the Test case description
228 file. We will use ``tc_prox_baremetal_l2fwd-2.yaml`` as an example to
229 show you how to understand the test description file.
230
231 .. image:: images/PROX_Test_BM_Script.png
232    :width: 800px
233    :alt: NSB PROX Test Description File
234
235 Now let's examine the components of the file in detail
236
237 1. ``traffic_profile`` - This specifies the traffic profile for the
238    test. In this case ``prox_binsearch.yaml`` is used. See nsb-traffic-profile-label_
239
240 2. ``topology`` - This is either ``prox-tg-topology-1.yaml`` or
241     ``prox-tg-topology-2.yaml`` or ``prox-tg-topology-4.yaml``
242     depending on number of ports required.
243
244 3. ``nodes`` - This names the Traffic Generator and the System
245    under Test. Does not need to change.
246
247 4. ``prox_path`` - Location of the Prox executable on the traffic
248    generator (Either baremetal or Openstack Virtual Machine)
249
250 5. ``prox_config`` - This is the ``SUT Config File``.
251    In this case it is ``handle_l2fwd-2.cfg``
252
253    A number of additional parameters can be added. This example
254    is taken from VPE::
255
256     options:
257       vnf__0:
258         prox_path: /opt/nsb_bin/prox
259         prox_config: ``configs/handle_vpe-4.cfg``
260         prox_args:
261           ``-t``: ````
262         prox_files:
263           ``configs/vpe_ipv4.lua`` : ````
264           ``configs/vpe_dscp.lua`` : ````
265           ``configs/vpe_cpe_table.lua`` : ````
266           ``configs/vpe_user_table.lua`` : ````
267           ``configs/vpe_rules.lua`` : ````
268         prox_generate_parameter: True
269
270    ``prox_files`` - this specified that a number of addition files
271    need to be provided for the test to run correctly. This files
272    could provide routing information,hashing information or a
273    hashing algorithm and ip/mac information.
274
275    ``prox_generate_parameter`` - this specifies that the NSB application
276    is required to provide information to the nsb Prox in the form
277    of a file called ``parameters.lua``, which contains information
278    retrieved from either the hardware or the openstack configuration.
279
280 6. ``prox_args`` - this specifies the command line arguments to start
281    prox. See `prox command line`_.
282
283 7. ``prox_config`` - This specifies the Traffic Generator config file.
284
285 8. ``runner`` - This is set to ``Duration`` - This specified that the
286    test run for a set duration. Other runner types are available
287    but it is recommend to use ``Duration``
288
289 9. ``context`` - This is ``context`` for a 2 port Baremetal configuration.
290    If a 4 port configuration was required then file
291    ``prox-baremetal-4.yaml`` would be used. This is the NSB Prox
292    baremetal configuration file.
293
294 .. _nsb-traffic-profile-label:
295
296 *Traffic Profile file*
297 ----------------------
298
299 This describes the details of the traffic flow. In this case ``prox_binsearch.yaml`` is used.
300
301 .. image:: images/PROX_Traffic_profile.png
302    :width: 800px
303    :alt: NSB PROX Traffic Profile
304
305
306 1. ``name`` - The name of the traffic profile. This name should match the name specified in the
307    ``traffic_profile`` field in the Test Description File.
308
309 2. ``traffic_type`` - This specifies the type of traffic pattern generated, This name matches
310    class name of the traffic generator See::
311
312       network_services/traffic_profile/prox_binsearch.py class ProxBinSearchProfile(ProxProfile)
313
314    In this case it lowers the traffic rate until the number of packets
315    sent is equal to the number of packets received (plus a
316    tolerated loss). Once it achieves this it increases the traffic
317    rate in order to find the highest rate with no traffic loss.
318
319    Custom traffic types can be created by creating a new traffic profile class.
320
321 3. ``tolerated_loss`` - This specifies the percentage of packets that can be lost/dropped before
322    we declare success or failure. Success is Transmitted-Packets from Traffic Generator is greater than or equal to
323    packets received by Traffic Generator plus tolerated loss.
324
325 4. ``test_precision`` - This specifies the precision of the test results. For some tests the success criteria
326    may never be achieved because the test precision may be greater than the successful throughput. For finer
327    results increase the precision by making this value smaller.
328
329 5. ``packet_sizes`` - This specifies the range of packets size this test is run for.
330
331 6. ``duration`` - This specifies the sample duration that the test uses to check for success or failure.
332
333 7. ``lower_bound`` - This specifies the test initial lower bound sample rate. On success this value is increased.
334
335 8. ``upper_bound`` - This specifies the test initial upper bound sample rate. On success this value is decreased.
336
337 Other traffic profiles exist eg prox_ACL.yaml which does not
338 compare what is received with what is transmitted. It just
339 sends packet at max rate.
340
341 It is possible to create custom traffic profiles with by
342 creating new file in the same folder as prox_binsearch.yaml.
343 See this prox_vpe.yaml as example::
344
345      schema: ``nsb:traffic_profile:0.1``
346
347      name:            prox_vpe
348      description:     Prox vPE traffic profile
349
350      traffic_profile:
351        traffic_type: ProxBinSearchProfile
352        tolerated_loss: 100.0 #0.001
353        test_precision: 0.01
354      # The minimum size of the Ethernet frame for the vPE test is 68 bytes.
355        packet_sizes: [68]
356        duration: 5
357        lower_bound: 0.0
358        upper_bound: 100.0
359
360 *Test Description File for Openstack*
361 -------------------------------------
362
363 We will use ``tc_prox_heat_context_l2fwd-2.yaml`` as a example to show
364 you how to understand the test description file.
365
366 .. image:: images/PROX_Test_HEAT_Script.png
367    :width: 800px
368    :alt: NSB PROX Test Description File
369
370 Now lets examine the components of the file in detail
371
372 Sections 1 to 8 are exactly the same in Baremetal and in Heat. Section
373 ``9`` is replaced with sections A to F. Section 9 was for a baremetal
374 configuration file. This has no place in a heat configuration.
375
376 A. ``image`` - yardstick-samplevnfs. This is the name of the image
377    created during the installation of NSB. This is fixed.
378
379 B. ``flavor`` - The flavor is created dynamically. However we could
380    use an already existing flavor if required. In that case the
381    flavor would be named::
382
383     flavor: yardstick-flavor
384
385 C. ``extra_specs`` - This allows us to specify the number of
386    cores sockets and hyperthreading assigned to it. In this case
387    we have 1 socket with 10 codes and no hyperthreading enabled.
388
389 D. ``placement_groups`` - default. Do not change for NSB PROX.
390
391 E. ``servers`` - ``tg_0`` is the traffic generator and ``vnf_0``
392    is the system under test.
393
394 F. ``networks`` - is composed of a management network labeled ``mgmt``
395    and one uplink network labeled ``uplink_0``  and one downlink
396    network labeled ``downlink_0`` for 2 ports. If this was a 4 port
397    configuration there would be 2 extra downlink ports. See this
398    example from a 4 port l2fwd test.::
399
400     networks:
401       mgmt:
402         cidr: '10.0.1.0/24'
403       uplink_0:
404         cidr: '10.0.2.0/24'
405         gateway_ip: 'null'
406         port_security_enabled: False
407         enable_dhcp: 'false'
408       downlink_0:
409         cidr: '10.0.3.0/24'
410         gateway_ip: 'null'
411         port_security_enabled: False
412         enable_dhcp: 'false'
413       downlink_1:
414         cidr: '10.0.4.0/24'
415         gateway_ip: 'null'
416         port_security_enabled: False
417         enable_dhcp: 'false'
418       downlink_2:
419         cidr: '10.0.5.0/24'
420         gateway_ip: 'null'
421         port_security_enabled: False
422         enable_dhcp: 'false'
423
424 .. _nsb-traffic-generator-label:
425
426 *Traffic Generator Config file*
427 -------------------------------
428
429 This section will describe the traffic generator config file.
430 This is the same for both baremetal and heat. See this example
431 of ``gen_l2fwd_multiflow-2.cfg`` to explain the options.
432
433 .. image:: images/PROX_Gen_2port_cfg.png
434    :width: 1400px
435    :alt: NSB PROX Gen Config File
436
437 The configuration file is divided into multiple sections, each
438 of which is used to define some parameters and options.::
439
440   [eal options]
441   [variables]
442   [port 0]
443   [port 1]
444   [port .]
445   [port Z]
446   [defaults]
447   [global]
448   [core 0]
449   [core 1]
450   [core 2]
451   [core .]
452   [core Z]
453
454 See `prox options`_ for details
455
456 Now let's examine the components of the file in detail
457
458 1. ``[eal options]`` - This specified the EAL (Environmental
459    Abstraction Layer) options. These are default values and
460    are not changed. See `dpdk wiki page`_.
461
462 2. ``[variables]`` - This section contains variables, as
463    the name suggests. Variables for Core numbers, mac
464    addresses, ip addresses etc. They are assigned as a
465    ``key = value`` where the key is used in place of the value.
466
467    .. caution::
468      A special case for valuables with a value beginning with
469      ``@@``. These values are dynamically updated by the NSB
470      application at run time. Values like MAC address,
471      IP Address etc.
472
473 3. ``[port 0]`` - This section describes the DPDK Port. The number
474    following the keyword ``port`` usually refers to the DPDK Port
475    Id. usually starting from ``0``. Because you can have multiple
476    ports this entry usually repeated. Eg. For a 2 port setup
477    ``[port0]`` and ``[port 1]`` and for a 4 port setup ``[port 0]``,
478    ``[port 1]``, ``[port 2]`` and ``[port 3]``::
479
480       [port 0]
481       name=p0
482       mac=hardware
483       rx desc=2048
484       tx desc=2048
485       promiscuous=yes
486
487    a. In this example ``name = p0`` assigned the name ``p0`` to the
488       port. Any name can be assigned to a port.
489    b. ``mac=hardware`` sets the MAC address assigned by the hardware
490       to data from this port.
491    c. ``rx desc=2048`` sets the number of available descriptors to
492       allocate for receive packets. This can be changed and can
493       effect performance.
494    d. ``tx desc=2048`` sets the number of available descriptors to
495       allocate for transmit packets. This can be changed and can
496       effect performance.
497    e. ``promiscuous=yes`` this enables promiscuous mode for this port.
498
499 4. ``[defaults]`` - Here default operations and settings can be over
500    written. In this example ``mempool size=4K`` the number of mbufs
501    per task is altered. Altering this value could effect
502    performance. See `prox options`_ for details.
503
504 5. ``[global]`` - Here application wide setting are supported. Things
505    like application name, start time, duration and memory
506    configurations can be set here. In this example.::
507
508       [global]
509       start time=5
510       name=Basic Gen
511
512     a. ``start time=5`` Time is seconds after which average
513        stats will be started.
514     b. ``name=Basic Gen`` Name of the configuration.
515
516 6. ``[core 0]`` - This core is designated the master core. Every
517    Prox application must have a master core. The master mode must
518    be assigned to exactly one task, running alone on one core.::
519
520     [core 0]
521     mode=master
522
523 7. ``[core 1]`` - This describes the activity on core 1. Cores can
524    be configured by means of a set of [core #] sections, where
525    # represents either:
526
527    a. an absolute core number: e.g. on a 10-core, dual socket
528       system with hyper-threading,
529       cores are numbered from 0 to 39.
530
531    b. PROX allows a core to be identified by a core number, the
532       letter 's', and a socket number.
533
534       It is possible to write a baremetal and an openstack test which use
535       the same traffic generator config file and SUT config file.
536       In this case it is advisable not to use physical
537       core numbering.
538
539       However it is also possible to write NSB Prox tests that
540       have been optimized for a particular hardware configuration.
541       In this case it is advisable to use the core numbering.
542       It is up to the user to make sure that cores from
543       the right sockets are used (i.e. from the socket on which the NIC
544       is attached to), to ensure good performance (EPA).
545
546    Each core can be assigned with a set of tasks, each running
547    one of the implemented packet processing modes.::
548
549      [core 1]
550      name=p0
551      task=0
552      mode=gen
553      tx port=p0
554      bps=1250000000
555      ; Ethernet + IP + UDP
556      pkt inline=${sut_mac0} 70 00 00 00 00 01 08 00 45 00 00 1c 00 01 00 00 40 11 f7 7d 98 10 64 01 98 10 64 02 13 88 13 88 00 08 55 7b
557      ; src_ip: 152.16.100.0/8
558      random=0000XXX1
559      rand_offset=29
560      ; dst_ip: 152.16.100.0/8
561      random=0000XXX0
562      rand_offset=33
563      random=0001001110001XXX0001001110001XXX
564      rand_offset=34
565
566    a. ``name=p0`` - Name assigned to the core.
567    b. ``task=0`` - Each core can run a set of tasks. Starting with ``0``.
568       Task 1 can be defined later in this core or
569       can be defined in another ``[core 1]`` section with ``task=1``
570       later in configuration file. Sometimes running
571       multiple task related to the same packet on the same physical
572       core improves performance, however sometimes it
573       is optimal to move task to a separate core. This is best
574       decided by checking performance.
575    c. ``mode=gen`` - Specifies the action carried out by this task on
576       this core. Supported modes are: classify, drop, gen, lat, genl4, nop, l2fwd, gredecap,
577       greencap, lbpos, lbnetwork, lbqinq, lb5tuple, ipv6_decap, ipv6_encap,
578       qinqdecapv4, qinqencapv4, qos, routing, impair,
579       mirror, unmpls, tagmpls, nat, decapnsh, encapnsh, police, acl
580       Which are :-
581
582        * Classify
583        * Drop
584        * Basic Forwarding (no touch)
585        * L2 Forwarding (change MAC)
586        * GRE encap/decap
587        * Load balance based on packet fields
588        * Symmetric load balancing
589        * QinQ encap/decap IPv4/IPv6
590        * ARP
591        * QoS
592        * Routing
593        * Unmpls
594        * Nsh encap/decap
595        * Policing
596        * ACL
597
598       In the traffic generator we expect a core to generate packets (``gen``)
599       and to receive packets & calculate latency (``lat``)
600       This core does ``gen`` . ie it is a traffic generator.
601
602       To understand what each of the modes support please see
603       `prox documentation`_.
604
605    d. ``tx port=p0`` - This specifies that the packets generated are
606       transmitted to port ``p0``
607    e. ``bps=1250000000`` - This indicates Bytes Per Second to
608       generate packets.
609    f. ``; Ethernet + IP + UDP`` - This is a comment. Items starting with
610       ``;`` are ignored.
611    g. ``pkt inline=${sut_mac0} 70 00 00 00 ...`` - Defines the packet
612       format as a sequence of bytes (each
613       expressed in hexadecimal notation). This defines the packet
614       that is generated. This packets begins
615       with the hexadecimal sequence assigned to ``sut_mac`` and the
616       remainder of the bytes in the string.
617       This packet could now be sent or modified by ``random=..``
618       described below before being sent to target.
619    h. ``; src_ip: 152.16.100.0/8`` - Comment
620    i. ``random=0000XXX1`` - This describes a field of the packet
621       containing random data. This string can be
622       8,16,24 or 32 character long and represents 1,2,3 or 4
623       bytes of data. In this case it describes a byte of
624       data. Each character in string can be 0,1 or ``X``. 0 or 1
625       are fixed bit values in the data packet and ``X`` is a
626       random bit. So random=0000XXX1 generates 00000001(1),
627       00000011(3), 00000101(5), 00000111(7),
628       00001001(9), 00001011(11), 00001101(13) and 00001111(15)
629       combinations.
630    j. ``rand_offset=29`` - Defines where to place the previously
631       defined random field.
632    k. ``; dst_ip: 152.16.100.0/8`` - Comment
633    l. ``random=0000XXX0`` - This is another random field which
634       generates a byte of 00000000(0), 00000010(2),
635       00000100(4), 00000110(6), 00001000(8), 00001010(10),
636       00001100(12) and 00001110(14) combinations.
637    m. ``rand_offset=33`` - Defines where to place the previously
638       defined random field.
639    n. ``random=0001001110001XXX0001001110001XXX`` - This is
640       another random field which generates 4 bytes.
641    o. ``rand_offset=34`` - Defines where to place the previously
642       defined 4 byte random field.
643
644    Core 2 executes same scenario as Core 1. The only difference
645    in this case is that the packets are generated
646    for Port 1.
647
648 8. ``[core 3]`` - This defines the activities on core 3. The purpose
649    of ``core 3`` and ``core 4`` is to receive packets
650    sent by the SUT.::
651
652      [core 3]
653      name=rec 0
654      task=0
655      mode=lat
656      rx port=p0
657      lat pos=42
658
659    a. ``name=rec 0`` - Name assigned to the core.
660    b. ``task=0`` - Each core can run a set of tasks. Starting with
661       ``0``. Task 1 can be defined later in this core or
662       can be defined in another ``[core 1]`` section with
663       ``task=1`` later in configuration file. Sometimes running
664       multiple task related to the same packet on the same
665       physical core improves performance, however sometimes it
666       is optimal to move task to a separate core. This is
667       best decided by checking performance.
668    c. ``mode=lat`` - Specifies the action carried out by this task on this core. Supported modes are: acl,
669       classify, drop, gredecap, greencap, ipv6_decap, ipv6_encap, l2fwd, lbnetwork, lbpos, lbqinq, nop,
670       police, qinqdecapv4, qinqencapv4, qos, routing, impair, lb5tuple, mirror, unmpls, tagmpls,
671       nat, decapnsh, encapnsh, gen, genl4 and lat. This task(0) per core(3) receives packets on port.
672    d. ``rx port=p0`` - The port to receive packets on ``Port 0``. Core 4 will receive packets on ``Port 1``.
673    e. ``lat pos=42`` - Describes where to put a 4-byte timestamp in the packet. Note that the packet length should
674       be longer than ``lat pos`` + 4 bytes to avoid truncation of the timestamp. It defines where the timestamp is
675       to be read from. Note that the SUT workload might cause the position of the timestamp to change
676       (i.e. due to encapsulation).
677
678 .. _nsb-sut-generator-label:
679
680 *SUT Config file*
681 -------------------------------
682
683 This section will describes the SUT(VNF) config file. This is the same for both
684 baremetal and heat. See this example of ``handle_l2fwd_multiflow-2.cfg`` to explain the options.
685
686 .. image:: images/PROX_Handle_2port_cfg.png
687    :width: 1400px
688    :alt: NSB PROX Handle Config File
689
690 See `prox options`_ for details
691
692 Now let's examine the components of the file in detail
693
694 1. ``[eal options]`` - same as the Generator config file. This specified the EAL (Environmental Abstraction Layer)
695    options. These are default values and are not changed.
696    See `dpdk wiki page`_.
697
698 2. ``[port 0]`` - This section describes the DPDK Port. The number following the keyword ``port`` usually refers to the DPDK Port Id. usually starting from ``0``.
699    Because you can have multiple ports this entry usually repeated. Eg. For a 2 port setup ``[port0]`` and ``[port 1]`` and for a 4 port setup ``[port 0]``, ``[port 1]``,
700    ``[port 2]`` and ``[port 3]``::
701
702       [port 0]
703       name=if0
704       mac=hardware
705       rx desc=2048
706       tx desc=2048
707       promiscuous=yes
708
709    a. In this example ``name =if0`` assigned the name ``if0`` to the port. Any name can be assigned to a port.
710    b. ``mac=hardware`` sets the MAC address assigned by the hardware to data from this port.
711    c. ``rx desc=2048`` sets the number of available descriptors to allocate for receive packets. This can be changed and can effect performance.
712    d. ``tx desc=2048`` sets the number of available descriptors to allocate for transmit packets. This can be changed and can effect performance.
713    e. ``promiscuous=yes`` this enables promiscuous mode for this port.
714
715 3. ``[defaults]`` - Here default operations and settings can be over written.::
716
717      [defaults]
718      mempool size=8K
719      memcache size=512
720
721    a. In this example ``mempool size=8K`` the number of mbufs per task is altered. Altering this value could effect performance. See `prox options`_ for details.
722    b. ``memcache size=512`` - number of mbufs cached per core, default is 256 this is the cache_size. Altering this value could effect performance.
723
724 4. ``[global]`` - Here application wide setting are supported. Things like application name, start time, duration and memory configurations can be set here.
725    In this example.::
726
727       [global]
728       start time=5
729       name=Basic Gen
730
731     a. ``start time=5`` Time is seconds after which average stats will be started.
732     b. ``name=Handle L2FWD Multiflow (2x)`` Name of the configuration.
733
734 5. ``[core 0]`` - This core is designated the master core. Every Prox application must have a master core. The master mode must be assigned to
735    exactly one task, running alone on one core.::
736
737     [core 0]
738     mode=master
739
740 6. ``[core 1]`` - This describes the activity on core 1. Cores can be configured by means of a set of [core #] sections,   where # represents either:
741
742    a. an absolute core number: e.g. on a 10-core, dual socket system with hyper-threading,
743       cores are numbered from 0 to 39.
744
745    b. PROX allows a core to be identified by a core number, the letter 's', and a socket number.
746       However NSB PROX is hardware agnostic (physical and virtual configurations are the same) it
747       is advisable no to use physical core numbering.
748
749    Each core can be assigned with a set of tasks, each running one of the implemented packet processing modes.::
750
751      [core 1]
752      name=none
753      task=0
754      mode=l2fwd
755      dst mac=@@tester_mac1
756      rx port=if0
757      tx port=if1
758
759    a. ``name=none`` - No name assigned to the core.
760    b. ``task=0`` - Each core can run a set of tasks. Starting with ``0``. Task 1 can be defined later in this core or
761       can be defined in another ``[core 1]`` section with ``task=1`` later in configuration file. Sometimes running
762       multiple task related to the same packet on the same physical core improves performance, however sometimes it
763       is optimal to move task to a separate core. This is best decided by checking performance.
764    c. ``mode=l2fwd`` - Specifies the action carried out by this task on this core. Supported modes are: acl,
765       classify, drop, gredecap, greencap, ipv6_decap, ipv6_encap, l2fwd, lbnetwork, lbpos, lbqinq, nop,
766       police, qinqdecapv4, qinqencapv4, qos, routing, impair, lb5tuple, mirror, unmpls, tagmpls,
767       nat, decapnsh, encapnsh, gen, genl4 and lat. This code does ``l2fwd`` .. ie it does the L2FWD.
768
769    d. ``dst mac=@@tester_mac1`` - The destination mac address of the packet will be set to the MAC address of ``Port 1`` of destination device. (The Traffic Generator/Verifier)
770    e. ``rx port=if0`` - This specifies that the packets are received from ``Port 0`` called if0
771    f. ``tx port=if1`` - This specifies that the packets are transmitted to ``Port 1``  called if1
772
773    If this example we receive a packet on core on a port, carry out operation on the packet on the core and transmit it on on another port still using the same task on the same core.
774
775    On some implementation you may wish to use multiple tasks, like this.::
776
777      [core 1]
778      name=rx_task
779      task=0
780      mode=l2fwd
781      dst mac=@@tester_p0
782      rx port=if0
783      tx cores=1t1
784      drop=no
785
786      name=l2fwd_if0
787      task=1
788      mode=nop
789      rx ring=yes
790      tx port=if0
791      drop=no
792
793    In this example you can see Core 1/Task 0 called ``rx_task`` receives the packet from if0 and perform the l2fwd. However instead of sending the packet to a
794    port it sends it to a core see ``tx cores=1t1``. In this case it sends it to Core 1/Task 1.
795
796    Core 1/Task 1 called ``l2fwd_if0``, receives the packet, not from a port but from the ring. See ``rx ring=yes``. It does not perform any operation on the packet See ``mode=none``
797    and sends the packets to ``if0`` see ``tx port=if0``.
798
799    It is also possible to implement more complex operations be chaining multiple operations in sequence and using rings to pass packets from one core to another.
800
801    In thus example we show a Broadband Network Gateway (BNG) with Quality of Service (QoS).  Communication from task to task is via rings.
802
803    .. image:: images/PROX_BNG_QOS.png
804       :width: 1000px
805       :alt: NSB PROX Config File for BNG_QOS
806
807 *Baremetal Configuration file*
808 ------------------------------
809
810 .. _baremetal-config-label:
811
812 This is required for baremetal testing. It describes the IP address of the various ports, the Network devices drivers and MAC addresses and the network
813 configuration.
814
815 In this example we will describe a 2 port configuration. This file is the same for all 2 port NSB Prox tests on the same platforms/configuration.
816
817   .. image:: images/PROX_Baremetal_config.png
818      :width: 1000px
819      :alt: NSB PROX Yardstick Config
820
821 Now lets describe the sections of the file.
822
823   1. ``TrafficGen`` - This section describes the Traffic Generator node of the test configuration. The name of the node ``trafficgen_1`` must match the node name
824      in the ``Test Description File for Baremetal`` mentioned earlier. The password attribute of the test needs to be configured. All other parameters
825      can remain as default settings.
826   2. ``interfaces`` - This defines the DPDK interfaces on the Traffic Generator.
827   3. ``xe0`` is DPDK Port 0. ``lspci`` and `` ./dpdk-devbind.py -s`` can be used to provide the interface information. ``netmask`` and ``local_ip`` should not be changed
828   4. ``xe1`` is DPDK Port 1. If more than 2 ports are required then ``xe1`` section needs to be repeated and modified accordingly.
829   5. ``vnf`` - This section describes the SUT of the test configuration. The name of the node ``vnf`` must match the node name in the
830      ``Test Description File for Baremetal`` mentioned earlier. The password attribute of the test needs to be configured. All other parameters
831      can remain as default settings
832   6. ``interfaces`` - This defines the DPDK interfaces on the SUT
833   7. ``xe0`` - Same as 3 but for the ``SUT``.
834   8. ``xe1`` - Same as 4 but for the ``SUT`` also.
835   9. ``routing_table`` - All parameters should remain unchanged.
836   10. ``nd_route_tbl`` - All parameters should remain unchanged.
837
838 *Grafana Dashboard*
839 -------------------
840
841 The grafana dashboard visually displays the results of the tests. The steps required to produce a grafana dashboard are described here.
842
843 .. _yardstick-config-label:
844
845   a. Configure ``yardstick`` to use influxDB to store test results. See file ``/etc/yardstick/yardstick.conf``.
846
847      .. image:: images/PROX_Yardstick_config.png
848         :width: 1000px
849         :alt: NSB PROX Yardstick Config
850
851      1. Specify the dispatcher to use influxDB to store results.
852      2. "target = .. " - Specify location of influxDB to store results.
853         "db_name = yardstick" - name of database. Do not change
854         "username = root" - username to use to store result. (Many tests are run as root)
855         "password = ... " - Please set to root user password
856
857   b. Deploy InfludDB & Grafana. See how to Deploy InfluxDB & Grafana. See `grafana deployment`_.
858   c. Generate the test data. Run the tests as follows .::
859
860        yardstick --debug task start tc_prox_<context>_<test>-ports.yaml
861
862      eg.::
863
864        yardstick --debug task start tc_prox_heat_context_l2fwd-4.yaml
865
866   d. Now build the dashboard for the test you just ran. The easiest way to do this is to copy an existing dashboard and rename the
867      test and the field names. The procedure to do so is described here. See `opnfv grafana dashboard`_.
868
869 How to run NSB Prox Test on an baremetal environment
870 ====================================================
871
872 In order to run the NSB PROX test.
873
874   1. Install NSB on Traffic Generator node and Prox in SUT. See `NSB Installation`_
875
876   2. To enter container::
877
878        docker exec -it yardstick /bin/bash
879
880   3. Install baremetal configuration file (POD files)
881
882      a. Go to location of PROX tests in container ::
883
884           cd /home/opnfv/repos/yardstick/samples/vnf_samples/nsut/prox
885
886      b. Install prox-baremetal-2.yam and prox-baremetal-4.yaml for that topology
887         into this directory as per baremetal-config-label_
888
889      c. Install and configure ``yardstick.conf`` ::
890
891             cd /etc/yardstick/
892
893         Modify /etc/yardstick/yardstick.conf as per yardstick-config-label_
894
895   4. Execute the test. Eg.::
896
897         yardstick --debug task start ./tc_prox_baremetal_l2fwd-4.yaml
898
899 How to run NSB Prox Test on an Openstack environment
900 ====================================================
901
902 In order to run the NSB PROX test.
903
904   1. Install NSB on Openstack deployment node. See  `NSB Installation`_
905
906   2. To enter container::
907
908        docker exec -it yardstick /bin/bash
909
910   3. Install configuration file
911
912      a. Goto location of PROX tests in container ::
913
914           cd /home/opnfv/repos/yardstick/samples/vnf_samples/nsut/prox
915
916      b. Install and configure ``yardstick.conf`` ::
917
918             cd /etc/yardstick/
919
920         Modify /etc/yardstick/yardstick.conf as per yardstick-config-label_
921
922
923   4. Execute the test. Eg.::
924
925         yardstick --debug task start ./tc_prox_heat_context_l2fwd-4.yaml
926
927 Frequently Asked Questions
928 ==========================
929
930 Here is a list of frequently asked questions.
931
932 *NSB Prox does not work on Baremetal, How do I resolve this?*
933 -------------------------------------------------------------
934
935 If PROX NSB does not work on baremetal, problem is either in network configuration or test file.
936
937 *Solution*
938
939 1. Verify network configuration. Execute existing baremetal test.::
940
941        yardstick --debug task start ./tc_prox_baremetal_l2fwd-4.yaml
942
943    If test does not work then error in network configuration.
944
945       a. Check DPDK on Traffic Generator and SUT via:- ::
946
947            /root/dpdk-17./usertools/dpdk-devbind.py
948
949       b. Verify MAC addresses match ``prox-baremetal-<ports>.yaml`` via ``ifconfig`` and ``dpdk-devbind``
950
951       c. Check your eth port is what you expect. You would not be the first person to think that
952          the port your cable is plugged into is ethX when in fact it is ethY. Use
953          ethtool to visually confirm that the eth is where you expect.::
954
955             ethtool -p ethX
956
957          A led should start blinking on port. (On both System-Under-Test and Traffic Generator)
958
959       d. Check cable.
960
961          Install Linux kernel network driver and ensure your ports are
962          ``bound`` to the driver via ``dpdk-devbind``. Bring up port on both
963          SUT and Traffic Generator and check connection.
964
965          i) On SUT and on Traffic Generator::
966
967               ifconfig ethX/enoX up
968
969          ii) Check link
970
971                ethtool ethX/enoX
972
973              See ``Link detected`` if ``yes`` .... Cable is good. If ``no`` you have an issue with your cable/port.
974
975 2. If existing baremetal works then issue is with your test. Check the traffic generator gen_<test>-<ports>.cfg to ensure
976    it is producing a valid packet.
977
978 *How do I debug NSB Prox on Baremetal?*
979 ---------------------------------------
980
981 *Solution*
982
983 1. Execute the test as follows::
984
985      yardstick --debug task start ./tc_prox_baremetal_l2fwd-4.yaml
986
987 2. Login to Traffic Generator as ``root``.::
988
989      cd
990      /opt/nsb_bin/prox -f /tmp/gen_<test>-<ports>.cfg
991
992 3. Login to SUT as ``root``.::
993
994      cd
995      /opt/nsb_bin/prox -f /tmp/handle_<test>-<ports>.cfg
996
997 4. Now let's examine the Generator Output. In this case the output of gen_l2fwd-4.cfg.
998
999      .. image:: images/PROX_Gen_GUI.png
1000         :width: 1000px
1001         :alt: NSB PROX Traffic Generator GUI
1002
1003    Now let's examine the output
1004
1005      1. Indicates the amount of data successfully transmitted on Port 0
1006      2. Indicates the amount of data successfully received on port 1
1007      3. Indicates the amount of data successfully handled for port 1
1008
1009    It appears what is transmitted is received.
1010
1011    .. Caution::
1012       The number of packets MAY not exactly match because the ports are read in sequence.
1013
1014    .. Caution::
1015       What is transmitted on PORT X may not always be received on same port. Please check the Test scenario.
1016
1017 5. Now lets examine the SUT Output
1018
1019      .. image:: images/PROX_SUT_GUI.png
1020         :width: 1400px
1021         :alt: NSB PROX SUT GUI
1022
1023    Now lets examine the output
1024
1025      1. What is received on 0 is transmitted on 1, received on 1 transmitted on 0,
1026         received on 2 transmitted on 3 and received on 3 transmitted on 2.
1027      2. No packets are Failed.
1028      3. No Packets are discarded.
1029
1030   We can also dump the packets being received or transmitted via the following commands. ::
1031
1032        dump                   Arguments: <core id> <task id> <nb packets>
1033                               Create a hex dump of <nb_packets> from <task_id> on <core_id> showing how
1034                               packets have changed between RX and TX.
1035        dump_rx                Arguments: <core id> <task id> <nb packets>
1036                               Create a hex dump of <nb_packets> from <task_id> on <core_id> at RX
1037        dump_tx                Arguments: <core id> <task id> <nb packets>
1038                               Create a hex dump of <nb_packets> from <task_id> on <core_id> at TX
1039
1040   eg.::
1041
1042        dump_tx 1 0 1
1043
1044 *NSB Prox works on Baremetal but not in Openstack. How do I resolve this?*
1045 --------------------------------------------------------------------------
1046
1047 NSB Prox on Baremetal is a lot more forgiving than NSB Prox on Openstack. A badly
1048 formed packed may still work with PROX on Baremetal. However on
1049 Openstack the packet must be correct and all fields of the header correct.
1050 Eg A packet with an invalid Protocol ID would still work in Baremetal
1051 but this packet would be rejected by openstack.
1052
1053 *Solution*
1054
1055  1. Check the validity of the packet.
1056  2. Use a known good packet in your test
1057  3. If using ``Random`` fields in the traffic generator, disable them and retry.
1058
1059
1060 *How do I debug NSB Prox on Openstack?*
1061 ---------------------------------------
1062
1063 *Solution*
1064
1065 1. Execute the test as follows::
1066
1067      yardstick --debug task start --keep-deploy ./tc_prox_heat_context_l2fwd-4.yaml
1068
1069 2. Access docker image if required via::
1070
1071       docker exec -it yardstick /bin/bash
1072
1073 3. Install openstack credentials.
1074
1075    Depending on your openstack deployment, the location of these credentials may vary.
1076    On this platform I do this via::
1077
1078      scp root@10.237.222.55:/etc/kolla/admin-openrc.sh .
1079      source ./admin-openrc.sh
1080
1081 4. List Stack details
1082
1083    a. Get the name of the Stack.
1084
1085          .. image:: images/PROX_Openstack_stack_list.png
1086             :width: 1000px
1087             :alt: NSB PROX openstack stack list
1088
1089    b. Get the Floating IP of the Traffic Generator & SUT
1090
1091       This generates a lot of information. Please not the floating IP of the VNF and
1092       the Traffic Generator.
1093
1094          .. image:: images/PROX_Openstack_stack_show_a.png
1095             :width: 1000px
1096             :alt: NSB PROX openstack stack show (Top)
1097
1098       From here you can see the floating IP Address of the SUT / VNF
1099
1100          .. image:: images/PROX_Openstack_stack_show_b.png
1101             :width: 1000px
1102             :alt: NSB PROX openstack stack show (Top)
1103
1104       From here you can see the floating IP Address of the Traffic Generator
1105
1106    c. Get ssh identity file
1107
1108       In the docker container locate the identity file.::
1109
1110         cd /home/opnfv/repos/yardstick/yardstick/resources/files
1111         ls -lt
1112
1113 5. Login to SUT as ``Ubuntu``.::
1114
1115      ssh -i ./yardstick_key-01029d1d ubuntu@172.16.2.158
1116
1117    Change to root::
1118
1119      sudo su
1120
1121     Now continue as baremetal.
1122
1123 6. Login to SUT as ``Ubuntu``.::
1124
1125      ssh -i ./yardstick_key-01029d1d ubuntu@172.16.2.156
1126
1127    Change to root::
1128
1129      sudo su
1130
1131     Now continue as baremetal.
1132
1133 *How do I resolve "Quota exceeded for resources"*
1134 -------------------------------------------------
1135
1136 *Solution*
1137
1138 This usually occurs due to 2 reasons when executing an openstack test.
1139
1140 1. One or more stacks already exists and are consuming all resources. To resolve ::
1141
1142      openstack stack list
1143
1144    Response::
1145
1146      +--------------------------------------+--------------------+-----------------+----------------------+--------------+
1147      | ID                                   | Stack Name         | Stack Status    | Creation Time        | Updated Time |
1148      +--------------------------------------+--------------------+-----------------+----------------------+--------------+
1149      | acb559d7-f575-4266-a2d4-67290b556f15 | yardstick-e05ba5a4 | CREATE_COMPLETE | 2017-12-06T15:00:05Z | None         |
1150      | 7edf21ce-8824-4c86-8edb-f7e23801a01b | yardstick-08bda9e3 | CREATE_COMPLETE | 2017-12-06T14:56:43Z | None         |
1151      +--------------------------------------+--------------------+-----------------+----------------------+--------------+
1152
1153    In this case 2 stacks already exist.
1154
1155    To remove stack::
1156
1157      openstack stack delete yardstick-08bda9e3
1158      Are you sure you want to delete this stack(s) [y/N]? y
1159
1160 2. The openstack configuration quotas are too small.
1161
1162    The solution is to increase the quota. Use below to query existing quotas::
1163
1164      openstack quota show
1165
1166    And to set quota::
1167
1168      openstack quota set <resource>
1169
1170 *Openstack Cli fails or hangs. How do I resolve this?*
1171 ------------------------------------------------------
1172
1173 *Solution*
1174
1175 If it fails due to ::
1176
1177    Missing value auth-url required for auth plugin password
1178
1179 Check your shell environment for Openstack variables. One of them should contain the authentication URL ::
1180
1181
1182    OS_AUTH_URL=``https://192.168.72.41:5000/v3``
1183
1184 Or similar. Ensure that openstack configurations are exported. ::
1185
1186    cat  /etc/kolla/admin-openrc.sh
1187
1188 Result ::
1189
1190    export OS_PROJECT_DOMAIN_NAME=default
1191    export OS_USER_DOMAIN_NAME=default
1192    export OS_PROJECT_NAME=admin
1193    export OS_TENANT_NAME=admin
1194    export OS_USERNAME=admin
1195    export OS_PASSWORD=BwwSEZqmUJA676klr9wa052PFjNkz99tOccS9sTc
1196    export OS_AUTH_URL=http://193.168.72.41:35357/v3
1197    export OS_INTERFACE=internal
1198    export OS_IDENTITY_API_VERSION=3
1199    export EXTERNAL_NETWORK=yardstick-public
1200
1201 and visible.
1202
1203 If the Openstack Cli appears to hang, then verify the proxys and no_proxy are set correctly.
1204 They should be similar to ::
1205
1206    FTP_PROXY="http://proxy.ir.intel.com:911/"
1207    HTTPS_PROXY="http://proxy.ir.intel.com:911/"
1208    HTTP_PROXY="http://proxy.ir.intel.com:911/"
1209    NO_PROXY="localhost,127.0.0.1,10.237.222.55,10.237.223.80,10.237.222.134,.ir.intel.com"
1210    ftp_proxy="http://proxy.ir.intel.com:911/"
1211    http_proxy="http://proxy.ir.intel.com:911/"
1212    https_proxy="http://proxy.ir.intel.com:911/"
1213    no_proxy="localhost,127.0.0.1,10.237.222.55,10.237.223.80,10.237.222.134,.ir.intel.com"
1214
1215 Where
1216
1217     1) 10.237.222.55 = IP Address of deployment node
1218     2) 10.237.223.80 = IP Address of Controller node
1219     3) 10.237.222.134 = IP Address of Compute Node
1220     4) ir.intel.com = local no proxy
1221
1222
1223
1224
1225
1226