UDP – Why ICMP Destination Port Unreachable Error is Generated

icmpudp

My doubt is why an icmp destination port unreachable error message generated for udp. Why we can't simply discard the udp packet if the destination port is not reachable by saying udp is connection-less

Best Answer

From ICMP RFC 792:

  If, in the destination host, the IP module cannot deliver the
  datagram  because the indicated protocol module or process port is
  not active, the destination host may send a destination
  unreachable message to the source host.

Because the keyword is MAY, it is not required for the receiving host to send a destination port unreachable if there is no process listening at that tcp or udp port, but it is allowed per the standard.

As a UDP application developer, it is helpful to know that the destination port is unreachable, so the ICMP error message is helpful and appreciated.

Sometimes, the answer is, “we do it because the standard says to do it”.

Related Topic