MEMCAP traffic capturing
You can use the MEMCAP plugin for traffic capturing.
MEMCAP is a framework that defines and implements a protocol for offloading the traffic capturing process using the memory-mapped interface. This approach reduces the operational overhead on the capturing component. Captured data is subsequently collected and processed by the MEMCAP Sink sub-component. By delegating resource-intensive tasks, such as I/O processing and system upgrades, to separate components, MEMCAP reduces resource requirements and improves scalability.
The Fast Path Provider (FPP) pod acts as a traffic collector and communicates with the MEMCAP Sink pod using a shared memory interface. Multiple FPP-based instances, such as FPP, Connectivity Gateway (CGW) or User Plane Gateway (UPG), located on a single node communicate with a single MEMCAP Sink pod located on the same node.
Terminology
Here's the terminology used within this document:
- Collector - FPP pod which provides capture streams. It can provide multiple PCAP streams in parallel.
- Sink - a component that receives data from collectors, processes it, and outputs as
.pcapngfiles. - Class - a traffic class which allows for different processing in MEMCAP Sink. For example,
hw_iface_l2is a VPP interface-based L2 traffic capturing, andupf_session_ipis a UPG IMSI-based IP traffic capturing. - Target - an arbitrary name used to direct traffic capture streams to destinations. On the collector side, different traffic capture streams can use the same target name. On the MEMCAP Sink side, different destinations can use the same target name as well. Target names can be chosen arbitrarily and do not require provisioning in advance.
- Stream - an instance of active traffic capture. For example, a stream of interface
eth0to targeteth-ifwith classhw_iface_l2. - Destination - the endpoint for a PCAP stream, which can be a file or an HTTP stream.
MEMCAP consists of the following sub-components:
-
VPP MEMCAP plugin implements the collector side of the MEMCAP connection. It implements the
hw_iface_l2collector, which allows you to collect traffic from L2 VPP interfaces. It also provides a framework for easy integration with other VPP plugins. -
MEMCAP Sink manages connections to collectors and processes the captured traffic data. It outputs the data in the
.pcapngfile format, which you can save to a disk with options for compression and rotation. Additionally, it allows streaming of.pcapngfiles over an HTTP connection for real-time analysis.
This is a sample operational workflow:
Installation
MEMCAP Sink is installed as a regular Helm chart. To install it, use the following command:
The -n fpp part of the command specifies a namespace where the MEMCAP sink will be deployed. For more details about the memcap.yaml file, read the Configuration section below.
Configuration
You can configure MEMCAP Sink using Helm chart configurable parameters. Such configuration allows you to:
- Name a PCAP file
- Enable file rotation
- Define how many packets are stored in a single file
- Define the maximum number of files
- Enable file compression
These are the parameters that you can configure:
See the MEMACAP sink configuration example:
This configuration creates a single PCAP file for two targets (pgw-pfcp and scg-pfcp). The PCAP file is stored in the MEMCAP pod in the location specified in the file_prefix field. A file name always contains an autogenerated suffix to avoid collisions during rotations or restarts. You can copy a PCAP file from the pod to an external machine for further analysis. For example, you can use this command:
Usage
Enable traffic capturing
To initiate traffic capturing on a specific interface, use this command:
filter {tcpdump filter}- allows you to define libpcap-based filters that are the same as in the tcpdump utility. The filter format is described in the libpcap documentationman pcap-filter. Examples:filter {arp or icmp},filter {src net 192.0.2.0/24 and port 2020}.packet_max_bytesis an optional parameter which allows you to limit the size of collected data to reduce memory usage of a traffic capturerxandtxallow you to specify the direction in which traffic should be collected. Leaving those flags out collects traffic in both directions.
Note that you can create multiple captures for the same interface when using different capture targets. This is useful if you want to simultaneously collect differently filtered traffic to separate files from a single interface.
Each active stream on the interface may slow down the entire interface performance. To reduce performance degradation, it's best to keep the number of streams attached to interfaces low. This can be done by combining filters using the libpcap or operator.
Disable traffic capturing
To disable traffic capturing on a specific interface, use this command:
Monitor traffic capture
To view the created interface captures, use the command:
See the output example:
To view all the created MEMCAP streams from all plugins, use the command:
See the output example:
To view MEMCAP connection state, use the command:
See the output example:
Capture information
You can use the additional metadata provided in a .pcapng file for advanced filters in tools like Wireshark:
Simultaneous streaming through HTTP
Currently, MEMCAP Sink does not support simultaneous streaming from multiple nodes through a single connection. For simultaneous streaming on multiple nodes, you must repeat these steps for every node:
Set up port forwarding to one of MEMCAP Sink pods. The pod must be located on the node where you want to capture traffic.
bashThis command maps port
9999on your local machine, allowing direct access to the streaming service.To start streaming the
.pcapngfile to Wireshark, create an HTTP request and redirect it as a stream to Wireshark. You can specify multiple target names in the URL, separated by commas, to select the traffic capture as required.bashThis command performs the following actions:
curl --compressed- starts a cURL and requests a server to perform the request compression and decompression before writing data to a pipe.localhost:9999/pcap/TARGET1,TARGET2,TARGET3- URL to the forwarded MEMCAP Sink API port with a comma-separated list of target names.-N- disables pipe buffering to ensure real-time updates in Wireshark.| wireshark -k -i -- sends (pipes) the output from curl directly into Wireshark, which starts analyzing the stream immediately.-o 'gui.window_title:memcap-stream'- sets the Wireshark window title for easy identification.-o 'capture.no_interface_load:TRUE'- prevents Wireshark from listing local interfaces, which speeds up the startup.
As a result, you should see live traffic in Wireshark.