David542
David542

Reputation: 110267

Internet checksum -- Adding hex numbers together for checksum

I came across the following example of creating an Internet Checksum:

Take the example IP header 45 00 00 54 41 e0 40 00 40 01 00 00 0a 00 00 04 0a 00 00 05:

  1. Adding the fields together yields the two’s complement sum 01 1b 3e.
  2. Then, to convert it to one’s complement, the carry-over bits are added to the first 16-bits: 1b 3e + 01 = 1b 3f.
  3. Finally, the one’s complement of the sum is taken, resulting to the checksum value e4c0.

I was wondering how the IP header is added together to get 01 1b 3e?

Upvotes: 0

Views: 595

Answers (2)

absolutelydevastated
absolutelydevastated

Reputation: 1747

Split your IP header into 16-bit parts.

45 00 
00 54 
41 e0 
40 00 
40 01 
00 00 
0a 00 
00 04 
0a 00 
00 05

The sum is 01 1b 3e. You might want to look at how packet header checksums are being calculated here https://en.m.wikipedia.org/wiki/IPv4_header_checksum.

Upvotes: 1

Cheri
Cheri

Reputation: 263

The IP header is added together with carry in hexadecimal numbers of 4 digits. i.e. the first 3 numbers that are added are 0x4500 + 0x0054 + 0x41e0 +...

Upvotes: 1

Related Questions