cpworker User Manual

June 30, 2026 ยท View on GitHub

Overview

cpworker is a network packet capture tool built on libpcap, supporting multiple output methods and intelligent traffic control.

Configuration Template

{
    "cpu_affinity": "1",
    "log_level": "INFO",
    "control": {
        "type": "unix",
        "unix": {
            "path": "/var/run/cloud-probe/cpworker.sock"
        }
    },
    "execution_model": "rtc",
    "pipeline": {
        "buffer_size_mb": 256
    },
    "tasks": [
        {
            "req_pattern": {
                "type": "custom",
                "custom": {
                    "pattern": "host nic.eth0 and port 8011"
                }
            },
            "capturer": {
                "type": "libpcap",
                "libpcap": {
                    "interface": "eth0",
                    "snaplen": 2048,
                    "netns": "/proc/1432897/ns/net",
                    "bpf": "host nic.eth0",
                    "buffer_size_mb": 256,
                    "timeout_ms": 3
                }
            },
            "outputs": [
                {
                    "type": "file",
                    "rate_limit_mbps": 10,
                    "slice": 2048,
                    "vxlan": {
                        "host": "10.1.2.3",
                        "port": 4789,
                        "capture_time": false,
                        "vni1": 1,
                        "vni2": 33,
                        "bind_device": "eth3",
                        "pmtudisc": "want"
                    },
                    "gre": {
                        "host": "10.1.2.3",
                        "service_tag": 34,
                        "bind_device": "eth3",
                        "pmtudisc": "want"
                    },
                    "zmq": {
                        "host": "10.1.2.3",
                        "port": 1234,
                        "hwm": 1000,
                        "service_tag": 3
                    },
                    "file": {
                        "name": "$PCAP_STORE_PATH/test.pcap"
                    },
                    "rotating_file": {
                        "file_root": "$PCAP_STORE_PATH",
                        "max_file_interval": 60
                    }
                }
            ]
        }
    ]
}

For more configuration examples, see: examples

Top-level Parameters

ParameterTypeDefaultDescription
cpu_affinitystring-Set CPU affinity
log_levelstringINFOLog level (DEBUG, INFO, WARN, ERROR)
controlobject-Control plane communication interface
control.typestring-Control interface type (currently supports: unix)
control.unix.pathstring-Unix socket file path
execution_modelstringrtcPacket process execution model (rtc, pipeline)
pipeline.buffer_size_mbint-Pipeline buffer size if execution_mode is pipeline

Task Parameters

ParameterTypeDefaultDescription
req_patternobject-Packet direction detection
req_pattern.typestring-Direction mode (auto/custom). NONCHECK if unconfigured
req_pattern.custom.patternstring-Pattern where nic.eth0 will be replaced with eth0's IP
capturerobject-Packet capture settings
capturer.typestring-Capture type (currently supports: libpcap)

capturer.libpcap Parameters

ParameterTypeDefaultDescription
interfacestring-Capture NIC name (required)
snaplenint2048Packet truncation length
netnsstring-Network namespace of the NIC
bpfstring-BPF filter
buffer_size_mbint-Buffer size (MB)
timeout_msint-Timeout (milliseconds)

Output Parameters

ParameterTypeDefaultDescription
typestring-Output type
rate_limit_mbpsint-Max output rate (Mbps), unlimited by default
sliceint-Packet truncation size (no truncation by default)

output.gre Parameters

ParameterTypeDefaultDescription
hoststring-Destination IP
bind_devicestring-Bind interface (default: any)
pmtudiscstring-MTU discovery mode (do/dont/want)
service_tagint-Service tag

output.vxlan Parameters

ParameterTypeDefaultDescription
hoststring-Destination IP
portint-Destination port
capture_timebool-Add capture timestamp
vni1int-VNI1 value (mutually exclusive with vni2)
vni2int-VNI2 value (mutually exclusive with vni1)
bind_devicestring-Bind interface (default: any)
pmtudiscstring-MTU discovery mode (do/dont/want)

output.zmq Parameters

ParameterTypeDefaultDescription
hoststring-Destination IP
portint-Destination port
hwmint-ZMQ high watermark
service_tagint-Service tag
uuidstring""Probe UUID carried in heartbeat packets
heartbeat_msint0Heartbeat interval in ms (0โ€“60000); 0 disables heartbeat

output.file Parameters

ParameterTypeDefaultDescription
namestring-Output filename

output.rotating_file Parameters

ParameterTypeDefaultDescription
file_rootstring-Output directory
max_file_intervalstring-Max duration per file