Cisco TRex搭建与测试

本文最后更新于:2022年6月13日 上午

介绍

  • TRex是一个由DPDK驱动的开源、低成本、有状态和无状态的流量生成器。它产生3-7层流量,并在一个工具中提供了商业工具提供的功能
  • TRex无状态功能包括对多流的支持,更改任何数据包字段的能力,并提供每个流的统计数据,延迟和抖动
  • 高级状态功能包括对模拟L7流量的支持,支持全功能的可扩展TCP/UDP支持
  • TRex仿真功能包括客户端L3协议,即ARP, IPv6, ND, MLD, IGMP, ICMP, DOT1X,以模拟一个规模的客户端和服务器
  • TRex可以在一台服务器上扩展到200Gb/秒

配置回环

安装文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 创建目录
[root@T-rex ~]# mkdir -p /opt/trex
[root@T-rex ~]# cd /opt/trex

# 最新(稳定)版本:
[root@T-rex trex]# wget --no-cache https://trex-tgn.cisco.com/trex/release/latest
[root@T-rex trex]# tar -xzvf latest

# 最新(测试)版本:
[root@T-rex trex]# wget --no-cache https://trex-tgn.cisco.com/trex/release/be_latest

# 要获取特定版本,其中 X.XX = major.minor 版本号 ↓
# TRex 版本说明:https://trex-tgn.cisco.com/trex/doc/release_notes.html
[root@T-rex trex]# wget --no-cache https://trex-tgn.cisco.com/trex/release/vX.XX.tar.gz

文件结构

目录 描述
/ t-rex-64/dpdk_set_ports/stl-sim
/stl 无状态本机 (py) 配置文件
/stl/hlt 无状态 HLT 配置文件
/ko DPDK 的内核模块
/external_libs 服务器/客户端使用的 Python 外部库
/exp 用于单元测试的黄金 PCAP 文件
/cfg 配置文件示例
/cap2 有状态的配置文件
/avl 有状态配置文件 - SFR 配置文件
/automation 有状态和无状态的 Python 客户端/服务器代码
/automation/regression 无状态和有状态的回归
/automation/config 回归设置配置文件
/automation/trex_control_plane/interactive/trex 无状态库和控制台
/automation/trex_control_plane/interactive/trex/stl 无状态库
/automation/trex_control_plane/interactive/trex/examples/stl 无状态示例

Trex - stateless模式

1 模式配置和启动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 进入Trex目录
[root@T-rex trex]# cd /opt/trex/v2.97

# 查看当前接口情况
[root@T-rex v2.97]# ./dpdk_setup_ports.py -s

Network devices using DPDK-compatible driver
============================================
0000:84:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' drv=igb_uio unused=ixgbe,vfio-pci,uio_pci_generic
0000:84:00.1 '82599ES 10-Gigabit SFI/SFP+ Network Connection' drv=igb_uio unused=ixgbe,vfio-pci,uio_pci_generic

Network devices using kernel driver
===================================
0000:07:00.0 'I350 Gigabit Network Connection' if=eth0 drv=igb unused=igb_uio,vfio-pci,uio_pci_generic *Active*
0000:07:00.1 'I350 Gigabit Network Connection' if=eth1 drv=igb unused=igb_uio,vfio-pci,uio_pci_generic

Other network devices
=====================
<none>

2 产看端口指定序号

1
2
3
4
5
6
7
8
9
10
11
12
[root@T-rex v2.97]# ./dpdk_setup_ports.py -c
+----+------+---------+-------------------+------------------------------------------------+---------+----------+----------+
| ID | NUMA | PCI | MAC | Name | Driver | Linux IF | Active |
+====+======+=========+===================+================================================+=========+==========+==========+
| 0 | 0 | 07:00.0 | 6c:92:bf:0e:b0:11 | I350 Gigabit Network Connection | igb | eth0 | *Active* |
+----+------+---------+-------------------+------------------------------------------------+---------+----------+----------+
| 1 | 0 | 07:00.1 | 6c:92:bf:0e:b0:10 | I350 Gigabit Network Connection | igb | eth1 | |
+----+------+---------+-------------------+------------------------------------------------+---------+----------+----------+
| 2 | 1 | 84:00.0 | 00:1b:21:87:1a:cc | 82599ES 10-Gigabit SFI/SFP+ Network Connection | igb_uio | | |
+----+------+---------+-------------------+------------------------------------------------+---------+----------+----------+
| 3 | 1 | 84:00.1 | 00:1b:21:87:1a:cd | 82599ES 10-Gigabit SFI/SFP+ Network Connection | igb_uio | | |
+----+------+---------+-------------------+------------------------------------------------+---------+----------+----------+

3 绑定dpdk接口(绑定两个接口)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -i 交互模式
[root@T-rex v2.97]# ./dpdk_setup_ports.py -i


# 以mac地址的方式绑定
By default, IP based configuration file will be created. Do you want to use MAC based config? (y/N) y
+----+------+---------+-------------------+------------------------------------------------+---------+----------+----------+
| ID | NUMA | PCI | MAC | Name | Driver | Linux IF | Active |
+====+======+=========+===================+================================================+=========+==========+==========+
| 0 | 0 | 07:00.0 | 6c:92:bf:0e:b0:11 | I350 Gigabit Network Connection | igb | eth0 | *Active* |
+----+------+---------+-------------------+------------------------------------------------+---------+----------+----------+
| 1 | 0 | 07:00.1 | 6c:92:bf:0e:b0:10 | I350 Gigabit Network Connection | igb | eth1 | |
+----+------+---------+-------------------+------------------------------------------------+---------+----------+----------+
| 2 | 1 | 84:00.0 | 00:1b:21:87:1a:cc | 82599ES 10-Gigabit SFI/SFP+ Network Connection | igb_uio | | |
+----+------+---------+-------------------+------------------------------------------------+---------+----------+----------+
| 3 | 1 | 84:00.1 | 00:1b:21:87:1a:cd | 82599ES 10-Gigabit SFI/SFP+ Network Connection | igb_uio | | |
+----+------+---------+-------------------+------------------------------------------------+---------+----------+----------+
Please choose an even number of interfaces from the list above, either by ID, PCI or Linux IF
Stateful will use order of interfaces: Client1 Server1 Client2 Server2 etc. for flows.
Stateless can be in any order.
For performance, try to choose each pair of interfaces to be on the same NUMA.


# 输入两个口的ID
Enter list of interfaces separated by space (for example: 1 3) : 2 3


# 输入n不变成DUT
For interface 2, assuming loopback to its dual interface 3.
Destination MAC is 00:1b:21:87:1a:cd. Change it to MAC of DUT? (y/N). n


# 输入n不变成DUT
For interface 3, assuming loopback to its dual interface 2.
Destination MAC is 00:1b:21:87:1a:cc. Change it to MAC of DUT? (y/N). n


# 输入y打印出配置
Print preview of generated config? (Y/n) y
### Config file generated by dpdk_setup_ports.py ###

- version: 2
interfaces: ['84:00.0', '84:00.1']
port_info:
- dest_mac: 00:1b:21:87:1a:cd # MAC OF LOOPBACK TO IT'S DUAL INTERFACE
src_mac: 00:1b:21:87:1a:cc
- dest_mac: 00:1b:21:87:1a:cc # MAC OF LOOPBACK TO IT'S DUAL INTERFACE
src_mac: 00:1b:21:87:1a:cd

platform:
master_thread_id: 0
latency_thread_id: 1
dual_if:
- socket: 1
threads: [8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31]


# 输入y保存配置文件
Save the config to file? (Y/n)y
Default filename is /etc/trex_cfg.yaml
Press ENTER to confirm or enter new file:


# 输入y覆盖旧的配置文件
File /etc/trex_cfg.yaml already exist, overwrite? (y/N)y

4 查看一下配置文件是否正确

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@T-rex v2.97]# cat /etc/trex_cfg.yaml
### Config file generated by dpdk_setup_ports.py ###

- version: 2
interfaces: ['84:00.0', '84:00.1']
port_info:
- dest_mac: 00:1b:21:87:1a:cd # MAC OF LOOPBACK TO IT'S DUAL INTERFACE
src_mac: 00:1b:21:87:1a:cc
- dest_mac: 00:1b:21:87:1a:cc # MAC OF LOOPBACK TO IT'S DUAL INTERFACE
src_mac: 00:1b:21:87:1a:cd

platform:
master_thread_id: 0
latency_thread_id: 1
dual_if:
- socket: 1
threads: [8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31]

5 修改文件、回放脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -c 代表核数  -m 代表倍数  -d 代表运行时间
[root@T-rex v2.97]# ./t-rex-64 -f cap2/http_simple.yaml -c 4 -m 10000000 -d 100

-Per port stats table
ports | 0 | 1
-----------------------------------------------------------------------------------------
opackets | 58459241 | 0
obytes | 3741391872 | 0
ipackets | 0 | 0
ibytes | 0 | 0
ierrors | 0 | 0
oerrors | 0 | 0
Tx Bw | 6.67 Gbps | 0.00 bps

-Global stats enabled
Cpu Utilization : 67.2 % 5.0 Gb/core
Platform_factor : 1.0
Total-Tx : 6.67 Gbps
Total-Rx : 0.00 bps
Total-PPS : 13.02 Mpps
Total-CPS : 13.02 Mcps

Expected-PPS : 27.76 Mpps
Expected-CPS : 27.76 Mcps
Expected-BPS : 14.21 Gbps

Active-flows : 0 Clients : 255 Socket-util : 0.0000 %
Open-flows : 58465556 Servers : 65535 Socket : 3 Socket/Clients : 0.0
Total_queue_full : 2986413
drop-rate : 6.67 Gbps
current time : 5.8 sec
test duration : 94.2 sec

6 测试多流流量

  • 系统会提示核心数上限

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 开启TRex服务端程序 `-c 可以指定核心数`
[root@T-rex v2.97]# ./t-rex-64 -i -c 24

# 打开另一个终端 `-r 只读模式`
[root@T-rex v2.97]# ./trex-console

# 在客户端程序中开启流量发送测试脚本
[root@T-rex v2.97]# start -f stl/bench.py -m 100% -t size=64,vm=random

# 查看当前统计信息
trex>tui

# 停止
tui>stop

# 清除
tui>clear
  • tui 测试信息展示


Cisco TRex搭建与测试
https://simple2ich4n.top/15279/
作者
2ich4n
发布于
2022年5月12日
更新于
2022年6月13日
许可协议