Subject: Re: A question about the IP header checksum
To: None <tech-net@NetBSD.org>
From: John Nemeth <jnemeth@victoria.tc.ca>
List: tech-net
Date: 12/05/2007 14:26:05
On Apr 27,  6:36pm, Alan Barrett wrote:
} On Wed, 05 Dec 2007, patrick@klos.com wrote:
} > The IP header checksum is pretty straightforward: add up all the (2 byte)
} > words in the IP header using one's complement addition, then take the one's
} > complement of the sum and insert that as the checksum.  Here's the question:
} > 
} >     Is it proper to substitute a resulting value of 0x0000 with 0xffff as 
} >     is done in UDP?
} 
} Yes, 0x0000 and 0xffff are interchangeable in IP and TCP checksums,
} though 0x0000 is special in UDP checksums.

     Umm, RFC 791 says this:

-----

  Header Checksum:  16 bits

    A checksum on the header only.  Since some header fields change
    (e.g., time to live), this is recomputed and verified at each point
    that the internet header is processed.

    The checksum algorithm is:

      The checksum field is the 16 bit one's complement of the one's
      complement sum of all 16 bit words in the header.  For purposes of
      computing the checksum, the value of the checksum field is zero.

    This is a simple to compute checksum and experimental evidence
    indicates it is adequate, but it is provisional and may be replaced
    by a CRC procedure, depending on further experience.

-----

>From that, how do you get that 0x0000 and 0xffff are equivalent?

}-- End of excerpt from Alan Barrett