1. Gyanastra
  2. Computer Networks
  3. ICMP
  4. ICMP Error Handling and the No-ICMP-for-ICMP Rule (Infinite Loop Avoidance)
Free lesson, no account needed 6 min read 11 practice questions after it

Computer Networks · ICMP

ICMP Error Handling and the No-ICMP-for-ICMP Rule (Infinite Loop Avoidance)

Overview

ICMP acts as an assistant to IP: when an IP packet is lost or discarded, ICMP sends an error message back to the source.
However, a special rule forbids generating ICMP errors for discarded ICMP packets, because otherwise feedback about lost feedback would loop forever and halt the network.

Key concepts

  • ICMP error handling: Whenever an IP packet is lost or discarded, ICMP responds by sending feedback (an error message) back to the source. This feedback mechanism is called error handling.
  • Unreliable datagram service: IP is a datagram service that is unreliable — anything can go wrong and the sender cannot find out on its own.
    Analogy: sending a postal letter; if it is not received by the destination, you will not even know about it.
  • Courtesy, not a rule: Anyone (router) who discards your IP packet is supposed to send an ICMP packet to the source saying "I discarded it." This is only a courtesy, not a rule.
  • The No-ICMP-for-ICMP rule: Whenever an IP packet is discarded, an ICMP packet is generated. But if an ICMP packet (carried inside an IP packet) is discarded, no ICMP packet should ever be generated.
  • Congestion: The most popular reason a packet is discarded — a router is already busy, has no space to take in more packets, and more packets keep arriving, so it discards them.

How it works

  1. Consider routers R1, R2, R3 and a destination. An IP packet travels R1 → R2 → R3 and is discarded at R3 (due to congestion).
  2. As a courtesy, R3 (the discarder) sends an ICMP packet back to the source of the discarded IP packet. Sender of this ICMP packet = R3; destination = the original source.
  3. This ICMP packet itself travels inside an IP packet. Suppose, because of high congestion at R2, this ICMP packet is again discarded at R2.
  4. Now R2 discards the packet whose source is R3. If we followed the same logic, R2 should send an ICMP packet to R3 saying "I discarded your packet" (reason: congestion).
  5. That ICMP packet (R2 → R3) is again inside an IP packet. If it is discarded (say at R3 due to huge congestion), then again an ICMP packet would have to be sent — from R3 to R2 — saying "I discarded your ICMP packet."
  6. If that is discarded by R2, again an ICMP packet from R2 to R3, and so on.
  7. This creates an infinite loop: a packet is lost, the feedback message is also lost, and making the feedback reliable would mean sending ICMP for every discarded ICMP. Everything would come to a halt because of this heavy traffic.
  8. Therefore the rule: if an IP packet is discarded, ICMP is generated; but if an ICMP packet is discarded, no ICMP is ever generated. This avoids the infinite loop.
  9. Consequence: even though IP has the assistant ICMP, the entire package together is still unreliable. IP combined with ICMP is still unreliable.

Formulas

  • IP packet discarded → ICMP error generated
  • ICMP packet discarded → no ICMP generated

Worked examples

Infinite loop scenario (R1, R2, R3):

  1. IP packet travels R1 → R2 → R3 and is discarded at R3 due to congestion.
  2. R3 sends an ICMP error to the original source; this ICMP packet is itself carried inside an IP packet.
  3. That ICMP packet is discarded at R2 due to high congestion.
  4. Following the same logic, R2 would send an ICMP error to R3 (the source of the discarded packet), reason: congestion.
  5. That ICMP packet (R2 → R3) is again inside an IP packet; if discarded at R3 due to huge congestion, R3 would send an ICMP error to R2.
  6. If that is discarded by R2, R2 sends another ICMP error to R3, and so on — an infinite loop that halts the network with heavy traffic.
  7. The No-ICMP-for-ICMP rule breaks the loop: the discarded ICMP packet at step 3 generates no further ICMP.

Revision summary

  • IP packet discarded → ICMP generated; ICMP packet discarded → no ICMP generated. This is the first rule of ICMP error handling.
  • Sending the ICMP error back to the source is a courtesy, not a rule.
  • The sender of the ICMP error is the router/station that discarded the packet; the destination is the source of the discarded packet.
  • Congestion (router busy, no buffer space) is the most common reason for discarding packets.
  • Without the rule, an infinite loop occurs and the network halts due to heavy traffic.
  • IP + ICMP together is still an unreliable protocol, for two reasons: (1) no ICMP is generated for an ICMP packet; (2) even when ICMP is sent, there is no guarantee it will reach the other side.

Previous-year exam insights

  • ICMP error messages are never sent for: an ICMP error message itself, a packet whose destination is a broadcast or multicast address, a fragment other than the first fragment, a packet with a non-zero source address that is not a single host (e.g., 0.0.0.0 or a broadcast source), or a packet with a special address such as loopback.
  • ICMP error messages always carry the IP header plus the first 8 bytes (64 bits) of the payload of the original datagram that caused the error, so the source can identify which packet failed.
  • The main ICMP error types are Destination Unreachable (type 3), Source Quench (type 4, deprecated), Time Exceeded (type 11, used by traceroute), Parameter Problem (type 12) and Redirect (type 5); query messages include Echo Request/Reply (types 8/0, used by ping) and Timestamp Request/Reply (types 13/14).
  • ICMP is a network-layer (layer 3) protocol encapsulated directly in IP (protocol number 1); it does not use TCP or UDP ports, and it reports errors only to the source of the original datagram, never to intermediate routers.
  • The ICMP error message's source address is the address of the router or host that detected and discarded the packet, and its destination address is the source address of the discarded datagram.
  • Because ICMP errors are not generated for ICMP errors and ICMP messages themselves can be lost, IP with ICMP remains a best-effort, unreliable service; reliability must be provided by upper layers such as TCP.
Pages 1–2 of 2