Byte order and packet formats
Endianness
There are two ways how computer represent a multibyte value. How you layout a multibyte value in memory is called endianness.
- Little endian: least significant byte is at lowest address.
- Big endian: most significant byte is at lowest address. This is human readable.
Network Byte Order
- Different processor have different endianness
- To interoperate, they need to agree how to represent multi-byte fields.
- We don't want two computers to care or know whether the other side is big endian or little endian.
- So all protocols that are internet specifications use a big endian format.
Portable Code
- You have to convert network byte order values to your host order
- There are some C networking libraries provide utility functions that convert between host order and netowrk order.