3

If I send some sequence of bytes on a UDP socket (ie, in a single send call), is it possible that the receiving socket will receive only part of the transmitted message (ignoring the case of too small a buffer). Or will the byte sequence be delivered in its entirety or not at all, but never partially or in multiple groups?

alecbz
  • 6,292
  • 4
  • 30
  • 50
  • 3
    UDP has o guaranteed delivery but, from a client perspective, when a datagram is received it is guaranteed to be complete. – mac Mar 20 '14 at 21:18

2 Answers2

3

Yes. UDP datagrams are delivered entire and intact or not at all.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • I don't think the question is about the datagrams themselves but the entire content of the buffer sent in the `send()` call. At least that's how I understood it. – Asblarf Mar 20 '14 at 21:53
  • @Asbkarf A distinction without a difference. The 'entire content of the buffer sent in the send() call' *is* a datagram. – user207421 Mar 20 '14 at 21:55
  • Even if it's bigger than the MTU? – Asblarf Mar 20 '14 at 21:56
  • If it's bigger than the MTU it may not be sent at all. It certainly won't be split into multiple datagrams, if that's what you're getting at. – user207421 Mar 20 '14 at 21:58
  • I see, then it means that it may (or may not) be fragmented by the lower layer protocol but will still remain a single UDP datagram. Got it now. – Asblarf Mar 20 '14 at 22:08
  • @EJP Coolio. An assignment has us building a reliable channel on top of UDP and this is what I'd assumed, but a friend was concerned about not accounting for partial packet loss or something like that, and I wasn't sure if that was a potential issue. Out of curiosity, do you have a source on that? Where's a good place to go to resolve these kinds of questions (anything other than the standard itself?) – alecbz Mar 20 '14 at 23:01
  • @alecbenzer The best place *is* the standard, in this case the RFC. Nobody can argue with that. I wouldn't be asking for anything else. – user207421 Mar 20 '14 at 23:02
  • @alecbenzer [RFC 768](https://www.ietf.org/rfc/rfc768.txt) describes the UDP checksum, which ensures that the datagram is received intact. – Ross Patterson Mar 21 '14 at 11:07
  • @Asblarf IP may fragment a datagram into multiple packets, and some hypothetical physical layer might break it up even further, but the receiving UDP layer will reassemble the datagram before giving it to the receiving program. – Ross Patterson Mar 21 '14 at 11:08
  • Seven years later: I just googled for that subject, and the first hit led to the following page: https://www.ibm.com/docs/de/aix/7.1?topic=tuning-udp This is about IBM AIX, but explains the matter in a nice, short and understandable fashion. We can safely assume that other operating systems are behaving the same way: AIX adheres to standards / RFCs and would be incompatible to other O/Ss otherwise. – Binarus Jun 21 '21 at 06:44
-2

UDP does not guarantee that payload from machine A will make it to machine B. Datagrams carrying the payload of your send() call may be lost during data transfer. Machine B will just deliver to the application what made it to there. Part of the original payload may still be in flight (or lost).

Asblarf
  • 483
  • 1
  • 4
  • 14
  • 1
    Machine B will deliver an entire datagram or nothing. -1 – user207421 Mar 20 '14 at 21:52
  • @EJP -1, really? I never said datagrams may be partially delivered. I said the _payload_, i.e. the contents of the `send()` buffer. Your -1 is definitely out of place, here. – Asblarf Mar 20 '14 at 21:54
  • 1
    Again that's a distinction without a difference. Every send() call sends one datagram. – user207421 Mar 20 '14 at 21:56
  • Yes, really, you *did* say that datagrams may be partially delivered, and you said it here: 'Machine B will just deliver to the application what made it to there". You don't appear to understand your own writing. – user207421 Jun 07 '23 at 00:45