Lesson 7 of 9 · 21m
Capture First Principles: tcpdump, Wireshark, and Capture Placement
How to capture the right traffic at the right point, choose filters that do not lie to you, and read time, sequence, and direction before trusting tool labels.
Most bad packet analysis starts before the first packet is captured: wrong interface, wrong host, wrong filter, or no connection handshake in the file. Capture placement determines what questions the evidence can answer. A capture is not a truth machine; it is a viewpoint.
Capture where the ambiguity lives
If the question is “did the server receive it,” capture near the server. If the question is “did the client send it,” capture near the client. If the question is “what changed in the middle,” capture on both sides and compare.
tcpdump -i eth0 -nn -s0 -w /tmp/server.pcap host 203.0.113.20-nn avoids reverse DNS and port-name lookups. -s0 captures full packets. Write to disk rather than scrolling forever in a terminal during an incident.
Filters select evidence; they do not create it
Capture filters are compiled into kernel packet filtering and can drop traffic before you ever see it. Use broad capture filters, then narrow display filters in Wireshark.
# broad, capture-side
tcpdump -i any -nn -s0 -w issue.pcap 'tcp port 443 or icmp or icmp6'
# display-side in Wireshark
tcp.stream eq 42
tcp.analysis.retransmission || tcp.analysis.duplicate_ackOn multi-interface hosts, -i any is convenient but adds cooked capture framing and can complicate interpretation. Prefer a specific interface when you know it.
Time is the first column that matters
Look at inter-arrival gaps before diving into flags. A one-second stall before an ACK is different from a millisecond retransmission. In Wireshark, configure time display as seconds since previous displayed packet when reconstructing a flow, but use absolute timestamps when correlating across hosts.
tcpdump -nn -tttt -r issue.pcap 'tcp[tcpflags] & tcp-syn != 0'Clock skew makes two-host correlation dangerous. Synchronize with NTP and record capture start times, but expect small offsets. Sequence progression is often more reliable than wall-clock comparison.
Do not outsource thinking to expert labels
Wireshark’s expert system is useful, but labels such as “spurious retransmission” and “fast retransmission” are inference. Check sequence arithmetic, direction, and whether the handshake was present. A capture that starts midstream lacks negotiation context such as window scaling and SACK permission.
A minimum useful capture routine
- Record the exact symptom and affected four-tuple.
- Capture client and server simultaneously when possible.
- Include ICMP and relevant infrastructure traffic, not just TCP.
- Start before reproducing; stop after several clean failures.
- Save the original file untouched and analyze a copy.
Field notes
-wwrites packets; piping live output to text loses the ability to inspect fields later.- Reverse DNS lookups during analysis inject irrelevant latency and sometimes wrong names.
- Capture offloads such as TSO/GRO can make outbound packets look oversized on the sending host.
- Dropped-by-kernel counters in tcpdump mean your capture itself missed evidence.
- Never publish pcaps casually; they often contain credentials, cookies, and internal addressing.
Was this lesson helpful?