我有一个四端口英特尔 1G 网卡。我正在使用 DPDK 在一个物理端口上发送数据并在另一个物理端口上接收数据。
我在 DPDK 代码中看到了一些示例,但无法使其工作。如果有人知道该怎么做,请给我发送简单的说明,以便我可以遵循和理解。我为大页面正确设置了我的 PC,加载驱动程序,并分配网络端口以使用 dpdk 驱动程序等...我可以从 DPDK 运行 helloworld,因此系统设置对我来说看起来不错。
提前致谢。温度5556
我有一个四端口英特尔 1G 网卡。我正在使用 DPDK 在一个物理端口上发送数据并在另一个物理端口上接收数据。
我在 DPDK 代码中看到了一些示例,但无法使其工作。如果有人知道该怎么做,请给我发送简单的说明,以便我可以遵循和理解。我为大页面正确设置了我的 PC,加载驱动程序,并分配网络端口以使用 dpdk 驱动程序等...我可以从 DPDK 运行 helloworld,因此系统设置对我来说看起来不错。
提前致谢。温度5556
构建 DPDK 后:
cd
到 DPDK 目录。
跑sudo build/app/testpmd -- --interactive
你应该看到这样的输出:
$ sudo build/app/testpmd -- --interactive
EAL: Detected 8 lcore(s)
EAL: No free hugepages reported in hugepages-1048576kB
EAL: Multi-process socket /var/run/.rte_unix
EAL: Probing VFIO support...
EAL: WARNING: cpu flags constant_tsc=yes nonstop_tsc=no -> using unreliable clock cycles !
EAL: PCI device 0002:00:02.0 on NUMA socket 0
EAL: probe driver: 15b3:1004 net_mlx4
PMD: net_mlx4: PCI information matches, using device "mlx4_0" (VF: true)
PMD: net_mlx4: 1 port(s) detected
PMD: net_mlx4: port 1 MAC address is 00:0d:3a:f4:6e:17
Interactive-mode selected
testpmd: create a new mbuf pool <mbuf_pool_socket_0>: n=203456, size=2176, socket=0
testpmd: preferred mempool ops selected: ring_mp_mc
Warning! port-topology=paired and odd forward ports number, the last port
will pair with itself.
Configuring Port 0 (socket 0)
Port 0: 00:0D:3A:F4:6E:17
Checking link statuses...
Done
testpmd>
不要担心“没有免费的大页面”消息。这意味着它找不到任何 1024 MB 的大页面,但由于它继续正常,它一定找到了一些 2 MB 的大页面。如果它改为“EAL:使用 2 MB 大页面”就好了。
在提示符下键入start tx_first
,然后quit
。您应该会看到如下内容:
testpmd> start tx_first
io packet forwarding - ports=1 - cores=1 - streams=1 - NUMA support enabled, MP over anonymous pages disabled
Logical Core 1 (socket 0) forwards packets on 1 streams:
RX P=0/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
io packet forwarding packets/burst=32
nb forwarding cores=1 - nb forwarding ports=1
port 0:
CRC stripping enabled
RX queues=1 - RX desc=1024 - RX free threshold=0
RX threshold registers: pthresh=0 hthresh=0 wthresh=0
TX queues=1 - TX desc=1024 - TX free threshold=0
TX threshold registers: pthresh=0 hthresh=0 wthresh=0
TX RS bit threshold=0 - TXQ offloads=0x0
testpmd> quit
Telling cores to stop...
Waiting for lcores to finish...
---------------------- Forward statistics for port 0 ----------------------
RX-packets: 0 RX-dropped: 0 RX-total: 0
TX-packets: 32 TX-dropped: 0 TX-total: 32
----------------------------------------------------------------------------
+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
RX-packets: 0 RX-dropped: 0 RX-total: 0
TX-packets: 32 TX-dropped: 0 TX-total: 32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
在我的系统中只有一个 DPDK 端口,所以我发送了 32 个数据包但没有收到任何数据。如果我有一个多端口卡,端口之间直接有电缆,那么我会看到 RX 计数也会增加。
您可以使用 TESTPMD 来测试 DPDK。
TestPMD 可以用作数据包生成器(tx_only 模式)、接收器(rx_only 模式)或转发器(io 模式)。
如果您愿意仅将 TESTPMD 用作转发器,则需要将生成器节点连接到您的盒子。
我建议您从以下示例开始:
生成器(pktgen)--> testPMD(io 模式)---------> 接收器(testPMD rx_only 模式)。
在 pktgen 生成器中指定 MAC 地址目的地,它是接收方接收端口的 MAC 地址。
PKTGEN 及其工作原理在此链接中有更多说明:
http://pktgen.readthedocs.io/en/latest/getting_started.html
此处解释了 TESTPMD 及其工作原理:
我希望这有帮助。