Subject: Re: A question about the IP header checksum
To: None <patrick@klos.com>
From: None <jonathan@dsg.stanford.edu>
List: tech-net
Date: 12/05/2007 16:22:02
In message <200712052052.lB5KqSd9028342@sage.klos.com>,
patrick@klos.com writes:

>Hello IP Gurus,
>
>I have a question about the IP header checksum that I'm looking for a
>definitive answer for.  I'm pretty sure I have the answer, but if anyone 
>can help me substantiate my answer, it would really help.
>
>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?
>

Long verbose answer:

It's not *im*proper to do that, since 1's complement arithmetic, zero
is a signed value. There are two zero values. 0xFFFF is -0, and 0x0000
is +0.  But I don't see any good or compelling reason to do so.
The, er, "very controversial" [rfc-1122, sec 4.1.3.4] mechanism
whereby a UDP sender indicates "sender did not compute a UDP checksum"
are applicable only to UDP.

Indeed, rfc-1122 notes that UDP receiver who has received a UDP packet
with a nonzero UDP checksum doesn't need to take any special action
(with regard to verifying the received checksum) with regard to -0 and
+0; they are equivalent.


May I ask: why would you want to make this 0x0000 -> 0xffff
substituion for an IP header checksum?