如何使用DPDK发送和接收数据

时间:2017-04-06 05:10:21

标签: dpdk

我有一个四端口Intel 1G网卡。我正在使用DPDK在一个物理端口上发送数据,在另一个物理端口上接收数据。

我在DPDK代码中看到了一些示例,但无法使其正常工作。如果有人知道该怎么做,请发给我简单的说明,这样我就可以理解。我正确设置我的电脑用于大页面,加载驱动程序,并分配网络端口以使用dpdk驱动程序等...我可以从DPDK运行helloworld,因此系统设置对我来说没问题。

提前致谢。 temp5556

2 个答案:

答案 0 :(得分:2)

建立DPDK之后:

  1. cd到DPDK目录。

  2. 运行sudo build/app/testpmd -- --interactive

  3. 你应该看到这样的输出:

    $ 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>
    
    不要担心&#34;没有免费的大页面&#34;信息。这意味着它无法找到任何1024 MB的大页面,但它继续正常,它必须找到大约2 MB的大页面。如果它说“#EAL:使用2 MB大页面&#34;它会很好。代替。

    在提示符处键入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数也会增加。

答案 1 :(得分:1)

您可以使用TESTPMD测试DPDK。

TestPMD可以作为数据包生成器(tx_only模式),接收器(rx_only模式)或转发器(io模式)工作。

如果您愿意仅使用TESTPMD作为转发器,则需要将生成器节点连接到您的盒子。

我建议您从以下示例开始:

generator(pktgen)------&gt; testPMD(io模式)----------&gt; recevier(testPMD rx_only模式)。

在pktgen生成器中指定mac地址目的地,即接收端口的MAC地址。

PKTGEN及其详细工作原理在此链接中有更多解释:

http://pktgen.readthedocs.io/en/latest/getting_started.html

TESTPMD及其工作原理在此解释:

http://www.intel.com/content/dam/www/public/us/en/documents/guides/dpdk-testpmd-application-user-guide.pdf

我希望这会有所帮助。

相关问题