3dffcab467567d2915fdf61b9293c2a89e8502ab
[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      platform:
70          master_thread_id: 0
71          latency_thread_id: 1
72          dual_if:
73            - socket: 1
74              threads: [22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43]
75
76 Stop the previous VPP session and start it again in order to add a route for new
77 IP addresses 16.0.0.0/8 and 48.0.0.0/8, according to Figure 2. Those IP addresses
78 are needed because TRex generates packets that use these addresses. Refer to the
79 `TRex Manual <http://trex-tgn.cisco.com/trex/doc/index.html>`_ for details on
80 these traffic templates.
81
82 .. code-block:: console
83
84    csp2s22c03$ sudo service vpp stop
85    csp2s22c03$ sudo service vpp start
86    csp2s22c03$ sudo vppctl
87        _______    _        _   _____  ___
88     __/ __/ _ \  (_)__    | | / / _ \/ _ \
89     _/ _// // / / / _ \   | |/ / ___/ ___/
90     /_/ /____(_)_/\___/   |___/_/  /_/
91    
92    vpp# sho int
93                  Name               Idx       State          Counter          Count
94    FortyGigabitEthernet82/0/0        1        down
95    FortyGigabitEthernet82/0/1        2        down
96    local0                            0        down
97    
98    vpp#
99    vpp# set interface ip address FortyGigabitEthernet82/0/0 10.10.1.1/24
100    vpp# set interface ip address FortyGigabitEthernet82/0/1 10.10.2.1/24
101    vpp# set interface state FortyGigabitEthernet82/0/0 up
102    vpp# set interface state FortyGigabitEthernet82/0/1 up
103    vpp# ip route add 16.0.0.0/8 via 10.10.1.2
104    vpp# ip route add 48.0.0.0/8 via 10.10.2.2
105    vpp# clear run
106
107 Now, you can generate a simple traffic flow from *net2s22c05* using the traffic
108 configuration file "cap2/dns.yaml".
109
110 .. code-block:: console
111
112    NET2S22C05$ sudo ./t-rex-64 -f cap2/dns.yaml -d 1 -l 1000
113     summary stats
114     --------------
115     Total-pkt-drop       : 0 pkts
116     Total-tx-bytes       : 166886 bytes
117     Total-tx-sw-bytes    : 166716 bytes
118     Total-rx-bytes       : 166886 byte
119    
120     Total-tx-pkt         : 2528 pkts
121     Total-rx-pkt         : 2528 pkts
122     Total-sw-tx-pkt      : 2526 pkts
123     Total-sw-err         : 0 pkts
124     Total ARP sent       : 4 pkts
125     Total ARP received   : 2 pkts
126     maximum-latency   : 35 usec
127     average-latency   : 8 usec
128     latency-any-error : OK
129
130 On *csp2s22c03*, the *show run* command displays the graph runtime statistics.
131
132 .. figure:: /_images/build-a-fast-network-stack-terminal-2.png
133