Question

Is there any standard that says that udp packets must not be combined together by operating system?

In other words can I be sure that when I send small udp packets by sendto or analogues, I will receive udp packets of the same size by recvfrom, if I request length, which is far more than the size any of the sent packets?

Ok, I am sure that receving side cannot concatenate datagrams, because they may come reordered or be missed. But what is about sending side? Say I make several sendto to the same address, why OS should not concatenate data?

Was it helpful?

Solution

It is not explicitly stated, but it is implied in the specification of the UDP protocol (RFC 768) that multiple packets that are sent independently are received independently.

UPD stands for User Datagram Protocol, and it is the Datagram that is relevant here.
A datagram is defined as

A self-contained, independent entity of data carrying sufficient information to be routed from the source to the destination computer without reliance on earlier exchanges between this source and destination computer and the transporting network.
-- RFC 1594

As datagrams are defined to be independent and self-contained, and because their delivery order (and if they arrive at all) is unspecified, there is no way by which an OS could stich multiple datagrams together in a meaningful way.

Licensed under: CC-BY-SA with attribution
scroll top