CS Atlas GATE 2027
Computer Networks course
0 / 90 complete

Computer Networks/Phase 2 · Data Link Layer

Lesson 2.2.3 · Item 28 of 90

The Internet checksum: compute and verify

Read at your own pace. Try the questions before opening the answers.

On this page

Recall warm-up

  1. d_min = 5: errors detected? corrected?
    Stuck? Peek at 2.2.2 Hamming distance: detect d − 1, correct ⌊(d − 1)/2⌋
    • d(x, y) = number of 1s in x ⊕ y; d_min = smallest over codeword pairs.
    • Detect d_min − 1; correct ⌊(d_min − 1)/2⌋.
    • Detect s needs d ≥ s + 1; correct t needs d ≥ 2t + 1.
    • Hamming code: smallest r with 2ʳ ≥ m + r + 1.

    Read lesson 2.2.2

  2. 2-D parity check bits for a 3 × 5 block?
    Stuck? Peek at 2.2.1 Single-bit vs burst errors; redundancy; 1-D and 2-D parity
    • Single-bit vs burst; burst length = first to last damaged bit inclusive.
    • Codeword = dataword (k) + r check bits.
    • 1-D parity: detects odd numbers of flips only.
    • 2-D parity: R + C + 1 check bits; detects all 1–3-bit errors, corrects 1, misses some 4-bit rectangles.

    Read lesson 2.2.1

  3. How does 1's-complement addition treat the final carry?
    Stuck? Peek at 0.2.3 XOR, 1's complement addition and modulo-2 division
    • AND (mask), OR, NOT (flip), XOR (1 where bits differ).
    • a ⊕ a = 0, a ⊕ 0 = a, (a ⊕ k) ⊕ k = a.
    • 1's complement = flip all bits; 1's-complement addition wraps the end carry back in.
    • Modulo-2: + = − = XOR, no carries; bits ↔ polynomial.
    • Mod-2 division: leading 1 → XOR divisor; leading 0 → XOR zeros; remainder = (divisor length − 1) bits.

    Read lesson 0.2.3

The Hook

A shopkeeper adds up a bill, writes the total on the slip, and the customer re-adds the items to compare. The Internet checksum works the same way, with one twist: the sender writes the complement of the total, so that the receiver's sum of everything (data + checksum) comes out as all 1s. It is cheap enough to compute in software for every unit, which is why it is used in network- and transport-layer headers you will meet in Phases 3 and 4.

Predict First

A sender adds the data words, takes the 1's complement, and sends it along. The receiver adds the data words and the checksum. If nothing was damaged, what will the receiver's sum be?

,

All 1s (0xFFFF for 16-bit words). A number plus its 1's complement is all 1s. Complementing that gives 0, so the receiver accepts when its complemented sum is 0.

Core Concept

Sender algorithm

  1. Split the data into 16-bit words (pad with a zero byte if the length is odd).
  2. Add all words using 1's-complement addition (wrap every carry back in).
  3. The checksum = 1's complement of that sum (flip every bit). Put it in the checksum field, which was set to 0 while summing.
16-bit words
1's-complement sum
carries wrap around
complement
flip all bits
checksum field
Sum with wrap-around, then complement.

Receiver check

The receiver adds every word including the checksum with 1's-complement addition. Result all 1s (complement 0) → accept; anything else → error detected, discard.

StepValue (example 2)
sum of data0100 1010 1100 0010
checksum (complement)1011 0101 0011 1101
receiver: sum + checksum1111 1111 1111 1111 ✓
Data sum plus its complement is all 1s.

What it catches and misses

  • Detects all single-bit errors and most bursts.
  • Misses errors that leave the 1's-complement sum unchanged: for example, swapping two 16-bit words (addition is order-independent), or a +x in one word cancelled by −x in another.
  • Weaker than the polynomial code of the next lesson, but very cheap in software.
Strength
cheap; catches every single-bit error
Weakness
reordered words or compensating errors go unnoticed
Checksum trade-off.

Putting it together

  • Sum the words with wrap-around, send the complement.
  • The receiver's total including the checksum must be all 1s.
  • Cheap and catches single-bit errors, but blind to reordering.

Visual

Worked visual sequence

The supplied notes include an interactive visual for this concept; this reading view preserves the surrounding explanation and sequence.

Internet checksum of three 16-bit words, step by step (computed).

Worked Examples

Easy

Practise with 4-bit words: data 7, 11, 13. Find the 1's-complement sum and the checksum.

Show the full solution

7 + 11 = 18 ≥ 16 → 18 − 16 + 1 = 3. Then 3 + 13 = 16 ≥ 16 → 16 − 16 + 1 = 1 (0001). Checksum = complement of 0001 = 1110 (14). Check: 1 + 14 = 15 = 1111, all 1s.

Medium

Compute the 16-bit Internet checksum of 0110011001100000, 0101010101010101, 1000111100001100 and verify it.

Show the full solution

First two words: 1011101110110101. Adding the third gives 1 0100101011000001; wrap the carry: 0100101011000010. Checksum = complement = 1011010100111101. Receiver: sum of all four words = 1111111111111111 → accept.

GATE

Data words 0x1234, 0xF0F0, 0xABCD. Find the Internet checksum in hex.

Show the full solution

0x1234 + 0xF0F0 = 0x10324 → wrap: 0x0324 + 1 = 0x0325. 0x0325 + 0xABCD = 0xAEF2 (no carry). Checksum = 0xFFFF − 0xAEF2 = 0x510D.

GATE Traps

  • Set the checksum field to 0 before the sender sums.
  • Do not drop the carry — wrap it back in. Ordinary binary addition gives a different (wrong) checksum.
  • The checksum is the complement of the sum, not the sum itself.

Memory Hook

"Sum, wrap, flip — and the receiver must see all ones."

Connect the Dots

The checksum is cheap but blind to reordering. Next (2.2.4): the stronger link-layer check — treat the bits as a polynomial and send the remainder of a modulo-2 division (Lesson 0.2.3) — catches every burst up to a known length.

Self-Test

  1. MCQ

    The 16-bit Internet checksum of the words 0x4500, 0x0073, 0x4000, 0x4011 is:

    1. 0x3A7B
    2. 0xC584
    3. 0x3A7A
    4. 0xC585
  2. MCQ

    At the receiver, data words plus checksum add (1's complement) to 0xFFFF. The receiver:

    1. detects an error
    2. accepts the data
    3. requests the checksum again
    4. cannot decide
  3. MSQ

    Which errors can the Internet checksum miss?

    1. Two 16-bit words swapped
    2. A single flipped bit
    3. One word +1 and another word −1
    4. A word 0x0000 changed into 0xFFFF
  4. NAT

    16-bit 1's-complement sum of 0xFFF0 and 0x0020, in decimal?

    Write your answer before opening the key.

Rule Card

  • 16-bit words; checksum field = 0 while summing.
  • Sum with 1's-complement addition (wrap carries); checksum = complement of the sum.
  • Receiver: sum of all words + checksum = 0xFFFF → accept.
  • Misses word reordering and compensating errors.

Concept Ledger

  • Internet checksum
  • 16-bit word sum with wrap-around
  • checksum = complement of the sum
  • receiver verification (all 1s)

Answer Vault

Try the questions first. Open when you are ready to check.

Warm-up answers

  1. Detected 4, corrected 2.
  2. 3 + 5 + 1 = 9.
  3. It wraps around and is added back at the right end.

Self-test answers

  1. A — Sum = 0xC584 (no carries); checksum = 0xFFFF − 0xC584 = 0x3A7B.
    • B: That is the sum, not its complement.
    • C: Off by one (2's-complement thinking).
    • D: Sum off by one.
  2. B — All 1s means no error detected.
    • A: All 1s is the success value.
    • C: No such step.
    • D: All 1s is decisive.
  3. ACD — Reordering and compensating changes keep the sum; flipping 0x0000 into 0xFFFF also keeps the 1's-complement sum (both represent zero).
    • B: Every single-bit error changes the sum.
  4. 17 — 0xFFF0 + 0x0020 = 0x10010 → 0x0010 + 1 = 0x0011 = 17.

Flashcards

  1. Internet checksum steps?
    Reveal answerSum 16-bit words in 1's complement (wrap carries), then flip all bits.
  2. Receiver accepts when?
    Reveal answerSum of all words including checksum = 0xFFFF.
  3. One error the checksum cannot see?
    Reveal answerTwo words swapped.

Exam shortcuts

  • Hex shortcut: add in hex; whenever the result exceeds 0xFFFF, drop the leading 1 and add 1; checksum = 0xFFFF − sum (each digit from F). — 16-bit words.
  • Receiver test: sum(all words incl. checksum) = 0xFFFF ⇔ no error detected. — the same 1's-complement addition as the sender.

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.