无法使用testpmd生成.pcap文件

时间:2018-04-16 14:55:13

标签: dpdk

我正在尝试将testpmd用作流量嗅探器,我想将该流量保存到.pcap文件中。 我已经安装并配置了DPDK并绑定了我想要捕获流量的接口。

使用兼容DPDK的驱动程序的网络设备

0000:01:00.0'I210千兆网络连接157b'drv = igb_uio unused = igb

使用内核驱动程序的网络设备

0000:02:00.0'I210千兆网络连接157b'如果= enp2s0 drv = igb unused = igb_uio 活动 0000:03:00.0'I210千兆网络连接157b'如果= enp3s0 drv = igb unused = igb_uio 活动 0000:04:00.0'QCA986x / 988x 802.11ac无线网络适配器003c'如果= wlp4s0 drv = ath10k_pci unused = igb_uio

我发现的问题如下:

my@server:~/dpdk-stable-17.11.1$ sudo build/app/testpmd -c '0xf' -n 4 --vdev 'eth_pcap0,rx_iface=enp1s0,tx_pcap=/home/output.pcap' -- --port-topology=chained --total-num-mbufs=2048 --nb-cores=3

EAL: Detected 4 lcore(s)
EAL: Probing VFIO support...
EAL: PCI device 0000:01:00.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:157b net_e1000_igb
EAL: PCI device 0000:02:00.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:157b net_e1000_igb
EAL: PCI device 0000:03:00.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:157b net_e1000_igb
PMD: Initializing pmd_pcap for eth_pcap0
PMD: Couldn't open enp1s0: enp1s0: SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: No such device
PMD: Couldn't open interface enp1s0
vdev_probe(): failed to initialize eth_pcap0 device

EAL: Bus (vdev) probe failed.
USER1: create a new mbuf pool <mbuf_pool_socket_0>: n=2048, size=2176, socket=0
Configuring Port 0 (socket 0)
Port 0: 00:0D:B9:48:87:54
Checking link statuses...
Done
No commandline core given, start packet forwarding
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=3 - nb forwarding ports=1
  port 0:
  CRC stripping enabled
  RX queues=1 - RX desc=128 - RX free threshold=32
  RX threshold registers: pthresh=8 hthresh=8  wthresh=4
  TX queues=1 - TX desc=512 - TX free threshold=0
  TX threshold registers: pthresh=8 hthresh=1  wthresh=16
  TX RS bit threshold=0 - TXQ flags=0x0
Press enter to exit
PMD: eth_igb_interrupt_action():  Port 0: Link Up - speed 1000 Mbps - full-duplex

Port 0: LSC event

Telling cores to stop...
Waiting for lcores to finish...

  ---------------------- Forward statistics for port 0  ----------------------
  RX-packets: 4498370        RX-dropped: 1630          RX-total: 4500000
  TX-packets: 4498370        TX-dropped: 0             TX-total: 4498370
  ----------------------------------------------------------------------------

  +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
  RX-packets: 4498370        RX-dropped: 1630          RX-total: 4500000
  TX-packets: 4498370        TX-dropped: 0             TX-total: 4498370
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Done.

Shutting down port 0...
Stopping ports...
Done
Closing ports...
Done

Bye...

PMD无法打开enp1s0,因为它正由DPDK使用,因此内核无法访问它。

我该怎么办?

提前致谢!!

1 个答案:

答案 0 :(得分:0)

  

PMD无法打开enp1s0,因为它正由DPDK使用,因此内核无法访问它。

你是对的。 pcap PMD背后的想法是使用pcap库在DPDK中使用内核接口和/或.pcap文件。但是一旦你将接口绑定到UIO,就不能再使用pcap库打开它了:

PMD: Initializing pmd_pcap for eth_pcap0
PMD: Couldn't open enp1s0: enp1s0: SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: No such device
PMD: Couldn't open interface enp1s0
vdev_probe(): failed to initialize eth_pcap0 device

相反,我们可以使用另一个界面(例如,enp2s0)作为来源:

--vdev 'eth_pcap0,rx_iface=enp2s0,tx_pcap=/home/output.pcap'

或者我们可以使用另一个.pcap文件作为来源:

--vdev 'eth_pcap0,rx_pcap=/home/input.pcap,tx_pcap=/home/output.pcap'

另请注意,写入.pcap可能会降低testpmd的效果,即效果会受到pcap_dump()来电的约束。