Trex是思科的一款基于DPDK的网络测试工具。首先安装centos 7.5,然后安装kernel-devel-3.10.0-862.el7.x86_64.rpm。
最好不要用# yum install kernel-devel,以免安装了最新的,和当前kernel不匹配。
下载MLNX_OFED_LINUX-4.4-1.0.0.0-rhel7.5-x86_64.iso,安装:
./mlnxofedinstall --upstream-libs --dpdk --without-fw-update
下载DPDK,https://github.com/DPDK/dpdk.git
commit 686a41ac97c20aad4a9901f567e7a68db163f3d7
Author: Thomas Monjalon
Date: Mon Aug 6 01:45:20 2018 +0200
version: 18.08-rc3
Signed-off-by: Thomas Monjalon
编译DPDK:
export RTE_SDK=`pwd`;
export RTE_TARGET=x86_64-native-linuxapp-gcc;
make install T=x86_64-native-linuxapp-gcc -j16
下载TRex:
wget https://trex-tgn.cisco.com/trex/release/latest -O /tmp/trex_latest
mkdir /usr/trex
tar -xvf /tmp/trex_latest -C /usr/trex
配置 /etc/trex_cfg.yaml
# cat /etc/trex_cfg.yaml
### Config file generated by dpdk_setup_ports.py ###
- version: 2
interfaces: ['04:00.0', '04:00.1']
port_info:
- dest_mac: 02:25:d0:13:01:02
src_mac: 24:8a:07:88:27:ca
- dest_mac: 24:8a:07:88:27:ca # MAC OF LOOPBACK TO IT'S DUAL INTERFACE
src_mac: 24:8a:07:88:27:cb
platform:
master_thread_id: 0
latency_thread_id: 1
dual_if:
- socket: 0
threads: [2,4,6,8,10,12,14]
# cat /etc/trex_cfg.yaml
### Config file generated by dpdk_setup_ports.py ###
- version: 2
interfaces: ['04:00.0', '04:00.1']
port_info:
- dest_mac: 24:8a:07:88:27:ca
src_mac: 24:8a:07:88:27:9a
- dest_mac: 24:8a:07:88:27:9a
src_mac: 24:8a:07:88:27:9b
platform:
master_thread_id: 0
latency_thread_id: 1
dual_if:
- socket: 0
threads: [2,4,6,8,10,12,14]
sudo ./t-rex-64 -c 4 -i
然后再另外一个窗口:
./trex-console
trex>start -f stl/udp_1pkt_tuple_gen.py -p 0 -m 1%
trex>stop
输出如下:
-Per port stats table
ports | 0 | (link DOWN) 1
-----------------------------------------------------------------------------------------
opackets | 43288075 | 0
obytes | 2770451776 | 0
ipackets | 88 | 0
ibytes | 19408 | 0
ierrors | 0 | 0
oerrors | 0 | 0
Tx Bw | 0.00 bps | 0.00 bps
-Global stats enabled
Cpu Utilization : 0.0 %
Platform_factor : 1.0
Total-Tx : 0.00 bps
Total-Rx : 0.00 bps
Total-PPS : 0.00 pps
Total-CPS : 0.00 cps
Expected-PPS : 0.00 pps
Expected-CPS : 0.00 cps
Expected-BPS : 0.00 bps
Active-flows : 0 Clients : 0 Socket-util : 0.0000 %
Open-flows : 0 Servers : 0 Socket : 0 Socket/Clients : -nan
drop-rate : 0.00 bps
current time : 1347.2 sec
test duration : 0.0 sec
[root@dev-r630-03 trexPackage]# ./trex-console
Using 'python' as Python interpeter
Connecting to RPC server on localhost:4501 [SUCCESS]
Connecting to publisher server on localhost:4500 [SUCCESS]
Acquiring ports [0, 1]: [SUCCESS]
Server Info:
Server version: v2.53 @ STL
Server mode: Stateless
Server CPU: 4 x Intel(R) Xeon(R) CPU E5-2623 v4 @ 2.60GHz
Ports count: 1 x 40Gbps @ MT28800 Family [ConnectX-5 Ex] 1 x 100Gbps @ MT28800 Family [ConnectX-5 Ex]
-=TRex Console v3.0=-
Type 'help' or '?' for supported actions
trex>start -f stl/udp_1pkt_tuple_gen.py -p 0 -m 1%
Removing all streams from port(s) [0]: [SUCCESS]
Attaching 1 streams to port(s) [0]: [SUCCESS]
Starting traffic on port(s) [0]: [SUCCESS]
33.89 [ms]
trex>stop
Stopping traffic on port(s) [0]: [SUCCESS]
3.72 [ms]
trex>
对端收到的包:
09:15:02.253774 24:8a:07:88:27:9a > 24:8a:07:88:27:ca, ethertype IPv4 (0x0800), length 60: 16.0.0.1.1407 > 48.0.0.1.12: UDP, length 18
09:15:02.253779 24:8a:07:88:27:9a > 24:8a:07:88:27:ca, ethertype IPv4 (0x0800), length 60: 16.0.0.1.1403 > 48.0.0.1.12: UDP, length 18
09:15:02.253784 24:8a:07:88:27:9a > 24:8a:07:88:27:ca, ethertype IPv4 (0x0800), length 60: 16.0.0.2.1532 > 48.0.0.1.12: UDP, length 18
09:15:02.253790 24:8a:07:88:27:9a > 24:8a:07:88:27:ca, ethertype IPv4 (0x0800), length 60: 16.0.0.1.1431 > 48.0.0.1.12: UDP, length 18
09:15:02.253796 24:8a:07:88:27:9a > 24:8a:07:88:27:ca, ethertype IPv4 (0x0800), length 60: 16.0.0.2.1508 > 48.0.0.1.12: UDP, length 18
09:15:02.253823 24:8a:07:88:27:9a > 24:8a:07:88:27:ca, ethertype IPv4 (0x0800), length 60: 16.0.0.2.1603 > 48.0.0.1.12: UDP, length 18
09:15:02.253824 24:8a:07:88:27:9a > 24:8a:07:88:27:ca, ethertype IPv4 (0x0800), length 60: 16.0.0.2.1611 > 48.0.0.1.12: UDP, length 18
09:15:02.253825 24:8a:07:88:27:9a > 24:8a:07:88:27:ca, ethertype IPv4 (0x0800), length 60: 16.0.0.2.1617 > 48.0.0.1.12: UDP, length 18
09:15:02.253825 24:8a:07:88:27:9a > 24:8a:07:88:27:ca, ethertype IPv4 (0x0800), length 60: 16.0.0.2.1619 > 48.0.0.1.12: UDP, length 18