0

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?

1 Answer 1

1

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.

4
  • Yes, I understand all that, but I'm sorry that wasn't my question. I wanted to know whether the application layer is also limited by such limits in the case of UDP. Because in the case of TCP, the application layer may send arbitrarily large messages, which will then get segmented at the transport layer. Commented Aug 10, 2023 at 11:43
  • 1
    I thought it was obvious - have added a sentence for that.
    – Zac67
    Commented Aug 10, 2023 at 11:53
  • So, this does count as a major difference between TCP and UDP, doesn't it? In the case of TCP, the application layer can create an arbitrarily large message, whereas in the case of UDP, the application layer can only create messages of limited size. Commented Aug 10, 2023 at 12:32
  • 1
    @KushagrJaiswal Pretty much so.
    – Zac67
    Commented Aug 10, 2023 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.