Excerpt from implementation section of Wikipedia page for traceroute:
. . . until the destination is reached and returns an ICMP Destination Unreachable message if UDP packets are being used or an ICMP Echo Reply message if ICMP Echo messages are being used.
It says that at the final hop traceroute is expecting ICMP "Destination Unreachable" when it I was expecting it to use an ICMP "Echo Reply".
I saw the history of the page and it was changed by a person named 'Guy Harris'. He says:
. . . If you use UDP packets, as traceroute does by default, the final hop returns ICMP Destination Unreachable (unless you're unlucky enough to have send a UDP packet to a port with a listener), not ICMP Echo Reply.
Can somebody please throw some light to this?
Because traceroute needs to get message when the UDP datagram has reached the destination.
Traceroute works as follow:
Traceroute design to send the UDP datagram to a port of host, and it is almost impossible that the port is listened (33435
for example). The destination host receives the UDP datagram, finds the datagram's target port is not listened, and then return "Destination Unreachable" message -- more accurately, "Port Unreachable".
That's why traceroute expect a "Destination Unreachable" message at the final hop to determine that the UDP datagram has already reached the destination.
BTW, if the target port is accidentally listened on destination host, that's just the scenario described by Guy Harris: "unless you're unlucky enough to have send a UDP packet to a port with a listener"