network-programmingudpipmtu

Can UDP packet be fragmented to several smaller ones


Can UDP packet be fragmented to several smaller ones if it exceeds MTU? It seems that MTU fragmentation is about IP layer so I think it can.

If so, what is the recommended max. packet size to send over UDP to avoid fragmentation and why?


Solution

  • Any IP datagram can be fragmented if it is larger than the MTU. Whether it contains UDP, TCP, ICMP, etc. does not matter.

    Most Ethernet networks support a 1500 byte MTU. With the IPv4 header being 20 bytes and the UDP header being 8 bytes, the payload of a UDP packet should be no larger than 1500 - 20 - 8 = 1472 bytes to avoid fragmentation.

    This is assuming no IP options exist in the packet. If so, the payload will need to be smaller than that to account for it.

    This applies to IPv4 only. IPv6 does not support fragmentation.

    You can see also this question regarding MTU for UDP.