🎓 BookMCQ
← Back to 19. Network Layer Protocols

📝 ICMP checksum calculation (10 MCQs)

One's-Complement Checksum in ICMPv4

The ICMPv4 checksum detects errors in an ICMP message during transmission for each message. It is a 16-bit one's-complement checksum calculated over the entire ICMP message, including its header and data. The checksum field is set to zero during calculation, and the resulting value is inserted before transmission. This mechanism detects many bit errors but does not correct corrupted messages.

Sixteen-Bit Words and End-Around Carry

The message is divided into consecutive 16-bit words. These words are added using one's-complement arithmetic, in which any carry beyond the most significant bit is wrapped around and added to the least significant bit. The final sum is complemented bit by bit to produce the checksum, which is stored in the ICMP header.

Verification at the Receiving Host

The receiver adds all 16-bit words of the received ICMP message, including the transmitted checksum, using the same one's-complement arithmetic. A valid result is all binary ones, hexadecimal 0xFFFF. If the result differs, the message is treated as corrupted and discarded. The checksum covers ICMP content, while IPv4 has a separate header checksum.

A Simple Two-Word Checksum Calculation

Consider two 16-bit words, 0x1234 and 0x5678. Their sum is 0x68AC, with no overflow carry. Taking the one's complement gives 0x9753, which is the checksum. At reception, adding 0x1234, 0x5678 and 0x9753 produces 0xFFFF, demonstrating a valid check under this simplified example. The same method applies to ICMP data and header bytes.

Checksum Use and Detection Limits

ICMP checksum calculation is similar to the checksum method used by several Internet protocols, but each protocol defines exactly which bytes are included. The checksum is useful for detecting accidental corruption, not for authentication or protection against deliberate modification. Cryptographic integrity mechanisms are required when attackers must be prevented from altering messages undetected.

Frequent Errors in Checksum Arithmetic

'The checksum is calculated by ordinary addition only' is incomplete because end-around carry is required. 'The checksum field is included with its old value' is incorrect because it is zeroed during generation. 'A valid checksum proves the sender is genuine' is incorrect because the method provides error detection, not cryptographic authentication.

Solving ICMP Checksum Questions

Practice splitting messages into 16-bit words, setting the checksum field to zero, adding with end-around carry, and complementing the final sum. For verification, include the received checksum and check for 0xFFFF. Handle an odd final byte by padding it with zero for calculation, and distinguish ICMP checksum from the IPv4 header checksum.

One's-Complement Checksum Calculation Terms

  • Checksum - Detects accidental message corruption.
  • One's complement - Inverts each bit.
  • End-around carry - Wraps overflow into least bit.
  • Word - A 16-bit calculation unit.
  • Verification - Recalculates sum with checksum included.
  • Padding - Adds zero byte to odd-length data.
3
Easy
5
Medium
2
Hard

📝 All ICMP checksum calculation MCQs

Q1. What is the primary function of the checksum field in an ICMP message?

A.To indicate the message type
B.To detect errors in the ICMP header and data ✅
C.To specify the code of the message
D.To provide routing information
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The checksum is a 16‑bit field used to verify the integrity of the ICMP header and payload. By recomputing the checksum at the receiver and comparing it with the transmitted value, any corruption introduced during transmission can be detected, prompting the packet to be discarded.

Q2. Suppose an ICMP Echo Request packet has a correct checksum before transmission. During transit, a single bit in the data section flips from 0 to 1. How will the receiver's checksum verification respond?

A.It will still consider the packet valid because a single‑bit error does not affect the checksum
B.The computed checksum will differ, causing the packet to be discarded ✅
C.The receiver will correct the bit automatically
D.The checksum field will be ignored
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A one‑bit error changes the sum of the 16‑bit words, so the one's‑complement sum calculated by the receiver will no longer match the transmitted checksum. The mismatch signals corruption, and the receiver discards the packet according to the ICMP error‑handling rules.

Q3. An ICMP message is generated on a big‑endian host and received by a little‑endian host. Both compute the checksum using the standard one's‑complement addition on 16‑bit words. Which statement best describes the outcome?

A.The checksum will be double the correct value
B.The checksum will be incorrect unless the receiver swaps byte order before summing
C.The checksum field is ignored on little‑endian hosts
D.The checksum will always match because the algorithm is endianness‑independent ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: Network protocols define the byte order as big‑endian (network order). Regardless of a host's native endianness, it converts received bytes to network order before performing the one's‑complement addition. Consequently, both hosts obtain identical checksum values, ensuring correct error detection.

Q4. If an ICMP packet's checksum field is set to 0xFFFF, what does this indicate about the computed checksum of the packet?

A.The packet contains no errors
B.The actual checksum calculation yielded 0x0000, which is transmitted as 0xFFFF ✅
C.The sender omitted the checksum
D.The packet is a special control message
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: In one's‑complement arithmetic, a computed sum of 0x0000 is represented as 0xFFFF to avoid ambiguity with an all‑zero field, which historically signaled that the checksum was not present. Therefore, a transmitted value of 0xFFFF means the true checksum result was zero.

Q5. Which of the following is a key difference between the ICMP checksum and the TCP checksum?

A.ICMP checksum is optional
B.TCP checksum uses two's complement arithmetic
C.ICMP checksum covers only the ICMP header and data, while TCP checksum also includes a pseudo‑header ✅
D.TCP checksum is 8 bits long
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The TCP checksum adds a pseudo‑header containing source and destination IP addresses, protocol number, and TCP length, enhancing error detection across the IP layer. ICMP checksum, however, only covers its own header and payload, making it simpler but less comprehensive than TCP's approach.

Q6. Why does the ICMP protocol employ one's‑complement addition rather than standard two‑complement addition for its checksum calculation?

A.One's‑complement addition detects all single‑bit errors
B.It aligns with the IPv4 header checksum definition ✅
C.It allows the checksum of a zero‑value packet to be represented as 0xFFFF, simplifying detection of missing checksums
D.It reduces computational complexity on early hardware
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Both ICMP and the IPv4 header use the same checksum algorithm, which is based on one's‑complement addition. Maintaining a consistent method simplifies implementation in routers and hosts, allowing the same routine to verify both the IP header and any encapsulated ICMP message without additional code.

Q7. In IPv4, an ICMP message with a checksum field of 0x0000 is treated as having a valid checksum, whereas in IPv6 the same value indicates an omitted checksum. How does this difference affect a router that forwards both IPv4 and IPv6 ICMP packets?

A.The router treats both cases identically
B.The router drops all packets with checksum 0x0000
C.The router adds a pseudo‑header to IPv4 packets
D.The router must recompute the checksum for IPv6 packets but can skip verification for IPv4 packets with zero ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: IPv4 permits a zero checksum to mean the checksum was correctly computed as zero, so routers can accept it without recomputation. IPv6, however, interprets 0x0000 as an omitted checksum, requiring the router to calculate the checksum before forwarding. This dual behavior forces the router to apply different validation logic based on the IP version.

Q8. Given the following ICMP Echo Request payload (in hexadecimal): 08 00 00 00 12 34 56 78, what is the correct checksum that should be placed in the third and fourth bytes? Assume the checksum field is initially zero.

A.3142
B.47266
C.36707 ✅
D.23870
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The payload is split into 16‑bit words: 0x0800, 0x0000, 0x1234, 0x5678. Summing them using one's‑complement addition yields 0x709C. The one's‑complement of this sum (0xFFFF − 0x709C) is 0x8F63, which is the value that must be placed in the checksum field.

Q9. A router processes thousands of ICMP Echo Requests per second. Which algorithmic optimization most effectively reduces CPU cycles while still guaranteeing correct checksum verification?

A.Recalculate the checksum from scratch for each packet
B.Store pre‑computed checksums for common payloads
C.Disable checksum verification for high‑throughput interfaces
D.Use incremental checksum update when only the payload changes ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: When only a small part of the payload changes (e.g., the sequence number), the router can adjust the previously computed checksum by adding the difference of the altered words. This incremental update avoids summing the entire packet each time, dramatically lowering CPU usage while preserving accurate error detection.

Q10. When a network interface card (NIC) performs hardware checksum offloading for ICMP packets, what must a security appliance consider when performing deep packet inspection that includes checksum validation?

A.The appliance can trust the checksum field without verification
B.The appliance must recompute the checksum in software because the transmitted packet may have a placeholder value ✅
C.Offloading eliminates the need for any checksum handling
D.The appliance should disable offloading on the NIC to avoid inconsistencies
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Hardware offloading often replaces the checksum field with a temporary placeholder before the NIC computes the real value. Consequently, a security appliance that inspects packets before the NIC finishes offloading cannot rely on the existing field and must independently recompute the checksum to ensure the packet's integrity.

🔗 Related Topics (MCQs)