docs: Add more on trex
[vpp.git] / docs / usecases / simpleperf / trex.rst
1 .. _trex:
2
3 Using VPP with TRex
4 ===================
5
6 In this example we use only two systems, *csp2s22c03* and *net2s22c05*, to run
7 **TRex** VPP is installed on **csp2s22c03** and run as a packet forwarding
8 engine. On *net2s22c05*, TRex is used to generate both client and server-side
9 traffic. **TRex** is a high-performance traffic generator. It leverages DPDK and
10 run in user space. Figure 2 illustrates this configuration.
11
12 VPP is set up on *csp2s22c03* exactly as it was in the previous example. Only
13 the setup on *net2s22c05* is modified slightly to run TRex preconfigured traffic
14 files.
15
16 .. figure:: /_images/trex.png
17
18 Figure 2: The TRex traffic generator sends packages to the host that has VPP running.
19
20
21 First we install **TRex**.
22
23 .. code-block:: console
24
25    NET2S22C05$ wget --no-cache http://trex-tgn.cisco.com/trex/release/latest
26    NET2S22C05$ tar -xzvf latest
27    NET2S22C05$ cd v2.37
28
29 Then show the devices we have.
30
31 .. code-block:: console
32
33    NET2S22C05$ sudo ./dpdk_nic_bind.py -s
34
35    Network devices using DPDK-compatible driver
36    ============================================
37    0000:87:00.0 'Ethernet Controller XL710 for 40GbE QSFP+' drv=vfio-pci unused=i40e
38    0000:87:00.1 'Ethernet Controller XL710 for 40GbE QSFP+' drv=vfio-pci unused=i40e
39
40    Network devices using kernel driver
41    ===================================
42    0000:03:00.0 'Ethernet Controller 10-Gigabit X540-AT2' if=enp3s0f0 drv=ixgbe unused=vfio-pci *Active*
43    0000:03:00.1 'Ethernet Controller 10-Gigabit X540-AT2' if=enp3s0f1 drv=ixgbe unused=vfio-pci
44    0000:81:00.0 '82599 10 Gigabit TN Network Connection' if=ens787f0 drv=ixgbe unused=vfio-pci
45    0000:81:00.1 '82599 10 Gigabit TN Network Connection' if=ens787f1 drv=ixgbe unused=vfio-pci
46
47    Other network devices
48    =====================
49    <none>
50
51 Create the */etc/trex_cfg.yaml* configuration file. In this configuration file,
52 the port should match the interfaces available in the target system, which is
53 *net2s22c05* in our example. The IP addresses correspond to Figure 2. For more
54 information on the configuration file, please refer to the `TRex Manual <http://trex-tgn.cisco.com/trex/doc/index.html>`_.
55
56 .. code-block:: console
57
58    NET2S22C05$ cat /etc/trex_cfg.yaml
59    - port_limit: 2
60      version: 2
61      interfaces: ['87:00.0', '87:00.1']
62      port_bandwidth_gb: 40
63      port_info:
64          - ip: 10.10.2.2
65            default_gw: 10.10.2.1
66          - ip: 10.10.1.2
67            default_gw: 10.10.1.1
68    
69 Stop the previous VPP session and start it again in order to add a route for new
70 IP addresses 16.0.0.0/8 and 48.0.0.0/8, according to Figure 2. Those IP addresses
71 are needed because TRex generates packets that use these addresses. Refer to the
72 `TRex Manual <http://trex-tgn.cisco.com/trex/doc/index.html>`_ for details on
73 these traffic templates.
74
75 .. code-block:: console
76
77    csp2s22c03$ sudo service vpp stop
78    csp2s22c03$ sudo service vpp start
79    csp2s22c03$ sudo vppctl
80        _______    _        _   _____  ___
81     __/ __/ _ \  (_)__    | | / / _ \/ _ \
82     _/ _// // / / / _ \   | |/ / ___/ ___/
83     /_/ /____(_)_/\___/   |___/_/  /_/
84    
85    vpp# sho int
86                  Name               Idx       State          Counter          Count
87    FortyGigabitEthernet82/0/0        1        down
88    FortyGigabitEthernet82/0/1        2        down
89    local0                            0        down
90    
91    vpp#
92    vpp# set interface ip address FortyGigabitEthernet82/0/0 10.10.1.1/24
93    vpp# set interface ip address FortyGigabitEthernet82/0/1 10.10.2.1/24
94    vpp# set interface state FortyGigabitEthernet82/0/0 up
95    vpp# set interface state FortyGigabitEthernet82/0/1 up
96    vpp# ip route add 16.0.0.0/8 via 10.10.1.2
97    vpp# ip route add 48.0.0.0/8 via 10.10.2.2
98    vpp# clear run
99
100 Now, you can generate a simple traffic flow from *net2s22c05* using the traffic
101 configuration file "cap2/dns.yaml".
102
103 .. code-block:: console
104
105    NET2S22C05$ sudo ./t-rex-64 -f cap2/dns.yaml -d 1 -l 1000
106     summary stats
107     --------------
108     Total-pkt-drop       : 0 pkts
109     Total-tx-bytes       : 166886 bytes
110     Total-tx-sw-bytes    : 166716 bytes
111     Total-rx-bytes       : 166886 byte
112    
113     Total-tx-pkt         : 2528 pkts
114     Total-rx-pkt         : 2528 pkts
115     Total-sw-tx-pkt      : 2526 pkts
116     Total-sw-err         : 0 pkts
117     Total ARP sent       : 4 pkts
118     Total ARP received   : 2 pkts
119     maximum-latency   : 35 usec
120     average-latency   : 8 usec
121     latency-any-error : OK
122
123 On *csp2s22c03*, the *show run* command displays the graph runtime statistics.
124
125 .. figure:: /_images/build-a-fast-network-stack-terminal-2.png