DEV Community

Mango Developer
Mango Developer

Posted on Originally published at mangodeveloper.com

Analyzing Wireshark Captures: A Developer's Guide to Reading the Wire

The bug was a 200ms latency spike in our API that happened only in production. Logs showed nothing. APM showed nothing. We were about to add time.Sleep(200 * time.Millisecond) to a test to "make it deterministic" when someone suggested capturing the traffic. Five minutes with tcpdump and ten minutes with Wireshark later, we found it: a TCP retransmission caused by an MTU mismatch between our k8s pod and the NAT gateway. The packet was being sent, dropped, sent again, and the second one made it through-200ms later.

Wireshark is the tool that lets you see what's actually happening on the network. Not what your code thinks is happening, not what the logs claim happened, but what the packets actually said. It's the most powerful debugging tool most developers never learn, because it's intimidating-there are 80,000 display filters, the UI looks like a 1995 spreadsheet, and "I'll just add another log line" is always faster in the moment.

But "another log line" doesn't see TCP retransmissions, TLS handshake failures, DNS loops, or the difference between "the server is slow" and "the network is dropping packets." Wireshark does. This is the practical guide to using it without getting lost in the menu bar.

What Wireshark Is (and What It Isn't)

Wireshark is a graphical network protocol analyzer. It reads packet capture files (.pcap / .pcapng), decodes the protocols inside, and lets you filter, follow, and analyze the conversation. The capture itself is done by dumpcap (Wireshark's capture engine, which uses libpcap on Unix or Npcap on Windows) or by tcpdump on a server where you don't have a GUI.

Tool Interface Strength When to use
Wireshark GUI Best protocol decoding, deep analysis At your desk, analyzing pcaps
tshark CLI Wireshark's engine, scriptable On servers, in scripts, CI
tcpdump CLI Ubiquitous, simple, fast capture Capturing on servers
ngrep CLI Regex on payload Quick "is this string in the traffic"
Zeek (Bro) CLI Connection-level logging at scale Network-wide monitoring
CloudShark Web Wireshark in a browser, shareable Team collaboration on pcaps
Burp Suite GUI HTTP/HTTPS only, MITM App-level security testing
mitmproxy CLI/Web HTTP/HTTPS MITM, scriptable Dev HTTP debugging

Wireshark's strength is breadth: it decodes 2,000+ protocols, from TCP and HTTP to obscure industrial control systems. Its weakness is that breadth makes it intimidating. The 80/20 of Wireshark is: capture with tcpdump, transfer the pcap, open in Wireshark, filter with display filters, follow TCP streams, read the protocol decode. Master that and you can debug 90% of network problems.

Prerequisites

  • A machine where you can install Wireshark (Linux, macOS, Windows). The desktop app is the analysis tool.
  • tcpdump on the server you want to capture from. Available on every Linux by default or via apt install tcpdump.
  • Root/sudo on the capture host. Packet capture requires CAP_NET_RAW-regular users can't sniff interfaces.
  • A basic understanding of TCP, HTTP, and DNS. If "three-way handshake" doesn't ring a bell, spend 20 minutes on a TCP primer first.
  • For TLS decryption: the ability to set SSLKEYLOGFILE on the client, or access to the server's private key (rare; usually you use the keylog approach).
  • ~100MB of free disk for captures. A 60-second capture of a busy interface can be 50MB.

How Wireshark Fits Together

CodeCopy

Enter fullscreen mode Exit fullscreen mode

┌──────────────────────────────────────────────────────────────────────┐
│ Production host (server, pod, container host) │
│ │
│ tcpdump -i eth0 -w capture.pcap Wireshark/dumpcap │
│ │ │ │
│ │ captures packets via libpcap/Npcap │ │
│ ▼ ▼ │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ capture.pcap │ ─── scp to laptop ──────> │ Wireshark │ │
│ │ (binary) │ │ (GUI) │ │
│ └──────────────┘ │ │ │
│ │ - Display │ │
│ │ filters │ │
│ │ - Stream │ │
│ │ following │ │
│ │ - Protocol │ │
│ │ decode │ │
│ └──────────────┘ │
└──────────────────────────────────────────────────────────────────────┘

Enter fullscreen mode Exit fullscreen mode

Two distinct phases: capture (on the server, where the traffic is) and analysis (on your laptop, where the GUI is). Don't run Wireshark on a production server-its GUI dependencies are heavy, and X-forwarding over SSH is painful. Capture with tcpdump -w file.pcap, copy the file, open in Wireshark.

Capture Filters vs Display Filters

Wireshark has two filter languages, and confusing them is the #1 beginner mistake.

Capture filters use BPF (Berkeley Packet Filter) syntax. They run in the kernel, before packets hit your capture file. Use them to limit what you capture-e.g., "only port 443 traffic from this host." They're fast (kernel-level) but limited in expressiveness.

BashCopy

Enter fullscreen mode Exit fullscreen mode


shell

Capture only port 443 traffic

tcpdump -i eth0 'tcp port 443' -w https.pcap

Capture only traffic to/from a specific host

tcpdump -i eth0 'host 10.0.0.5' -w host.pcap

Capture only HTTP traffic (port 80) from one subnet

tcpdump -i eth0 'tcp port 80 and src net 10.0.0.0/8' -w http.pcap

Capture DNS queries

tcpdump -i eth0 'udp port 53' -w dns.pcap

Exclude SSH (so you don't capture your own session)

tcpdump -i eth0 'not tcp port 22' -w nossh.pcap

Enter fullscreen mode Exit fullscreen mode


markdown

Display filters use Wireshark's own syntax. They run in Wireshark after the capture is loaded. Use them to find specific packets in a capture you've already taken. They're expressive (can filter on any decoded field) but only work in Wireshark/tshark, not tcpdump.

CodeCopy

Enter fullscreen mode Exit fullscreen mode


plaintext

In Wireshark's filter bar:

http.request.method == "POST"
ip.addr == 10.0.0.5 and tcp.port == 443
dns.qry.name contains "example.com"
tcp.analysis.retransmission
tls.handshake.type == 1 # ClientHello
http.response.code >= 400

Enter fullscreen mode Exit fullscreen mode


markdown

Rule of thumb: capture broadly (few filters), filter narrowly (lots of display filters). If you capture too narrowly, you'll miss the actual problem and have to re-capture. If you capture too broadly, the file is huge but you can always filter down. Disk is cheap; re-capturing is not.

tcpdump: Capturing on the Server

BashCopy

Enter fullscreen mode Exit fullscreen mode


shell

Basic capture to file

sudo tcpdump -i eth0 -w capture.pcap

Capture with size limit (rotate files)

sudo tcpdump -i eth0 -w capture-%Y-%m-%d_%H-%M-%S.pcap -G 60 -s 0

-G 60: rotate every 60 seconds

-s 0: capture full packets (default in modern tcpdump)

Capture with file size limit (rotate at 100MB)

sudo tcpdump -i eth0 -w capture.pcap -W 10 -C 100

-W 10: keep 10 files

-C 100: rotate at 100MB

Total: 1GB of capture history

Capture a specific connection (host + port)

sudo tcpdump -i eth0 'host 10.0.0.5 and port 443' -w conn.pcap

Capture with a BPF filter and time limit

sudo timeout 60 tcpdump -i eth0 'tcp port 443' -w 60s.pcap

Capture from a specific interface

sudo tcpdump -i any 'port 443' -w any.pcap # all interfaces
ip a # list interfaces to pick the right one

Don't resolve hostnames (faster, smaller files)

sudo tcpdump -nn -i eth0 -w capture.pcap

Enter fullscreen mode Exit fullscreen mode


markdown

The flags I use every time:

  • -i eth0 - interface. Use -i any on Linux to capture on all interfaces (helpful when traffic crosses the loopback bridge in Docker).
  • -w file.pcap - write to file. Without this, tcpdump prints to stdout (fine for debugging, useless for Wireshark analysis).
  • -s 0 (or -s 65535) - capture full packet payload. Default in modern tcpdump; explicitly set it if you're on an old version.
  • -nn - don't resolve hostnames or ports. Faster capture, smaller files, and you avoid the DNS resolution noise polluting your capture.
  • -G 60 and -C 100 - rotation. Long-running captures without rotation will write one enormous file that's slow to open in Wireshark.

tshark: Wireshark on the Command Line

tshark is Wireshark's CLI. Same decode engine, no GUI. Useful for scripted analysis, quick checks over SSH, and CI.

BashCopy

Enter fullscreen mode Exit fullscreen mode


shell

Read a pcap and print packets (one line per packet)

tshark -r capture.pcap

Read with specific fields (think: awk for packets)

tshark -r capture.pcap -T fields \
-e frame.time_relative \
-e ip.src \
-e ip.dst \
-e tcp.dstport \
-e http.request.method \
-e http.request.uri

Apply a display filter

tshark -r capture.pcap -Y 'http.request.method == "POST"'

Count HTTP status codes

tshark -r capture.pcap -Y 'http.response' -T fields -e http.response.code | sort | uniq -c

Find all unique Host headers

tshark -r capture.pcap -Y 'http.host' -T fields -e http.host | sort -u

Find all DNS queries

tshark -r capture.pcap -Y 'dns.flags.response == 0' -T fields -e dns.qry.name | sort -u

Extract all HTTP response times (server latency)

tshark -r capture.pcap -Y 'http.request or http.response' \
-T fields -e frame.time_relative -e http.request.uri -e http.response.code

Enter fullscreen mode Exit fullscreen mode


markdown

For a "what's slow in my API" analysis, the response-time extraction is gold. Sort the output by duration and you'll see the slowest endpoints immediately.

Display Filters: the Real Power

The display filter bar is where Wireshark earns its keep. Some filters I use weekly:

CodeCopy

Enter fullscreen mode Exit fullscreen mode


plaintext

HTTP

http # any HTTP traffic
http.request # only requests
http.request.method == "POST" # only POSTs
http.response.code == 500 # only 500s
http.response.code >= 400 # all errors
http.host contains "api.example.com" # specific host
http.request.uri contains "/v1/users" # specific endpoint

TLS

tls # any TLS traffic
tls.handshake.type == 1 # ClientHello
tls.handshake.type == 2 # ServerHello
tls.alert.message.level == 2 # fatal alerts
tls.record.content_type == 23 # application data (encrypted)

TCP

tcp.flags.syn == 1 and tcp.flags.ack == 0 # SYN (connection start)
tcp.flags.reset == 1 # RST (connection abort)
tcp.analysis.retransmission # retransmissions (packet loss)
tcp.analysis.duplicate_ack # duplicate ACKs
tcp.analysis.zero_window # receiver can't keep up

DNS

dns # any DNS
dns.flags.response == 0 # only queries
dns.qry.type == A # only A records
dns.qry.name contains "example.com"
dns.flags.rcode != 0 # errors (NXDOMAIN, etc.)

IP

ip.addr == 10.0.0.5 # either src or dst
ip.src == 10.0.0.5 and ip.dst == 10.0.0.6
ip.ttl < 10 # suspicious TTL (routing issue)

Time

frame.time_relative > 1 # packets more than 1s into capture
tcp.time_delta > 0.5 # packets with > 500ms since previous

Enter fullscreen mode Exit fullscreen mode


plaintext

Filters compose with and, or, not, and parentheses:

CodeCopy

Enter fullscreen mode Exit fullscreen mode


plaintext

Slow POST requests to the API

http.request.method == "POST" and http.host contains "api" and tcp.time_delta > 0.5

Errors from one specific client

ip.src == 10.0.0.5 and (http.response.code >= 500 or tls.alert.message.level == 2)

Enter fullscreen mode Exit fullscreen mode


markdown

The display filter bar shows red (invalid syntax), yellow (valid but matches nothing), or green (valid and matches). If it's yellow after you type a filter, your syntax is right but the filter doesn't match anything in this capture-either no such packets exist, or you're using the wrong field name.

Right-click any field in the packet detail pane → "Apply as Filter" → "Selected" to add it to the filter bar without typing. This is how you discover field names.

Following Streams and Reading the Decode

A single HTTP request spans multiple packets (SYN, SYN-ACK, ACK, request headers, request body, response headers, response body, FIN...). Reading them one at a time is tedious. Follow TCP Stream reassembles the conversation into a single view.

Right-click any packet → "Follow" → "TCP Stream." You'll see the full request and response as text, with client→server traffic in one color and server→client in another. For HTTP, this is often enough to debug "what did the client actually send?"

For HTTP/2 and HTTP/3, "Follow HTTP/2 Stream" is more useful-HTTP/2 multiplexes multiple streams over one TCP connection, so following the TCP stream gives you interleaved frames that are hard to read.

The packet detail pane (middle of the Wireshark window) is the decoded protocol stack. Click any packet, then expand:

CodeCopy

Enter fullscreen mode Exit fullscreen mode


plaintext
Frame 1234: 66 bytes on wire
Ethernet II: Src 00:1a:2b:..., Dst 00:3c:4d:...
Internet Protocol v4: Src 10.0.0.5, Dst 10.0.0.6
Transmission Control Protocol: Src Port 443, Dst Port 54321, Seq 1, Ack 1
Transport Layer Security: ...
TLS Record Layer: Application Data
Content Type: Application Data (23)
Version: TLS 1.3
Length: 32
Encrypted Application Data: ...

Enter fullscreen mode Exit fullscreen mode


markdown

Each layer is expandable. The detail pane is what makes Wireshark a protocol analyzer and not just a packet lister-every field of every header is decoded and explained.

TLS Decryption with SSLKEYLOGFILE

The biggest limitation of packet capture post-2020: everything is TLS-encrypted. You can see the TCP conversation, but the HTTP inside is opaque. The fix is SSLKEYLOGFILE-a per-session key log that Wireshark can use to decrypt.

On the client (browser, curl, Python requests), set:

BashCopy

Enter fullscreen mode Exit fullscreen mode


shell

Linux/macOS

export SSLKEYLOGFILE=/tmp/sslkeys.log

Then run your client

curl https://api.example.com/

Or in Python

import os, requests
os.environ["SSLKEYLOGFILE"] = "/tmp/sslkeys.log"
requests.get("https://api.example.com/")

Enter fullscreen mode Exit fullscreen mode


plaintext

Modern browsers (Chrome, Firefox) honor SSLKEYLOGFILE automatically. So does requests/urllib3 if you set the env var before importing. Node.js needs NODE_EXTRA_CA_CERTS and a custom TLS hook-use the node --tls-keylog=/tmp/keys.log flag (Node 20+).

In Wireshark: Edit → Preferences → Protocols → TLS → "(Pre)-Master-Secret log filename" → select /tmp/sslkeys.log. Reload the capture. HTTP/2 frames are now decoded inside the TLS records.

CodeCopy

Enter fullscreen mode Exit fullscreen mode


plaintext
Before decryption:
Frame 1234: TLS Application Data (encrypted)

After decryption:
Frame 1234: TLS Application Data
[Decrypted TLS]
HTTP/2: HEADERS frame, :method=POST, :path=/v1/users
HTTP/2: DATA frame, body={"name":"alice"}

Enter fullscreen mode Exit fullscreen mode


markdown

This is the technique that makes Wireshark useful for HTTPS debugging. Without it, you're stuck looking at TCP retransmissions and TLS alerts-useful for some problems, useless for "what did the client actually send?"

For server-side decryption (decrypting traffic from a server you don't control the client of), you'd need the server's private key-but only if the connection uses RSA key exchange. Modern TLS 1.3 uses ephemeral Diffie-Hellman, which means even the server's private key can't decrypt captured traffic after the fact. The keylog approach is the only way.

Performance Analysis: Finding the Slow

Wireshark has several built-in performance graphs. Statistics menu:

TCP Stream Graphs → Time Sequence (Stevens): plots sequence numbers over time. A healthy connection is a smooth upward line. Flat segments = retransmissions (the sender is resending data that wasn't ACKed). Sudden jumps = the receiver ACKing a lot of data at once.

TCP Stream Graphs → Throughput: bytes/second over time. Useful for "is the bandwidth what I expect?"

TCP Stream Graphs → Round Trip Time: RTT per packet. Spikes = network latency variation.

I/O Graphs: plots arbitrary fields over time. The most useful is bytes/second per direction-shows you if the bottleneck is upstream or downstream.

For "API is slow" debugging, the workflow is:

  1. Capture traffic during a slow request.
  2. Apply display filter http or tls.handshake to see the conversation start.
  3. Find the request packet, note the timestamp.
  4. Find the response packet, note the timestamp.
  5. The difference is the server-side latency. Compare to your APM.
  6. If APM says 50ms but Wireshark says 250ms, the gap is network-DNS, TCP handshake, TLS handshake, or transit.

For DNS specifically:

BashCopy

Enter fullscreen mode Exit fullscreen mode


shell

Show all DNS queries with response time

tshark -r capture.pcap -Y 'dns.flags.response == 1' \
-T fields -e frame.time_relative -e dns.qry.name -e dns.time

Enter fullscreen mode Exit fullscreen mode


markdown

dns.time is a calculated field Wireshark adds-the time between query and response. Anything over 50ms is suspicious for a cached lookup; anything over 500ms means you're hitting an upstream resolver for every query.

Identifying Common Problems

Retransmissions and packet loss. Filter: tcp.analysis.retransmission. Every match is a packet the sender had to resend because the receiver didn't ACK it in time. A few retransmissions per connection are normal (wireless, busy networks). Hundreds in a 60-second capture indicate packet loss-check the network path, MTU, and switch errors.

Connection resets. Filter: tcp.flags.reset == 1. RST packets abort connections abruptly. Common causes: server crashed, firewall killed the connection, application called close() on a socket with data still in flight, or the client sent data the server considered invalid (e.g., HTTP/2 PRI magic mismatch).

TCP zero window. Filter: tcp.analysis.zero_window. The receiver advertised a zero-size window, meaning "stop sending, I can't process data fast enough." Indicates the receiver (often a slow application) can't keep up with the sender. Common in bulk transfers to slow consumers.

TLS handshake failures. Filter: tls.alert.message.level == 2. Fatal alerts abort the handshake. The tls.alert.message.description field tells you why-handshake_failure (cipher mismatch), bad_certificate (cert validation failed), unknown_ca (untrusted CA), protocol_version (TLS 1.0 refused by server, etc.).

DNS loops. Filter: dns.qry.name contains "example.com". If you see the same query repeated every few seconds, the resolver isn't caching. Check TTLs in the responses (dns.answers.ttl)-a TTL of 0 means "don't cache."

HTTP 5xx patterns. Filter: http.response.code >= 500. Correlate timestamps with server logs. If Wireshark shows a 503 but the server logs show 200, you're looking at a load balancer or CDN returning the error before the request reached the origin.

Slow POST bodies. Filter: http.request.method == "POST". Follow the TCP stream. If the request body comes in chunks over many seconds, the client is slow to send-often a misconfigured streaming upload or a flaky mobile connection.

Capturing in Production: SPAN, Mirrors, and Sidecars

You usually can't tcpdump directly on a production server-you don't have SSH, or the traffic is on a switch port you can't reach. Options:

Switch SPAN / port mirror. Configure the switch to copy traffic from one port to a monitoring port, plug in a capture box, run tcpdump. Standard practice in datacenters. Works for any traffic on that port, including inter-VLAN.

Container sidecar. In Kubernetes, run a sidecar container with tcpdump in the same pod as your app, sharing the network namespace:

YAMLCopy

Enter fullscreen mode Exit fullscreen mode


yaml

kubectl debug or a sidecar

apiVersion: v1
kind: Pod
metadata:
name: app-with-capture
spec:
containers:

  • name: app image: myapp:latest
  • name: capture image: nicolaka/netshoot:latest command: ["tcpdump", "-i", "any", "-w", "/captures/capture.pcap", "-W", "5", "-C", "100"] volumeMounts:
  • name: captures mountPath: /captures volumes:
  • name: captures emptyDir: {}
Enter fullscreen mode Exit fullscreen mode


plaintext

Or use kubectl debug for an ephemeral capture pod:

BashCopy

Enter fullscreen mode Exit fullscreen mode


shell
kubectl debug -it pod/my-app --image=nicolaka/netshoot -- tcpdump -i any -w /tmp/cap.pcap

Copy the file out

kubectl cp my-namespace/my-app:/tmp/cap.pcap ./cap.pcap

Enter fullscreen mode Exit fullscreen mode


markdown

Service mesh capture. If you're on Istio/Linkerd, the sidecar proxy (Envoy) can dump traffic natively. istioctl proxy-config cluster <pod> shows what the proxy sees. For raw packets, you still need tcpdump on the pod.

Cloud-provider packet capture. AWS VPC Traffic Mirroring, GCP Packet Mirroring, Azure vNet Tap-all let you mirror traffic from a subnet to a capture instance. Useful for traffic between VMs you can't SSH into.

For container-to-container traffic on the same host, tcpdump -i any captures all interfaces including the docker bridge. Filter by port to narrow down.

Privacy and PII Considerations

Packet captures contain everything: passwords in HTTP basic auth, session cookies, API keys in headers, PII in request bodies, internal IP addresses. Treat pcaps like credentials.

  • Don't share pcaps in Slack, GitHub issues, or vendor tickets without redaction. Use Wireshark's "Edit → Remove Packet Data" or editcap to strip payloads.
  • Don't store pcaps in public S3 buckets. Use a private bucket with short retention (7 days) and explicit IAM controls.
  • Anonymize IPs for sharing: editcap --inject-secrets tls,sslkeys.log capture.pcap decoded.pcap (note: this adds secrets, doesn't remove them-use a separate anonymization tool for IP scrubbing).
  • Strip payloads if you only need metadata: use Wireshark's "File → Export Specified Packets" with the "Displayed" option after applying a filter, or use editcap to truncate payloads.

For TLS-encrypted traffic with a keylog, the decrypted content is visible. If you needed the keylog to debug but want to share the pcap, regenerate the capture without the keylog, or strip the decrypted payloads in Wireshark before saving.

In regulated environments (HIPAA, PCI, GDPR), capturing production traffic may require legal review. The packet payload contains user data; capturing it creates a new copy of that data outside your normal data stores. Have a policy.

Common Mistakes

Capturing too much. "I'll just capture everything for an hour and filter later." On a 10Gbps interface, that's 4.5TB. Use BPF filters at capture time, set file rotation, and use -G/-C flags to limit size.

Forgetting -w. sudo tcpdump -i eth0 prints to stdout in human-readable form but doesn't write a pcap file. You can't analyze this in Wireshark. Always -w file.pcap.

Capturing on the wrong interface. On a server with multiple NICs, eth0 might not be where your traffic is. ip a to list interfaces; tcpdump -i any to capture on all of them (with a small perf cost).

Not excluding SSH. When you SSH to a server and run tcpdump, your SSH session traffic is also captured-polluting the file. Filter it out:

BashCopy

Enter fullscreen mode Exit fullscreen mode


shell
sudo tcpdump -i eth0 'not tcp port 22' -w capture.pcap

Enter fullscreen mode Exit fullscreen mode

Confusing capture and display filters. tcp.port == 443 is a display filter; tcp port 443 is a capture filter. Mixing them gives "syntax error" in tcpdump or Wireshark respectively.

Not rotating capture files. A single multi-GB pcap is slow to open in Wireshark (it loads the whole file into memory). Use rotation: -W 10 -C 100 keeps ten 100MB files.

Trying to decrypt TLS without the keylog. "I have the server's private key, why won't Wireshark decrypt?" Because TLS 1.3 uses ephemeral DH-server key alone is insufficient. You need the keylog.

Ignoring the time column. Wireshark's default time format is seconds since capture start. For "how long did this take," that's fine. For "when did this happen relative to my server logs," switch to UTC wall-clock time: View → Time Display Format → UTC Date and Time of Day.

Troubleshooting

"tcpdump: You don't have permission to capture." Need root or CAP_NET_RAW. Either sudo tcpdump or set the binary's capabilities: sudo setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump. The latter lets non-root users capture, which is convenient for dev workstations.

"Wireshark shows no packets." Either you didn't capture anything (BPF filter too narrow), the capture interface is wrong, or you're looking at the wrong file. Check the capture: tcpdump -r capture.pcap | head to verify it has packets.

"TLS isn't decrypting." Three checks: (1) is the keylog file path correct in Preferences → TLS? (2) does the keylog file contain entries for this connection? grep "CLIENT_RANDOM" /tmp/sslkeys.log should show entries. (3) is the client using the same TLS library that wrote the keylog? If you set SSLKEYLOGFILE for curl but the traffic is from Python requests, you need to set the env var in Python's process.

"Display filter shows yellow." Syntax is valid, no matches. Either the field name is wrong (hover for suggestions) or no packets in the capture match. Try a broader filter first: just http or dns.

"Following a stream gives me garbage." The stream is probably compressed (gzip) or binary. Wireshark doesn't decompress HTTP bodies automatically in the Follow Stream view. Use File → Export Objects → HTTP to extract decoded bodies, including decompressed.

"Captures are huge and Wireshark is slow." Use editcap to split: editcap -c 100000 capture.pcap split.pcap creates split_00000.pcap, split_00001.pcap, etc., each with 100k packets. Or use tshark for analysis instead of Wireshark-same filters, much faster on large files.

"I see 'TCP Out-of-Order' but my app works fine." Out-of-order packets are normal on the internet-they're a property of IP routing. Wireshark flags them as analysis info, not errors. Only worry about them if you're seeing them on a localhost connection (where they shouldn't happen) or accompanied by retransmissions.

"HTTP/2 traffic shows as 'HPACK' frames, not HTTP." HTTP/2 uses HPACK header compression. Wireshark decodes it, but you need to follow the HTTP/2 stream (not TCP stream) to see the logical request/response. Right-click → Follow → HTTP/2 Stream.

Real-World Case Studies

The 200ms API latency spike. Covered in the intro-was an MTU mismatch causing TCP retransmissions. Found by capturing on the pod, opening in Wireshark, filtering for tcp.analysis.retransmission, and seeing one retransmission per request, each ~200ms after the original.

The retry storm. A client library was retrying failed requests with no backoff. Server logs showed 100 req/s; Wireshark showed 4000 req/s because each retry was a new connection (full TCP + TLS handshake). Fix: client-side backoff and connection reuse. Found by filtering tls.handshake.type == 1 (ClientHello) and counting per second.

The SSL handshake failure. A client couldn't connect to a server after a cert renewal. Logs showed "handshake failure." Wireshark showed the client sending ClientHello with cipher list, server responding with fatal alert: handshake_failure. The new cert was signed with an algorithm the client didn't support (RSA-PSS vs RSA). Fix: regenerate the cert with broader compatibility.

The DNS-based load balancing failure. An API was randomly 503ing for one user in one region. Wireshark on the client showed DNS returning a different IP each query (expected-round-robin). One of the three IPs in the rotation wasn't responding. The client's resolver was caching the bad IP. Fix: remove the bad IP from DNS; add client-side retry on connection failure.

The Postgres connection leak. App server connections to Postgres were silently dropping. Wireshark on the DB host showed RST packets from Postgres after exactly 30 seconds of idle. The DB had idle_in_transaction_session_timeout = 30s but the app thought it had a 60s pool lease. Fix: align timeouts.

The CDN caching mystery. Static assets were being served stale. Wireshark on the client showed Cache-Control: max-age=300 from the CDN, but the origin was sending max-age=3600. The CDN was overriding on cache miss. Fix: configure the CDN to respect origin headers.

Cost and Alternatives

Wireshark is free (GPLv2). tcpdump is free (BSD). The cost is your time to learn them-about a day to get competent, a week to get fluent.

Alternative Cost When to choose
Wireshark + tcpdump Free Default for protocol-level debugging
mitmproxy Free HTTP/HTTPS only, want Python scripting
Burp Suite Community Free HTTP security testing
Burp Suite Pro $475/user/yr Professional pentest
CloudShark $99-499/mo Team collaboration on pcaps
Zeek + ELK Free + infra cost Network-wide monitoring, not per-issue debugging
AWS VPC Flow Logs Per-GB ingested "Did traffic flow between A and B" at cloud scale
Kentik Commercial Enterprise network observability

For dev work, Wireshark + tcpdump + mitmproxy covers 95% of cases. mitmproxy is worth a separate mention: it's an HTTP/HTTPS proxy with a Python scripting API that lets you intercept, modify, and replay requests. For "what does my app send to the API" debugging, mitmproxy is often faster than Wireshark because it operates at the HTTP layer, not the packet layer.

Conclusion

Wireshark is the tool that turns "the network is slow" from a vague complaint into a specific packet with a specific timestamp and a specific reason. It's not the first tool you reach for-logs and APM are faster for most issues-but it's the tool that resolves the issues logs can't see. TCP retransmissions, TLS handshake failures, DNS loops, MTU mismatches-these are invisible to your application code and visible only on the wire.

The learning curve is real, but the 80/20 is small: capture with tcpdump -w, open in Wireshark, apply a display filter, follow a stream, read the decode. Master that and you'll debug network issues in minutes that would otherwise take days of "let me add another log line and redeploy."

Two final pieces of advice. First, capture broadly-BPF filters at capture time should be loose; you can always filter in Wireshark, but you can't un-capture what you didn't capture. Second, save representative pcaps of "this works" and "this is broken" states. Comparing them is the fastest way to find the difference, and the act of saving them builds your personal library of "what does X look like on the wire."


Originally published on Mango Developer.

Top comments (0)