title: How to calculate Internet checksum?
body: <p>I have a question regarding how the Internet checksum is calculated. I couldn't find any good explanation from the book, so I ask it here.</p>
  <p>Have a look at the following example.</p>
  <p>The following two messages are sent: 10101001 and 00111001. The checksum is calculated with 1's complement. So far I understand. But how is the sum calculated? At first I thought it maybe is XOR, but it seems not to be the case.</p>
  <pre><code>              10101001
                00111001
                --------
     Sum        11100010
     Checksum:  00011101
  </code></pre>
  <p>And then when they calculate if the message arrived OK. And once again how is the sum calculated?</p>
  <pre><code>               10101001
                 00111001
                 00011101
                 --------
     Sum         11111111
     Complement  00000000  means that the pattern is O.K.
  </code></pre>