Search code examples
cwiresharklibpcappacket-capturewifi

How does wireshark interpret the order of bytes?


I'm working with the 802.11 radiotap header making my own parser and it states the packet format is this where the length is 2 bytes long:

enter image description here

In wireshark the hex of the header is this where the 2 bytes 19 00 are the length field, but wireshark ignores the trailing 00 and interprets it as legnth 25 (decimal) instead of length 6400 (decimal):

enter image description here

How does wireshark (correctly) know to interpret the number correctly?

The link above says the length is stored in little endian and my system is little endian so I'm not sure what's happening on that front?


Solution

  • How Wireshark interpret the endianess is up to the dissector developers to decide. They choose to either read the buffer as little endian or big endian. There are different parsing functions for each type. The endianess to use is usually found in the protocol's documentation.

    The protocol you are looking at is little endian. I'm not sure why the (original) accepted answer and the comments suggest otherwise. 19 00 is 25 in decimal, when using little endian. It might be a bit confusing, but the little end comes first. You can read about it here.