Computer Network Detailed Notes (4) Internet Control Message Protocol ICMP

4. Internet Control Message Protocol ICMP

Overview of the Internet Control Message Protocol: :

  • Role : Forward IP datagrams more efficiently and improve the chances of successful delivery.
  • Rationale : Allows hosts or routers to report error conditions and provide reports on abnormal conditions.
  • Layer : The standard protocol of the Internet, but it is not a high-level protocol, but an IP layer protocol.
  • Assembly : The ICMP message is used as the data of the IP layer datagram, and the header of the datagram is added to form an IP datagram and sent out.
  • Format : (as shown below)
    • The format of the first four bytes is uniform, and there are three fields: type, code and checksum.
    • Finally there is the data field, whose length depends on the type of ICMP.
      insert image description here

4.1. Types of ICMP messages

Basic classification of ICMP packets : ICMP error packets and ICMP query packets.

Several common ICMP packet types : (as shown in the figure below)

insert image description here

  • Destination unreachable : When a router or host cannot deliver a datagram, it sends a destination unreachable message to the source.
  • time exceeded :
    • When a router receives a datagram with a time-to-live of zero, it not only discards the datagram, but also sends a Time Exceeded message to the source.
    • When the end point cannot receive all the datagram fragments of a datagram within the specified time, it discards all the received datagram fragments and sends a time exceeded message to the source point.
  • Parameter problem : When the value of some fields in the header of the datagram received by the router or the destination host is incorrect, the datagram is discarded and a parameter problem message is sent to the source.
  • Change route (redirection) : The router sends a change route message to the host, letting the host know that the datagram should be sent to another router next time (that is, a better route has been found).

The role of other fields :

  • The role of the code field : to further distinguish several different cases in a certain type.
  • The function of the checksum field : check the entire ICMP message.

The composition of the ICMP error report : (as shown in the figure below)

insert image description here

  1. Extract the header and the first 8 bytes of the data field of the received IP datagram that needs error reporting, and use it as the data field of the ICMP error message.
  2. Adding the first eight bytes of the corresponding ICMP error report message constitutes the ICMP error report message.
  3. Add the header to the ICMP error report, encapsulate it as an IP datagram and send it out.

Situations where ICMP error report messages should not be sent :

  • For ICMP error report messages, ICMP error report messages should not be sent.
  • For all subsequent data fragments of the first fragmented data packet, no ICMP error report message is sent.
  • For datagrams with multicast addresses, ICMP error report messages are not sent.
  • For datagrams with special addresses, ICMP error report messages are not sent.

Two common ICMP query messages :

  • Echo Request or Echo Reply : The ICMP Echo Request message is an inquiry initiated by a host or router to a specific destination host. The host receiving this message must send an ICMP Echo Reply message to the source host or router. This query message is used to test whether the destination station is reachable and to know its related status.
  • Timestamp Request or Timestamp Reply : After the ICMP Timestamp Request message is sent, it can receive the ICMP Timestamp Response message from the other party. Using the timestamp recorded in the message, the sender can calculate the round-trip delay of the current network.

4.2. Examples of ICMP applications

Packet network detection (PING) :

  • Status and role : This is one of the important applications of ICMP, which is used to test the connectivity between two hosts.
  • Messages used : PING uses ICMP Echo Request and Echo Reply messages.
  • At the level : PING uses ICMP at the application layer, without TCP or UDP at the transport layer.
  • Use case :

insert image description here

Trace path (TRACERT) :

  • How it works :
    • A series of IP datagrams are sent from the source host to the destination host, and the undeliverable UDP user datagrams are encapsulated in the datagrams. The lifetime of each datagram is set to 1, 2, 3... respectively.
    • In the transmission path, if the time-to-live of a datagram becomes zero when reaching a certain router, the router discards the datagram and sends an ICMP time-exceeded message to the source host.
    • When the last datagram reaches the destination host, the TTL of the datagram is 1, so the host does not forward the datagram. However, because the IP datagram encapsulates an undeliverable datagram, the destination host sends an ICMP destination unreachable error report message to the source host.
    • In this way, the source host knows the IP addresses of the routers it passes through to reach the destination host, and the round-trip time to each router among them.
  • Use case :

insert image description here

Note : Because the congestion level of the Internet changes at any time, it is entirely possible that more routes will take less time.

Guess you like

Origin blog.csdn.net/hanmo22357/article/details/130839461