Skip to content
IT glossary
BackendUpdated December 3, 2026

UDP

UDP sends data over a network as separate messages called datagrams, without first setting up a connection. It does not guarantee that messages arrive, arrive only once, or arrive in the order they were sent.

What UDP does

UDP (User Datagram Protocol) is a transport protocol that runs over IP. IP addresses identify where a packet should go, while UDP ports help the receiving operating system hand the data to the right application. UDP is message-oriented: if you send two datagrams, the receiver reads them separately. TCP, by contrast, exposes a stream of bytes without preserving the boundaries between writes.

What happens when you send a datagram

UDP adds an eight-byte header containing the source port, destination port, datagram length, and checksum. The checksum can detect corruption; it does not repair the data or tell the sender that the message arrived. There is no UDP handshake before the first send, and UDP does not acknowledge, retransmit, or reorder messages.

A successful sendto() call means the local operating system accepted the data for sending. It does not mean that a process is listening at the other end or that the process received anything. If your application needs a reply, it must decide how long to wait and what to do if the reply never comes.

Example: a DNS lookup

A DNS resolver can send a query to a server's UDP port 53 and match the response to the query using a DNS transaction ID along with other checks. If no response arrives in time, the resolver can retry. The ID, timeout, and retry are part of DNS or the resolver's behavior, not features provided by UDP. If a response is marked as truncated, the resolver can retry over TCP to get the full answer.

When UDP is a good fit

For a live voice call, a late audio frame may be useless by the time it arrives. Skipping it may sound better than pausing playback while waiting for a retransmission. In an online game, a newer position update can similarly make an older one irrelevant. But UDP is not inherently faster in every workload, and using it does not mean giving up reliability altogether. For example, QUIC runs over UDP and provides reliable streams and congestion control itself.

Datagram size matters too. If the resulting IP packet exceeds the path MTU, it may be fragmented or dropped, depending on the IP version and configuration. Losing one fragment prevents delivery of the entire datagram. Applications generally size their messages for the network path rather than treating UDP's maximum datagram size as a target.

How it comes up in interviews

When asked to pick UDP or TCP, start with the consequences of loss and delay. Is an old update still worth delivering? Do messages need to be processed in order? If your design uses UDP and still needs reliability for some messages, explain which layer provides it and how it avoids treating a retry as a new operation.