求助:无法使用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; userx-txif 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 --statusto ensure0000:01:00.0is still underigb_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

