使用NVIDIA ConnectX网卡快速配置TRex的快速入门指南

本文档提供了使用NVIDIA ConnectX网卡快速配置TRex的步骤指南,涵盖范围、简介、参考资料、解决方案架构、关键组件与技术、软件栈组件、逻辑设计、部署与配置以及测试示例。

文档目录

使用NVIDIA ConnectX网卡快速配置TRex的快速入门指南

范围

使用TRex与NVIDIA ConnectX网络网卡通常非常直接,尤其对于熟悉Linux和网络工具的用户。 本文档提供了一份快速入门指南,以几个清晰的步骤概述了该过程,即使没有DPDK或高级网络方面的深厚专业知识也能轻松上手。

简介

TRex是Cisco开发的一款开源高性能流量生成器。它旨在生成逼真的网络流量,用于测试和基准测试网络设备和服务。 它支持L3-L7有状态和无状态流量生成,适用于从简单吞吐量测试到复杂应用级模拟的各种测试场景。 该软件通过使用DPDK优化了性能,DPDK允许直接访问网络硬件,绕过典型的Linux网络栈,从而实现更高的速度和效率。

借助NVIDIA ConnectX网卡,TRex通过利用以下关键硬件和软件特性实现高带宽:

  • DPDK集成: TRex基于DPDK构建,允许其绕过Linux内核,直接与网卡硬件交互。NVIDIA ConnectX网卡针对DPDK进行了高度优化,使TRex能够以非常高的速率高效发送和接收数据包。
  • 线速性能: ConnectX以太网卡可以轻松产生高达100Gbps的带宽,而较新的型号(如ConnectX-7和ConnectX-8)支持更高的数据速率,分别高达400Gbps和800Gbps。这使得它们非常适合要求苛刻的网络测试场景。
  • 低延迟和高效率: ConnectX网卡的架构专为低延迟、高吞吐量网络设计,这对于逼真的流量生成和准确的设备基准测试至关重要。

参考资料

解决方案架构

关键组件与技术

  • NVIDIA ConnectX智能网卡 10/25/40/50/100/200和400G以太网网卡 业界领先的NVIDIA® ConnectX®系列智能网卡提供先进的硬件卸载和加速。 NVIDIA以太网网卡为超大规模、公有云和私有云、存储、机器学习、AI、大数据和电信平台提供最高的ROI和最低的总拥有成本。

  • NVIDIA LinkX线缆 NVIDIA® LinkX®线缆和收发器产品系列提供了业界最完整的10、25、40、50、100、200和400GbE以太网以及100、200和400Gb/s InfiniBand产品线,适用于云、HPC、超大规模、企业、电信、存储和人工智能数据中心应用。

  • NVIDIA PMD NVIDIA轮询模式驱动(PMD)是一个开源上游驱动,嵌入在d p d k . o r g发布版中,旨在通过提供内核旁路用于接收和发送,并避免中断处理的性能开销,实现快速数据包处理和低延迟。

软件栈组件

(此处应包含软件栈组件的详细说明,但原文未提供具体内容,故保留占位)

逻辑设计

(此处应包含逻辑设计的详细说明,但原文未提供具体内容,故保留占位)

部署与配置

必备开发工具

(此处应包含必备开发工具的详细说明,但原文未提供具体内容,故保留占位)

安装RDMA-CORE

(此处应包含安装RDMA-CORE的详细说明,但原文未提供具体内容,故保留占位)

安装并编译TRex

(此处应包含安装并编译TRex的详细说明,但原文未提供具体内容,故保留占位)

设置TRex端口和被测设备对端端口

(此处应包含设置TRex端口和被测设备对端端口的详细说明,但原文未提供具体内容,故保留占位)

运行TRex服务器

(此处应包含运行TRex服务器的详细说明,但原文未提供具体内容,故保留占位)

测试示例

运行Testpmd

(此处应包含运行Testpmd的详细说明,但原文未提供具体内容,故保留占位)

启动TRex测试

上传TRex脚本

(此处应包含上传TRex脚本的详细说明,但原文未提供具体内容,故保留占位)

启动TRex控制台

(此处应包含启动TRex控制台的详细说明,但原文未提供具体内容,故保留占位)

开始发送流量

(此处应包含开始发送流量的详细说明,但原文未提供具体内容,故保留占位)

输出示例

(此处应包含输出示例的详细说明,但原文未提供具体内容,故保留占位)

范围

本文档介绍如何使用NVIDIA ConnectX网卡在几步内配置TRex流量生成器。

简介

本文档提供了一种快速部署TRex的方法,利用NVIDIA ConnectX网卡进行高性能网络测试。

参考资料

解决方案架构

关键组件与技术

  • TRex: 基于Cisco的流量生成器,支持有状态和无状态流量。
  • Testpmd: DPDK提供的包转发应用,用于回环流量。
  • NVIDIA ConnectX网卡: 高性能智能网卡,支持DPDK和RDMA。

软件栈组件

  • 操作系统: Ubuntu/Debian 或 CentOS/RHEL
  • DPDK: 数据平面开发套件
  • RDMA-CORE: 远程直接内存访问核心库
  • TRex-core: TRex流量生成器核心

逻辑设计

背靠背服务器安装,被测设备服务器运行testpmd,TRex流量生成器服务器运行TRex。

本文档演示单向流量:流量从第一个TRex端口发出,由Testpmd应用回环到第二个TRex端口。

逻辑设计图

部署与配置

必备开发工具

对于基于DEB的OS发行版:

sudo apt-get install build-essential automake autoconf subversion libssl-dev libtool

对于基于RPM的OS发行版:

sudo yum groupinstall 'Development Tools'

安装RDMA-CORE

对于基于DEB的OS发行版:

sudo apt install libibverbs-dev ibverbs-utils librdmacm-dev

对于基于RPM的OS发行版:

sudo yum install rdma-core-devel

安装并编译TRex

sudo git clone https://github.com/cisco-system-traffic-generator/trex-core.git
sudo cd trex-core/linux_dpdk
sudo ./b configure --no-ofed-check
sudo ./b build

设置TRex端口和被测设备对端端口

本例中选择NVIDIA ConnectX6-DX端口,ID为4和5。

每个TRex ConnectX6-DX端口配置为其所连接的Testpmd对端端口的目的MAC地址。

sudo cd trex-core/scripts/
sudo ./dpdk_setup_ports.py -i
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    | 02:00.0 | b8:83:03:45:ee:78 | NetXtreme BCM5719 Gigabit Ethernet PCIe                      | tg3       | eno1      | *Active* |
+----+------+---------+-------------------+--------------------------------------------------------------+-----------+-----------+----------+
| 1  | 0    | 02:00.1 | b8:83:03:45:ee:79 | NetXtreme BCM5719 Gigabit Ethernet PCIe                      | tg3       | eno2      |          |
+----+------+---------+-------------------+--------------------------------------------------------------+-----------+-----------+----------+
| 2  | 0    | 02:00.2 | b8:83:03:45:ee:7a | NetXtreme BCM5719 Gigabit Ethernet PCIe                      | tg3       | eno3      |          |
+----+------+---------+-------------------+--------------------------------------------------------------+-----------+-----------+----------+
| 3  | 0    | 02:00.3 | b8:83:03:45:ee:7b | NetXtreme BCM5719 Gigabit Ethernet PCIe                      | tg3       | eno4      |          |
+----+------+---------+-------------------+--------------------------------------------------------------+-----------+-----------+----------+
| 4  | 0    | 61:00.0 | b8:ce:f6:09:f9:f0 | MT43244 BlueField-3 integrated ConnectX-7 network controller | mlx5_core | ens2f0np0 |          |
+----+------+---------+-------------------+--------------------------------------------------------------+-----------+-----------+----------+
| 5  | 0    | 61:00.1 | b8:ce:f6:09:f9:f1 | MT43244 BlueField-3 integrated ConnectX-7 network controller | mlx5_core | ens2f1np1 |          |
+----+------+---------+-------------------+--------------------------------------------------------------+-----------+-----------+----------+
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.
Enter list of interfaces separated by space (for example: 1 3) : 4 5

For interface 4, assuming loopback to its dual interface 5.
Destination MAC is b8:ce:f6:09:f9:f1. Change it to MAC of DUT? (y/N).y
Please enter a new destination MAC of interface 4: 04:3f:72:fc:51:7e
For interface 5, assuming loopback to its dual interface 4.
Destination MAC is b8:ce:f6:09:f9:f0. Change it to MAC of DUT? (y/N).y
Please enter a new destination MAC of interface 5: 04:3f:72:fc:51:7f
Print preview of generated config? (Y/n)y
### Config file generated by dpdk_setup_ports.py ###

- version: 2
  interfaces: ['61:00.0', '61:00.1']
  port_info:
      - dest_mac: 04:3f:72:fc:51:7e
        src_mac:  b8:ce:f6:09:f9:f0
      - dest_mac: 04:3f:72:fc:51:7f
        src_mac:  b8:ce:f6:09:f9:f1

  platform:
      master_thread_id: 0
      latency_thread_id: 47
      dual_if:
        - socket: 0
          threads: [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]

Save the config to file? (Y/n)y
Default filename is /etc/trex_cfg.yaml
Press ENTER to confirm or enter new file:
File /etc/trex_cfg.yaml already exist, overwrite? (y/N)y
Saved to /etc/trex_cfg.yaml.

运行TRex服务器

统计上一步中自动列出的线程数(本例中为46个线程)。

将线程数输入以下命令(-c <线程数>)。

nohup ./t-rex-64 --no-ofed-check -i -c 46 &

测试示例

运行Testpmd

此testpmd命令行示例使用16个核心和队列,并带有相应的核心位掩码。

--eth-peer=0,<mac_address> 设置第一个testpmd端口的目的MAC地址为其所连接的TRex对端端口。

--eth-peer=1,<mac_address> 设置第二个testpmd端口的目的MAC地址为其所连接的TRex对端端口。

./dpdk-testpmd -c 0x1FFFF000000 -m 4096 -a 0000:b1:00.0,mprq_en=1 -a 0000:b1:00.1,mprq_en=1 -- --burst=64 --txd=1024 --rxd=1024 --mbcache=512 --rxq=16 --txq=16 --nb-cores=16 --rss-udp --forward-mode=io --eth-peer=0,b8:ce:f6:09:f9:f0 --eth-peer=1,b8:ce:f6:09:f9:f1 -a -i

启动TRex测试

上传TRex脚本

将文件 benchmark_udp_1pkt_simple.py 上传到 trex-core/scripts/stl/ 目录。

该脚本能够发送各种包长度,并带有源UDP端口范围。

from trex_stl_lib.api import *
import argparse

class STLS1(object):

    def create_stream (self, packet_len, stream_count):
        base_pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(sport=4337)
        base_pkt_len = len(base_pkt)
        base_pkt /= 'x' * max(0, packet_len - base_pkt_len)
        packets = []
        vm = STLScVmRaw( [
                                STLVmFlowVar(name="v_port",
                                                min_value=4337,
                                                  max_value=5337,
                                                  size=2, op="inc"),
                                STLVmWrFlowVar(fv_name="v_port",
                                            pkt_offset= "UDP.sport" ),
                                STLVmFixChecksumHw(l3_offset="IP",l4_offset="UDP",l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP),

                            ]
                        )
        for i in range(stream_count):
            packets.append(STLStream(
                packet = STLPktBuilder(pkt = base_pkt, vm = vm),
                mode = STLTXCont()
                ))
        return packets

    def get_streams (self, tunables, **kwargs):
        parser = argparse.ArgumentParser(description='Argparser for {}'.format(os.path.basename(__file__)),
                                         formatter_class=argparse.ArgumentDefaultsHelpFormatter)
        parser.add_argument('--packet_len',
                            type=int,
                            default=64,
                            help="The packets length in the stream")
parser.add_argument('--stream_count',
                    type=int,
                    default=1,
                    help="The number of streams")
args = parser.parse_args(tunables)
# create 1 stream
return self.create_stream(args.packet_len - 4, args.stream_count)

# dynamic load - used for trex console or simulator
def register():
    return STLS1()

Start Trex console

From trex-core/scripts/ directory.

sudo ./trex-console

Using 'python3' as Python interpreter
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:   v3.06 @ STL
Server mode:      Stateless
Server CPU:       46 x Intel(R) Xeon(R) Platinum 8168 CPU @ 2.70GHz
Ports count:      2 x 200Gbps @ MT43244 BlueField-3 integrated ConnectX-7 network controller

-=TRex Console v3.0=-

Type 'help' or '?' for supported actions

trex>

Start sending traffic

This example sends UDP packets at size of 64Bytes while utilizing 100% of line rate. Packets are sent through port 0 and return to port 1 accomplishing unidirectional test.

trex>start -f stl/benchmark_udp_1pkt_simple.py -p 0 -m 100% -t  packet_len=64

Output example

Of ~148Mpps and ~100Gbs with link speed of 100Gbs

uni_directional_trex.png

AZ.jpg Amir Zeidner For several years, Amir has worked as a 解决方案 Architect primarily in the Telco space, leading advanced solutions to answer 5G, NFV, and SDN networking infrastructure requirements. Amir’s expertise in data plane acceleration technologies, such as Accelerated Switching and Network Processing (ASAP²) and DPDK, together with a deep knowledge of open-source cloud-based infrastructures, allows him to promote and deliver unique end-to-end NVIDIA Networking solutions throughout the Telco world.

Related Documents

使用Nvidia ConnectX网卡快速配置TRex的快速入门指南

范围

本文档旨在指导用户通过几个步骤,使用Nvidia ConnectX网卡配置TRex流量生成器。

简介

TRex是一个开源的低成本流量生成器,基于Intel DPDK开发。结合Nvidia ConnectX网卡,可实现高性能网络测试。

参考文献

解决方案架构

关键组件和技术

  • Nvidia ConnectX网卡:支持高吞吐量和低延迟。
  • TRex:基于DPDK的流量生成器。
  • 交换机:用于连接测试设备。

软件栈组件

  • 网卡软件:包括驱动和工具。
  • 网卡固件:确保网卡功能正常。
  • DPDK:数据平面开发套件。

逻辑设计

TRex运行在服务器上,通过ConnectX网卡连接到交换机,生成测试流量。

部署和配置

前提条件

  • 安装Nvidia ConnectX网卡。
  • 安装网卡固件和软件。
  • 安装DPDK。

步骤

  1. 下载并编译TRex。
  2. 配置网卡绑定到DPDK。
  3. 启动TRex服务。
  4. 运行测试。

常见问题

问题1:网卡无法绑定到DPDK

解决方案:确保网卡固件版本兼容,并正确设置环境变量。

问题2:TRex启动失败

解决方案:检查配置文件中的接口参数是否正确。

相关页面