Reputation: 181
I'm using Netty-3.10 and I'm unable to find an answer to this question in the Netty documentation.
I have a UDP Netty service. I have a client that sends UDP packets to my host/port. My service works fantastically.
During code review I have gotten pushback that Netty doesn't explicitly state if it will only deliver a single, complete datagram to a pipeline. I guess that is fair, I can't find it explicitly in the documentation even though I don't see how any use of UDP has a chance of working if this was not the case. For example, partial updates could be out of order and interwoven with data from other hosts.
Is there a place in the Netty documentation that explicitly states that the Netty framework does not shard the UDP packets and deliver partial updates to a pipeline?
Thanks
Upvotes: 0
Views: 104
Reputation: 16066
I don't think this is a Netty specified rule but rather one of the UDP protocol. The Wikipedia page for User Datagram Protocol states:
Datagrams – Packets are sent individually and are checked for integrity only if they arrive. Packets have definite boundaries which are honored upon receipt, meaning a read operation at the receiver socket will yield an entire message as it was originally sent.
Therefore, since a full datagram will always be produced on a socket read, it makes sense that the pipeline would always be called once and once only, in contrast with TCP where the logical transmission may be fragmented and require multiple reads.
There is a useful and somewhat related note in the Netty QOTM example server implementation that states:
// Allow packets as large as up to 1024 bytes (default is 768).
// You could increase or decrease this value to avoid truncated packets
// or to improve memory footprint respectively.
//
// Please also note that a large UDP packet might be truncated or
// dropped by your router no matter how you configured this option.
// In UDP, a packet is truncated or dropped if it is larger than a
// certain size, depending on router configuration. IPv4 routers
// truncate and IPv6 routers drop a large packet. That's why it is
// safe to send small packets in UDP.
It is possible that reliability and message aggregation could be implemented by the application itself, in which case a larger application specific message could be built from one or more datagrams involving multiple pipeline invocations in order to aggregate the received datagrams, but each individual datagram, by definition, will only trigger one pipeline invocation.
Upvotes: 1