In my last post we were looking at some packet decodes. One of the biggest pains in working with decodes is following a specific field over multiple packets. Some fields are not too bad as they tend to get printed by default. Good examples are port numbers and TCP flag settings. But in the last post we were working with the IP ID. That usually only gets printed if you view verbose information, so now you end up with a lot of data on the screen that you do not care about.
Luckily, the new version of tshark fixes this problem. Let’s work with some example so you can see what I mean.
What is tshark?
Tshark is the command line packet utility that is included with Wireshark. If you are not familiar with Wireshark, it is arguably one of the best graphical packet decoding tools available today, and it is free for use. There are versions that run on Linux, BSD and Windows (YES! Even Windows!).
So why work at the command line if there is a GUI version? In the case of tshark, it is because you can get a better presentation layout of the data you actually want to see.
The problem
So let’s say we want to monitor the IP ID increment for multiple packets leaving a system. We may try a command similar to the following:
C:\>tshark -n -i 3 src host 192.168.100.5
Capturing on Intel(R) PRO/100 VE Network Connection (Microsoft’s Packet Scheduler)
0.000000 192.168.100.5 -> 192.168.100.3 TCP 0 > 1832 [RST, ACK] Seq=1 Ack=1 Win=0 Len=0
1.003331 192.168.100.5 -> 192.168.100.3 TCP 0 > 1833 [RST, ACK] Seq=1 Ack=1 Win=0 Len=0
2.007332 192.168.100.5 -> 192.168.100.3 TCP 0 > 1834 [RST, ACK] Seq=1 Ack=1 Win=0 Len=0
3.011347 192.168.100.5 -> 192.168.100.3 TCP 0 > 1835 [RST, ACK] Seq=1 Ack=1 Win=0 Len=0
4.015336 192.168.100.5 -> 192.168.100.3 TCP 0 > 1836 [RST, ACK] Seq=1 Ack=1 Win=0 Len=0
The above command tells tshark not to perform name resolution, listen on the system’s third interface, and only capture packets originating from the system at 192.168.100.5. There is a problem however, where’s the IP ID? Unfortunately, tshark, like tcpdump and windump, does not print the IP ID value by default. Even Wireshark buries it in the middle pane so it can be difficult to spot and follow over multiple packets.
So what to do? Normally we would simply add in the “verbose” switch. This is what I used in the last post to print the IP ID with tcpdump. With tcpdump and windump you use the switch “-v”, but with tshark the switch is capitalized “-V”. Here’s an example:
C:\>tshark -n -i 3 -V src host 192.168.100.5
Capturing on Intel(R) PRO/100 VE Network Connection (Microsoft’s Packet Scheduler)
Frame 1 (54 bytes on wire, 54 bytes captured)
Arrival Time: Aug 31, 2009 13:18:42.532218000
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 54 bytes
Capture Length: 54 bytes
[Frame is marked: False]
[Protocols in frame: eth:ip:tcp]
Ethernet II, Src: 00:07:e9:46:2d:55 (00:07:e9:46:2d:55), Dst: 00:17:08:54:9a:00 (00:17:08:54:9a:00)
Destination: 00:17:08:54:9a:00 (00:17:08:54:9a:00)
Address: 00:17:08:54:9a:00 (00:17:08:54:9a:00)
…. …0 …. …. …. …. = IG bit: Individual address (unicast)
…. ..0. …. …. …. …. = LG bit: Globally unique address (factory default)
Source: 00:07:e9:46:2d:55 (00:07:e9:46:2d:55)
Address: 00:07:e9:46:2d:55 (00:07:e9:46:2d:55)
…. …0 …. …. …. …. = IG bit: Individual address (unicast)
…. ..0. …. …. …. …. = LG bit: Globally unique address (factory default)
Type: IP (0×0800)
Internet Protocol, Src: 192.168.100.5 (192.168.100.5), Dst: 192.168.100.3 (192.168.100.3)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0×00 (DSCP 0×00: Default; ECN: 0×00)
0000 00.. = Differentiated Services Codepoint: Default (0×00)
…. ..0. = ECN-Capable Transport (ECT): 0
…. …0 = ECN-CE: 0
Total Length: 40
Identification: 0×0461 (1121)
Flags: 0×00
0… = Reserved bit: Not set
.0.. = Don’t fragment: Not set
..0. = More fragments: Not set
Fragment offset: 0
Time to live: 128
Protocol: TCP (0×06)
Header checksum: 0xed15 [correct]
[Good: True]
[Bad : False]
Source: 192.168.100.5 (192.168.100.5)
Destination: 192.168.100.3 (192.168.100.3)
Transmission Control Protocol, Src Port: 0 (0), Dst Port: 2535 (2535), Seq: 1, Ack: 1, Len: 0
Source port: 0 (0)
Destination port: 2535 (2535)
[Stream index: 0]
Sequence number: 1 (relative sequence number)
Acknowledgement number: 1 (relative ack number)
Header length: 20 bytes
Flags: 0×14 (RST, ACK)
0… …. = Congestion Window Reduced (CWR): Not set
.0.. …. = ECN-Echo: Not set
..0. …. = Urgent: Not set
…1 …. = Acknowledgement: Set
…. 0… = Push: Not set
…. .1.. = Reset: Set
[Expert Info (Chat/Sequence): Connection reset (RST)]
[Message: Connection reset (RST)]
[Severity level: Chat]
[Group: Sequence]
…. ..0. = Syn: Not set
…. …0 = Fin: Not set
Window size: 0
Checksum: 0×9078 [validation disabled]
[Good Checksum: False]
[Bad Checksum: False]
OK, if we sift through the output we can find the IP ID information. If we want to check the value over multiple packets however, its going to be time consuming.
Printing only specific fields
One of the features in the latest version of tshark is the ability to print only specific packet fields. This is performed using the “-T fields” switch. You then use the “-e” switch to specific the fields you wish to see, in the specific order you want them to be printed. Here’s an example:
C:\>tshark -n -i 3 -T fields -e ip.src -e ip.dst -e ip.proto -e ip.id src host 192.168.100.5
Capturing on Intel(R) PRO/100 VE Network Connection (Microsoft’s Packet Scheduler)
192.168.100.5 192.168.100.3 0×06 0×0491
192.168.100.5 192.168.100.3 0×06 0×0492
192.168.100.5 192.168.100.3 0×06 0×0495
192.168.100.5 192.168.100.3 0×06 0×0496
192.168.100.5 192.168.100.3 0×06 0×0497
The “-e” switch uses the same pcap syntax used by Wireshark for display filters. Packetlife has an excellent cheat sheet showing commonly used values. From left to right, I specified Source IP, Destination IP, transport, followed by the IP ID value. Note that with this format, it is now trivial to follow the IP ID increment in the packet stream.
Exec Summary
When performing packet decodes, it is not uncommon to end up with far more information on the screen than you actually need. In fact this can make it difficult to find the values you are trying to focus in on. The addition of tshark’s new display options can make following information over multiple packets far easier than it is with similar tools.

