You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:无法使用testpmd生成.pcap流量捕获文件

使用TestPMD作为流量嗅探器并保存PCAP文件

Alright, let's walk through exactly how to capture traffic with testpmd and save it to a .pcap file, using your existing DPDK setup. First, I see your target NIC is 0000:01:00.0—it's already bound to the igb_uio driver, which is perfect for DPDK operations.

Step 1: Launch TestPMD with PCAP Capture Enabled

Start testpmd with parameters that enable pcap capture and target your DPDK-bound NIC. Run this command (adjust CPU cores and memory channels to match your hardware):

sudo testpmd -l 0-1 -n 4 --vdev 'net_pcap0,dev=0000:01:00.0' -- --port-topology=chained --capture=rx --capture-file=my_traffic.pcap

Let's break down the key flags:

  • -l 0-1: Specifies CPU cores to use (replace with cores available on your system)
  • -n 4: Sets the number of memory channels (match your server's memory configuration—common values are 2 or 4)
  • --vdev 'net_pcap0,dev=0000:01:00.0': Creates a virtual pcap device tied to your DPDK-enabled NIC
  • --capture=rx: Captures only incoming (receive) traffic; use rx-tx if you need both send and receive
  • --capture-file=my_traffic.pcap: Defines the output .pcap filename

Step 2: Start Capturing Traffic in TestPMD's Interactive Mode

Once testpmd loads, you'll enter its command line interface. Start the capture with:

start

Let it run as long as you need to capture traffic. When you're done, stop the capture:

stop

Then exit testpmd completely:

quit

Step 3: Verify Your Capture

You can now inspect the generated .pcap file using tools like Wireshark or tshark. For a quick check in the terminal:

tshark -r my_traffic.pcap

Quick Troubleshooting Tips

  • If testpmd can't detect your NIC, re-verify the binding with dpdk-devbind.py --status to ensure 0000:01:00.0 is still under igb_uio
  • Always run testpmd with sudo—DPDK requires root-level access to hardware resources
  • To limit the number of captured packets, add --capture-packets=1000 (replace 1000 with your desired count) to the initial launch command

内容的提问来源于stack exchange,提问作者MZab

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:13:02