Quicklinks: rawshark: Rawshark: manpage | Wireshark Docs | code
This article exists ONLY to document it as a command-line component of Wireshark.
rawshark is custom-built for a 3rd-party and better tools exist to extract information from captures.
rawshark is a utility that takes an input stream and parses it. It is low-level and provides options you would expect to see if you were working with the source code. I asked the maintainers what its purpose was and one responded
Probably only @gerald-combs could say for sure what the original use case was though.
But the reason you should avoid using it because tshark can do everything it can
do, and better. To transition, rawshark’s options -nNrR
are the same as
tshark’s, and all of the others can be discarded.
This example goes over how to display UDP ports from this dhcp.pcap using rawshark. Included is the magical journey in getting there.
So rawshark will not take tshark raw output…
$ tshark -r dhcp.pcap -w - | rawshark -s -r - -d proto:udp -F udp.port
0 FT_UINT16 BASE_PT_UDP -
rawshark: The standard input appears to be damaged or corrupt.
(Bad packet length: 673213298
)
``
You would think that specifying proto
of udp for DHCP would work, but it
shows incorrect output. DHCP uses UDP ports 67 and 68:
$ cat dhcp.pcap | rawshark -s -r - -d proto:udp -F udp.port
0 FT_UINT16 BASE_PT_UDP - 1 FT_UINT16 BASE_PT_UDP -
1 1="65535" 0="65535" -
2 1="11" 0="33281" -
3 1="65535" 0="65535" -
4 1="11" 0="33281" -
``
Finally, by specifying encap type instead of proto, we get useful output.
$ cat dhcp.pcap | rawshark -s -r - -d encap:1 -F udp.port
FT_UINT16 BASE_PT_UDP - 1 FT_UINT16 BASE_PT_UDP -
1 1="68" 0="67" -
2 1="67" 0="68" -
3 1="68" 0="67" -
4 1="67" 0="68" -
``
tshark
is more useful with less work though, even if we pass in as a stream
(the supposed purpose of rawshark
):
$ cat dhcp.pcap | tshark -r -
1 0.000000 0.0.0.0 → 255.255.255.255 DHCP 314 DHCP Discover - Transaction ID 0x3d1d
2 0.000295 192.168.0.1 → 192.168.0.10 DHCP 342 DHCP Offer - Transaction ID 0x3d1d
3 0.070031 0.0.0.0 → 255.255.255.255 DHCP 314 DHCP Request - Transaction ID 0x3d1e
4 0.070345 192.168.0.1 → 192.168.0.10 DHCP 342 DHCP ACK - Transaction ID 0x3d1e
``
tshark has the advantage of being able to read files too: tshark -r dhcp.pcap
.