[comp.protocols.tcp-ip] TCP/IP checksum byte-swap invariance

chris@GYRE.UMD.EDU (Chris Torek) (03/29/88)

The invariance follows (I am tempted to say `is intuitively obvious',
but I suppose that would be teasing) from the fact that carries are
added back in at the low end of the sum as one goes along.  To
visualise this, imagine the bits arranged in a ring.  Note that the
ring is rotation independent---each bit depends only upon itself and
its nearest clockwise neighbour (in the figure below)---and that a byte
swap is simply an eight-bit rotation.

               1  0  15
             2         14
           3             13
          4               12
           5             11
             6         10
               7  8  9

(Apologies to those with proportionally spaced fonts.)  The only
time an orientation is imposed upon this ring is when it is placed
in a TCP or IP header, so this is the only time the machine's
byte sex must affect the calculation.

(As far as I know, I came up with this explanation myself.  It
seems obvious enough that someone else should have used it before.)

Chris