This patch is used to update the documents of D-release.
[kvmfornfv.git] / docs / userguide / packet_forwarding.userguide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2
3 .. http://creativecommons.org/licenses/by/4.0
4
5 =================
6 PACKET FORWARDING
7 =================
8
9 About Packet Forwarding
10 -----------------------
11
12 Packet Forwarding is a test suite of KVMFORNFV. These latency tests measures the time taken by a
13 **Packet** generated by the traffic generator to travel from the originating device through the
14 network to the destination device. Packet Forwarding is implemented using test framework
15 implemented by OPNFV VSWITCHPERF project and an ``IXIA Traffic Generator``.
16
17 Version Features
18 ----------------
19
20 +-----------------------------+---------------------------------------------------+
21 |                             |                                                   |
22 |      **Release**            |               **Features**                        |
23 |                             |                                                   |
24 +=============================+===================================================+
25 |                             | - Packet Forwarding is not part of Colorado       |
26 |       Colorado              |   release of KVMFORNFV                            |
27 |                             |                                                   |
28 +-----------------------------+---------------------------------------------------+
29 |                             | - Packet Forwarding is a testcase in KVMFORNFV    |
30 |                             | - Implements three scenarios (Host/Guest/SRIOV)   |
31 |                             |   as part of testing in KVMFORNFV                 |
32 |       Danube                | - Uses automated test framework of OPNFV          |
33 |                             |    VSWITCHPERF software (PVP/PVVP)                |
34 |                             |                                                   |
35 |                             | - Works with IXIA Traffic Generator               |
36 +-----------------------------+---------------------------------------------------+
37
38 VSPERF
39 ------
40
41 VSPerf is an OPNFV testing project.
42 VSPerf will develop a generic and architecture agnostic vSwitch testing framework and associated
43 tests, that will serve as a basis for validating the suitability of different vSwitch
44 implementations in a Telco NFV deployment environment. The output of this project will be utilized
45 by the OPNFV Performance and Test group and its associated projects, as part of OPNFV Platform and
46 VNF level testing and validation.
47
48 For complete VSPERF documentation go to `link.`_
49
50 .. _link.: http://artifacts.opnfv.org/vswitchperf/colorado/index.html
51
52
53 Installation
54 ~~~~~~~~~~~~
55
56 Guidelines of installating `VSPERF`_.
57
58 .. _VSPERF: http://artifacts.opnfv.org/vswitchperf/colorado/configguide/index.html
59
60 Supported Operating Systems
61 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
62
63 * CentOS 7
64 * Fedora 20
65 * Fedora 21
66 * Fedora 22
67 * RedHat 7.2
68 * Ubuntu 14.04
69
70 Supported vSwitches
71 ~~~~~~~~~~~~~~~~~~~
72
73 The vSwitch must support Open Flow 1.3 or greater.
74
75 * OVS (built from source).
76 * OVS with DPDK (built from source).
77
78 Supported Hypervisors
79 ~~~~~~~~~~~~~~~~~~~~~
80
81 * Qemu version 2.3.
82
83 Other Requirements
84 ~~~~~~~~~~~~~~~~~~
85
86 The test suite requires Python 3.3 and relies on a number of other
87 packages. These need to be installed for the test suite to function.
88
89 Installation of required packages, preparation of Python 3 virtual
90 environment and compilation of OVS, DPDK and QEMU is performed by
91 script **systems/build_base_machine.sh**. It should be executed under
92 user account, which will be used for vsperf execution.
93
94  **Please Note:** Password-less sudo access must be configured for given user
95                   before script is executed.
96
97 Execution of installation script:
98
99 .. code:: bash
100
101     $ cd vswitchperf
102     $ cd systems
103     $ ./build_base_machine.sh
104
105 Script **build_base_machine.sh** will install all the vsperf dependencies
106 in terms of system packages, Python 3.x and required Python modules.
107 In case of CentOS 7 it will install Python 3.3 from an additional repository
108 provided by Software Collections (`a link`_). In case of RedHat 7 it will
109 install Python 3.4 as an alternate installation in /usr/local/bin. Installation
110 script will also use `virtualenv`_ to create a vsperf virtual environment,
111 which is isolated from the default Python environment. This environment will
112 reside in a directory called **vsperfenv** in $HOME.
113
114 You will need to activate the virtual environment every time you start a
115 new shell session. Its activation is specific to your OS:
116
117 For running testcases VSPERF is installed on Intel pod1-node2 in which centos
118 operating system is installed. Only VSPERF installion on Centos is discussed here.
119 For installation steps on other operating systems please refer to `here`_.
120
121 .. _here: http://artifacts.opnfv.org/vswitchperf/colorado/configguide/index.html
122
123 For CentOS 7
124 ~~~~~~~~~~~~~~
125
126 ## Python 3 Packages
127
128 To avoid file permission errors and Python version issues, use virtualenv to create an isolated environment with Python3.
129 The required Python 3 packages can be found in the `requirements.txt` file in the root of the test suite.
130 They can be installed in your virtual environment like so:
131
132 .. code:: bash
133
134    scl enable python33 bash
135    # Create virtual environment
136    virtualenv vsperfenv
137    cd vsperfenv
138    source bin/activate
139    pip install -r requirements.txt
140
141
142 You need to activate the virtual environment every time you start a new shell session.
143 To activate, simple run:
144
145 .. code:: bash
146
147    scl enable python33 bash
148    cd vsperfenv
149    source bin/activate
150
151
152 Working Behind a Proxy
153 ~~~~~~~~~~~~~~~~~~~~~~
154
155 If you're behind a proxy, you'll likely want to configure this before running any of the above. For example:
156
157 .. code:: bash
158
159    export http_proxy="http://<username>:<password>@<proxy>:<port>/";
160    export https_proxy="https://<username>:<password>@<proxy>:<port>/";
161    export ftp_proxy="ftp://<username>:<password>@<proxy>:<port>/";
162    export socks_proxy="socks://<username>:<password>@<proxy>:<port>/";
163
164 .. _a link: http://www.softwarecollections.org/en/scls/rhscl/python33/
165 .. _virtualenv: https://virtualenv.readthedocs.org/en/latest/
166
167 For other OS specific activation click `this link`_:
168
169 .. _this link: http://artifacts.opnfv.org/vswitchperf/colorado/configguide/installation.html#other-requirements
170
171 Traffic-Generators
172 ------------------
173
174 VSPERF supports many Traffic-generators. For configuring VSPERF to work with the available traffic-generator go through `this`_.
175
176 .. _this: http://artifacts.opnfv.org/vswitchperf/colorado/configguide/trafficgen.html
177
178 VSPERF supports the following traffic generators:
179
180   * Dummy (DEFAULT): Allows you to use your own external
181     traffic generator.
182   * IXIA (IxNet and IxOS)
183   * Spirent TestCenter
184   * Xena Networks
185   * MoonGen
186
187 To see the list of traffic gens from the cli:
188
189 .. code-block:: console
190
191     $ ./vsperf --list-trafficgens
192
193 This guide provides the details of how to install
194 and configure the various traffic generators.
195
196 As KVM4NFV uses only IXIA traffic generator, it is discussed here. For complete documentation regarding traffic generators please follow this `link`_.
197
198 .. _link: https://gerrit.opnfv.org/gerrit/gitweb?p=vswitchperf.git;a=blob;f=docs/configguide/trafficgen.rst;h=85fc35b886d30db3b92a6b7dcce7ca742b70cbdc;hb=HEAD
199
200 IXIA Setup
201 ----------
202
203 Hardware Requirements
204 ~~~~~~~~~~~~~~~~~~~~~
205
206 VSPERF requires the following hardware to run tests: IXIA traffic generator (IxNetwork), a machine that
207 runs the IXIA client software and a CentOS Linux release 7.1.1503 (Core) host.
208
209 Installation
210 ~~~~~~~~~~~~
211
212 Follow the [installation instructions] to install.
213
214 On the CentOS 7 system
215 ~~~~~~~~~~~~~~~~~~~~~~
216
217 You need to install IxNetworkTclClient$(VER_NUM)Linux.bin.tgz.
218
219 On the IXIA client software system
220 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
221
222 Find the IxNetwork TCL server app (start -> All Programs -> IXIA -> IxNetwork -> IxNetwork_$(VER_NUM) -> IxNetwork TCL Server)
223   - Right click on IxNetwork TCL Server, select properties
224   - Under shortcut tab in the Target dialogue box make sure there is the argument "-tclport xxxx"
225
226 where xxxx is your port number (take note of this port number you will need it for the 10_custom.conf file).
227
228 .. figure:: images/IXIA1.png
229    :name: IXIA1 setup
230    :width: 100%
231    :align: center
232
233 - Hit Ok and start the TCL server application
234
235 VSPERF configuration
236 --------------------
237
238 There are several configuration options specific to the IxNetworks traffic generator
239 from IXIA. It is essential to set them correctly, before the VSPERF is executed
240 for the first time.
241
242 Detailed description of options follows:
243
244  * TRAFFICGEN_IXNET_MACHINE - IP address of server, where IxNetwork TCL Server is running
245  * TRAFFICGEN_IXNET_PORT - PORT, where IxNetwork TCL Server is accepting connections from
246    TCL clients
247  * TRAFFICGEN_IXNET_USER - username, which will be used during communication with IxNetwork
248    TCL Server and IXIA chassis
249  * TRAFFICGEN_IXIA_HOST - IP address of IXIA traffic generator chassis
250  * TRAFFICGEN_IXIA_CARD - identification of card with dedicated ports at IXIA chassis
251  * TRAFFICGEN_IXIA_PORT1 - identification of the first dedicated port at TRAFFICGEN_IXIA_CARD
252    at IXIA chassis; VSPERF uses two separated ports for traffic generation. In case of
253    unidirectional traffic, it is essential to correctly connect 1st IXIA port to the 1st NIC
254    at DUT, i.e. to the first PCI handle from WHITELIST_NICS list. Otherwise traffic may not
255    be able to pass through the vSwitch.
256  * TRAFFICGEN_IXIA_PORT2 - identification of the second dedicated port at TRAFFICGEN_IXIA_CARD
257    at IXIA chassis; VSPERF uses two separated ports for traffic generation. In case of
258    unidirectional traffic, it is essential to correctly connect 2nd IXIA port to the 2nd NIC
259    at DUT, i.e. to the second PCI handle from WHITELIST_NICS list. Otherwise traffic may not
260    be able to pass through the vSwitch.
261  * TRAFFICGEN_IXNET_LIB_PATH - path to the DUT specific installation of IxNetwork TCL API
262  * TRAFFICGEN_IXNET_TCL_SCRIPT - name of the TCL script, which VSPERF will use for
263    communication with IXIA TCL server
264  * TRAFFICGEN_IXNET_TESTER_RESULT_DIR - folder accessible from IxNetwork TCL server,
265    where test results are stored, e.g. ``c:/ixia_results``; see test-results-share_
266  * TRAFFICGEN_IXNET_DUT_RESULT_DIR - directory accessible from the DUT, where test
267    results from IxNetwork TCL server are stored, e.g. ``/mnt/ixia_results``; see
268    test-results-share_
269
270 .. _test-results-share:
271
272 Test results share
273 ~~~~~~~~~~~~~~~~~~
274
275 VSPERF is not able to retrieve test results via TCL API directly. Instead, all test
276 results are stored at IxNetwork TCL server. Results are stored at folder defined by
277 ``TRAFFICGEN_IXNET_TESTER_RESULT_DIR`` configuration parameter. Content of this
278 folder must be shared (e.g. via samba protocol) between TCL Server and DUT, where
279 VSPERF is executed. VSPERF expects, that test results will be available at directory
280 configured by ``TRAFFICGEN_IXNET_DUT_RESULT_DIR`` configuration parameter.
281
282 Example of sharing configuration:
283
284  * Create a new folder at IxNetwork TCL server machine, e.g. ``c:\ixia_results``
285  * Modify sharing options of ``ixia_results`` folder to share it with everybody
286  * Create a new directory at DUT, where shared directory with results
287    will be mounted, e.g. ``/mnt/ixia_results``
288  * Update your custom VSPERF configuration file as follows:
289
290    .. code-block:: python
291
292        TRAFFICGEN_IXNET_TESTER_RESULT_DIR = 'c:/ixia_results'
293        TRAFFICGEN_IXNET_DUT_RESULT_DIR = '/mnt/ixia_results'
294
295    Note: It is essential to use slashes '/' also in path
296    configured by ``TRAFFICGEN_IXNET_TESTER_RESULT_DIR`` parameter.
297
298 * Install cifs-utils package.
299
300    e.g. at rpm based Linux distribution:
301
302 .. code-block:: console
303
304        yum install cifs-utils
305
306 * Mount shared directory, so VSPERF can access test results.
307
308    e.g. by adding new record into ``/etc/fstab``
309
310 .. code-block:: console
311
312        mount -t cifs //_TCL_SERVER_IP_OR_FQDN_/ixia_results /mnt/ixia_results
313              -o file_mode=0777,dir_mode=0777,nounix
314
315 It is recommended to verify, that any new file inserted into ``c:/ixia_results`` folder
316 is visible at DUT inside ``/mnt/ixia_results`` directory.
317
318
319 Cloning and building src dependencies
320 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321
322 In order to run VSPERF, you will need to download DPDK and OVS. You can do this manually and build
323 them in a preferred location, or you could use vswitchperf/src. The vswitchperf/src directory
324 contains makefiles that will allow you to clone and build the libraries that VSPERF depends on,
325 such as DPDK and OVS. To clone and build simply:
326
327 .. code:: bash
328
329    cd src
330    make
331
332 To delete a src subdirectory and its contents to allow you to re-clone simply use:
333
334 .. code:: bash
335
336    make cleanse
337
338 Configure the `./conf/10_custom.conf` file
339 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
340
341 The supplied `10_custom.conf` file must be modified, as it contains configuration items for which there are no reasonable default values.
342
343 The configuration items that can be added is not limited to the initial contents. Any configuration item
344 mentioned in any .conf file in `./conf` directory can be added and that item will be overridden by the custom
345 configuration value.
346
347 Using a custom settings file
348 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349
350 Alternatively a custom settings file can be passed to `vsperf` via the `--conf-file` argument.
351
352 .. code:: bash
353
354    ./vsperf --conf-file <path_to_settings_py> ...
355
356 Note that configuration passed in via the environment (`--load-env`) or via another command line
357 argument will override both the default and your custom configuration files. This
358 "priority hierarchy" can be described like so (1 = max priority):
359
360 1. Command line arguments
361 2. Environment variables
362 3. Configuration file(s)
363
364 vloop_vnf
365 ~~~~~~~~~
366
367 VSPERF uses a VM image called vloop_vnf for looping traffic in the deployment
368 scenarios involving VMs. The image can be downloaded from
369 `<http://artifacts.opnfv.org/>`__.
370
371 Please see the installation instructions for information on :ref:`vloop-vnf`
372 images.
373
374 .. _l2fwd-module:
375
376 l2fwd Kernel Module
377 ~~~~~~~~~~~~~~~~~~~
378
379 A Kernel Module that provides OSI Layer 2 Ipv4 termination or forwarding with
380 support for Destination Network Address Translation (DNAT) for both the MAC and
381 IP addresses. l2fwd can be found in <vswitchperf_dir>/src/l2fwd
382
383 .. figure:: images/Guest_Scenario.png
384    :name: Guest_Scenario
385    :width: 100%
386    :align: center
387
388
389 Executing tests
390 ~~~~~~~~~~~~~~~~
391
392 Before running any tests make sure you have root permissions by adding the following line to /etc/sudoers:
393 .. code:: bash
394
395    username ALL=(ALL)       NOPASSWD: ALL
396
397 username in the example above should be replaced with a real username.
398
399 To list the available tests:
400
401 .. code:: bash
402
403    ./vsperf --list-tests
404
405
406 To run a group of tests, for example all tests with a name containing
407 'RFC2544':
408
409 .. code:: bash
410
411    ./vsperf --conf-file=user_settings.py --tests="RFC2544"
412
413 To run all tests:
414
415 .. code:: bash
416
417    ./vsperf --conf-file=user_settings.py
418
419 Some tests allow for configurable parameters, including test duration (in seconds) as well as packet sizes (in bytes).
420
421 .. code:: bash
422
423    ./vsperf --conf-file user_settings.py
424        --tests RFC2544Tput
425        --test-param` "rfc2544_duration=10;packet_sizes=128"
426
427 For all available options, check out the help dialog:
428
429 .. code:: bash
430
431     ./vsperf --help
432
433
434 Testcases
435 ----------
436
437 Available Tests in VSPERF are:
438
439    * phy2phy_tput
440    * phy2phy_forwarding
441    * back2back
442    * phy2phy_tput_mod_vlan
443    * phy2phy_cont
444    * pvp_cont
445    * pvvp_cont
446    * pvpv_cont
447    * phy2phy_scalability
448    * pvp_tput
449    * pvp_back2back
450    * pvvp_tput
451    * pvvp_back2back
452    * phy2phy_cpu_load
453    * phy2phy_mem_load
454
455 VSPERF modes of operation
456 --------------------------
457
458 VSPERF can be run in different modes. By default it will configure vSwitch,
459 traffic generator and VNF. However it can be used just for configuration
460 and execution of traffic generator. Another option is execution of all
461 components except traffic generator itself.
462
463 Mode of operation is driven by configuration parameter -m or --mode
464
465 .. code-block:: console
466
467     -m MODE, --mode MODE  vsperf mode of operation;
468        Values:
469             "normal" - execute vSwitch, VNF and traffic generator
470             "trafficgen" - execute only traffic generator
471             "trafficgen-off" - execute vSwitch and VNF
472             "trafficgen-pause" - execute vSwitch and VNF but wait before traffic transmission
473
474 In case, that VSPERF is executed in "trafficgen" mode, then configuration
475 of traffic generator can be modified through ``TRAFFIC`` dictionary passed to the
476 ``--test-params`` option. It is not needed to specify all values of ``TRAFFIC``
477 dictionary. It is sufficient to specify only values, which should be changed.
478 Detailed description of ``TRAFFIC`` dictionary can be found at: ref:`configuration-of-traffic-dictionary`.
479
480 Example of execution of VSPERF in "trafficgen" mode:
481
482 .. code-block:: console
483
484     $ ./vsperf -m trafficgen --trafficgen IxNet --conf-file vsperf.conf \
485         --test-params "TRAFFIC={'traffic_type':'rfc2544_continuous','bidir':'False','framerate':60}"
486
487
488 Packet Forwarding Test Scenarios
489 --------------------------------
490
491 KVMFORNFV currently implements three scenarios as part of testing:
492
493   * Host Scenario
494   * Guest Scenario.
495   * SR-IOV Scenario.
496
497
498 Packet Forwarding Host Scenario
499 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
500
501 Here host DUT has VSPERF installed in it and is properly configured to use IXIA Traffic-generator
502 by providing IXIA CARD, PORTS and Lib paths along with IP.
503 please refer to figure.2
504
505 .. figure:: images/Host_Scenario.png
506    :name: Host_Scenario
507    :width: 100%
508    :align: center
509
510 Packet Forwarding Guest Scenario
511 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
512
513 Here the guest is a Virtual Machine (VM) launched by using vloop_vnf provided by vsperf project
514 on host/DUT using Qemu. In this latency test the time taken by the frame/packet to travel from the
515 originating device through network involving a guest to destination device is calculated.
516 The resulting latency values will define the performance of installed kernel.
517
518 .. figure:: images/Guest_Scenario.png
519    :name: Guest_Scenario
520    :width: 100%
521    :align: center
522
523 Packet Forwarding SRIOV Scenario
524 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
525
526 In this test the packet generated at the IXIA is forwarded to the Guest VM launched on Host by
527 implementing SR-IOV interface at NIC level of host .i.e., DUT. The time taken by the packet to
528 travel through the network to the destination the IXIA traffic-generator is calculated and
529 published as a test result for this scenario.
530
531 SRIOV-support_ is given below, it details how to use SR-IOV.
532
533 .. figure:: images/SRIOV_Scenario.png
534    :name: SRIOV_Scenario
535    :width: 100%
536    :align: center
537
538 Using vfio_pci with DPDK
539 ~~~~~~~~~~~~~~~~~~~~~~~~~
540
541 To use vfio with DPDK instead of igb_uio add into your custom configuration
542 file the following parameter:
543
544 .. code-block:: python
545
546     PATHS['dpdk']['src']['modules'] = ['uio', 'vfio-pci']
547
548
549 **NOTE:** In case, that DPDK is installed from binary package, then please
550
551      set ``PATHS['dpdk']['bin']['modules']`` instead.
552
553 **NOTE:** Please ensure that Intel VT-d is enabled in BIOS.
554
555 **NOTE:** Please ensure your boot/grub parameters include
556 the following:
557
558 .. code-block:: console
559
560    iommu=pt intel_iommu=on
561
562 To check that IOMMU is enabled on your platform:
563
564 .. code-block:: console
565
566     $ dmesg | grep IOMMU
567     [    0.000000] Intel-IOMMU: enabled
568     [    0.139882] dmar: IOMMU 0: reg_base_addr fbffe000 ver 1:0 cap d2078c106f0466 ecap f020de
569     [    0.139888] dmar: IOMMU 1: reg_base_addr ebffc000 ver 1:0 cap d2078c106f0466 ecap f020de
570     [    0.139893] IOAPIC id 2 under DRHD base  0xfbffe000 IOMMU 0
571     [    0.139894] IOAPIC id 0 under DRHD base  0xebffc000 IOMMU 1
572     [    0.139895] IOAPIC id 1 under DRHD base  0xebffc000 IOMMU 1
573     [    3.335744] IOMMU: dmar0 using Queued invalidation
574     [    3.335746] IOMMU: dmar1 using Queued invalidation
575    ....
576
577 .. _SRIOV-support:
578
579 Using SRIOV support
580 ~~~~~~~~~~~~~~~~~~~
581
582 To use virtual functions of NIC with SRIOV support, use extended form
583 of NIC PCI slot definition:
584
585 .. code-block:: python
586
587     WHITELIST_NICS = ['0000:03:00.0|vf0', '0000:03:00.1|vf3']
588
589 Where ``vf`` is an indication of virtual function usage and following
590 number defines a VF to be used. In case that VF usage is detected,
591 then vswitchperf will enable SRIOV support for given card and it will
592 detect PCI slot numbers of selected VFs.
593
594 So in example above, one VF will be configured for NIC '0000:05:00.0'
595 and four VFs will be configured for NIC '0000:05:00.1'. Vswitchperf
596 will detect PCI addresses of selected VFs and it will use them during
597 test execution.
598
599 At the end of vswitchperf execution, SRIOV support will be disabled.
600
601 SRIOV support is generic and it can be used in different testing scenarios.
602 For example:
603
604
605 * vSwitch tests with DPDK or without DPDK support to verify impact
606   of VF usage on vSwitch performance
607 * tests without vSwitch, where traffic is forwared directly
608   between VF interfaces by packet forwarder (e.g. testpmd application)
609 * tests without vSwitch, where VM accesses VF interfaces directly
610   by PCI-passthrough to measure raw VM throughput performance.
611
612 Using QEMU with PCI passthrough support
613 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
614
615 Raw virtual machine throughput performance can be measured by execution of PVP
616 test with direct access to NICs by PCI passthrough. To execute VM with direct
617 access to PCI devices, enable vfio-pci_. In order to use virtual functions,
618 SRIOV-support_ must be enabled.
619
620 Execution of test with PCI passthrough with vswitch disabled:
621
622 .. code-block:: console
623
624     $ ./vsperf --conf-file=<path_to_custom_conf>/10_custom.conf \
625                --vswitch none --vnf QemuPciPassthrough pvp_tput
626
627 Any of supported guest-loopback-application_ can be used inside VM with
628 PCI passthrough support.
629
630 Note: Qemu with PCI passthrough support can be used only with PVP test
631 deployment.
632
633 .. _guest-loopback-application: