Newsgroups: comp.protocols.tcp-ip
Path: utzoo!utgpu!watserv1!sunee!erick
From: erick@sunee.waterloo.edu (Erick Engelke)
Subject: Re: Byte and bit order within packet headers
Message-ID: <1991Apr26.051536.10284@sunee.waterloo.edu>
Organization: University of Waterloo
References: <9104241753.AA21589@dino.alias.com>
Date: Fri, 26 Apr 1991 05:15:36 GMT
Lines: 38

In article <9104241753.AA21589@dino.alias.com> mandrews@alias.com (Mark Andrews) writes:
>
>I have a question concerning concering the byte and bit order of fields
>within packet headers. Many of the RFCS (including RFC1060) state rules
>about the byte (octet) order:
>

Much confusion stems from the fact that Intel processors store 
bits in the following order

  +--+--+--+--+--+--+--+---+---+--+--+--+--+--+--+---+
  |07 06 05 04 03 02 01 00 | 15 14 13 12 11 10 09 08 |
  +--+--+--+--+--+--+--+---+---+--+--+--+--+--+--+---+
  |  first stored byte     |  second stored byte     |  etc.

whereas network order is

  +--+--+--+--+--+--+--+---+---+--+--+--+--+--+--+---+
  |15 14 13 12 11 10 09 08 | 07 06 05 04 03 02 01 00 |
  +--+--+--+--+--+--+--+---+---+--+--+--+--+--+--+---+

so the bits and nybbles are already in network order, you simply need to
organize quantities larger than a byte, namely 16 and 32 bit values.

The intel code should have
    unsigned  ip_h : 4;
    unsigned  ip_v : 4;

I hope this clears it up a bit.

Erick


-- 
----------------------------------------------------------------------------
Erick Engelke                                       Watstar Computer Network
Watstar Network Guy                                   University of Waterloo
Erick@Development.Watstar.UWaterloo.ca              (519) 885-1211 Ext. 2965
