aboutsummaryrefslogtreecommitdiffstats
path: root/docbook/wsug_src/WSUG_chapter_work.asciidoc
blob: 6e91a4258b9d7eb778fed6d2ccab8367b10e99f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
// WSUG Chapter Work

[[ChapterWork]]

== Working with captured packets

[[ChWorkViewPacketsSection]]

=== Viewing packets you have captured

Once you have captured some packets or you have opened a previously saved
capture file, you can view the packets that are displayed in the packet list
pane by simply clicking on a packet in the packet list pane, which will bring up
the selected packet in the tree view and byte view panes.

You can then expand any part of the tree to view detailed information about each
protocol in each packet. Clicking on an item in the tree will highlight the
corresponding bytes in the byte view. An example with a TCP packet selected is
shown in <<ChWorkSelPack1>>. It also has the Acknowledgment number in the TCP
header selected, which shows up in the byte view as the selected bytes.

[[ChWorkSelPack1]]

.Wireshark with a TCP packet selected for viewing
image::wsug_graphics/ws-packet-selected.png[{screenshot-attrs}]

You can also select and view packets the same way while Wireshark is capturing
if you selected “Update list of packets in real time” in the “Capture
Preferences” dialog box.

In addition you can view individual packets in a separate window as shown in
<<ChWorkPacketSepView>>. You can do this by double-clicking on an item in the
packet list or by selecting the packet in which you are interested in the packet
list pane and selecting menu:View[Show Packet in New Window]. This allows you to
easily compare two or more packets, even across multiple files.

[[ChWorkPacketSepView]]

.Viewing a packet in a separate window
image::wsug_graphics/ws-packet-sep-win.png[{screenshot-attrs}]

Along with double-clicking the packet list and using the main menu there are a
number of other ways to open a new packet window:

- Hold down the shift key and double-click on a frame link in the packet
  details.
- From <<PacketListPopupMenuTable>>.
- From <<PacketDetailsPopupMenuTable>>.

[[ChWorkDisplayPopUpSection]]

=== Pop-up menus

You can bring up a pop-up menu over either the “Packet List”, its column header,
or “Packet Details” pane by clicking your right mouse button at the
corresponding pane.

[[ChWorkColumnHeaderPopUpMenuSection]]

==== Pop-up menu of the “Packet List” column header

[[ChWorkColumnHeaderPopUpMenu]]
.Pop-up menu of the “Packet List” column header
image::wsug_graphics/ws-column-header-popup-menu.png[{screenshot-attrs}]

The following table gives an overview of which functions are available in this
header, where to find the corresponding function in the main menu, and a short
description of each item.

[[ColumnHeaderPopupMenuTable]]
.The menu items of the “Packet List” column header pop-up menu
[options="header",cols="3,2,5"]
|===============
|Item|Identical to main menu’s item:|Description
|menu:Sort Ascending[]|| Sort the packet list in ascending order based on this column.
|menu:Sort Descending[]|| Sort the packet list in descending order based on this column.
|menu:No Sort[]|| Remove sorting order based on this column.
|menu:Align Left[]|| Set left alignment of the values in this column.
|menu:Align Center[]|| Set center alignment of the values in this column.
|menu:Align Right[]|| Set right alignment of the values in this column.
|menu:Column Preferences...[]|| Open the Preferences dialog box on the column tab.
|menu:Resize Column[]|| Resize the column to fit the values.
|menu:Rename Column Title[]|| Allows you to change the title of the column header.
|menu:Displayed Column[]|menu:View[]| This menu items folds out with a list of all configured columns. These columns can now be shown or hidden in the packet list.
|menu:Hide Column[]|| Allows you to hide the column from the packet list.
|menu:Remove Column[]|| Allows you to remove the column from the packet list.
|===============

[[ChWorkPacketListPanePopUpMenuSection]]

==== Pop-up menu of the “Packet List” pane

[[ChWorkPacketListPanePopUpMenu]]

.Pop-up menu of the “Packet List” pane
image::wsug_graphics/ws-packet-pane-popup-menu.png[{screenshot-attrs}]

The following table gives an overview of which functions are available  in this pane, where to find the corresponding function in the main menu,  and a short description of each item.

[[PacketListPopupMenuTable]]
.The menu items of the “Packet List” pop-up menu
[options="header",cols="3,2,5"]
|===============
|Item|Identical to main menu’s item:|Description
|menu:Mark Packet (toggle)[]|menu:Edit[]| Mark/unmark a packet.
|menu:Ignore Packet (toggle)[]|menu:Edit[]| Ignore or inspect this packet while dissecting the capture file.
|menu:Set Time Reference (toggle)[]|menu:Edit[]| Set/reset a time reference.
|menu:Manually Resolve Address[]|| Allows you to enter a name to resolve for the selected address.
|menu:Apply as Filter[]|menu:Analyze[]| Prepare and apply a display filter based on the currently selected  item.
|menu:Prepare a Filter[]|menu:Analyze[]| Prepare a display filter based on the currently selected item.
|menu:Conversation Filter[]|| This menu item applies a display filter with the address information  from the selected packet. E.g. the IP menu entry will set a filter  to show the traffic between the two IP addresses of the current  packet. XXX - add a new section describing this better.
|menu:Colorize Conversation[]|| This menu item uses a display filter with the address information  from the selected packet to build a new colorizing rule.
|menu:SCTP[]|| Allows you to analyze and prepare a filter for this SCTP association.
|menu:Follow TCP Stream[]|menu:Analyze[]| Allows you to view all the data on a TCP  stream between a pair of nodes.
|menu:Follow UDP Stream[]|menu:Analyze[]| Allows you to view all the data on a UDP datagram stream between a pair of nodes.
|menu:Follow SSL Stream[]|menu:Analyze[]| Same as “Follow TCP Stream” but for SSL. XXX - add a new section describing this better.
|menu:Copy/ Summary (Text)[]|| Copy the summary fields as displayed to the clipboard, as tab-separated text.
|menu:Copy/ Summary (CSV)[]|| Copy the summary fields as displayed to the clipboard, as comma-separated text.
|menu:Copy/ As Filter[]|| Prepare a display filter based on the currently selected item and copy that filter to the clipboard.
|menu:Copy/ Bytes (Offset Hex Text)[]|| Copy the packet bytes to the clipboard in hexdump-like format.
|menu:Copy/ Bytes (Offset Hex)[]|| Copy the packet bytes to the clipboard in hexdump-like format, but without the text portion.
|menu:Copy/ Bytes (Printable Text Only)[]|| Copy the packet bytes to the clipboard as ASCII text, excluding non-printable characters.
|menu:Copy/ Bytes (Hex Stream)[]|| Copy the packet bytes to the clipboard as an unpunctuated list of hex digits.
|menu:Copy/ Bytes (Binary Stream)[]|| Copy the packet bytes to the clipboard as raw binary. The data is stored in the clipboard as MIME-type “application/octet-stream”.
|menu:Decode As...[]|menu:Analyze[]| Change or apply a new relation between two dissectors.
|menu:Print...[]|File| Print packets.
|menu:Show Packet in New Window[]|menu:View[]| Display the selected packet in a new window.
|===============


[[ChWorkPacketDetailsPanePopUpMenuSection]]

==== Pop-up menu of the “Packet Details” pane

[[ChWorkPacketDetailsPanePopUpMenu]]

.Pop-up menu of the “Packet Details” pane
image::wsug_graphics/ws-details-pane-popup-menu.png[{screenshot-attrs}]

The following table gives an overview of which functions are available in this
pane, where to find the corresponding function in the main menu, and a short
description of each item.

[[PacketDetailsPopupMenuTable]]

.The menu items of the “Packet Details” pop-up menu
[options="header",cols="3,2,5"]
|===============
|Item|Identical to main menu’s item:|Description
|menu:Expand Subtrees[]|menu:View[]| Expand the currently selected subtree.
|menu:Collapse Subtrees[]|menu:View[]| Collapse the currently selected subtree.
|menu:Expand All[]|menu:View[]| Expand all subtrees in all packets in the capture.
|menu:Collapse All[]|menu:View[]| Wireshark keeps a list of all the protocol subtrees that are  expanded, and uses it to ensure that the correct subtrees  are expanded when you display a packet. This menu item  collapses the tree view of all packets in the capture list.
|menu:Apply as Column[]|| Use the selected protocol item to create a new column in the packet list.
|menu:Apply as Filter[]|menu:Analyze[]| Prepare and apply a display filter based on the currently selected item.
|menu:Prepare a Filter[]|menu:Analyze[]| Prepare a display filter based on the currently selected item.
|menu:Colorize with Filter[]|| This menu item uses a display filter with the information from the selected protocol item to build a new colorizing rule.
|menu:Follow TCP Stream[]|menu:Analyze[]| Allows you to view all the data on a TCP stream between a pair of nodes.
|menu:Follow UDP Stream[]|menu:Analyze[]| Allows you to view all the data on a UDP datagram stream between a pair of nodes.
|menu:Follow SSL Stream[]|menu:Analyze[]| Same as “Follow TCP Stream” but for SSL. XXX - add a new section describing this better.
|menu:Copy/ Description[]|menu:Edit[]| Copy the displayed text of the selected field to the system  clipboard.
|menu:Copy/ Fieldname[]|menu:Edit[]| Copy the name of the selected field to the system clipboard.
|menu:Copy/ Value[]|menu:Edit[]| Copy the value of the selected field to the system clipboard.
|menu:Copy/ As Filter[]|menu:Edit[]| Prepare a display filter based on the currently selected item and copy it to the clipboard.
|menu:Copy/ Bytes (Offset Hex Text)[]|| Copy the packet bytes to the clipboard in hexdump-like format; similar to the Packet List Pane  command, but copies only the bytes relevant to the selected part of the tree (the bytes selected in the Packet Bytes Pane).
|menu:Copy/ Bytes (Offset Hex)[]|| Copy the packet bytes to the clipboard in hexdump-like format, but without the text portion; similar to the         Packet List Pane  command, but copies only the bytes relevant to the selected part of the tree (the bytes selected in the Packet Bytes Pane).
|menu:Copy/ Bytes (Printable Text Only)[]|| Copy the packet bytes to the clipboard as ASCII text, excluding non-printable characters; similar to the Packet List Pane  command, but copies only the bytes relevant to the selected part of the tree (the bytes selected in the Packet Bytes Pane).
|menu:Copy/ Bytes (Hex Stream)[]|| Copy the packet bytes to the clipboard as an unpunctuated list of hex digits; similar to the Packet List Pane  command, but copies only the bytes relevant to the selected part of the tree (the bytes selected in the Packet Bytes Pane).
|menu:Copy/ Bytes (Binary Stream)[]|| Copy the packet bytes to the clipboard as raw binary; similar to the Packet List Pane  command, but copies only the bytes relevant to the selected part of the tree (the bytes selected in the Packet Bytes Pane). The data is stored in the clipboard as MIME-type “application/octet-stream”.
|menu:Export Selected Packet Bytes...[]|menu:File[]| This menu item is the same as the File menu item of the same  name. It allows you to export raw packet bytes to a binary file.
|menu:Wiki Protocol Page[]|| Show the wiki page corresponding to the currently selected protocol  in your web browser.
|menu:Filter Field Reference[]|| Show the filter field reference web page corresponding to the  currently selected protocol in your web browser.
|menu:Protocol Preferences...[]|| The menu item takes you to the properties dialog and selects the  page corresponding to the protocol if there are properties  associated with the highlighted field.   More information on preferences can be found in  <<ChCustGUIPrefPage>>.
|menu:Decode As...[]|menu:Analyze[]| Change or apply a new relation between two dissectors.
|menu:Disable Protocol[]|| Allows you to temporarily disable a protocol dissector, which may be blocking the legitimate dissector.
|menu:Resolve Name[]|menu:View[]| Causes a name resolution to be performed for  the selected packet, but NOT every packet in the capture.
|menu:Go to Corresponding Packet[]|menu:Go[]| If the selected field has a corresponding packet, go to it.  Corresponding packets will usually be a request/response packet pair  or such.
|===============

[[ChWorkDisplayFilterSection]]

=== Filtering packets while viewing

Wireshark has two filtering languages: One used when capturing packets, and one
used when displaying packets. In this section we explore that second type of
filter: Display filters. The first one has already been dealt with in
<<ChCapCaptureFilterSection>>.

Display filters allow you to concentrate on the packets you are interested in
while hiding the currently uninteresting ones. They allow you to select packets
by:

* Protocol

* The presence of a field

* The values of fields

* A comparison between fields

* ... and a lot more!

To select packets based on protocol type, simply type the protocol in which you
are interested in the _Filter:_ field in the filter toolbar of the Wireshark
window and press enter to initiate the filter. <<ChWorkTCPFilter>> shows an
example of what happens when you type _tcp_ in the filter field.


[NOTE]
====
All protocol and field names are entered in lowercase.  Also, don’t  forget to press enter after entering the filter expression.
====


[[ChWorkTCPFilter]]

.Filtering on the TCP protocol
image::wsug_graphics/ws-display-filter-tcp.png[{screenshot-attrs}]

As you might have noticed, only packets of the TCP protocol are displayed now
(e.g. packets 1-10 are hidden). The packet numbering will remain as before, so
the first packet shown is now packet number 11.

[NOTE]
====
When using a display filter, all packets remain in the capture file. The display
filter only changes the display of the capture file but not its content!
====

You can filter on any protocol that Wireshark understands. You can also filter
on any field that a dissector adds to the tree view, but only if the dissector
has added an abbreviation for the field. A list of such fields is available in
Wireshark in the _Add Expression..._ dialog box. You can find more information
on the _Add Expression..._ dialog box in <<ChWorkFilterAddExpressionSection>>.

For example, to narrow the packet list pane down to only those packets to or
from the IP address 192.168.0.1, use `ip.addr==192.168.0.1`.

[NOTE]
====
To remove the filter, click on the btn:[Clear] button  to the right of the filter field.
====

[[ChWorkBuildDisplayFilterSection]]

=== Building display filter expressions

Wireshark provides a simple but powerful display filter language that allows you
to build quite complex filter expressions. You can compare values in packets as
well as combine expressions into more specific expressions. The following
sections provide more information on doing this.

[TIP]
====
You will find a lot of Display Filter examples at the _Wireshark Wiki Display
Filter page_ at: link:{wireshark-wiki-url}DisplayFilters[].
====

==== Display filter fields

Every field in the packet details pane can be used as a filter string, this will
result in showing only the packets where this field exists. For example: the
filter string: _tcp_ will show all packets containing the tcp protocol.

There is a complete list of all filter fields available through the menu item
menu:Help[Supported Protocols] in the page “Display Filter Fields” of the
“Supported Protocols” dialog.

// XXX - add some more info here and a link to the statusbar info.

==== Comparing values

You can build display filters that compare values using a number of different
comparison operators. They are shown in <<DispCompOps>>.

[TIP]
====
You can use English and C-like terms in the same way, they can even be  mixed in a filter string.
====

[[DispCompOps]]

.Display Filter comparison operators
[options="header",cols="1,1,4"]
|===============
|English|C-like|Description and example
|eq |== |Equal. `ip.src==10.0.0.5`
|ne |!= |Not equal. `ip.src!=10.0.0.5`
|gt |>  |Greater than. `frame.len > 10`
|lt |<  |Less than. `frame.len < 128`
|ge |>= |Greater than or equal to. `frame.len ge 0x100`
|le |\<= |Less than or equal to. `frame.len <= 0x20`
|contains||Protocol, field or slice contains a value. `sip.To contains "a1762"`
|matches|~|Protocol or text field match Perl regualar expression. `http.host matches "acme\.(org\|com\|net)"`
|bitwise_and|&|Compare bit field value. `tcp.flags & 0x02`
|===============

In addition, all protocol fields have a type. <<ChWorkFieldTypes>> provides a list
of the types and example of how to express them.

[[ChWorkFieldTypes]]

.Display Filter Field Types
Unsigned integer::
  Can be 8, 16, 24, 32, or 64 bits. You can express integers in decimal, octal,
  or  hexadecimal. The following display filters are  equivalent:

  ip.len le 1500

  ip.len le 02734

  ip.len le 0x5dc

Signed integer::
  Can be 8, 16, 24, 32, or 64 bits. As with unsigned integers you can use
  decimal, octal, or  hexadecimal.

Boolean::
  A boolean field is present in the protocol decode only if its value is true. For
  example, `tcp.flags.syn` is present, and thus true, only if the SYN flag is
  present in a TCP segment header.

  The filter expression  `tcp.flags.syn` will select only  those packets for which
  this flag exists, that is,  TCP segments where the segment header contains the
  SYN flag. Similarly, to find source-routed token ring packets, use a filter
  expression of  `tr.sr`.

Ethernet address::
  6 bytes separated by a colon (:), dot (.) or dash (-) with one or two bytes between separators:

  eth.dst == ff:ff:ff:ff:ff:ff

  eth.dst == ff-ff-ff-ff-ff-ff

  eth.dst == ffff.ffff.ffff

IPv4 address::
  ip.addr == 192.168.0.1

  Classless InterDomain Routing (CIDR) notation can be used to test if
  an IPv4 address is in a certain subnet. For example, this display
  filter will find all packets in the 129.111 Class-B network:

  ip.addr == 129.111.0.0/16

IPv6 address::
  `ipv6.addr == ::1`

  As with IPv4 addresses, IPv6 addresses can match a subnet.

Text string::
  `http.request.uri == "https://www.wireshark.org/"`

----
udp contains 81:60:03
----
The example above match packets that contains the 3-byte sequence 0x81, 0x60,
0x03 anywhere in the UDP header or payload.
----
sip.To contains "a1762"
----
Above example match packets where SIP To-header contains the string "a1762"
anywhere in the header.
----
http.host matches "acme\.(org|com|net)"
----
The example above match HTTP packets where the HOST header contains acme.org or acme.com
or acme.net. Comparisons are case-insensitive. Note: Wireshark needs to be built with
libpcre in order to be able to use the `matches` resp. `{tilde}` operator.
----
tcp.flags & 0x02
----
That expression will match all packets that contain a “tcp.flags” field with the 0x02 bit,
i.e. the SYN bit, set.

==== Combining expressions

You can combine filter expressions in Wireshark using the  logical operators shown in <<FiltLogOps>>

[[FiltLogOps]]

.Display Filter Logical Operations
[options="header",cols="1,1,4"]
|===============
|English|C-like|Description and example
|and     |&amp;&amp;| Logical AND. `ip.src==10.0.0.5 and tcp.flags.fin`
|or      |\|\|      | Logical OR. `ip.scr==10.0.0.5 or ip.src==192.1.1.1`
|xor     |^^        | Logical XOR. `tr.dst[0:3] == 0.6.29 xor tr.src[0:3] == 0.6.29`
|not     |!         | Logical NOT. `not llc`
|[...]   |          | See “Substring Operator” below.
|in      |          | See “Membership Operator” below.
|===============

==== Substring Operator
Wireshark allows you to select subsequences of a sequence in rather elaborate
ways. After a label you can place a pair of brackets [] containing a comma
separated list of range specifiers.
----
eth.src[0:3] == 00:00:83
----
The example above uses the n:m format to specify a single range. In this case n
is the beginning offset and m is the length of the range being specified.
----
eth.src[1-2] == 00:83
----
The example above uses the n-m format to specify a single range. In this case n
is the beginning offset and m is the ending offset.
----
eth.src[:4] == 00:00:83:00
----
The example above uses the :m format, which takes everything from the beginning
of a sequence to offset m. It is equivalent to 0:m
----
eth.src[4:] == 20:20
----
The example above uses the n: format, which takes everything from offset n to
the end of the sequence.
----
eth.src[2] == 83
----
The example above uses the n format to specify a single range. In this case the
element in the sequence at offset n is selected. This is equivalent to n:1.
----
eth.src[0:3,1-2,:4,4:,2] ==
00:00:83:00:83:00:00:83:00:20:20:83
----
Wireshark allows you to string together single ranges in a comma separated list
to form compound ranges as shown above.

==== Membership Operator.
Wireshark allows you to test a field for membership in a set of values or
fields. After the field name, use the in operator followed by the set items
surrounded by braces {}.
----
tcp.port in {80 443 8080}
----
This can be considered a shortcut operator, as the previous expression could
have been expressed as:
----
tcp.port == 80 || tcp.port == 443 || tcp.port == 8080
----

[[ChWorkBuildDisplayFilterMistake]]

==== A Common Mistake

Using the != operator on combined expressions like eth.addr, ip.addr, tcp.port,
and udp.port will probably not work as expected.

Often people use a filter string to display something like `ip.addr == 1.2.3.4`
which will display all packets containing the IP address 1.2.3.4.

Then they use `ip.addr != 1.2.3.4` to see all packets not containing the IP
address 1.2.3.4 in it. Unfortunately, this does _not_ do the expected.

Instead, that expression will even be true for packets where either source or
destination IP address equals 1.2.3.4. The reason for this, is that the
expression `ip.addr != 1.2.3.4` must be read as “the packet contains a field
named ip.addr with a value different from 1.2.3.4”. As an IP datagram contains
both a source and a destination address, the expression will evaluate to true
whenever at least one of the two addresses differs from 1.2.3.4.

If you want to filter out all packets containing IP datagrams to or from IP
address 1.2.3.4, then the correct filter is `!(ip.addr == 1.2.3.4)` as it reads
“show me all the packets for which it is not true that a field named ip.addr
exists with a value of 1.2.3.4”, or in other words, “filter out all packets
for which there are no occurrences of a field named ip.addr with the value
1.2.3.4”.

[[ChWorkFilterAddExpressionSection]]


=== The “Filter Expression” dialog box

When you are accustomed to Wireshark’s filtering system and know what labels you
wish to use in your filters it can be very quick to simply type a filter string.
However if you are new to Wireshark or are working with a slightly unfamiliar
protocol it can be very confusing to try to figure out what to type. The
“Filter Expression” dialog box helps with this.

[TIP]
====
The “Filter Expression” dialog box is an excellent way to learn how to write
Wireshark display filter strings.
====


[[ChWorkFilterAddExpression1]]

.The “Filter Expression” dialog box
image::wsug_graphics/ws-filter-add-expression.png[{screenshot-attrs}]

When you first bring up the Filter Expression dialog box you are shown a tree
of field names, organized by protocol, and a box for selecting a relation.

_Field Name_::
Select a protocol field from the protocol field tree. Every protocol with
filterable fields is listed at the top level. (You can search for a particular
protocol entry by entering the first few letters of the protocol name). By
expanding a protocol name you can get a list of the field names available for
filtering for that protocol.

_Relation_::
Select a relation from the list of available relation. The _is present_ is a
unary relation which is true if the selected field is present in a packet. All
other listed relations are binary relations which require additional data (e.g.
a _Value_ to match) to complete.

When you select a field from the field name list and select a binary relation
(such as the equality relation ==) you will be given the opportunity to enter a
value, and possibly some range information.

_Value_::
You may enter an appropriate value in the _Value_ text box. The _Value_ will
also indicate the type of value for the _field name_ you have selected (like
character string).

_Predefined values_::
Some of the protocol fields have predefined values available, much like enum’s
in C. If the selected protocol field has such values defined, you can choose one
of them here.

_Range_::
A range of integers or a group of ranges, such as `1-12` or `39-42,98-2000`.

_OK_::
When you have built a satisfactory expression click btn:[OK] and a filter string
will be built for you.

_Cancel_::
You can leave the “Add Expression...” dialog box without any effect by
clicking the btn:[Cancel] button.

[[ChWorkDefineFilterSection]]

=== Defining and saving filters

You can define filters with Wireshark and give them labels for later use. This
can save time in remembering and retyping some of the more complex filters you
use.

To define a new filter or edit an existing one, select menu:Capture[Capture
Filters...] or menu:Analyze[Display Filters...]. Wireshark will then pop up the
Filters dialog as shown in
<<FiltersDialog>>.

The mechanisms for defining and saving capture filters and display filters are
almost identical. Both will be described here but the differences between these two
will be marked as such.

[WARNING]
====
You must use btn:[Save] to save your filters permanently. btn:[OK] or
btn:[Apply] will not save the filters and they will be lost when you close
Wireshark.
====

[[FiltersDialog]]

.The “Capture Filters” and “Display Filters” dialog boxes
image::wsug_graphics/ws-filters.png[{screenshot-attrs}]

_New_::
This button adds a new filter to the list of filters. The currently entered
values from Filter name and Filter string will be used. If any of these fields
are empty, it will be set to “new”.


_Delete_::
This button deletes the selected filter. It will be greyed out, if no filter is
selected.


_Filter_::
You can select a filter from this list (which will fill in the filter name and
filter string in the fields down at the bottom of the dialog box).


_Filter name:_::
You can change the name of the currently selected filter here.
+
The filter name will only be used in this dialog to identify the filter for your
convenience, it will not be used elsewhere. You can add multiple filters with
the same name, but this is not very useful.

_Filter string:_::
You can change the filter string of the currently selected filter here. Display
Filter only: the string will be syntax checked while you are typing.

_Add Expression..._::
Display Filter only: This button brings up the Add Expression dialog box which
assists in building filter strings. You can find more information about the Add
Expression dialog in <<ChWorkFilterAddExpressionSection>>

_OK_::
Display Filter only: This button applies the selected filter to the current
display and closes the dialog.

_Apply_::
Display Filter only: This button applies the selected filter to the current
display, and keeps the dialog open.

_Save_::
Save the current settings in this dialog. The file location and format is
explained in <<AppFiles>>.

_Close_::
Close this dialog. This will discard unsaved settings.

[[ChWorkDefineFilterMacrosSection]]

=== Defining and saving filter macros

You can define filter macros with Wireshark and give them labels for later use.
This can save time in remembering and retyping some of the more complex filters
you use.

// XXX - add an explanation of this.

[[ChWorkFindPacketSection]]

=== Finding packets

You can easily find packets once you have captured some packets or have read in
a previously saved capture file. Simply select the _Find Packet..._ menu item
from the _Edit_ menu. Wireshark will pop up the dialog box shown in
<<ChWorkFindPacketDialog>>.

==== The “Find Packet” dialog box

[[ChWorkFindPacketDialog]]

.The “Find Packet” dialog box
image::wsug_graphics/ws-find-packet.png[{screenshot-attrs}]

You might first select the kind of thing to search for:

* _Display filter_
+
Simply enter a display filter string into the  _Filter:_ field, select a direction, and click on OK.
+
For example, to find the three way handshake for a connection from  host 192.168.0.1, use the following filter string:
----
ip.src==192.168.0.1 and tcp.flags.syn==1
----
For more details on display filters, see <<ChWorkDisplayFilterSection>>

* _Hex Value_
+
Search for a specific byte sequence in the packet data.
+
For example, use “00:00” to find the next packet including two  null bytes in the packet data.

* _String_
+
Find a string in the packet data, with various options.
+
The value to be found will be syntax checked while you type it in. If the syntax
check of your value succeeds, the background of the entry field will turn green,
if it fails, it will turn red.

You can choose the search direction:

* _Up_
+
Search upwards in the packet list (decreasing packet numbers).

* _Down_
+
Search downwards in the packet list (increasing packet numbers).

==== The “Find Next” command

“Find Next” will continue searching with the same options used in the last
“Find Packet”.

==== The “Find Previous” command

“Find Previous” will do the same thing as “Find Next”, but in the reverse
direction.

[[ChWorkGoToPacketSection]]

=== Go to a specific packet

You can easily jump to specific packets with one of the menu items in the  Go menu.

==== The “Go Back” command

Go back in the packet history, works much like the page history in current  web browsers.

==== The “Go Forward” command

Go forward in the packet history, works much like the page history in  current web browsers.

==== The “Go to Packet” dialog box

[[ChWorkGoToPacketDialog]]

.The “Go To Packet” dialog box
image::wsug_graphics/ws-goto-packet.png[{screenshot-attrs}]

This dialog box will let you enter a packet number. When you press btn:[OK],
Wireshark will jump to that packet.

==== The “Go to Corresponding Packet” command

If a protocol field is selected which points to another packet in the capture
file, this command will jump to that packet.

As these protocol fields now work like links (just as in your Web browser), it’s
easier to simply double-click on the field to jump to the corresponding field.

==== The “Go to First Packet” command

This command will simply jump to the first packet displayed.

==== The “Go to Last Packet” command

This command will simply jump to the last packet displayed.

[[ChWorkMarkPacketSection]]

=== Marking packets

You can mark packets in the “Packet List” pane. A marked packet will be shown
with black background, regardless of the coloring rules set. Marking a packet
can be useful to find it later while analyzing in a large capture file.

The packet marks are not stored in the capture file or anywhere else. All
packet marks will be lost when you close the capture file.

You can use packet marking to control the output of packets when saving,
exporting, or printing. To do so, an option in the packet range is available,
see <<ChIOPacketRangeSection>>.

There are three functions to manipulate the marked state of a packet:

* _Mark packet (toggle)_ toggles the marked state  of a single packet.

* _Mark all displayed packets_ set the mark state of all  displayed packets.

* _Unmark all packets_ reset the mark state of all  packets.

These mark functions are available from the “Edit” menu, and the “Mark packet
(toggle)” function is also available from the pop-up menu of the “Packet
List” pane.

[[ChWorkIgnorePacketSection]]

=== Ignoring packets

You can ignore packets in the “Packet List” pane. Wireshark will then pretend
that this packets does not exist in the capture file. An ignored packet will be
shown with white background and gray foreground, regardless of the coloring
rules set.

The packet ignored marks are not stored in the capture file or anywhere else.
All “packet ignored” marks will be lost when you close the capture file.

There are three functions to manipulate the ignored state of a packet:

* _Ignore packet (toggle)_ toggles the ignored state  of a single packet.

* _Ignore all displayed packets_ set the ignored state of all  displayed packets.

* _Un-Ignore all packets_ reset the ignored state of all  packets.

These ignore functions are available from the “Edit” menu, and the “Ignore
packet (toggle)” function is also available from the pop-up menu of the
“Packet List” pane.

[[ChWorkTimeFormatsSection]]

=== Time display formats and time  references

While packets are captured, each packet is timestamped. These timestamps will be
saved to the capture file, so they will be available for later analysis.

A detailed description of timestamps, timezones and alike can be found at:
<<ChAdvTimestamps>>.

The timestamp presentation format and the precision in the packet list can be
chosen using the View menu, see <<ChUseWiresharkViewMenu>>.

The available presentation formats are:

* _Date and Time of Day: 1970-01-01 01:02:03.123456_ The absolute date and time
  of the day when the packet was captured.

* _Time of Day: 01:02:03.123456_ The absolute time of the day when the packet
  was captured.

* _Seconds Since Beginning of Capture: 123.123456_ The time relative to the
  start of the capture file or the first “Time Reference” before this packet
  (see <<ChWorkTimeReferencePacketSection>>).

* _Seconds Since Previous Captured Packet: 1.123456_ The time relative to the
  previous captured packet.

* _Seconds Since Previous Displayed Packet: 1.123456_ The time relative to the
  previous displayed packet.

* _Seconds Since Epoch (1970-01-01): 1234567890.123456_ The time relative to
  epoch (midnight UTC of January 1, 1970).

The available precisions (aka. the number of displayed decimal places) are:

* _Automatic_ The timestamp precision of the loaded capture file format will be
  used (the default).

* _Seconds, Deciseconds, Centiseconds, Milliseconds, Microseconds or
  Nanoseconds_ The timestamp precision will be forced to the given setting. If
  the actually available precision is smaller, zeros will be appended. If the
  precision is larger, the remaining decimal places will be cut off.

Precision example: If you have a timestamp and it’s displayed using, “Seconds
Since Previous Packet” the value might be 1.123456. This will be displayed
using the “Automatic” setting for libpcap files (which is microseconds). If
you use Seconds it would show simply 1 and if you use Nanoseconds it shows
1.123456000.

[[ChWorkTimeReferencePacketSection]]

==== Packet time referencing

The user can set time references to packets. A time reference is the starting
point for all subsequent packet time calculations. It will be useful, if you
want to see the time values relative to a special packet, e.g. the start of a
new request. It’s possible to set multiple time references in the capture file.

The time references will not be saved permanently and will be lost when you
close the capture file.

Time referencing will only be useful if the time display format is set to
“Seconds Since Beginning of Capture”. If one of the other time display formats
are used, time referencing will have no effect (and will make no sense either).

To work with time references, choose one of the menu:Time Reference[] items in
the menu:[Edit] menu or from the pop-up menu of the “Packet List” pane. See
<<ChUseEditMenuSection>>.

* _Set Time Reference (toggle)_ Toggles the time reference state of the
  currently selected packet to on or off.

* _Find Next_ Find the next time referenced packet in the “Packet List” pane.

* _Find Previous_ Find the previous time referenced packet in the “Packet
  List” pane.

[[ChWorkTimeReference]]

.Wireshark showing a time referenced packet
image::wsug_graphics/ws-time-reference.png[{screenshot-attrs}]

A time referenced packet will be marked with the string $$*REF*$$ in the Time
column (see packet number 10). All subsequent packets will show the time since
the last time reference.

// End of WSUG Chapter Work