Questions about ping and tracroute in icmp

Question 1: When tracing the traceroute path, why does it send a port that is unreachable at the application layer of the destination host, and then the destination host responds to an ICMP packet with an unreachable port? Why can't I directly transmit icmp reply like a ping packet?

Because if you use icmp rely to reply, there is no way for the source host to be a router or a host, and the router will only reply to the source host icmp reply, and the host will submit the network layer data to the transport layer for processing, and then return to the source host port. The ICMP message reached.

 

Question 2: When the destination host accepts the IP data packet with the TTL value of 1, it will not be lost, so it will not generate a timeout ICMP data packet, then how does the program determine whether the destination host has been reached?

When traceroute sends UDP packets to the destination host, it uses a high non-well-known UDP port number (greater than 30000) to ensure that its application layer does not listen to this port. Therefore, when the datagram arrives at the destination host, it is due to the upper application layer of the destination host. If no application is listening on this port, an ICMP message of "port unreachable" will be generated, so what traceroute has to do is to distinguish whether the received ICMP message is timed out or the port is unreachable, so as to distinguish whether it is a router or a destination host. .

 

The red circle represents the RTT of three packets, and the round trip time of each packet.

Reference article: https://www.cnblogs.com/cotyb/p/5341439.html


Guess you like

Origin blog.51cto.com/12540278/2546199