How a computer "knows" what to respond to particular ICMP messages? As is known there are various ICMP messages that differ by type and / or code. For example ICMP type 0 is "echo reply", type 13 /14 timestamp reply. So whenever a PC receives a ICMP message with valu "0" as a type or any other particular type - how does it know what to respond ? Where is that instruction written ?

Thank you so much

  • ICMP is an integral part of IP. RFC 792, Internet Control Message Protocol says, "ICMP, uses the basic support of IP as if it were a higher level protocol, however, ICMP is actually an integral part of IP, and must be implemented by every IP module."
    – Ron Maupin
    Feb 27, 2020 at 16:27
  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can post and accept your own answer.
    – Ron Maupin
    Dec 17, 2020 at 15:17

2 Answers 2


ICMP is part of the OS's network stack. It belongs to the network layer.

Each ICMP message type requires specific handling. An ICMP echo request triggers an appropriate echo reply, redirects or router advertisements feed the local routing table, destination unreachable messages are passed "up" the stack to the transport-layer protocol, and so on.

An echo reply (type 0) that is not expected is silently dropped.


Most ICMP messages can be divided into three categories, queries, replies and errors.

Queries and their corresponding replies have an identifier and sequence number, these can be used to match up replies to the corresponding query. A I understand it in practice ICMP query clients are usually implemented using "raw sockets" to receive all incoming ICMP packets and filter them in the application. This is inefficient but the amounts of traffic involved are too small for anyone to care.

ICMP errors contain a portion of the packet that caused the error (originally the internet header and the first 64 bits of payload, however later RFCs suggested including as much of the original packet as possible to support tunneling scenarios). This portion of the packet that caused the error can be used to pass the error up the stack to the appropriate transport protcol, which in turn can pass it to the appropriate socket.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.