ct collector reports information from socket buffers (struct sk_buff) about their connection tracking (conntrack) status.
Overview
Thect collector provides visibility into the Linux connection tracking subsystem, which is fundamental to stateful firewalls, NAT, and network connection management. It extracts conntrack information from packets as they flow through the networking stack.
What Data is Retrieved
Thect collector retrieves:
- Connection state: ESTABLISHED, NEW, RELATED, REPLY, etc.
- Connection status: Status flags from conntrack
- Protocol information: TCP, UDP, ICMP with protocol-specific data
- Direction: Original and reply tuple information
- Zones: Conntrack zones if used
- Marks and labels: Conntrack mark and label values
- Parent connection: For RELATED connections (e.g., FTP data connections)
Probe Installation
The
ct collector does not install any probes. It only retrieves data when a struct sk_buff * is available in probe arguments._nfct field from the socket buffer to access conntrack information.
Prerequisites
Kernel Configuration
Thect collector requires connection tracking support in the kernel:
Must be enabled (
y) or available as a module (m).If built as a module, the nf_conntrack module must be loaded.Command-Line Options
Thect collector has no specific command-line options.
Event Sections Produced
Thect collector produces the ct event section.
See ct event documentation for detailed format.
Event Format
The event format includes several parts:State Information
state is one of:
ESTABLISHED: Connection is establishedRELATED: Related to an existing connectionNEW: New connectionREPLY: Reply directionRELATED_REPLY: Reply to a related connectionUNTRACKED: Not tracked by conntrack
Status Information
enum ip_conntrack_status in kernel uapi headers.
Connection Information
For TCP and UDP:Supported Protocols
The collector supports protocol-specific data for:- IPv4/IPv6: Address information
- TCP: Port numbers and TCP state (ESTABLISHED, SYN_SENT, etc.)
- UDP: Port numbers
- ICMP: Type, code, and identifier
Usage Examples
Basic Conntrack Monitoring
Monitor connection tracking state:Filter by Connection State
Monitor specific connections:Track Connection Lifecycle
Follow a connection from start to finish:Debug NAT Issues
See how NAT affects connections:With Netfilter
Combine with firewall analysis:Example Output
Established TCP Connection
- Connection is in ESTABLISHED state
- TCP connection state is also ESTABLISHED
- Original direction: client to server
- Reply direction: server to client
- No zone, mark is 0
New Connection
NAT Example
- Packet shows source IP 203.0.113.50 (after SNAT)
- Conntrack original shows 192.168.1.100 (before NAT)
- Reply tuple shows what the return traffic will look like
Related Connection
Integration with Other Collectors
skb
Essential for seeing packet content:skb-tracking
Track packets through NAT:skb-drop
Debug connection tracking issues:nft (Netfilter)
See firewall and conntrack together:dev
Include device information:ns
Namespace and conntrack:Use Cases
NAT Troubleshooting
Firewall State Debugging
Connection Tracking Issues
Related Connection Analysis
Mark-Based Routing
Understanding Conntrack Fields
Connection States
- NEW: First packet of a new connection
- ESTABLISHED: Connection has seen packets in both directions
- RELATED: Related to an existing connection (e.g., FTP data, ICMP errors)
- REPLY: Packet in the reply direction
- UNTRACKED: Explicitly not tracked (raw table NOTRACK)
TCP States
Reported in parentheses for TCP:NONE: No state yetSYN_SENT: SYN sentSYN_RECV: SYN receivedESTABLISHED: Connection establishedFIN_WAIT: ClosingCLOSE_WAIT: Remote closedLAST_ACK: Final ACKTIME_WAIT: Waiting for final timeoutCLOSE: Connection closed
Zones
Zones isolate conntrack tables:- Used in virtualized environments
- Same connection can exist in different zones
- Zone 0 is the default
Marks
Marks are 32-bit values:- Set by firewall rules
- Used for policy routing
- Can be matched in filters
Labels
Labels are bit flags:- 128-bit bitfield
- Set by firewall rules
- Shown in hexadecimal if set
Technical Details
Kernel Types
Thect collector activates when these types appear in probe arguments:
struct sk_buff *
Data Extraction
The collector:- Reads the
_nfctfield fromstruct sk_buff - Extracts the connection tracking entry
- Reads protocol-specific information
- Formats output based on protocol
Source Code References
- Collector:
retis/src/collect/collector/ct/ct.rs - eBPF hook:
retis/src/collect/collector/ct/bpf/ct_hook.bpf.c - Event factory:
retis/src/collect/collector/ct/bpf.rs
Best Practices
- Combine with skb: See packet content and conntrack state together
- Use tracking for NAT: Track packets through address translation
- Filter appropriately: Focus on relevant protocols/hosts
- Check prerequisites: Ensure nf_conntrack is loaded
- Understand state flow: Know the connection lifecycle
Performance Considerations
- No probe overhead: Doesn’t install probes
- Minimal extraction: Only reads when skb has conntrack entry
- Efficient parsing: Protocol-specific parsers are optimized
- Works with any probe: Activates automatically when skb is available
Troubleshooting
No Conntrack Information
If conntrack information is missing:- Verify nf_conntrack is loaded:
lsmod | grep nf_conntrack - Check if traffic is tracked:
conntrack -L - Ensure traffic isn’t marked NOTRACK
- Verify
ctcollector is enabled
Module Not Loaded
If Retis reports module error:Incomplete Information
If some fields are missing:- Some fields are protocol-specific
- UNTRACKED connections have minimal information
- Check if connection is fully established
See Also
- nft collector - Netfilter rules and actions
- skb collector - Packet data
- ct event format - Event format details
- Filtering - Filter by conntrack state
