Skip to main content
Wireshark Intro: Capture & Display Filters
Lesson 11 of 11

Wireshark Intro: Capture & Display Filters

Capture network traffic safely, separate BPF capture filters from Wireshark display filters, inspect packets with tshark, and reconstruct cleartext streams and files.

Intermediate 28 min Networking
Authorised environments only — The techniques described here are used only in training labs and on systems you own or have written permission to test.

Learning objectives

  • Explain the difference between BPF capture filters and Wireshark display filters
  • Write accurate display filters to isolate hosts, ports, TCP handshake flags, and application protocols
  • Triage a PCAP file from the command line using tshark protocol hierarchy and field extraction
  • Reconstruct a TCP or HTTP conversation and export transferred objects in Wireshark

Recommended first: TCP, UDP, Ports & ICMP DiagnosticsHTTP/HTTPS Requests, Methods & TLS OverviewSystematic Network Troubleshooting with CLI

#Why this matters

Tools like ss and nc show connection state, not the exact bytes crossing the wire. When debugging a protocol fault, investigating an unexpected outbound connection, or solving a digital forensics (raqamli-izquarlik) CTF challenge, you need packet-level evidence. Wireshark and tshark decode protocols and let you isolate a single request or transferred file in seconds.

#Capture filters vs. display filters

New analysts often confuse Wireshark's two filter engines because both appear in the same workflow, yet they use different syntax and act at different stages.

Aspect Capture filter Display filter
Syntax engine BPF (same as tcpdump) Wireshark display filter syntax
When applied Before saving packets to disk While viewing an existing PCAP
Effect on file Discards unmatched packets permanently Hides packets visually; file stays intact
Example host 10.10.10.50 and tcp port 80 ip.addr == 10.10.10.50 && tcp.port == 80

Use a capture filter only when traffic volume would fill disk space or drop frames. In labs and incident triage, capture broadly and rely on display filters so you keep surrounding context like DNS lookups.

#Essential display filters and tshark workflows

Display filters use dotted field names and comparison operators (==, !=, &&, ||, !). A core set handles most triage:

Goal Wireshark / tshark display filter
Traffic to or from a host ip.addr == 10.10.10.50
Exclude a host safely !(ip.addr == 10.10.10.1)
Initial TCP SYN packets only tcp.flags.syn == 1 && tcp.flags.ack == 0
TCP retransmissions tcp.analysis.retransmission
DNS queries for a domain dns.qry.name contains "lab.local"
Cleartext HTTP POST requests http.request.method == "POST"

In tshark, -r <file> reads a capture and -Y "<filter>" applies a display filter (whereas -f sets a BPF capture filter). Start with Protocol Hierarchy (-q -z io,phs) to spot cleartext protocols quickly.

Triaging a lab PCAP with tshark
$ tshark -r lab_capture.pcapng -q -z io,phs
===================================================================
Protocol Hierarchy Statistics
Filter: 

eth                                      frames:412 bytes:184920
  ip                                     frames:408 bytes:184680
    udp                                  frames:24 bytes:2140
      dns                                frames:24 bytes:2140
    tcp                                  frames:384 bytes:182540
      tls                                frames:310 bytes:161200
      http                               frames:74 bytes:21340
===================================================================
$ tshark -r lab_capture.pcapng -Y "http.request" -T fields -e frame.number -e ip.src -e http.request.method -e http.request.uri
118	10.10.10.25	GET	/index.html
142	10.10.10.25	POST	/login
165	10.10.10.25	GET	/downloads/report.txt

Here -Y selects matching frames and -T fields -e ... prints only the fields you need.

#Following streams and extracting objects

Reading single packets is slow when an HTTP exchange or upload spans multiple TCP segments. Wireshark groups all packets sharing a 4-tuple (source IP/port, destination IP/port) into a numbered TCP stream.

  1. OverviewRun Protocol Hierarchy to spot cleartext protocols
  2. FilterNarrow to suspicious IP, port, or http.request
  3. ReconstructFollow TCP or HTTP Stream to read full dialogue
  4. ExtractExport HTTP objects to save transferred files

In the GUI, right-click a packet and select Follow, then TCP Stream (or HTTP Stream). In tshark, print the reassembled ASCII conversation for stream 0 with -q -z follow,tcp,ascii,0. To recover files sent over HTTP, open File, Export Objects, HTTP in Wireshark, or run tshark --export-objects http,./extracted.

#Common mistakes

  • Writing ip.addr != 10.10.10.1 to exclude a host: Every packet has two ip.addr values (source and destination), so != still matches whenever the other IP differs. Always write !(ip.addr == 10.10.10.1).
  • Using display syntax in a capture filter: ip.addr == 10.10.10.5 fails at capture time; use BPF syntax (host 10.10.10.5).
  • Capturing on the wrong interface: Localhost traffic (127.0.0.1) appears on lo, not eth0.
  • Expecting plaintext inside TLS: Follow TCP Stream shows encrypted bytes without session keys, though SNI and certificates in the handshake remain readable.

#Summary

  • Capture filters use BPF syntax and drop unmatched packets permanently; display filters use Wireshark syntax and preserve the capture file.
  • Start triage with Protocol Hierarchy (io,phs) to locate cleartext traffic and unexpected protocols.
  • Use tshark -Y with -T fields for targeted extraction, and Follow Stream or Export Objects to reconstruct conversations and files.
  • Negate multi-value fields with !(ip.addr == ...) instead of !=.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge