Skip to content

Ring Buffer Packet Loss Notification Issue #229

@sakateka

Description

@sakateka

Problem Description

The pdump module has a critical issue where packets are being silently lost when the ring buffer is written too fast and the reader doesn't catch up, but the code doesn't notify the user about these losses. This leads to incomplete packet captures without any indication that data has been lost.

Current Implementation Analysis

Ring Buffer Loss Detection

The controlplane already detects when packets are lost due to ring buffer overwrites in modules/pdump/controlplane/ring.go:

  • Lines 171-248: The workerArea.read() method detects overwrites by comparing readableIdx with the reader's position
  • Lines 222-248: When overwrites are detected, the code discards corrupted data and logs debug messages, but doesn't expose this information to users
  • Lines 236-241: Complete overwrites result in all buffered data being discarded silently

Current User Interface

The CLI provides three main commands:

  • show - Display current configuration
  • set - Configure capture parameters (filter, mode, snaplen, ring_size)
  • read - Stream captured packets

The problem: There's no mechanism to report packet loss statistics to users during packet capture.

Proposed Solution

  1. Add Loss Notification Messages to Protobuf API
  2. Track and Report Losses in Ring Buffer
  3. Update Ring Buffer Readers to Send Loss Notifications
  4. Update Service to Handle Loss Notifications
  5. Update CLI to Display Loss Notifications

Usage Examples

# Run packet capture - losses will be shown on stderr in real-time
pdump read --cfg capture1 --instances 0 -o capture.pcap

# Example output to stderr:
# 15 packets were overwritten (worker 0)
# 8 packets were overwritten (worker 1)  
# 23 packets were overwritten (worker 0)
# Total packets lost: 46

# Redirect only packet data to file, see losses on console
pdump read --cfg capture1 --instances 0 -f pcap > capture.pcap

This solution provides immediate feedback about packet losses during capture while maintaining a clean separation between packet data (stdout/files) and loss notifications (stderr). The terminology clearly distinguishes between packets lost due to ring buffer overwrites versus actual dropped packets that can be captured from drop queues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions