80 likes | 333 Views
Checksum Calculations. Instructor: Anirban Mahanti Office: ICT 745 Email: mahanti@cpsc.ucalgary.ca Class Location: ICT 122 Lectures: MWF 12:00 – 12:50 hours
E N D
Checksum Calculations Instructor: Anirban Mahanti Office: ICT 745 Email: mahanti@cpsc.ucalgary.ca Class Location: ICT 122 Lectures: MWF 12:00 – 12:50 hours Text Book: “Computer Networking: A Top Down Approach Featuring the Internet”, 3rd edition, Jim Kurose, Keith Ross Addison-Wesley, 2005. Slides are adapted from the companion web site of the book. CPSC 441: Checksum
IP Checksum Calculation At the sender • Set the value of the checksum field to 0. • Divide the header into 16-bit words • Add all segments using one’s complement arithmetic • The final result is complemented to obtain the checksum At the receiver • Divide header into 16-bit words, adds them, and complement’s the results • All zero’s => accept datagram, else reject CPSC 441: Checksum
Binary Checksum Example Carry from 16th column 001 001 0001 0000 0000 001 0000 00000001 0000 0000 0000 1 0000 0000 000001 0000 0000 0000001 0000 1000 1000 1001 1000 0000 0001 0001 1001 1111 0001 1111 0010 0111 1011 1001 1 0010 0111 1011 1010 1101 1000 0100 0101 Carry from 13th column Carry from 12th column Carry from 5th column Carry from 4th column Carry from 3rd column Carry from 2nd column Carry from 1st column CPSC 441: Checksum
UDP Checksum 32-bit source IP address 32-bit destination IP address The pseudo-header length protocol 0’s • Add pseudo-header • Fill checksum with 0’s • Divide into 16-bit words (adding padding if required) • Add words using 1’s complement arithmetic • Complement the result and put in checksum field • Drop pseudo-header and padding • Deliver UDP segment to IP source port # dest port # checksum length data (add padding to make data a multiple of 16 bits) 32 bits CPSC 441: Checksum
Checksum calculation at Receiver • Add pseudo-header to the UDP segment • Add padding, if needed • Divide into 16-bit words and add words using 1’s complement arithmetic • Complement result • If result is all 0’s • Drop pseudo-header and padding (if any) • Accept segment Else drop segment CPSC 441: Checksum