Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
GimmeJob
Sign in
Testing tools: hands-on guides · Chapter 05 / 09

Testing Tools

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 factDetails
Installwireshark.org. Windows needs Npcap (offered by the installer). On Linux, add your user to the wireshark group
LicenseFree, open source
Best forDNS, 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 bug

Starting a capture: interfaces, permissions and capture filters

  1. Start Wireshark. The welcome screen lists interfaces with a live activity sparkline. Pick the one carrying your traffic: Wi-Fi, Ethernet, lo/Loopback for localhost, or a Docker bridge.
  2. 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.
  3. Double-click the interface to start. Use the red square to stop and the green shark fin to restart.
  4. Reproduce the problem, then stop the capture as soon as you can. Busy networks fill files quickly.
  5. 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.5Traffic to or from one machine
port 443HTTPS (both directions)
tcp port 1883Plain MQTT
port 53DNS
net 192.168.1.0/24One subnet
not port 22Everything except your SSH session
host 10.0.0.5 and port 8080One service on one host
Caveat: Capture filters and display filters use different languages. port 443 is a capture filter, and tcp.port == 443 is 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.

Wireshark packet list filtered with a display filter
Official Wireshark User’s Guide screenshot: filtering on the TCP protocol.
Display filterShows
httpHTTP/1.x (unencrypted or decrypted)
http.request.method == "POST"POST requests
http.response.code >= 400Client and server errors
dnsAll DNS queries and answers
dns.flags.rcode != 0Failed lookups (NXDOMAIN, SERVFAIL...)
tls.handshake.type == 1TLS ClientHello (shows the SNI host name)
tls.handshake.extensions_server_name contains "example"TLS connections to a given host
tcp.flags.reset == 1Connections reset (RST)
tcp.analysis.flagsAny TCP problem Wireshark detected
tcp.analysis.retransmissionRetransmitted segments
ip.addr == 10.0.0.5Packets to or from one address
tcp.port == 8883MQTT over TLS
mqttDecoded MQTT packets
frame.time_delta > 1Gaps 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

  1. Select any packet of the conversation.
  2. Choose Analyze → Follow → TCP Stream (or HTTP Stream, TLS Stream, UDP Stream). You can also right-click → Follow.
  3. Wireshark applies a filter such as tcp.stream eq 7 and opens a window with the whole conversation as text. Client data is in one colour and server data in another.
  4. Use Show data as to switch between ASCII, hex dump and raw. Use Save as… to keep the conversation.
  5. Close the window and change the stream number in the filter to step to the next conversation.
Wireshark Follow TCP Stream dialog
Official Wireshark User’s Guide screenshot: the Follow TCP Stream dialog.

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:

  1. In Wireshark open Edit → Preferences → Protocols → TLS (on macOS: Wireshark → Settings). Set (Pre)-Master-Secret log filename to the same file.
  2. Capture while you reproduce. The capture must include the start of each connection (the handshake).
  3. Packets that showed only Application Data now decode as http or http2. You can filter with http2 or http.request and use Follow → HTTP Stream.
  4. 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.retransmission to see whether errors cluster at a specific moment.
  • Statistics → Protocol Hierarchy shows the share of each protocol in the capture.
Symptom in the appLook for in Wireshark
"Server not found"dns with rcode errors, or no DNS answer at all
Hangs, then times outSYN without SYN-ACK, or long gaps followed by RST
"Connection reset"tcp.flags.reset == 1 and who sent it
Slow but succeedsRetransmissions, zero window, high delta times
TLS or certificate errorAlert 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 summary
Caveat: 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

TaskHow
Record only one host or portCapture filter host 10.0.0.5, port 443
Show only errorshttp.response.code >= 400
DNS failuresdns.flags.rcode != 0
Which host did TLS go totls.handshake.type == 1 → SNI field
TCP troubletcp.analysis.flags, tcp.flags.reset == 1
One conversationRight-click → Follow → TCP Stream
Filter by clickingRight-click a field → Apply as Filter
Decrypt your HTTPSSSLKEYLOGFILE + Preferences → Protocols → TLS
Problems summaryAnalyze → Expert Information
Top talkersStatistics → Conversations
Server capturesudo tcpdump -i any -w file.pcap port 443
Scripted analysistshark -r file.pcap -Y "<display filter>"
Hands-on lab: explain one HTTPS request, packet by packet
  1. Start Wireshark on your active interface with the capture filter port 53 or port 443.
  2. In a terminal that has SSLKEYLOGFILE set (see the decryption section), run curl -s https://example.com -o /dev/null. Stop the capture.
  3. Apply dns. Find the query for example.com and its answer. Write down the IP address and the time it took.
  4. Apply tls.handshake.type == 1. Expand Transport Layer Security → Handshake → Extension: server_name and confirm the SNI is example.com.
  5. Right-click that packet → Follow → TCP Stream. Without keys, the stream is unreadable binary, which is expected for TLS.
  6. Open Edit → Preferences → Protocols → TLS, set the key log file, and click OK. Apply http || http2. The request and the response are now readable.
  7. Open Statistics → Conversations → TCP. Note the duration and bytes of the conversation.
  8. Apply tcp.analysis.flags and open Analyze → Expert Information. On a healthy network you should see few or no warnings. Record anything you find.
  9. File → Export Specified Packets → only displayed packets → save as example-https.pcapng. Delete the key log file.

Write-up template: DNS answered in x ms with IP y. The TLS handshake with SNI example.com finished at t1. The first response byte arrived at t2. There were no resets or retransmissions.

Official Wireshark User’s Guide · Wireshark TLS wiki

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 .pcapng together with the exact filter that shows the problem.

Source registry

Verified 22 Nov 2026
Wireshark User’s Guide

Capturing, filtering, following streams, statistics and exporting packets

Wireshark Foundation · verified
Source ↗
Wireshark User’s Guide: Building display filter expressions

Display filter fields, comparison and logical operators

Wireshark Foundation · verified
Source ↗
Wireshark User’s Guide: Following protocol streams

Reconstructing TCP, UDP, TLS and HTTP conversations

Wireshark Foundation · verified
Source ↗
Wireshark wiki: TLS

TLS decryption with key log files and the tls.keylog_file preference

Wireshark Foundation · verified
Source ↗
tshark manual page

Command-line capture and analysis with display filters, fields and statistics

Wireshark Foundation · verified
Source ↗
tcpdump manual page

Server-side packet capture with interfaces, BPF filters and output files

The Tcpdump Group · verified
Source ↗