[Network basics] ICMP protocol

table of Contents

  1. ICMP concept
  2. ICMP effect
  3. ICMP redirect
  4. ICMP error detection
  5. ICMP packet format
  6. ICMP message type and encoding type
  7. ICMP application-ping

1. The concept of ICMP

ICMP protocol: internet control message protocol, is an important protocol at the network layer. Based on IP, strictly speaking it does not belong to the network layer protocol, but it does not reach the transport layer level.

2. The role of ICMP

Used to transfer various errors and control information between network devices, and to collect various network information, diagnose and eliminate various network faults, etc.

He is used to pass errors, control, and query information

3. ICMP redirect

The ICMP redirect message is one of ICMP control messages. Under certain circumstances, when the router detects that a machine uses non-optimized routing, it sends an ICMP redirect message to the host, requesting the host to change the route. The router will also forward the initial packet to its destination.
Insert picture description here

  1. If the host wants to achieve communication, it needs to forward the data packet to the gateway, which is set on the interface of the router.
  2. Host A wants to communicate with server A through the default gateway, so it will pass the data packet to RTB.
  3. RTB will query its routing table and find that RTA is the optimal path. RTB will first forward the data packet to RTA and let him send it to server A
  4. RTB will send a redirect message to host A, telling host A to go directly to RTA if it wants to go to network segment 20.0.0.0

4. ICMP error detection

ICMP echo request and ICMP echo reply are used to query and respond to certain information, respectively, for error detection

ICMP Echo messages are often used to diagnose the network connectivity between the source and destination, and can also provide other information, such as the round-trip time of the message. Send echo request to query, echo reply to reply, if it receives 00, it means that the query information is normal; if it starts with 3, it means it is unreachable.

5. ICMP error report

When the network device cannot access the target network, it will automatically send an ICMP destination unreachable message to the sending device.

  • Unreachable type:
    • The network is unreachable
    • The host is unreachable
    • Port is unreachable
    • The protocol is unreachable

6. ICMP packet format

Insert picture description here

  • Type: ICMP message type
    1. ICMP echo request
    2. ICMP echo reply
    3. Unreachable purpose
    4. Redirect
  • Code: Different information in the same message type
  • Checksum: Checksum

7. ICMP message type and encoding type

Insert picture description here

  • Type: type
  • Code: code

8. ICMP application-Ping

  1. -a source-ip-address specifies the source IP address for sending ICMP ECHO-REQUEST messages. If no source IP address is specified, the IP address of the outgoing interface will be used as the source address for ICMP ECHO-REQUEST packets.
  2. -c count specifies the number of times to send ICMP ECHO-REQUEST messages. By default, 5 ICMP ECHO-REQUEST messages are sent.
  3. -h ttl-value specifies the TTL value. The default value is 255.
  4. -t timeout specifies the timeout period to wait for ICMP ECHO-REPLY after sending ICMP ECHO-REQUEST.
Published 30 original articles · won 9 · visited 1120

Guess you like

Origin blog.csdn.net/TKE_Yolanda/article/details/105445249