3 ethereal-filter - Ethereal filter syntax and reference
7 B<ethereal> [other options]
8 S<[ B<-R> "filter expression" ]>
10 B<tethereal> [other options]
11 S<[ B<-R> "filter expression" ]>
15 B<Ethereal> and B<Tethereal> share a powerful filter engine that helps remove
16 the noise from a packet trace and lets you see only the packets that interest
17 you. If a packet meets the requirements expressed in your filter, then it
18 is displayed in the list of packets. Display filters let you compare the
19 fields within a protocol against a specific value, compare fields against
20 fields, and check the existence of specified fields or protocols.
22 Filters are also used by other features such as statistics generation and
23 packet list colorization (the latter is only available to B<Ethereal>). This
24 manual page describes their syntax and provides a comprehensive reference of
29 =head2 Check whether a field or protocol exists
31 The simplest filter allows you to check for the existence of a protocol or
32 field. If you want to see all packets which contain the IPX protocol, the
33 filter would be "ipx" (without the quotation marks). To see all packets
34 that contain a Token-Ring RIF field, use "tr.rif".
36 Think of a protocol or field in a filter as implicitly having the "exists"
39 Note: all protocol and field names that are available in B<Ethereal> and
40 B<Tethereal> filters are listed in the B<FILTER PROTOCOL REFERENCE> (see
43 =head2 Comparison operators
45 Fields can also be compared against values. The comparison operators
46 can be expressed either through C-like symbols or through English-like
53 ge, >= Greater than or Equal to
54 le, <= Less than or Equal to
56 =head2 Search and match operators
58 Additional operators exist expressed only in English, not punctuation:
60 contains Does the protocol, field or slice contain a value
61 matches Does the text string match the given Perl regular expression
63 The "contains" operator allows a filter to search for a sequence of
64 characters or bytes. For example, to search for a given HTTP
65 URL in a capture, the following filter can be used:
67 http contains "http://www.ethereal.com"
69 The "contains" operator cannot be used on atomic fields,
70 such as numbers or IP addresses.
72 The "matches" operator allows a filter to apply to a specified
73 Perl-compatible regular expression (PCRE). The "matches" operator is only
74 implemented for protocols and for protocol fields with a text string
75 representation. For example, to search for a given WAP WSP User-Agent,
78 wsp.user_agent matches "(?i)cldc"
80 This example shows an interesting PCRE feature: pattern match options have to
81 be specified with the B<(?>optionB<)> construct. For instance, B<(?i)> performs
82 a case-insensitive pattern match. More information on PCRE can be found in the
83 pcrepattern(3) man page (Perl Regular Expressions are explained in
84 B<http://www.perldoc.com/perl5.8.0/pod/perlre.html>).
86 Note: the "matches" operator is only available if B<Ethereal> or B<Tethereal>
87 have been compiled with the PCRE library. This can be checked by running:
92 or selecting the "About Ethereal" item from the "Help" menu in B<Ethereal>.
94 =head2 Protocol field types
96 Each protocol field is typed. The types are:
98 Unsigned integer (8-bit, 16-bit, 24-bit, or 32-bit)
99 Signed integer (8-bit, 16-bit, 24-bit, or 32-bit)
101 Ethernet address (6 bytes)
107 Double-precision floating point number
109 An integer may be expressed in decimal, octal, or hexadecimal notation.
110 The following three display filters are equivalent:
116 Boolean values are either true or false. In a display filter expression
117 testing the value of a Boolean field, "true" is expressed as 1 or any
118 other non-zero value, and "false" is expressed as zero. For example, a
119 token-ring packet's source route field is Boolean. To find any
120 source-routed packets, a display filter would be:
124 Non source-routed packets can be found with:
128 Ethernet addresses and byte arrays are represented by hex
129 digits. The hex digits may be separated by colons, periods, or hyphens:
131 eth.dst eq ff:ff:ff:ff:ff:ff
133 fddi.src == aa-aa-aa-aa-aa-aa
136 IPv4 addresses can be represented in either dotted decimal notation or
137 by using the hostname:
139 ip.dst eq www.mit.edu
140 ip.src == 192.168.1.1
142 IPv4 addresses can be compared with the same logical relations as numbers:
143 eq, ne, gt, ge, lt, and le. The IPv4 address is stored in host order,
144 so you do not have to worry about the endianness of an IPv4 address
145 when using it in a display filter.
147 Classless InterDomain Routing (CIDR) notation can be used to test if an
148 IPv4 address is in a certain subnet. For example, this display filter
149 will find all packets in the 129.111 Class-B network:
151 ip.addr == 129.111.0.0/16
153 Remember, the number after the slash represents the number of bits used
154 to represent the network. CIDR notation can also be used with
155 hostnames, as in this example of finding IP addresses on the same Class C
160 The CIDR notation can only be used on IP addresses or hostnames, not in
161 variable names. So, a display filter like "ip.src/24 == ip.dst/24" is
164 IPX networks are represented by unsigned 32-bit integers. Most likely
165 you will be using hexadecimal when testing IPX network values:
167 ipx.src.net == 0xc0a82c00
169 Strings are enclosed in double quotes:
171 http.request.method == "POST"
173 Inside double quotes, you may use a backslash to embed a double quote
174 or an arbitrary byte represented in either octal or hexadecimal.
176 browser.comment == "An embedded \" double-quote"
178 Use of hexadecimal to look for "HEAD":
180 http.request.method == "\x48EAD"
182 Use of octal to look for "HEAD":
184 http.request.method == "\110EAD"
186 This means that you must escape backslashes with backslashes inside
189 smb.path contains "\\\\SERVER\\SHARE"
191 looks for \\SERVER\SHARE in "smb.path".
193 =head2 The slice operator
195 You can take a slice of a field if the field is a text string or a
197 For example, you can filter on
198 the vendor portion of an ethernet address (the first three bytes) like
201 eth.src[0:3] == 00:00:83
205 http.content_type[0:4] == "text"
207 You can use the slice operator on a protocol name, too.
208 The "frame" protocol can be useful, encompassing all the data captured
209 by B<Ethereal> or B<Tethereal>.
211 token[0:5] ne 0.0.0.1.1
213 frame[100-199] contains "ethereal"
215 The following syntax governs slices:
217 [i:j] i = start_offset, j = length
218 [i-j] i = start_offset, j = end_offset, inclusive.
219 [i] i = start_offset, length = 1
220 [:j] start_offset = 0, length = j
221 [i:] start_offset = i, end_offset = end_of_field
223 Offsets can be negative, in which case they indicate the
224 offset from the B<end> of the field. The last byte of the field is at offset
225 -1, the last but one byte is at offset -2, and so on.
226 Here's how to check the last four bytes of a frame:
228 frame[-4:4] == 0.1.2.3
232 frame[-4:] == 0.1.2.3
234 You can concatenate slices using the comma operator:
236 ftp[1,3-5,9:] == 01:03:04:05:09:0a:0b
238 This concatenates offset 1, offsets 3-5, and offset 9 to the end of the ftp
241 =head2 Type conversions
243 If a field is a text string or a byte array, it can be expressed in whichever
244 way is most convenient.
246 So, for instance, the following filters are equivalent:
248 http.request.method == "GET"
249 http.request.method == 47.45.54
251 A range can also be expressed in either way:
256 =head2 Bit field operations
258 It is also possible to define tests with bit field operations. Currently the
259 following bit field operation is supported:
261 bitwise_and, & Bitwise AND
263 The bitwise AND operation allows testing to see if one or more bits are set.
264 Bitwise AND operates on integer protocol fields and slices.
266 When testing for TCP SYN packets, you can write:
270 Similarly, filtering for all WSP GET and extended GET methods is achieved with:
274 When using slices, the bit mask must be specified as a byte string, and it must
275 have the same number of bytes as the slice itself, as in:
279 =head2 Logical expressions
281 Tests can be combined using logical expressions.
282 These too are expressable in C-like syntax or with English-like
289 Expressions can be grouped by parentheses as well. The following are
290 all valid display filter expressions:
292 tcp.port == 80 and ip.src == 192.168.2.1
294 http and frame[100-199] contains "ethereal"
295 (ipx.src.net == 0xbad && ipx.src.node == 0.0.0.0.0.1) || ip
297 Remember that whenever a protocol or field name occurs in an expression, the
298 "exists" operator is implicitly called. The "exists" operator has the highest
299 priority. This means that the first filter expression must be read as "show me
300 the packets for which tcp.port exists and equals 80, and ip.src exists and
301 equals 192.168.2.1". The second filter expression means "show me the packets
302 where not (llc exists)", or in other words "where llc does not exist" and hence
303 will match all packets that do not contain the llc protocol.
304 The third filter expression includes the constraint that offset 199 in the
305 frame exists, in other words the length of the frame is at least 200.
307 A special caveat must be given regarding fields that occur more than
308 once per packet. "ip.addr" occurs twice per IP packet, once for the
309 source address, and once for the destination address. Likewise,
310 "tr.rif.ring" fields can occur more than once per packet. The following
311 two expressions are not equivalent:
313 ip.addr ne 192.168.4.1
314 not ip.addr eq 192.168.4.1
316 The first filter says "show me packets where an ip.addr exists that
317 does not equal 192.168.4.1". That is, as long as one ip.addr in the
318 packet does not equal 192.168.4.1, the packet passes the display
319 filter. The other ip.addr could equal 192.168.4.1 and the packet would
321 The second filter says "don't show me any packets that have an
322 ip.addr field equal to 192.168.4.1". If one ip.addr is 192.168.4.1,
323 the packet does not pass. If B<neither> ip.addr field is 192.168.4.1,
324 then the packet is displayed.
326 It is easy to think of the 'ne' and 'eq' operators as having an implict
327 "exists" modifier when dealing with multiply-recurring fields. "ip.addr
328 ne 192.168.4.1" can be thought of as "there exists an ip.addr that does
329 not equal 192.168.4.1". "not ip.addr eq 192.168.4.1" can be thought of as
330 "there does not exist an ip.addr equal to 192.168.4.1".
332 Be careful with multiply-recurring fields; they can be confusing.
334 Care must also be taken when using the display filter to remove noise
335 from the packet trace. If, for example, you want to filter out all IP
336 multicast packets to address 224.1.2.3, then using:
340 may be too restrictive. Filtering with "ip.dst" selects only those
341 B<IP> packets that satisfy the rule. Any other packets, including all
342 non-IP packets, will not be displayed. To display the non-IP
343 packets as well, you can use one of the following two expressions:
345 not ip or ip.dst ne 224.1.2.3
346 not ip.addr eq 224.1.2.3
348 The first filter uses "not ip" to include all non-IP packets and then
349 lets "ip.dst ne 224.1.2.3" filter out the unwanted IP packets. The
350 second filter has already been explained above where filtering with
351 multiply occuring fields was discussed.
353 =head1 FILTER PROTOCOL REFERENCE
355 Each entry below provides an abbreviated protocol or field name. Every
356 one of these fields can be used in a display filter. The type of the
359 =insert_dfilter_table
363 The B<ethereal-filters> manpage is part of the B<Ethereal> distribution.
364 The latest version of B<Ethereal> can be found at
365 B<http://www.ethereal.com>.
367 Regular expressions in the "matches" operator are provided with B<libpcre>,
368 the Perl-Compatible Regular Expressions library: see B<http://www.pcre.org/>.
370 This manpage does not describe the capture filter syntax, which is
371 different. See the tcpdump(8) manpage for a description of capture
372 filters. Microsoft Windows versions use WinPcap from
373 B<http://winpcap.polito.it/> for which the capture filter syntax is described
374 in B<http://winpcap.polito.it/docs/man/html/group__language.html>.
378 I<ethereal(1)>, I<tethereal(1)>, I<editcap(1)>, I<tcpdump(8)>, I<pcap(3)>
382 See the list of authors in the B<Ethereal> man page for a list of authors of