Traffic capturing
There are three possible ways of capturing traffic on a VPP instance:
- Using the VPPCTL CLI tool trace command
- Using the VPPCTL CLI tool pcap trace command
- Using a dedicated pod with the SPAN interface
Caution
The trace and pcap trace CLI commands use memory to store the trace, so before using it, assess how much memory is left on the pod. The alternative is to use kernel-based PCAP capturing inside the workload pod that uses the TAP interface.
Check the memory
To assess how much memory is left on the FPP pod, check main heap stats:
Output example:
Heap stats are also exposed in these FPP metrics:
vpp_main_heap_total_bytesvpp_main_heap_used_bytesvpp_main_heap_free_bytes
Measured the pcap size based on packet size and the number of packets to capture:
- 10k of UDP 64B packets → ~20 MB
- 10k of UDP 594B packets → ~60 MB
- 10k of UDP 1518B packets → ~110 MB
- 1M of UDP 1518B packets → ~900 MB
The memory taken from the heap does not return as free but is reused normally. Due to VPP heap fragmentation, VPP stats (and corresponding metrics exposed by the FPP pod) will not respond with released memory.
Capturing using trace
You can enable text-based tracing of packets arriving on VPP interfaces using the command vppctl trace:
In this case, 10 packets are captured. The trace is gathered on the VPP node. The possible values are:
- memif-input
- dpdk-input
To see all available options, go to the official VPPCTL trace documentationOpens in a new tab.
To see the gathered packets, run:
See the output example:
To clear the trace, run:
Capturing using pcap trace
You can gather PCAPs from a specific VPP interface or from a VPP graph node.
- To gather packets from the VPP interface, use the
pcap tracecommand. - To gather traffic from a VPP graph node, use the
pcap dispatch tracecommand.
pcap trace
To enable pcap trace on the memif interface, capturing both RX and TX directions, run this command in the FPP pod:
1000is the limit of captured packetsmemif1/101-grx26is the name of VPP interface on which the trace should be gathered.
For more details about the pcap trace command, read the official VPP documentationOpens in a new tab.
To see the status of PCAP capturing:
Sample output:
To stop the trace, run:
The PCAPs are stored in the /tmp/rxtxdrop.pcap file in the FPP pod. Copy this file from the pod to an external machine for further analysis. For example, you can use this command:
pcap dispatch trace
The pcap dispatch trace command records VPP graph nodes that the packet goes through when it's processed. It allows you to see the path that the packet was steered or check why it was dropped. To activate the trace, you must set the observation point (VPP graph node):
- dpdk-input - used for physical interfaces
- memif-input - used for in-memory VPP interfaces
To enable pcap dispatch trace, run:
This gathers 1000 packets of DPDK traffic. The 100 value is required but ignored by VPP.
For more details about the pcap dispatch trace command, read the official VPP documentationOpens in a new tab.
To see the status of the dispatch trace, run:
Sample output:
To stop the trace, run:
This saves the PCAP file in /tmp/dispatch.pcap inside the FPP pod. To download it
to the local machine, use this command:
Traffic filtering
VPP allows filtering the packets before dumping them into the PCAP file. To do so, first create the classifier:
After creating the classifier, pass filter at the end of the pcap trace command, for example:
For more details about the classify filter command, read the official VPP documentationOpens in a new tab.
SPAN interfaces
For FPP-based CNFs, traffic can be captured using the SPAN functionality of FPP.
This approach is mandatory for VPP-based CNFs that use the memif interface type on FPP.
You can find more details in the fpp-manager documentation.
To capture traffic from an FPP interface, a dedicated pod with the pcap-collector container can be started.
A target FPP interface is attached to the pod, which receives the SPAN traffic of a defined FPP source interface.
The respective NetworkAttachmentDefinition (created on the Core Cluster) looks like this:
If the CNI-less feature is used, you must define vppInterfaceRef in the spanSource section, with the name and the namespace of the slave memif VPPInterface CR. See an example of NetworkAttachmentDefinition (created on the Core Cluster):
The pod must refer to the created resource through an annotation in order to create an sxb interface where the mirrored traffic can be captured:
In order not to send the mirrored traffic across nodes through the distributed switch domain, pin the capturing pod to the same node as the CNF is running on.
To avoid bogus traffic being sent from the capturing pod through the Kubernetes pod network, ensure that no main routing table applies, for example, by using the following script:
Tracing commands
These are the other useful VPP CLI commands for traffic capturing:
trace add memif-input 20- enable text-based tracing of packets arriving on memif interfaces (that is, packets coming from VPP apps in case of VPPSwitch). Suitable during very low traffictrace add virtio-input 20- enable text-based tracing of packets arriving on tap interfaces (that is, packets coming from Linux networking pods in case of VPPSwitch). Suitable during very low traffictrace add dpdk-input 20- enable text-based tracing of packets arriving on uplinksshow trace- show text-based traceclear trace- clear and disable text-based tracepcap trace tx rx max 10000 intfc memif1/100 file foo.pcap- enable PCAP capture in both RX and TX directions, writing to/tmp/foo.pcapinside the pod. Will capture up to 10000 packets. Note that the whole trace is stored in RAM and thus cannot be unlimited.pcap trace off- disable tracing and write the capture filepcap dispatch trace on max 10000 file vppcapture buffer-trace memif-input 100- enable dispatch trace that stores VPP graph node info inside the PCAP, max 10000 packets, and write it to/tmp/vppcaptureinside the podpcap dispatch trace off- disable dispatch tracing and write the capture file