[ih] UDP checksums (Was: UDP Length Field?)

Noel Chiappa jnc at mercury.lcs.mit.edu
Sun Nov 29 13:15:26 PST 2020


    > From: Joseph Touch

    > Either 0 or -0 could come up as a valid 1's complement sum over the
    > words

Perhaps I'm confused, but I don't see how you could get 0 (i.e. all 0 bits) as
a 1's complement sum from anything except a 'packet' containing nothing but
0's, i.e. no valid packet (and from that observation, _if correct_, the rest
of my prior comment flows). Here's my thinking about 'no 0 sum'; if I've
somehow blown it, I would appreciate having my error pointed out! (Truly! :-)

Consider the computation of the partial 1's complement S, Sn, for words
0-n. It's Sn-1+ Wn (word n) = PSn (partial sum) + Cn (carry). Cn is then added
to PSn to produce Sn.

The only way for Sn to be 0 is either a) for PSn to be -1, and Cn to be 1; or
b) for PSn to be 0, and Cn to be 0. The latter I think can only happen in the
degenerate case I mentioned to start with: numbers Sn-1 and Wn can only
produce a PSn of 0 either if i) both are 0 (the degenerate case), or ii) they
are two numbers that sum to 0 - but that will produce a carry, so Cn will be 1
- so there is no ii).

As to the first possibility (PSn to be -1, and Cn to be 1), there's no way to
get that, I think: e.g. if Sn-1 is -1, and Wn is -1, then Cn will be 1, but
PSn will be -2. Any other values for Sn-1 and Wn will also produce values for
PSn and Cn which are not -1 and 1. I think?

    Noel



More information about the Internet-history mailing list