UDP and TCP use 1s complement for their checksums. Suppose you have the following three 8-bit bytes: 01010011, 01100110, 01110100. What is the 1s complement of the sum of these 8-bit bytes? (Note that although UDP and TCP use 16-bit words in computing the checksum, for this problem you are being asked to consider 8-bit sums.) Show all work. Why is it that UDP takes the 1s complement of the sum; that is, why not just use the sum? With the 1s complement scheme, how does the receiver detect errors? Is it possible that a 1-bit error will go undetected? How about a 2-bit error?
Given 8-bit bytes are as follows:
01010011
01100110
01110100
Calculate the sum of the given 3 bytes.
Add first two 8-bit bytes:
0 |
1 |
0 |
1 |
0 |
0 |
1 |
1 |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
0 |
1 |
0 |
1 |
1 |
1 |
0 |
0 |
1 |
Now add the result with the 3rd byte.
|
1 |
0 |
1 |
1 |
1 |
0 |
0 |
1 |
|
0 |
1 |
1 |
1 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
1 |
1 |
0 |
1 |
Wrap around the extra bit.
0 |
0 |
1 |
0 |
1 |
1 |
0 |
1 |
|
|
|
|
|
|
|
1 |
0 |
0 |
1 |
0 |
1 |
1 |
1 |
0 |
The sum three 8-bit bytes is 00101110. Invert all the bits to get the check sum.
Check sum is 11010001.
Now calculate the 1’s compliment of the sum. Convert all 0’s to 1’s and vice versa to find the 1’s compliment.
The 1’s compliment of (sum) 00101110 is 11010001.
It is clear that the 1’s compliment and the checksum are same.
User Datagram Protocol (UDP) uses the 1’s complement as it is same as the checksum of the sum.
The checksum is used by the receiver (host) to identify the errors in the segment.
The process of detecting errors by the receiver:
The receiver performs the following steps at the receiver end to identify the errors in the segment.
Error types that are identified using 1’s compliment method: