Back to the 2017 paper

Module 3: Network Layer & Routing

201714m

With the help of a neat and labelled diagram, explain the message format of ICMP. Explain various types of ICMP error messages and query messages.

Worked SolutionAI Assisted

ICMP — Message Format and Message Types

ICMP (Internet Control Message Protocol) is a network-layer companion protocol to IP, used for error reporting and query/diagnostic functions. ICMP messages are encapsulated inside IP datagrams (protocol field = 1), so they are delivered like ordinary packets — but ICMP never carries user data.

1. ICMP Message Format

Every ICMP message begins with a common 4-byte header, followed by type-dependent data:

+--------+--------+-----------------+
| Type | Code | Checksum |
+--------+--------+-----------------+
| Rest of Header (4 bytes) |
| (depends on Type/Code) |
+-----------------------------------+
| Data (variable length) |
| (first 8 bytes = IP header + |
| first 8 bytes of the data that |
| caused the error) |
+-----------------------------------+
  • Type (1 byte): identifies the general message type (e.g., 3 = Destination Unreachable, 8 = Echo Request).
  • Code (1 byte): refines the Type (e.g., for Type 3: 0 = network unreachable, 3 = port unreachable).
  • Checksum (2 bytes): 16-bit one's-complement checksum over the whole ICMP message (calculated exactly like the IP header checksum).
  • Rest of Header (4 bytes): meaning depends on type — e.g., unused/zero, pointer for Type 12, gateway address for Type 5, identifier + sequence number for Echo.
  • Data: for error messages, ICMP embeds the IP header plus the first 8 bytes of the payload of the original datagram that caused the error, so the source can identify the offending process/port (since the first 8 bytes of TCP/UDP header contain source/destination ports).

2. Error Messages

Type Code Message Meaning
3 0 Destination Unreachable — network Router cannot find the network route
3 1 Destination Unreachable — host Network reachable but host not found
3 2 Protocol unreachable Destination host does not support the upper-layer protocol
3 3 Port unreachable No process listening at the destination port (used by UDP)
3 4 Fragmentation needed & DF set Router must fragment but Don't-Fragment bit is 1
4 0 Source Quench Congestion — sender should slow down (deprecated)
5 0/1 Redirect (network/host) Router tells the source a better first-hop route
11 0 Time Exceeded — TTL expired Hop count exceeded (used by traceroute)
11 1 Time Exceeded — reassembly timeout Fragments not all arrived within the reassembly window
12 0 Parameter Problem Error in the IP header; pointer field gives offending byte

Rules: ICMP errors are never sent for ICMP error messages (prevents infinite loops), not for fragmented datagrams (except Type 3 Code 4), and never for multicast/broadcast destination addresses.

3. Query Messages (request–reply pairs)

Type (Req/Rep) Message Purpose
8 / 0 Echo Request / Echo Reply ping — check host reachability and round-trip time
13 / 14 Timestamp Request / Reply Measure RTT and synchronise clocks (carry originate, receive, transmit times)
17 / 18 Address Mask Request / Reply A host obtains its subnet mask from a router
9 / 10 Router Advertisement / Solicitation Host discovers active routers on its local network

4. Summary

  • Format: Type–Code–Checksum (4 bytes) + Rest-of-Header + Data; checksum covers the entire ICMP message.
  • Error messages (Types 3, 4, 5, 11, 12) report failures back to the source — they are one-way and always include part of the offending packet.
  • Query messages (Echo, Timestamp, Mask, Router discovery) are request–reply pairs used for diagnostics and configuration.
  • ICMP does not correct errors or retransmit data — it only informs; recovery is left to TCP or the application.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.