What is Network Byte Order?

Tim Rohaly

Network Byte Order is the Internet Protocol standard ordering of bytes for multi-byte integers. All integers sent over the network are supposed to conform to NBO, regardless of the byte ordering used internally on either end. Use of this machine-independent standard network representation ensures that different operating systems can exchange data.

The ordering of bytes in NBO is the same as big-endian. That is, the high-order byte of the integer is sent first, followed by the lower-order bytes in turn. In Java, int datatypes are 32 bits, or 4 bytes. As an example, consider the integer 305419896, which can be expressed in hex as 0x12345678, where each hexadecimal digit represents 4 bits. With NBO, the byte 0x12 is sent over the network first, followed by 0x34, etc.

All I/O in Java always uses Network Byte Order.