Network Byte Order

Introduction

In computing, byte order or endianness is the way simple numeral values are stored. It names in particular the storing order of integers in the main memory. The applicable storage format must be defined if the number of bits required to encode the numeral to be stored is larger than the number of bits available in the smallest addressable unit. Normally, the smallest addressable unit is one byte. If more than one byte is needed for storing, the numeral is then stored in several bytes with the memory addresses stated in immediate sequence. Whilst cross-producer standards have been established with many other types of storage organization, two variants persist for byte order.

Big Endian

In Big Endian, the byte with the most significant bits (i.e. the most significant digits) is stored first, i.e. at the lowest memory address. In general, the term means that in composite data, the most significant (highest-ranking) component is mentioned first, as in the German notation for time: hours:minutes:seconds.

Little Endian

In Little Endian, on the other hand, the byte with the least significant bits (i.e. the least significant digits) is stored at the smallest memory address, or the least significant component is mentioned first, as in the German notation for dates: day.month.year.

Converting Big Endian to Little Endian

Since it is occasionally necessary to convert the one format to the other (especially in network programming) the commonly used programming languages include special functions for that. "C" for example offers the functions "htonl ()" and "ntohl ()", Perl uses "pack" and "unpack" with the "N" parameter. The network byte order must be given in binary.