UDP – Maximum Size of Application-Layer Message

tcpudp

TCP is capable of segmentation, i.e. even if the application layer creates an arbitrarily large message, the transport layer under TCP will split it into segments.

Now, as per this answer, UDP doesn't have any provisions for segmentation.

Also, as per this article, there is a maximum limit of 65,515 bytes on the size of a UDP datagram for IPv4.

So, if the application layer creates a message larger than a UDP datagram's maximum size, and if UDP has no provisions for segmentation, then how will such a message fit completely into a single UDP datagram?

Best Answer

The maximum for a UDP datagram is limited by the maximum IP packet size of 65,535 octets/bytes.

Part of the IP packet is used by headers - at minimum, 20 bytes for IPv4 without options, and 8 bytes for UDP. This results in a maximum UDP datagram size (including UDP header) of 65,515 bytes, the maximum payload 65,507 bytes. IPv6 increases its header size to 40 bytes, so its 20 bytes less for UDP.

Most networks don't support maximum sized IP packets in one piece. Fragmentation allows passing of packets larger than the underlying network allows directly.

Without fragmentation, an IP packet needs to fit into the current link layer's data frame. For standard Ethernet, the maximum payload is 1500 bytes, so the maximum unfragmented UDP datagram is 1480 bytes for IPv4 or 1460 bytes for IPv6.

If you don't know the underlying network's frame size, the answer is more complicated. In theory, the MTU may be as small as 68 bytes (see RFC 791), so only UDP datagrams of 48 bytes are absolutely guaranteed without fragmentation over IPv4. IPv6 increases the minimum MTU to 1280 bytes, so a UDP datagram of 1240 bytes is guaranteed unfragmented.

The application layer protocol is carried as payload in the UDP datagram, so above limitations apply.

Related Topic