Actually, I should clarify an important misconception: eBPF isn't necessarily "faster" than classic BPF for packet filtering - they're fundamentally different technologies solving different problems. Let me explain why eBPF appears more efficient for your specific task.
The Key Difference: Where and How They Operate
Classic BPF (what tcpdump uses)
Purpose: Packet filtering and copying
Operation: Evaluates packets at the packet capture point
Data flow: Kernel function call → eBPF program → Extract data → Userspace
Why eBPF is More Efficient for Connection Tracking
The efficiency gain comes from avoiding packet processing entirely:
Classic BPF/tcpdump approach:
code
1. Packet arrives
2. Kernel processes packet through network stack
3. BPF filter evaluates packet (is it TCP SYN?)
4. Copy entire packet to userspace buffer
5. Tcpdump parses packet headers
6. Extract destination IP
eBPF/tcpconnect approach:
code
1. Application calls connect()
2. eBPF program attached to tcp_v6_connect() runs
3. Directly read destination IP from kernel structures
4. Pass only the IP to userspace
The Numbers Behind the Efficiency
For your use case (1000 connections/minute):
Classic BPF overhead per connection:
Packet inspection: ~4μs
Packet copy (IPv6+TCP ~60-80 bytes): ~5μs
Context switch to userspace: ~2μs
Userspace parsing: ~15μs
Total: ~26μs per connection
eBPF overhead per connection:
Function probe execution: ~0.5μs
Read kernel structure: ~0.2μs
Copy IP address (16 bytes): ~0.3μs
Total: ~1μs per connection
That's a 26x difference in per-event overhead!
Why the Difference is So Large
No packet handling: eBPF intercepts at the system call level, before packets are even created
No data copying: eBPF reads directly from kernel memory structures
No parsing: The destination IP is already in a structured format in kernel memory
Minimal data transfer: Only the IP address (16 bytes) vs entire packet (60-80 bytes)
It's Not About BPF vs eBPF Speed
The instruction execution speed of BPF vs eBPF is similar. The massive efficiency gain comes from:
Different interception points: System calls vs packet path
Data access method: Direct kernel memory vs packet copies
Amount of data processed: Just what you need vs entire packets
Analogy
Think of it like getting someone's phone number:
Classic BPF/tcpdump: Like recording their entire conversation, then playing it back to extract when they mention their number
eBPF/tcpconnect: Like looking directly at their contact card when they hand it to you
Both methods work, but one requires far less effort because it intercepts the information at a more efficient point.
When Classic BPF Still Makes Sense
Classic BPF/tcpdump is still valuable when you need:
Full packet contents
Complex protocol analysis
Packets that don't trigger system calls
Compatibility with older systems
For your specific task (tracking destination IPs of new connections), eBPF's ability to hook directly into the connection establishment function makes it dramatically more efficient than packet capture.
User
To summarize, what amount of CPU should I plan for in case I choose tcpdump? I need an immediate estimate and some future proofing
Assistant
CPU Reservation for tcpdump
Based on the analysis for 1000 connections/minute:
Immediate Estimate
Reserve: 0.5% of one CPU core
This includes:
Actual overhead: ~0.06% CPU
Safety margin: ~8x multiplier
Covers normal variations in system load
Future Proofing Recommendations
For production planning, reserve: 1% of one CPU core
This accounts for:
Potential 5x increase in connection rate (5000 conn/min)
CPU frequency scaling/power saving impacts
Competition from other processes
Kernel version differences
Occasional traffic spikes
Scaling Formula
If your connection rate changes:
code
CPU % = (connections_per_minute / 1000) × 0.5%
Examples:
2000 conn/min → 1% CPU
5000 conn/min → 2.5% CPU
10000 conn/min → 5% CPU
Additional Considerations
Multi-core systems: This is per-core usage. On an 8-core system, 1% of one core = 0.125% total CPU
Burst capacity: If connections come in bursts rather than evenly distributed, double the reservation
Output method: Writing to disk adds ~20% more overhead than these estimates (which assume memory/stdout)
Bottom line: Reserve 1% of one CPU core for comfortable operation with headroom for growth.
User
How is time split between kernel and user?
Assistant
CPU Time Split: Kernel vs User for tcpdump
Based on the detailed analysis for 1000 connections/minute: