Checksum Calculations Instructor Carey Williamson Office ICT 740





- Slides: 5
Checksum Calculations Instructor: Carey Williamson Office: ICT 740 Email: carey@cpsc. ucalgary. ca Class Location: MFH 164 Lectures: TR 8: 00 – 9: 15 Notes derived from “Computer Networking: A Top Down Approach Featuring the Internet”, 2005, 3 rd edition, Jim Kurose, Keith Ross, Addison-Wesley. Slides are adapted from the companion web site of the book, as modified by Anirban Mahanti (and Carey Williamson). CPSC 441: Checksum 1
IP Checksum Calculation At the sender r Set the value of the checksum field to 0. r Divide the header into 16 -bit words m Add all segments using one’s complement arithmetic r The final result is complemented to obtain the checksum At the receiver r Divide header into 16 -bit words, adds them, and complement’s the results r All zero’s => accept datagram, else reject CPSC 441: Checksum 2
Binary Checksum Example 001 Carry from 16 th column 001 Carry from 13 th column th 0001 Carry from 12 column th 0000 001 Carry from 5 column th 0000 0001 Carry from 4 column rd 0000 1 Carry from 3 column nd 0000 01 Carry from 2 column 0000 001 Carry from 1 st column 0000 1001 1000 0000 1111 1000 0001 1001 0001 1111 0010 0111 1001 1 0010 1101 0111 1000 1011 0100 1010 0101 CPSC 441: Checksum 3
UDP Checksum The pseudo-header r Add pseudo-header r Fill checksum with 0’s r Divide into 16 -bit words r r (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 32 -bit source IP address 32 -bit destination IP address length 0’s protocol source port # dest port # length checksum data (add padding to make data a multiple of 16 bits) 32 bits CPSC 441: Checksum 4
Checksum calculation at Receiver r Add pseudo-header to the UDP segment r Add padding, if needed r Divide into 16 -bit words and add words using 1’s complement arithmetic r Complement result r If result is all 0’s m Drop pseudo-header and padding (if any) m Accept segment Else drop segment CPSC 441: Checksum 5