tcpdump and Wireshark Filter Practice

Free tcpdump and Wireshark filter practice for GIAC GCIA and Cisco CBRFIR: read a tcp[13] flag filter or a display filter and tick the packets it matches. Check my answer names the slip, such as == where a mask was needed or ip.addr != read as either side.

Practise

tcpdump capture filter

Flag values in tcp[13]
CWR 128ECE 64URG 32ACK 16PSH 8RST 4SYN 2FIN 1
Wireshark 3.6 and later
== any equal!= all not equal=== all equal!== any not equal

Check your answer to see the working.

tcpdump problems use the eight flags in TCP header byte 13, numbered as in the tcpdump manual. Wireshark problems use the operator meanings of Wireshark 3.6 and later. Addresses, ports and flags are made up for practice.

Practise the exams

GIAC GCIA lists Tcpdump Filters and Wireshark Fundamentals as exam objectives, and Cisco 300-215 CBRFIR v1.1 covers display filtering in Wireshark. The drill is also useful for GCIH and CySA+. Start with the free real exam questions, then get the full pack.

GIAC GCIA507 real exam questions · US$39
Free: 127 questionsGet the full pack
Cisco 300-215 CBRFIR134 real exam questions · US$39
Free: 26 questionsGet the full pack
GIAC GCIH842 real exam questions · US$39
Free: 210 questionsGet the full pack
CompTIA CySA+ CS0-003641 real exam questions · US$39
Free: 160 questionsGet the full pack

Filter FAQ

What does tcp[13] mean in a tcpdump filter?

It is byte 13 of the TCP header, counting from 0, and it holds eight flags: CWR, ECE, URG, ACK, PSH, RST, SYN and FIN. The tcpdump manual numbers the bits 0 to 7 from the right, so FIN is 1, SYN 2, RST 4, PSH 8, ACK 16, URG 32, ECE 64 and CWR 128. A packet's value is the sum of the flags it has: SYN and ACK together are 18. You can write tcp[tcpflags] instead of tcp[13].

Why does tcp[13] == 2 miss SYN-ACK packets?

Because == compares the whole byte. Only SYN gives 2; SYN with ACK gives 18. The tcpdump manual's fix is to mask first: tcp[13] & 2 == 2 keeps the SYN bit and ignores the rest, so it captures SYN and SYN-ACK packets alike.

What is the difference between & mask == mask and & mask != 0?

With == mask every masked bit must be set. With != 0 one is enough. pcap-filter gives both: tcp[tcpflags] & (tcp-rst|tcp-ack) == (tcp-rst|tcp-ack) needs RST and ACK together, while tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 captures a packet with SYN or FIN. A mask can also test for a bit being off: tcp[13] & 18 == 2 means SYN set and ACK clear.

Why does ip.addr != 10.0.0.5 hide packets in both directions?

ip.addr is both the source and the destination address, and since Wireshark 3.6 != means all not equal: every ip.addr in the packet must differ. So any packet to or from 10.0.0.5 is hidden, the same as !(ip.addr == 10.0.0.5). The other reading, any not equal, is written !== and shows a packet when either address differs.

What is the difference between tcp.port != 80 and !(tcp.port == 80)?

Packets without the field. A field in a test is checked for existence first, so tcp.port != 80 is false for a UDP packet and hides it. !(tcp.port == 80) turns a false test around, so it shows UDP packets as well. The wireshark-filter manual makes the same point with ip.dst ne 224.1.2.3 and not ip.dst eq 224.1.2.3.

Does tcp.port match the source or the destination port?

Either. tcp.port == 443 shows a packet whose source or destination port is 443. Each comparison can be true for a different port, so tcp.port >= 1000 && tcp.port <= 2000 matches a packet with ports 51234 and 443. The in operator tests one port at a time, so tcp.port in {1000..2000} needs one port inside the range.

Which comes first in a display filter, && or ||?

Wireshark works out not (!) first, then and (&&), then or (||), so a || b && c reads a || (b && c). tcpdump is different: pcap-filter gives and and or equal precedence, worked left to right. Brackets make either one clear.

Which exams cover this?

GIAC GCIA lists Tcpdump Filters ("craft tcpdump filters that match on given criteria") and Wireshark Fundamentals among its exam objectives. Cisco 300-215 CBRFIR v1.1 covers analysing traffic with network monitoring tools such as display filtering in Wireshark.

Sources
  • tcpdump.org, tcpdump(1) manual page, "Particular TCP Flag Combinations": the control bits in octet 13 numbered 0 to 7 from the right, tcp[13] == 2 for SYN only, 18 for SYN-ACK, tcp[13] & 2 == 2, tcp[tcpflags] and the named flag values.
  • tcpdump.org, pcap-filter(7) manual page: relations of two arithmetic expressions, C-style constants, & and |, the TCP flag names, the SYN or FIN and RST and ACK examples, and and or with equal precedence.
  • Wireshark, wireshark-filter(4) manual page: == any equal, != all not equal, === all equal, !== any not equal, CIDR, membership, the implicit field test (ip.dst ne 224.1.2.3) and the order of not (!), and (&&) and or (||).
  • Wireshark, User's Guide 6.4, Building Display Filter Expressions: ip.addr for packets to or from an address, the note that != changed in Wireshark 3.6, tcp.port as the source or destination port and the membership range note.
  • Exam fit: GIAC GCIA exam objectives (Tcpdump Filters, Wireshark Fundamentals) and Cisco 300-215 CBRFIR v1.1 exam topics (display filtering in Wireshark).
  • Checked 21 November 2026: the drill reproduces the manual pages' examples, and an independent solver that parses each filter as written agreed with it on 6,000 generated problems. Addresses, ports and flag sets are made up for practice.

Checked 21 November 2026 against the tcpdump and pcap-filter manual pages, the wireshark-filter manual page and the Wireshark User's Guide.

More free tools

All free tools