Tcpdump: Intercepting Network Traffic, Auditing Packet Payloads, and Diagnosing Production Latency Spikes
==================================================================================================
OPERATIONAL MANUAL & PROTOCOL ANALYSIS: TCPDUMP LOW-LEVEL INTERCEPTION
==================================================================================================
PRACTICAL REAL-WORLD PROBLEM STATEMENT
In cloud-native infrastructure, distributed microservices, and high-throughput enterprise networks, high-level application logs and metric aggregators frequently fail to diagnose low-level transport layer anomalies. When an HTTP microservice returns an intermittent 504 Gateway Timeout or a gRPC connection stalls during socket initialization, application logs record only the terminal symptom—an expired context or broken pipe. They lack visibility into the underlying state transitions of the Linux networking stack, such as packet drops, TCP window exhaustion, selective acknowledgment (SACK) renegotiations, or silent packet corruption introduced by middleboxes.
tcpdump is the definitive command-line packet analyzer for Linux, operating at the boundary between the kernel network subsystem and user space. By tapping directly into raw socket interfaces (AF_PACKET) via libpcap, tcpdump evaluates network traffic using the Berkeley Packet Filter (BPF) engine. This architecture permits high-performance packet filtering in kernel space before memory-intensive payload copying occurs.
System administrators and DevOps engineers rely on tcpdump to perform root-cause analysis on production issues that evade traditional tracing frameworks, including asymmetric routing, DNS resolution latency, TCP handshaking resets under load surges, and payload malformations.
+------------------------------------------+
| Network Interface (NIC) |
+------------------------------------------+
|
v
+------------------------------------------+
| Driver Ring Buffer & NAPI Poll |
+------------------------------------------+
|
v
+------------------------------------------+
| Kernel sk_buff Processing |
+------------------------------------------+
|
+----------------------+----------------------+
| |
v v
+---------------------------+ +---------------------------+
| BPF Engine Filter | | TCP/IP Protocol Stack |
| (Kernel Space Execution) | | (IP, TCP/UDP Processing) |
+---------------------------+ +---------------------------+
| |
v v
+---------------------------+ +---------------------------+
| AF_PACKET Socket Buffer | | Application Socket Buffer |
| (SO_RCVBUF) | | (e.g., Nginx, Go) |
+---------------------------+ +---------------------------+
| |
v v
+---------------------------+ +---------------------------+
| tcpdump Process (User) | | User Space App Process |
+---------------------------+ +---------------------------+
CORE FLAGS & COMMAND SYNTAX BREAKDOWN
Command-line options in tcpdump control packet capture behavior, buffer allocation, network interface binding, display formatting, and disk serialization. Precise flag composition is vital in production environments to avoid dropping packets or over-subscribing system memory.
| Flag / Option | Operational Description | Production Impact & Recommended Context |
|---|---|---|
-i <interface> |
Binds capture to a specific network interface (e.g., eth0, bond0, lo) or any for all active interfaces. |
Avoid using any on high-throughput interfaces due to Linux cooked-mode encapsulation (LINUX_SLL) overhead. |
-n |
Disables IP address-to-hostname resolution. | Mandatory in production. Prevents tcpdump from issuing blocking DNS queries for every intercepted packet. |
-nn |
Disables both hostname and port/protocol translation (e.g., outputs 80 instead of http). |
Mandatory in production. Saves CPU cycles and preserves raw port numbers for automated parsing. |
-v / -vv / -vvv |
Increases output verbosity to display IP header fields (TTL, Identification, TOS/DSCP), TCP options, and ICMP details. | Use -vv to inspect TCP window scaling, MSS negotiation, and selective ACK (SACK) permissions. |
-s <len> / --snapshot-length |
Sets the packet snapshot length in bytes. Default in modern libpcap is 262144 (256 KB). |
Set to -s 0 for full payload capture, or -s 96 if only frame headers are required to conserve memory. |
-w <filename> |
Writes raw unparsed packet structures directly to a standard format .pcap file rather than printing formatted text to stdout. |
Bypasses text format rendering overhead. Essential for offline analysis with tools like Wireshark. |
-r <filename> |
Reads and parses saved .pcap files offline. |
Allows zero-overhead filtering and inspection on dedicated analysis workstations. |
-A |
Renders captured packet payload content exclusively in standard ASCII characters. | Optimized for inspecting unencrypted text protocols such as HTTP/1.1, SMTP, and raw JSON-RPC. |
-X |
Displays packet payload content in both Hexadecimal and ASCII formats side-by-side. | Critical for debugging binary protocols (gRPC, Redis RESP, DNS) and inspecting alignment offsets. |
-XX |
Same as -X, but also renders the Link-Layer (Ethernet) header in hex/ASCII. |
Required when debugging VLAN tags (802.1Q), ARP anomalies, or MAC address spoofing. |
-C <file_size> |
Rotates output capture file when it exceeds file_size (measured in millions of bytes, ~MB). |
Prevents single pcap files from consuming entire disk partitions during long captures. |
-W <file_count> |
Limits total rotated files to file_count, creating a fixed ring buffer that overwrites older files. |
Used with -C to bound maximum storage footprint: $\text{Storage}_{\text{max}} = C \times W$. |
-B <buffer_size> |
Sets the Linux kernel socket receive buffer size (SO_RCVBUF) in kibibytes (KiB). |
Prevents kernel packet drops during bursty traffic by expanding the socket buffer queue. |
-p / --no-promiscuous-mode |
Disables promiscuous mode on the targeted network interface. | Prevents interface mode switches that could alert security systems or affect virtual bridge drivers. |
5 TANGIBLE REAL-LIFE PRODUCTION USE-CASES
USE-CASE 1: Isolating Inter-Service Microservice Traffic on Specific Interfaces and Port Ranges
Scenario
A Kubernetes worker node running multiple pod networks exhibits latency spikes during inter-service RPC calls between an API Gateway and an upstream authentication service. The SysAdmin must isolate traffic originating from the internal subnet 10.244.1.0/24 destined for services operating across ports 8080 through 8085 on interface eth0, ignoring unrelated traffic.
Command Execution
sudo tcpdump -i eth0 -nn -vvv -s 1500 \
'src net 10.244.1.0/24 and dst net 10.244.2.0/24 and tcp portrange 8080-8085'
Terminal Output
04:15:22.891024 IP (tos 0x0, ttl 64, id 41203, offset 0, flags [DF], proto TCP (6), length 60)
10.244.1.45.48912 > 10.244.2.12.8082: Flags [S], cksum 0xa41f (correct), seq 312849102, win 64240, options [mss 1460,sackOK,TS val 289381921 ecr 0,nop,wscale 7], length 0
04:15:22.891312 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
10.244.2.12.8082 > 10.244.1.45.48912: Flags [S.], cksum 0x12b4 (correct), seq 892019481, ack 312849103, win 65160, options [mss 1460,sackOK,TS val 3910294811 ecr 289381921,nop,wscale 7], length 0
04:15:22.891345 IP (tos 0x0, ttl 64, id 41204, offset 0, flags [DF], proto TCP (6), length 52)
10.244.1.45.48912 > 10.244.2.12.8082: Flags [.], cksum 0x8f10 (correct), seq 1, ack 1, win 502, options [nop,nop,TS val 289381921 ecr 3910294811], length 0
Step-by-Step SysAdmin Explanation
- BPF Expression Evaluation: The kernel BPF interpreter filters incoming frames against three logical primitives:
src net,dst net, andtcp portrange. Packets not matching all three conditions are discarded in kernel space. - Three-Way Handshake Verification:
- Line 1 displays the initialSYNpacket (Flags [S]) from client10.244.1.45:48912to service10.244.2.12:8082. The IP header shows Don't Fragment ([DF]) set, with an initial TCP Window Size of64240.
- Line 2 shows theSYN-ACKresponse (Flags [S.]). The round-trip propagation delay for the handshake is computed as:
$$\Delta t = 04:15:22.891312 - 04:15:22.891024 = 0.288\text{ ms} = 288\ \mu\text{s}$$
- Line 3 confirms completion with anACKpacket (Flags [.]), establishing the socket state. - TCP Option Negotiation: Both sides advertise Maximum Segment Size (
mss 1460), Window Scaling (wscale 7), and Selective Acknowledgment capability (sackOK). The actual receive window capacity is calculated as:
$$\text{Effective Window} = \text{win} \times 2^{\text{wscale}} = 65160 \times 2^7 = 8,340,480\text{ bytes}$$
USE-CASE 2: Capturing Raw DNS Queries and HTTP Header Payloads to Diagnose Latency Spikes
Scenario
An e-commerce platform experiences periodic micro-stalls during checkout processing. The DevOps team suspects either slow upstream DNS resolution or delayed HTTP gateway processing. By capturing both UDP port 53 and TCP port 80 HTTP payload data simultaneously, the engineer can establish precise timing boundaries for name resolution versus application layer processing.
Command Execution
sudo tcpdump -i any -nn -s 0 -A \
'udp port 53 or (tcp port 80 and (((ip[20:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0))'
Terminal Output
04:20:10.100123 IP 10.0.0.5.54123 > 10.0.0.2.53: 41205+ A? payment-gateway.internal. (46)
04:20:12.102450 IP 10.0.0.2.53 > 10.0.0.5.54123: 41205 1/0/0 A 10.0.2.99 (62)
04:20:12.103100 IP 10.0.0.5.38910 > 10.0.2.99.80: Flags [P.], seq 1:312, ack 1, win 502, length 311
E... @.@..g
. . ...c...P..a.#...........
GET /v2/charge HTTP/1.1
Host: payment-gateway.internal
User-Agent: PaymentService/2.1.0
X-Request-ID: req-781a-904b
Content-Type: application/json
Content-Length: 42
{"transaction_id": 98412, "amount": 149.50}
Step-by-Step SysAdmin Explanation
- Advanced BPF Offset Calculation: The expression
(((ip[20:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)isolates TCP packets containing actual data payloads by subtracting header lengths from total IP packet length:
-ip[20:2]extracts the Total Length field from the IPv4 header (bytes 2–3).
-(ip[0]&0xf)<<2isolates the Internet Header Length (IHL) field from byte 0 and multiplies by 4 to get IP header size in bytes.
-(tcp[12]&0xf0)>>2extracts the Data Offset field from byte 12 of the TCP header and multiplies by 4 to calculate TCP header size in bytes.
- If $\text{Total Length} - \text{IP Header Length} - \text{TCP Header Length} > 0$, the packet contains payload data.
+-------------------------------------------------------------------+
| IPv4 Header (ip[0..19]) |
| Byte 0: [ Version (4 bits) | IHL (4 bits) ] -> (ip[0]&0xf) * 4 |
| Bytes 2-3: Total Length -> ip[20:2] |
+-------------------------------------------------------------------+
| TCP Header (tcp[0..19+]) |
| Byte 12: [ Data Offset (4 bits) | Reserved ] -> (tcp[12]&0xf0)>>2|
+-------------------------------------------------------------------+
| TCP Payload (Data Bytes) |
| Payload Length = Total Length - IP Header Length - TCP Header |
+-------------------------------------------------------------------+
- Root Cause Identification:
- The DNS query (A? payment-gateway.internal.) was transmitted at04:20:10.100123.
- The DNS response arrived at04:20:12.102450.
- Resolution Latency:
$$T_{\text{DNS}} = 12.102450 - 10.100123 = 2.002327\text{ seconds}$$
- This 2-second delay indicates an internal DNS resolver timeout (typically caused by an unreachable primary nameserver in/etc/resolv.conftriggering a fallback to a secondary server). - Application Payload Inspection: The ASCII display (
-A) exposes the raw HTTP request structure immediately following resolution, confirming that once DNS resolved, the application layer dispatched thePOSTrequest within $0.65\text{ ms}$.
USE-CASE 3: Filtering TCP Handshake Flags (SYN/ACK/FIN/RST) to Debug Connection Resets During Load Surges
Scenario
During peak traffic surges, an application balancer reports high rates of 502 Bad Gateway errors due to unexpected TCP resets (RST) initiated by backend application instances. The SysAdmin must isolate all RST and SYN packets across the backend cluster to determine whether connections are being actively rejected by the kernel backlog or explicitly reset by application runtimes.
Command Execution
sudo tcpdump -i eth0 -nn -vv \
'tcp[tcpflags] & (tcp-rst|tcp-syn) != 0 and host 192.168.10.50'
Terminal Output
04:30:01.401928 IP (tos 0x0, ttl 64, id 12094, offset 0, flags [DF], proto TCP (6), length 40)
192.168.10.12.51092 > 192.168.10.50.8080: Flags [S], cksum 0xd1a2 (correct), seq 10928301, win 29200, length 0
04:30:01.401955 IP (tos 0x0, ttl 64, id 0, offset 0, flags [NONE], proto TCP (6), length 40)
192.168.10.50.8080 > 192.168.10.12.51092: Flags [R.], cksum 0x41f2 (correct), seq 0, ack 10928302, win 0, length 0
Step-by-Step SysAdmin Explanation
- Mathematical Representation of TCP Flag Bitmasking: Byte 13 of the TCP header contains the control flags field. Individual bits map to standard control flags:
Bit Position: 7 6 5 4 3 2 1 0
Control Flag: [ CWR | ECE | URG | ACK | PSH | RST | SYN | FIN ]
Binary Value: 128 64 32 16 8 4 2 1
Hex Value: 0x80 0x40 0x20 0x10 0x08 0x04 0x02 0x01
To isolate packets where either RST (bit 2 = 4) or SYN (bit 1 = 2) is active, tcpdump applies a bitwise AND mask ($\text{Mask} = 0x04 \mid 0x02 = 0x06 = 6$):
$$\text{Filter Condition}: (\text{tcp}[13] \ \& \ 0x06) \neq 0$$
Using native tcpdump flag aliases, this is expressed as 'tcp[tcpflags] & (tcp-rst|tcp-syn) != 0'.
- Packet Analysis & Diagnostics:
- Packet 1 shows a connection attempt (Flags [S]) to port8080.
- Packet 2 shows an immediate reset acknowledgment response (Flags [R.],win 0) originating from192.168.10.50.8080within $27\ \mu\text{s}$.
- Root Cause: An immediateRSTresponse to aSYNpacket withwin 0indicates that the kernel socket listen queue (somaxconn) on host192.168.10.50is completely saturated. The Linux kernel drops incoming connection attempts or responds with a TCP reset whennet.ipv4.tcp_abort_on_overflow = 1.
USE-CASE 4: Capturing Raw Packet Content in ASCII and Hexadecimal to Inspect Malformed API Requests
Scenario
A backend API service crashes with unhandled exception errors (500 Internal Server Error) when processing specific JSON payloads. Application logs fail to output the body due to crash loops. The SysAdmin needs to inspect the exact hex and ASCII representation of inbound packets on TCP port 8080 to check for illegal control characters, non-UTF-8 encodings, or missing boundary markers without redeploying code or modifying application log configurations.
Command Execution
sudo tcpdump -i eth0 -nn -XX -s 0 'tcp port 8080 and dst host 10.0.1.15'
Terminal Output
04:40:15.892019 IP (tos 0x0, ttl 64, id 51029, offset 0, flags [DF], proto TCP (6), length 142)
10.0.1.2.49012 > 10.0.1.15.8080: Flags [P.], seq 39102:40004, ack 10294, win 502, length 102
0x0000: 0015 5d01 0203 0015 5d0a 0b0c 0800 4500 ..].....].....E.
0x0010: 008e c755 4000 4006 f4a2 0a00 0102 0a00 ...U@.@.........
0x0020: 010f bf74 1f90 0000 98be 0002 8306 8018 ...t............
0x0030: 01f6 ad3a 0000 0101 080a 114a e201 0000 ...:.......J....
0x0040: 0000 7b22 7573 6572 5f69 6422 3a20 3438 ..{"user_id": 48
0x0050: 3931 2c20 2272 6f6c 6522 3a20 2261 646d 91, "role": "adm
0x0060: 696e 5c78 3030 222c 2022 6461 7461 223a in\x00", "data":
0x0070: 2022 7465 7374 227d 0a "test"}.
Step-by-Step SysAdmin Explanation
- Link-Layer & Protocol Frame Dissection:
-0x0000to0x000d: Ethernet Frame Header (14 bytes). MAC Destination (00:15:5d:01:02:03), MAC Source (00:15:5d:0a:0b:0c), EtherType (0800= IPv4).
-0x000eto0x0021: IPv4 Header (20 bytes). Source IP10.0.1.2(0a00 0102), Destination IP10.0.1.15(0a00 010f).
-0x0022to0x0041: TCP Header (32 bytes with options). Source Port49012(bf74), Destination Port8080(1f90). - Payload Analysis:
- Payload data begins at offset0x0042(7b22={").
- Inspection of ASCII content at offset0x0060reveals an unescaped null byte literal representation:"role": "admin\x00". - Operational Remediation: The presence of the hex sequence
5c 78 30 30(\x00) proves that an upstream client is transmitting literal unescaped control characters within string fields. This payload bypasses basic string sanitizers and causes JSON parsers to abort with structural parsing errors.
USE-CASE 5: Managing Continuous Packet Dumps with Rotating Ring Buffers to Catch Intermittent Network Glitches
Scenario
A critical database host experiences brief, unpredictable packet loss once every few days. Capturing full packet payload continuously would exhaust the available root disk partition (/var/log) within hours. The SysAdmin must configure a continuous, self-maintaining ring buffer capture bounded to a maximum storage allocation of $1\text{ GB}$, with automated background compression.
Command Execution
sudo tcpdump -i eth0 -nn -w /var/log/captures/db_glitch.pcap \
-C 100 -W 10 -z gzip 'tcp port 5432 and (tcp[tcpflags] & (tcp-rst|tcp-fin) != 0)'
Terminal Output
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
tcpdump: opening '/var/log/captures/db_glitch.pcap0' for writing
tcpdump: rotating dump file /var/log/captures/db_glitch.pcap0 to /var/log/captures/db_glitch.pcap1 because it exceeded 100000000 bytes
tcpdump: compress_command executed: gzip /var/log/captures/db_glitch.pcap0
Step-by-Step SysAdmin Explanation
- Ring Buffer Storage Calculation:
--C 100specifies that when a capture file reaches $100\text{ MB}$ ($100 \times 10^6\text{ bytes}$),tcpdumpcloses the current file and opens a new index segment.
--W 10limits the file rotation ring to 10 total files (db_glitch.pcap0throughdb_glitch.pcap9).
- The absolute maximum disk space consumed by uncompressed captures is strictly bounded:
$$S_{\text{max}} = C \times W = 100\text{ MB} \times 10 = 1,000\text{ MB} = 1\text{ GB}$$ - Asynchronous Compression Integration:
--z gzipinstructstcpdumpto invoke thegzipbinary in a separate process asynchronously whenever a file rotation occurs.
- Due to the high compression ratio of PCAP header structures (~60–80% for TCP metadata), the effective disk footprint drops to approximately $200\text{ MB}$–$400\text{ MB}$. - Privilege Dropping & File System Permissions:
- When running with-zundersudo,tcpdumpdrops privileges to thetcpdumpuser ornobodyafter opening the network socket.
- Security Precaution: Ensure the target output directory (/var/log/captures/) is owned by thetcpdumpuser:
bash sudo mkdir -p /var/log/captures sudo chown -R tcpdump:tcpdump /var/log/captures
KEY PITFALLS & PRODUCTION SAFETY PRECAUTIONS
+-----------------------------------------------------------------------------------+
| PRODUCTION RISK ASSESSMENT MATRIX |
+---------------------+-------------------------------+-----------------------------+
| Hazard Vector | Operational Impact | Prevention Strategy |
+---------------------+-------------------------------+-----------------------------+
| High Bitrate CPU | Kernel Packet Drops, | Apply precise BPF filters; |
| Saturation | CPU Core Overload | expand socket buffer (-B). |
+---------------------+-------------------------------+-----------------------------+
| Storage Partition | System Service Outages | Implement rotating buffers |
| Exhaustion | (Disk Full Crisis) | (-C / -W); monitor space. |
+---------------------+-------------------------------+-----------------------------+
| Promiscuous Mode | Virtual Switch Flooding, | Disable promiscuous mode |
| Overhead | Intrusion Alert Triggers | using -p flag. |
+---------------------+-------------------------------+-----------------------------+
| Sensitive Payload | Security & Compliance | Restrict snaplen (-s 96); |
| Exposure | Violations (PII / Secrets) | enforce file permissions. |
+---------------------+-------------------------------+-----------------------------+
1. Kernel Packet Drop Mitigation via Buffer Sizing
When capturing traffic on high-throughput interfaces (e.g., 10 GbE / 40 GbE links), the speed at which libpcap copies frames from the kernel socket to user space can fall behind interface arrival rates. This results in buffer overflows, indicated in tcpdump execution summaries as:
140294 packets captured
139102 packets received by filter
1192 packets dropped by kernel
To mitigate packet drops by the kernel:
- Expand the kernel socket receive buffer (SO_RCVBUF) using the -B flag (value in KiB):
bash
sudo tcpdump -i eth0 -B 4096 -nn 'tcp port 443'
- Adjust OS-level maximum socket buffer thresholds via sysctl:
bash
sudo sysctl -w net.core.rmem_max=16777216
2. High-Throughput CPU Saturation
Executing an un-filtered capture (tcpdump -i eth0) on saturated networks forces the kernel to process every frame through the AF_PACKET socket handler. On 10 GbE links operating near line rate (~14.88 million packets per second for 64-byte frames), this can saturate a CPU core and degrade overall system throughput.
- Safety Rule: Always define a restrictive BPF expression to filter frames in kernel space. Avoid capturing payload bytes (-s 0) unless explicitly necessary for payload-level protocol debugging; use -s 96 to capture only transport and network headers.
3. Promiscuous Mode Side Effects
By default, tcpdump places targeted network interface controllers (NICs) into promiscuous mode, forcing the hardware layer to process all frames traversing the physical media, regardless of MAC address destination.
- In virtualized environments (AWS EC2, KVM, VMware), enabling promiscuous mode on virtual bridges can cause underlying hypervisors to flood traffic across virtual switch ports, increasing host CPU consumption.
- Use -p (--no-promiscuous-mode) when inspecting traffic addressed directly to the host machine.
4. Sensitive Payload Exposure & PCAP Data Governance
Capturing full packet frames (-s 0, -A, -X) records unencrypted application payloads to disk. This can accidentally log sensitive data, including API keys, database credentials, JWT authorization tokens, and Personally Identifiable Information (PII).
- Security Rule: PCAP files must be written to directories secured with strict file permissions (chmod 600).
- Ensure PCAP captures stored on shared diagnostic servers are deleted or sanitized immediately following analysis to maintain compliance with standards such as PCI-DSS and GDPR.
TAKEAWAY BOX: PRODUCTION SYSADMIN CHEATSHEET
[!IMPORTANT]
THE PRODUCTION TCPDUMP MANDATE
Never runtcpdumpin production without-nor-nn. Hostname resolution issued during packet capture introduces blocking DNS lookups that distort capture timestamps, saturate internal resolvers, and misrepresent true packet arrival sequences.
==================================================================================================
TCPDUMP QUICK REFERENCE FOR PRODUCTION OPERATIONS
==================================================================================================
1. SAFE HEADLESS CAPTURE TO ROTATING PCAP:
$ sudo tcpdump -i eth0 -nn -s 96 -w /var/log/captures/trace.pcap -C 50 -W 5 'tcp port 80'
2. INSPECT TCP HANDSHAKE RESETS (RST / SYN):
$ sudo tcpdump -i eth0 -nn -vv 'tcp[tcpflags] & (tcp-rst|tcp-syn) != 0'
3. CAPTURE DNS QUERIES WITH ASCII OUTPUT:
$ sudo tcpdump -i eth0 -nn -A -s 512 'udp port 53'
4. ISOLATE HTTP POST PAYLOADS ONLY:
$ sudo tcpdump -i eth0 -nn -A -s 0 'tcp port 80 and tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x504f5354'
5. EXPAND RECEIVE BUFFER TO PREVENT KERNEL PACKET DROPS:
$ sudo tcpdump -i eth0 -B 8192 -nn -w /tmp/high_rate.pcap 'net 10.0.0.0/8'
==================================================================================================
AUTHORITATIVE TECHNICAL REFERENCES
-
Linux Programmer's Manual - tcpdump(8): Official command-line flag documentation and invocation specifications.
https://www.man7.org/linux/man-pages/man8/tcpdump.8.html -
Linux Programmer's Manual - pcap-filter(7): Comprehensive specification of Berkeley Packet Filter (BPF) syntax and byte-offset filter expressions.
https://www.man7.org/linux/man-pages/man7/pcap-filter.7.html -
Linux Programmer's Manual - packet(7): Technical details on Linux
AF_PACKETraw socket implementation and kernel packet interception.
https://www.man7.org/linux/man-pages/man7/packet.7.html -
Wikipedia - Berkeley Packet Filter (BPF): Overview of BPF architecture, kernel-space bytecode execution, and packet filtering history.
https://en.wikipedia.org/wiki/Berkeley_Packet_Filter -
Wikipedia - Transmission Control Protocol (TCP): Protocol standard, flag structure definitions, and state machine transitions.
https://en.wikipedia.org/wiki/Transmission_Control_Protocol -
The tcpdump & libpcap Official Project: Source code repository, release notes, and core library documentation.
https://www.tcpdump.org/