IP Checksum

IP Checksum is the 16-bit 1's complement of 1's complement sum of all 16-bit words in IP header.

Example:
Suppose the IP header has the following bytes where last two bytes (0's) are checksum bytes.
01 00 F2 03 F4 F5 F6 F7 00 00

16-bit words:
0100
F203
F4F5
F6F7
0000

Find 2's complement sum:
0100
F203
F4F5
F6F7
0000
-------
2DEEF

Add carry (2) to get 1's complement sum:
DEEF
0002
-------
DEF1

Find 1's complement of DEF1.
1's complement of DEF1(1101 1110 1111 0001) = (0010 0001 0000 1110) 210E

Checksum is 210E.

How to verify checksum?
Add checksum to IP header 16-bit words. Sum should be FFFF.
0100
F203
F4F5
F6F7
210E
-------
2FFFD

FFFD + 2 = FFFF


Source: http://www.netfor2.com/checksum.html

Stumble
Delicious
Technorati
Twitter
Facebook

Bookmark and Share
Your Ad Here

0 comments

Post a Comment