Question
Jan Villaroel
Topic: Computer Science Posted 1 year ago
UDP and TCP use 1s complement for their checksums. Suppose you have the following three 8-bit bytes: 01011111, 01110000, 11001001. What is the 1s complement of the sum of these 8-bit bytes?

UDP and TCP use 1s complement for their checksums. Suppose you have the following three 8-bit bytes: 01011111, 01110000, 11001001.

What is the 1s complement of the sum of these 8-bit bytes? (Note that although UDP and TCP use 16bit words in computing the checksum, for this problem you are being asked to consider 8bit 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 schema, how does the receiver detect errors?
Is it possible that a 1-bit error will go undetected? How about 2-bit error?


Answers
What are best answers and total votes?
No Votes
Vote
SignIn to Vote
Koala Tutor
Sep 21, 2023
Koala Ai Support

To find the 1s complement of the sum of the three 8-bit bytes, we add them together:
01011111 + 01110000 + 11001001 = 100010110

The sum is 9 bits long, so we take the 1s complement by inverting all the bits:
011101001

The reason UDP (and TCP) takes the 1s complement of the sum is for error detection. By taking the 1s complement, any errors in the data can be detected when the receiver computes the checksum.

With the 1s complement, the receiver can detect errors by adding up all the 8-bit bytes (including the checksum) and checking if the sum is all 1s. If the sum is all 1s, it means no errors were detected. If any bit is different from 1, it means an error was detected.

It is possible that a 1-bit error can go undetected. For example, if a single bit is flipped in the data and another bit is flipped in the checksum, the errors can cancel each other out and the sum will still be all 1s.

It is also possible that a 2-bit error can go undetected. If there are two flipped bits in the data and the same two bits are flipped in the checksum, the errors can cancel each other out and the sum will still be all 1s.

Koala Tutor Got a question with my answer?
Message Me