Protocols
Saved & recent

Network byte order

Also called: big-endian, endianness, byte order

Network byte order commonly means representing a multi-byte integer with its most significant byte first, also called big-endian order. Agreeing on byte order lets machines with different internal representations interpret the same wire value. A protocol’s specification still decides its encoding; not every binary protocol uses this convention.

For example, the 32-bit hexadecimal value 0x01020304 is transmitted as the byte sequence 01 02 03 04 in big-endian order. Reading those bytes as little-endian would produce a different value. Byte order describes the arrangement of whole bytes, not the electrical order of bits on a cable. Libraries commonly provide conversion or packing operations for this boundary.

Read first
Serialization
Related
Protocol Buffers, Encapsulation
Further reading
IETF RFC 4506 — XDR: External Data Representation Standard
0x01020304 01 02 03 04 byte order on the wire most significant byte 01 02 03 04 01 02 03 04 big-endian interpretation little-endian interpretation 0x01020304 0x04030201
Illustrative 32-bit value: big-endian encoding sends the most significant byte first; reversing the interpretation changes the value.

View in the full Protocols collection