views:

26

answers:

2

I have some question regarding how Internet checksum is calculated. I couldn't find any good explaination from the book, so I ask it here. I'm not sure if this is the correct place to ask, so I'm sorry if I asked it in wrong place.

If you look at the following example. The following two message is sent 10101001, and 00111001. The checksum is calculated with 1's complement. So far I understood. But how is the sum calculated? At first I thought it maybe is XOR, but it seems not to be the case.

              10101001
              00111001
              --------
   Sum        11100010
   Checksum:  00011101

And then when they calculate if the msg arrived OK. And once again how is the sum calculated?

               10101001
               00111001
               00011101
               --------
   Sum         11111111
   Complement  00000000  means that the pattern is O.K.
+1  A: 

It uses addition, hence the name "sum". 10101001 + 00111001 = 11100010.

Wooble
ah, got it sorted out now thanks
starcorn
+1  A: 

If by internet checksum you mean TCP Checksum there's a good explination here and even some code.

When you're calculating the checksum remember that it's not just a function of the data but also of the "pseudo header" which puts the source IP, dest IP, protocol, and length of the TCP packet into the data to be checksummed. This ties the tcp meta-data to some data in the IP header.

TCP/IP Illustrated Vol 1 is a good reference for this and explains it all in detail.

Paul Rubel