2

As we all perfectly know, UDP does not support retransmission along with some other things.

We also aware of such thing like MTU that works basically in the following way -- when one of the network devices on the path between source and destination points does not support packet of some size, it just drops it.

In case of TCP, it's not a problem -- it already knows MSS after handshake that is always less than MTU (am I right?), so there's no possibility to send a packet with the size greater than MTU.

However, I wonder how does it work in case of UDP? As I already said, there's no retransmission in this protocol and there's no such thing like MSS. So what happens when the packet is dropped due to exceeding MTU?

Or it just works because of the MTU nature (it actually belongs to the IP layer, not the transport layer protocols like UDP or TCP)? So the IP layer reconstruct the dropped packet in smaller units and send it again?

FrozenHeart
  • 19,844
  • 33
  • 126
  • 242
  • That is what ICMP is for. A router dropping a packet due to the MTU will send an ICMP error message back to the sender. – Ron Maupin Aug 07 '16 at 19:43
  • @Ron Maupin And what happens then? – FrozenHeart Aug 07 '16 at 19:44
  • You could ignore the message, or you could adjust the MTU. I'm not sure why you are so worried about the MTU. You are going to lose packets from congestion and congestion avoidance mechanisms. For instance, RED (Random Early Detection) will randomly drop packets to keep buffers from filling up. Full buffers just drop everything else coming into them, and that can lead to serious problems with TCP. – Ron Maupin Aug 07 '16 at 19:47
  • @Ron Maupin I just want to know how things are working at this level. So it works for UDP packets as well (not only for TCP) because it belongs to the IP layer, right? So IP layer receives ICMP packet about exceeding MTU size and it refragments TCP or UDP messages accordingly? – FrozenHeart Aug 07 '16 at 19:50
  • If the router fragments the packets, it doesn't send an ICMP message because it forwards the fragments. It is only when a router drops the packet due to MTU problems that it sends an ICMP message. The router doesn't really care about the layer-4 protocol since fragmentation is in IPv4 at layer-3. It is possible that the packets have the DF bit set, and the router will not fragment. – Ron Maupin Aug 07 '16 at 19:54
  • @Ron Maupin For example, we sent a UDP packet with the size equal to 2048 bytes. We successfully sent it over several network devices but one of them drops our packet due to exceeding MTU value. This router then send us an ICMP packet with its UDP value and the IP layer automatically re-fragment re-transmit the packet? Or the router that dropped the packet does re-fragmentation and re-transmission by itself, w/o source network point involved in that process? – FrozenHeart Aug 07 '16 at 20:06
  • If the router drops the packet, the application will need to resend it. If the router fragments the packet, and it forwards the fragments, the receiving hosts IP will un-fragment the packet and send it up the network stack. This is all detailed in [RFC 791, INTERNET PROTOCOL](https://tools.ietf.org/html/rfc791). You will receive an ICMP message if packets are dropped due to MTU, but you will not if they are dropped due to congestion. – Ron Maupin Aug 07 '16 at 20:12
  • @Ron Maupin So, intermediate routers are able to re-fragment the packets by themselves, w/o original source point being involved? – FrozenHeart Aug 07 '16 at 20:16
  • Routers will fragment packets, but they will not reassemble them. To reassemble the packets is up to IP on the receiving host. This is all explained in the RFC. This is only for IPv4. IPv6 doesn't allow fragmentation. – Ron Maupin Aug 07 '16 at 20:18

1 Answers1

0

First of all, you must distinguish between the local MTU, which is just the MTU of the local link, and the path MTU (PMTU), which is the smallest MTU of the local link. Consider the following topology:

    1500       1480       1500
A -------- B -------- C -------- D

then A's local MTU is 1500, but the PMTU is just 1480.

When router B receives a packet of size 1500 which it needs to forward, and the DF bit is set, it sends an ICMP packet back to the sender with the next hop's MTU, 1480 in this case. The sender can then reduce the packet size.

In TCP, this is done transparently by the network stack. In UDP, the application needs to deal with it. There are three ways to do that:

  1. always send packets that are small enough; 1024 is always safe over IPv6, and 512 is usually (but not always) safe over IPv4;

  2. use a connected UDP socket, and react to an EMSGSIZE error by reducing the packet size; or

  3. use any kind of UDP socket, request the PMTU ancillary data, and use the data provided.

Technique (3) is the most efficient. For IPv6, it is described in Section 11.3 of RFC 3542.

Community
  • 1
  • 1
jch
  • 5,382
  • 22
  • 41
  • 576 is always safe in IPv4. – user207421 Aug 08 '16 at 00:06
  • Thanks for the answer. And what if DF bit is not set? – FrozenHeart Aug 08 '16 at 06:25
  • @EJP 576 is only safe in IPv4 if the DF bit is not set — MTUs below 576 are allowed (the minimum is 68), but every node must be able to reassemble a 576-octet packet. FrozenHeart, if the DF bit is not set, router B will fragment the packet transparently to the sender; this is inefficient, and should not be used in modern applications. – jch Sep 04 '16 at 13:25
  • how can this be? You can send UDP over MTU and it is matter of lower protocols to deal with it along with retrasmission or guaranteeing delivery of packets between nodes at least. Otherwise UDP over MTU would never work, which it does... – Enerccio Aug 28 '18 at 12:06