1

Why do internet protocols use a network byte order? Suppose that the IP address of

139.156.32.45 is stored in memory starting from address A in network byte order, how

does it appear? And how does that bit stream appear when the address is transmitted in the

network?

1 Answer 1

2

Internet protocol (IP) uses 'network byte order' (big-endian) because it was agreed that it would do so (see RFC 1700. IP 139.156.32.45 in big-endian binary is 10001011.10011100.00100000.00101101 (. added for legibility), and this is how it would be transferred over the network.

Depending on your architecture this address can be stored in a big-endian or little-endian format. If you are using X86 architecture (little endian), the bits (per byte) would be reverted, so they would end up being stored as 11010001.00111001.00000100.10110100. In a SPARC CPU, which uses big-endianness the bits would be stored like the IP protocol uses them.

2
  • 1
    If I'm not mistaken, the bits per byte remain unchanged but the order of the bytes in a word change. In little endian, the address would be 00101101.00100000.10011100.10001011 Jun 3, 2014 at 14:43
  • 1
    There's no instruction that would reveal bit order, so your statement about it being "reversed" doesn't make any sense.
    – Ruslan
    Aug 6, 2019 at 6:36

Not the answer you're looking for? Browse other questions tagged .