This is Interesting: Free IT Magazines  
Home > Archive > Miscellaneous Internet Protocols > May 2004 > Please explain Network Byte Order





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Please explain Network Byte Order
Steve Jones

2004-05-20, 6:04 pm

Suppose I have an IP address,

123.45.160.13

So, in Hex (correct me if I'm wrong), that's

7B.2D.A0.0D

Now, can someone please explain

1. The algorithm to turn that into Network Byte Order
2. Show me exactly what it looks like in Network Byte Order
3. Tell me what Network Byte Order is the opposite of (Standard Byte
Order?! Non-Network Byte Order!?)

Thanks in advance for all replies.

Steve
Arkady Frenkel

2004-05-20, 6:04 pm

Simply reverse bytes for network order : 0D.A0.2D. 7B
usually inet_addr() do it for you
Arkady
"Steve Jones" <steveqdr@yahoo.com> wrote in message
news:bbeea79f.0307090744.11138cf@posting.google.com...
> Suppose I have an IP address,
>
> 123.45.160.13
>
> So, in Hex (correct me if I'm wrong), that's
>
> 7B.2D.A0.0D
>
> Now, can someone please explain
>
> 1. The algorithm to turn that into Network Byte Order
> 2. Show me exactly what it looks like in Network Byte Order
> 3. Tell me what Network Byte Order is the opposite of (Standard Byte
> Order?! Non-Network Byte Order!?)
>
> Thanks in advance for all replies.
>
> Steve



Robert Wessel

2004-05-20, 6:04 pm

steveqdr@yahoo.com (Steve Jones) wrote in message news:<bbeea79f.0307090744.11138cf@posting.google.com>...
> Suppose I have an IP address,
>
> 123.45.160.13
>
> So, in Hex (correct me if I'm wrong), that's
>
> 7B.2D.A0.0D
>
> Now, can someone please explain
>
> 1. The algorithm to turn that into Network Byte Order
> 2. Show me exactly what it looks like in Network Byte Order
> 3. Tell me what Network Byte Order is the opposite of (Standard Byte
> Order?! Non-Network Byte Order!?)
>


In network byte order, the four bytes of the IP address would be sent
7b, 2d, a0, 0d, just as you've listed above.

"Network byte order" is the same as "big endian" byte order. Network
byte order is distinct from the native byte order of a given machine.
On machines that are classically big endian (68K, S/370), network byte
order is identical to the native, internal formats. On machines which
are little endian (eg. x86), the order of the bytes would be reversed
(eg. the above IP address would be stored as 0d.a0.2d.7b in memory).
Other orders are possible as well (most notably the PDP-11).

So that machines can talk to each other, a fixed standard was needed,
and big endian was picked (although there's no technical reason why
another scheme couldn't have been used). As part of most TCP/IP
stacks, most machines provide a set of functions like "htons()"
("host-to-network-short"), which translate the native format to
network byte order. The do essentially nothing on a big endian
machine, but swap things around appropriately on other machines.
Fernando Gont

2004-05-20, 6:04 pm

On Wed, 9 Jul 2003 21:31:23 GMT, steve@nospam.Watt.COM (Steve Watt)
wrote:

>"Host byte order"


Actually, "network byte order" is not the opposite of "host byte
order", as they could represent *the* *same* byte order (in big-endina
systems).

"Network byte order" is big-endian.
Host byte order might be "little-endian" as well as "big-endian".

--
Fernando Gont
e-mail: fernando@ANTISPAM.gont.com.ar

[To send a personal reply, please remove the ANTISPAM tag]
Barry Margolin

2004-05-20, 6:04 pm

In article <3f144680.1248123@News.CIS.DFN.DE>,
Fernando Gont <fgont@softhome.net> wrote:
>On Wed, 9 Jul 2003 21:31:23 GMT, steve@nospam.Watt.COM (Steve Watt)
>wrote:
>
>
>Actually, "network byte order" is not the opposite of "host byte
>order", as they could represent *the* *same* byte order (in big-endina
>systems).


They are conceptual opposites, rather than physical opposites.

--
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2010 webservertalk.com