0% found this document useful (0 votes)
56 views2 pages

Checksum v3

The document explains how the UDP checksum is calculated correctly. It involves: 1. Dividing the segment into 16-bit words and summing them using 1's complement addition. 2. The final sum is complemented to produce the 16-bit checksum. 1's complement addition involves normally summing the numbers, adding back any carry, and taking the complement to handle overflow. This is demonstrated through examples calculating checksums of sample data words.

Uploaded by

Welvin Asid
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views2 pages

Checksum v3

The document explains how the UDP checksum is calculated correctly. It involves: 1. Dividing the segment into 16-bit words and summing them using 1's complement addition. 2. The final sum is complemented to produce the 16-bit checksum. 1's complement addition involves normally summing the numbers, adding back any carry, and taking the complement to handle overflow. This is demonstrated through examples calculating checksums of sample data words.

Uploaded by

Welvin Asid
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Further Correction of error on UDP Checksum: updated 13/10/03

My previous explanation of how the UDP checksum worked was incorrect. Here is the correct version.
1.
2.
3.

Segment is divided into consecutive 16 bit words


The words are summed up using 1s complement addition
The final sum from step 2 is then complemented. The resulting 16 bit word is the Checksum.

What is 1s complement addition?


1.
2.
3.
4.
5.

Sum the numbers normally


The carry of the sum is whatever bits are to the left of the rightmost 16 bits.
If carry=0 then the normal sum is the 1s complement sum.
If carry!=0 then add the carry back into normal sum to get 1s complement sum.
Examples below use 8 bits
1s complement is actually a way of adding signed numbers (but we will not discuss this)

1 0 0 0 1 0 0 1 Word 1
1 0 1 1 1 0 0 0 Word 2
------------------------------------1 0 1 0 0 0 0 0 1 Normal Sum (note carry to remove)
1 Remove carry and add it back
------------------------------------0 1 0 0 0 0 1 0 1s complement sum

0 0 1 0 1 0 0 1 Word 1
1 0 1 1 1 0 0 0 Word 2
--------------------------------1 1 1 0 0 0 0 1 1s complement sum

Checksum example
10001001
11110000
00111100
10100001

Input Word 1
Input Word 2
Input Word 3
Input Word 4

1 0 0 0 1 0 0 1 W1
1 1 1 1 0 0 0 0 W2
--------------------------------------------------------------------1 0 1 1 1 1 0 0 1 Normal sum
1 Carry
--------------------------------------------------------------------0 1 1 1 1 0 1 0 1s Comp sum W1, W2
0 0 1 1 1 1 0 0 W3
--------------------------------------------------------------------1 0 1 1 0 1 1 0 1s Comp sum W1, W2, W3
1 0 1 0 0 0 0 1 W4
--------------------------------------------------------------------1 0 1 0 1 1 0 0 1 Normal sum
1 Carry
--------------------------------------------------------------------0 1 0 1 1 0 1 0 1s Comp sum W1, W2, W3, W4
1 0 1 0 0 1 0 1 complement
= checksum of W1-W4

You might also like