[ih] UDP Length Field?

Joseph Touch touch at strayalpha.com
Sun Nov 29 11:36:01 PST 2020


Hi, Noel (et al.),

> On Nov 29, 2020, at 4:46 AM, Noel Chiappa via Internet-history <internet-history at elists.isoc.org> wrote:
> 
> (Oh, if you reach out to him, you could also ask why the 'no checksum' value
> is '0', and not '-1'

-1 is a valid number in one’s complement (1111 1111 1111 1110)

-1 in 2’s complement is 1111 1111 1111 1111 and is -0 in 1’s complement notation

> - remember that if present, the checksum field contains
> the complement of the sum, and since 0 is an 'impossible' value for the sum,

Either 0 or -0 could come up as a valid 1’s complement sum over the words; the Internet checksum is simply defined as “if either 0 or -0 comes up, use -0 as the inserted checksum”, i.e., it uses the complement of the one’s complement sum only when that sum is 0.

That’s just a choice, It could easily have been made the other way - but there is one small difference (see below).

> -1 is the _inherent_ 'impossible' checksum field value.

-1 in 1’s complement is a valid checksum; only “0” is declared “impossible” by fiat (not by a property of the number space), because it is used to indicate no-checksum.

> Using '0' for 'none'
> requires an extra step in the computation, since -1 [0 when complemented] is a
> legitimate possible sum value. At least, I think I have that correct; the
> brain is fading.)

There are the following possibilities:

(assume the packet are is block zeroed less expensively than per-word zeroing)

A. if you declare 0 as no-checksum, 
	checksummed packets it would need to correct the final sum before inserting it
	non-checksummed packets do nothing

B, if you declare -1 as no-checksum, 
	checksummed packets it would need to correct the final sum before inserting it
	non-checksummed packets need to insert -0

C. if you allow 0 and -0 as valid checksums
	all packets need to be checksummed, but no final step is needed to adjust

So if you want to reduce work for the non-checksummed packets, “B” is the choice.

Joe


More information about the Internet-history mailing list