Wireshark, tcpdump & tshark
Wireshark captures and decodes network packets. Reach for it when the question sits below HTTP: is DNS resolving, does the TCP connection open, does the TLS handshake fail, are packets being retransmitted, does an IoT device actually send its MQTT message? A proxy or DevTools can't see those layers. tcpdump and tshark are the command-line companions: you capture on a server or container, then open the file in Wireshark on your laptop.
| Key fact | Details |
|---|---|
| Install | wireshark.org. Windows needs Npcap (offered by the installer). On Linux, add your user to the wireshark group |
| License | Free, open source |
| Best for | DNS, TCP, TLS, timeouts, resets, retransmissions, non-HTTP protocols (MQTT, WebSocket, gRPC, database wire protocols) |
| File formats | .pcapng (default) and .pcap |
Choose the interface → capture filter (what to record) → reproduce → stop → display filter (what to show) → Follow stream / Expert Information / Conversations → export the filtered packets → attach the .pcapng and the filter to the bugStarting a capture: interfaces, permissions and capture filters
- Start Wireshark. The welcome screen lists interfaces with a live activity sparkline. Pick the one carrying your traffic: Wi-Fi, Ethernet,
lo/Loopbackfor localhost, or a Docker bridge. - Optionally type a capture filter in the field above the list. Capture filters use BPF syntax and decide what gets recorded, which keeps files small.
- Double-click the interface to start. Use the red square to stop and the green shark fin to restart.
- Reproduce the problem, then stop the capture as soon as you can. Busy networks fill files quickly.
- Save with File → Save As (
.pcapng). Use File → Export Specified Packets to save only the displayed packets.
| Capture filter (BPF) | Records |
|---|---|
host 10.0.0.5 | Traffic to or from one machine |
port 443 | HTTPS (both directions) |
tcp port 1883 | Plain MQTT |
port 53 | DNS |
net 192.168.1.0/24 | One subnet |
not port 22 | Everything except your SSH session |
host 10.0.0.5 and port 8080 | One service on one host |
Caveat: Capture filters and display filters use different languages.port 443is a capture filter, andtcp.port == 443is the display filter. If the filter bar turns red, you probably mixed them up.
Display filters QA uses every day
Display filters hide packets without deleting them. Type in the filter bar above the packet list and press Enter. The bar turns green for valid syntax and red for invalid.

| Display filter | Shows |
|---|---|
http | HTTP/1.x (unencrypted or decrypted) |
http.request.method == "POST" | POST requests |
http.response.code >= 400 | Client and server errors |
dns | All DNS queries and answers |
dns.flags.rcode != 0 | Failed lookups (NXDOMAIN, SERVFAIL...) |
tls.handshake.type == 1 | TLS ClientHello (shows the SNI host name) |
tls.handshake.extensions_server_name contains "example" | TLS connections to a given host |
tcp.flags.reset == 1 | Connections reset (RST) |
tcp.analysis.flags | Any TCP problem Wireshark detected |
tcp.analysis.retransmission | Retransmitted segments |
ip.addr == 10.0.0.5 | Packets to or from one address |
tcp.port == 8883 | MQTT over TLS |
mqtt | Decoded MQTT packets |
frame.time_delta > 1 | Gaps of more than 1 s since the previous packet |
Combine with and, or, not (or &&, ||, !) and parentheses, for example ip.addr == 10.0.0.5 and not dns.
Build filters by clicking: in the packet details pane, right-click any field → Apply as Filter → Selected. Wireshark writes the exact expression for you. Prepare as Filter puts it in the bar without applying it, so you can combine it.
QA tip: Switch View → Time Display Format → Seconds Since Previous Displayed Packet. Long gaps then jump out: a 30-second gap before a RST explains a "random" timeout.Follow TCP/HTTP stream
- Select any packet of the conversation.
- Choose Analyze → Follow → TCP Stream (or HTTP Stream, TLS Stream, UDP Stream). You can also right-click → Follow.
- Wireshark applies a filter such as
tcp.stream eq 7and opens a window with the whole conversation as text. Client data is in one colour and server data in another. - Use Show data as to switch between ASCII, hex dump and raw. Use Save as… to keep the conversation.
- Close the window and change the stream number in the filter to step to the next conversation.

Decrypting your own HTTPS traffic with SSLKEYLOGFILE
Modern TLS can't be decrypted with the server's private key. The practical method is a key log file: browsers (Chrome, Firefox) and curl built with OpenSSL can write their per-session secrets to a file, and Wireshark reads it.
Set the environment variable before starting the browser or tool, and start the browser from the same terminal:
# macOS / Linux
export SSLKEYLOGFILE="$HOME/tls-keys.log"
open -na "Google Chrome" --args --user-data-dir=/tmp/chrome-tls # macOS: separate profile
# or test with curl:
curl https://example.com# Windows (PowerShell); then start Chrome from this same window
$env:SSLKEYLOGFILE = "$env:USERPROFILE\tls-keys.log"
& "C:\Program Files\Google\Chrome\Application\chrome.exe" --user-data-dir="$env:TEMP\chrome-tls"Then:
- In Wireshark open Edit → Preferences → Protocols → TLS (on macOS: Wireshark → Settings). Set (Pre)-Master-Secret log filename to the same file.
- Capture while you reproduce. The capture must include the start of each connection (the handshake).
- Packets that showed only Application Data now decode as
httporhttp2. You can filter withhttp2orhttp.requestand use Follow → HTTP Stream. - Use File → Export Objects → HTTP to save files that were downloaded, such as images or JSON responses.
Caveat: The key file decrypts all traffic from that browser session, including your personal accounts. Use a separate profile and test accounts, and delete the file afterwards. Java (JSSE) apps don't honour SSLKEYLOGFILE.Spotting problems: Expert Information, Conversations and I/O graphs
- Analyze → Expert Information groups everything Wireshark found suspicious by severity (Error, Warning, Note, Chat). Look for retransmissions, duplicate ACKs, zero windows, resets and malformed packets. Double-click an entry to jump to the packet.
- Statistics → Conversations lists every pair of endpoints with packet and byte counts and duration. Sort by bytes to find the chatty or huge one. Right-click → Apply as Filter to isolate it.
- Statistics → Endpoints answers "which hosts did the app talk to at all?". It catches unexpected third-party calls or a test build calling production.
- Statistics → I/O Graphs plots packets per second. Add a graph with the filter
tcp.analysis.retransmissionto see whether errors cluster at a specific moment. - Statistics → Protocol Hierarchy shows the share of each protocol in the capture.
| Symptom in the app | Look for in Wireshark |
|---|---|
| "Server not found" | dns with rcode errors, or no DNS answer at all |
| Hangs, then times out | SYN without SYN-ACK, or long gaps followed by RST |
| "Connection reset" | tcp.flags.reset == 1 and who sent it |
| Slow but succeeds | Retransmissions, zero window, high delta times |
| TLS or certificate error | Alert record right after the ServerHello / Certificate |
tcpdump and tshark: capture on servers, analyse anywhere
On a Linux server or container there is no GUI. Capture with tcpdump, copy the file, and open it in Wireshark.
# capture all interfaces, no name resolution, full packets, port 443, stop after 5000 packets
sudo tcpdump -i any -nn -s 0 -c 5000 -w /tmp/api.pcap port 443
# quick live look at DNS
sudo tcpdump -i any -nn port 53
# copy it to your laptop
scp server:/tmp/api.pcap .tshark is Wireshark's engine in a terminal. It understands display filters, so you can analyse in scripts and CI:
tshark -D # list interfaces
tshark -i eth0 -f "tcp port 1883" -w mqtt.pcapng # capture with a capture filter
tshark -r api.pcap -Y "http.response.code >= 500" # read with a display filter
tshark -r api.pcap -Y "dns" -T fields -e dns.qry.name -e dns.a
tshark -r api.pcap -q -z conv,tcp # conversation statistics
tshark -r api.pcap -q -z expert # expert information summaryCaveat: Captures contain IP addresses, cookies, tokens and sometimes personal data. Capture only what you need (use a capture filter), store files like any other sensitive artifact, and get permission before capturing on shared or production networks.
Cheat sheet
| Task | How |
|---|---|
| Record only one host or port | Capture filter host 10.0.0.5, port 443 |
| Show only errors | http.response.code >= 400 |
| DNS failures | dns.flags.rcode != 0 |
| Which host did TLS go to | tls.handshake.type == 1 → SNI field |
| TCP trouble | tcp.analysis.flags, tcp.flags.reset == 1 |
| One conversation | Right-click → Follow → TCP Stream |
| Filter by clicking | Right-click a field → Apply as Filter |
| Decrypt your HTTPS | SSLKEYLOGFILE + Preferences → Protocols → TLS |
| Problems summary | Analyze → Expert Information |
| Top talkers | Statistics → Conversations |
| Server capture | sudo tcpdump -i any -w file.pcap port 443 |
| Scripted analysis | tshark -r file.pcap -Y "<display filter>" |
Summary
- Use a capture filter to limit what you record and a display filter to limit what you see. The two syntaxes are different.
- Follow Stream reconstructs one conversation. Expert Information and Conversations point you to resets, retransmissions and unexpected hosts.
- Decrypt your own browser or curl HTTPS traffic with
SSLKEYLOGFILE, and treat the key file as a secret. - On servers, capture with tcpdump or tshark and analyse in Wireshark. Attach the
.pcapngtogether with the exact filter that shows the problem.