Search code examples
udpchecksum

What's the result on the receiver's side when calculating a UDP checksum


I'm finding mixed answers on this. Many resources say that the receiver should receive a calculation of all 1's. In the Andrew S. Tanenbaum book entitled Computer Networks, it's written that "The checksum algorithm is simply to add up all the 16-bit words in one's complement and then to take the one's complement of the sum. As a consequence, when the receiver performs the calculation on the entire segment, including the Checksum field, the result should be 0." Does the receiver also take the one's complement of the resulting sum and get 0's? Which is the correct result that denotes there was no errors detected?


Solution

  • In one's complement arithmetic, all-1 and all-0 both represent the same value, 0.

    Wikipedia