【Trex】Trex初始化配置和server/client的启动

8 篇文章 1 订阅

Trex初始化配置和server/client的启动

第二章 Trex初始化配置和server/client的启动



一、Trex初始化配置

可以用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:

二、启动server和client

1.启动server

参数的具体含义可以用命令查看 : ./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

2.启动client

默认是用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

总结

接下来就是随意探索的时间段了。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
Trex是一款开源的数据包生成和流量生成工具,可以模拟真实网络环境下的高负载流量。根据需求,Trex可以配置多个收发口。 Trex目前支持多种网络接口类型,包括以太网网卡(支持Intel、Broadcom等品牌)、FPGA加速卡等。首先,我们需要确保计算机或服务器上有支持的网卡硬件。 在配置Trex之前,我们需要编辑trex_cfg.yaml文件,该文件位于Trex安装目录的etc文件夹中。在文件中,我们可以指定Trex要使用的物理接口数量,从而配置多个收发口。 要配置多个收发口,我们首先需要设置接口数量变量(这里以两个收发口为例): - 填写接口1的mac地址和PCI的地址。 - 填写接口2的mac地址和PCI的地址。 接下来,我们需要使用Trex所提供的命令行工具trex-console,通过运行以下命令来连接到Trex server: ``` trex-console -c ``` 在trex-console中,我们可以使用“bind”命令将网卡与对应的收发口绑定。例如,使用以下命令将接口1绑定到TrexA端口0: ``` bind 0 0 ``` 类似地,使用以下命令将接口2绑定到TrexB端口1: ``` bind 1 1 ``` 完成上述步骤后,我们可以通过运行测试用例来验证Trex配置的多个收发口是否正常工作。例如,我们可以使用Trex提供的测试用例中的“trex_stl_lib”测试多口并行发送和接收数据包的性能。 综上所述,我们可以通过编辑trex_cfg.yaml文件和使用trex-console命令行工具来配置Trex的多个收发口。可以根据具体需求,灵活设置Trex的收发口数量,并通过运行测试用例来验证配置是否成功。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值