第二章 Trex初始化配置和server/client的启动
可以用lspci命令查看网卡的在位情况。下面的01:00.0/01:00.1/05:00.0/05:00.1分别代表网卡的接口。
[root@localhost v2.95]# lspci
01:00.0 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
01:00.1 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
03:00.0 PCI bridge: Texas Instruments XIO2001 PCI Express-to-PCI Bridge
04:02.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8169 PCI Gigabit Ethernet Controller (rev 10)
05:00.0 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
05:00.1 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
切换到trex解压的目录,开始配置要使用的接口。Trex最少需要两个接口,也就是端口对的概念。如果只有一个可用的口,那可以采用dummy来占位。实际的环境已经升级到最新的v2.95,后续就用这个版本来举例。
[root@Trex85 v2.97]# ./dpdk_setup_ports.py -t
+----+------+---------+-------------------+-----------------------------------------------+---------+----------+----------+
| ID | NUMA | PCI | MAC | Name | Driver | Linux IF | Active |
+====+======+=========+===================+===============================================+=========+==========+==========+
| 0 | -1 | 00:1f.6 | 30:d0:42:f1:cb:5f | Ethernet Connection (11) I219-LM | e1000e | em1 | *Active* |
+----+------+---------+-------------------+-----------------------------------------------+---------+----------+----------+
| 1 | -1 | 04:00.0 | a0:36:9f:89:88:16 | I350 Gigabit Network Connection | igb | p1p1 | |
+----+------+---------+-------------------+-----------------------------------------------+---------+----------+----------+
| 2 | -1 | 04:00.1 | a0:36:9f:89:88:17 | I350 Gigabit Network Connection | igb | p1p2 | |
+----+------+---------+-------------------+-----------------------------------------------+---------+----------+----------+
| 3 | -1 | 06:00.0 | a0:36:9f:89:88:14 | I350 Gigabit Network Connection | igb | p7p1 | |
+----+------+---------+-------------------+-----------------------------------------------+---------+----------+----------+
| 4 | -1 | 06:00.1 | a0:36:9f:89:88:15 | I350 Gigabit Network Connection | igb | p7p2 | |
+----+------+---------+-------------------+-----------------------------------------------+---------+----------+----------+
| 5 | -1 | 0a:00.0 | 08:57:00:ef:62:48 | RTL-8100/8101L/8139 PCI Fast Ethernet Adapter | 8139too | p2p1 | |
+----+------+---------+-------------------+-----------------------------------------------+---------+----------+----------+
#再用如下命令初始化配置,按照提示输入,最终生成默认的配置文件/etc/trex_cfg.yaml.
[root@localhost v2.95]# ./dpdk_setup_ports.py -i
[root@Trex85 v2.97]# cat /etc/trex_cfg.yaml
### Config file generated by dpdk_setup_ports.py ###
- version: 2
interfaces: ['01:00.0', '01:00.1']
port_info:
- dest_mac: b4:96:91:86:59:9a # MAC OF LOOPBACK TO IT'S DUAL INTERFACE
src_mac: b4:96:91:86:59:98
- dest_mac: b4:96:91:86:59:98 # MAC OF LOOPBACK TO IT'S DUAL INTERFACE
src_mac: b4:96:91:86:59:9a
platform:
master_thread_id: 0
latency_thread_id: 1
dual_if:
- socket: 0
threads: [2,3,4,5,6,7,8,9,10,11]
如果要用到IPv6的接口,添加stack: linux_based。仅仅构造IPv6的报文发送是不需要的。
- version: 2
interfaces: ['01:00.0', '01:00.1', '05:00.0', '05:00.1']
stack: linux_based
port_info:
参数的具体含义可以用命令查看 : ./t-rex-64 -h
–vlan 是用82599es的芯片网卡要带的,其他的可以不带
[root@Trex85 v2.97]# ./t-rex-64 -i --stl --vlan --ipv6
Starting Scapy server.... Scapy server is started
Trying to bind to vfio-pci ...
Trying to compile and bind to igb_uio ...
ERROR: We don't have precompiled igb_uio.ko module for your kernel version.
Will try compiling automatically...
Success.
/usr/local/python3/bin/python3 dpdk_nic_bind.py --bind=igb_uio 0000:04:00.0 0000:04:00.1 0000:06:00.0 0000:06:00.1
The ports are bound/configured.
Starting TRex v2.97 please wait ...
set driver name net_e1000_igb
driver capability : TCP_UDP_OFFLOAD TSO SLRO
set dpdk queues mode to DROP_QUE_FILTER
Number of ports found: 4
zmq publisher at: tcp://*:4500
wait 10 sec ..........
port : 0
------------
link : link : Link Up - speed 1000 Mbps - full-duplex
promiscuous : 0
port : 1
------------
link : link : Link Up - speed 1000 Mbps - full-duplex
promiscuous : 0
port : 2
------------
link : link : Link Up - speed 100 Mbps - full-duplex
promiscuous : 0
port : 3
------------
link : link : Link Up - speed 100 Mbps - full-duplex
promiscuous : 0
number of ports : 4
max cores for 2 ports : 1
tx queues per port : 3
-------------------------------
RX core uses TX queue number 1 on all ports
core, c-port, c-queue, s-port, s-queue, lat-queue
------------------------------------------
1 0 0 1 0 2
2 2 0 3 0 2
-------------------------------
启动后server窗口就保持实时刷新的状态,一直开着就行了。另外在新链接上开启client。
-Per port stats table
ports | 0 | 1 | 2 | 3
-----------------------------------------------------------------------------------------
opackets | 0 | 0 | 0 | 0
obytes | 0 | 0 | 0 | 0
ipackets | 0 | 0 | 0 | 0
ibytes | 0 | 0 | 0 | 0
ierrors | 0 | 0 | 0 | 0
oerrors | 0 | 0 | 0 | 0
Tx Bw | 0.00 bps | 0.00 bps | 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 : 24.3 sec
test duration : 0.0 sec
默认是用python3来启动的,也可以通过加参数–python2强制使用Python2来运行client。
遇到任何疑惑都随时加个-h就能获取详细的帮助。
[root@248 v2.95]# ./trex-console
Using 'python3' as Python interpeter
Connecting to RPC server on localhost:4501 [SUCCESS]
Connecting to publisher server on localhost:4500 [SUCCESS]
Acquiring ports [0, 1, 2, 3]: [SUCCESS]
Server Info:
Server version: v2.95 @ STL
Server mode: Stateless
Server CPU: 2 x Intel(R) Xeon(R) CPU E3-1245 v3 @ 3.40GHz
Ports count: 4 x 10Gbps @ Ethernet Controller X710 for 10GbE SFP+
-=TRex Console v3.0=-
Type 'help' or '?' for supported actions
trex>
第一个命令就是portattr查看端口的情况
trex>portattr
Port Status
port | 0 | 1 | 2 | 3
----------------+----------------------+----------------------+----------------------+---------------------
driver | net_i40e | net_i40e | net_i40e | net_i40e
description | Ethernet Controlle | Ethernet Controlle | Ethernet Controlle | Ethernet Controlle
link status | UP | UP | UP | UP
link speed | 10 Gb/s | 10 Gb/s | 10 Gb/s | 10 Gb/s
port status | IDLE | IDLE | IDLE | IDLE
promiscuous | off | off | off | off
multicast | on | on | on | on
flow ctrl | none | none | none | none
vxlan fs | - | - | - | -
-- | | | |
layer mode | Ethernet | Ethernet | Ethernet | Ethernet
src IPv4 | - | - | - | -
IPv6 | off | off | off | off
src MAC | 6c:fe:54:25:2f:d0 | 6c:fe:54:25:2f:d1 | 6c:fe:54:25:2f:d2 | 6c:fe:54:25:2f:d3
--- | | | |
Destination | 6c:fe:54:25:2f:d1 | 6c:fe:54:25:2f:d0 | 6c:fe:54:25:2f:d3 | 6c:fe:54:25:2f:d2
ARP Resolution | - | - | - | -
---- | | | |
VLAN | - | - | - | -
----- | | | |
PCI Address | 0000:01:00.0 | 0000:01:00.1 | 0000:01:00.2 | 0000:01:00.3
NUMA Node | 0 | 0 | 0 | 0
RX Filter Mode | hardware match | hardware match | hardware match | hardware match
RX Queueing | off | off | off | off
Grat ARP | off | off | off | off
接下来就是随意探索的时间段了。