# UDP (User Datagram Protocol)

URL: https://softwaredictionary.org/terms/udp
Category: Networking
Last updated: 2026-09-30

In short: UDP is a lightweight internet protocol that sends small, independent messages called datagrams without a connection, favoring speed over guaranteed delivery.

## What is UDP?

UDP, the User Datagram Protocol, is a simple transport protocol that sends data as independent messages called datagrams. It does not set up a connection first, and it does not confirm that a message arrived, resend lost messages, or put them back in order. Like TCP, it runs on top of IP and uses port numbers to deliver each datagram to the right program.

Because UDP skips handshakes, acknowledgments, and retransmissions, it has very little overhead and low latency. Each datagram carries a small header with the source port, destination port, length, and a checksum used to detect corrupted data. If an application needs reliability, it must add its own rules on top, which is exactly what newer protocols such as QUIC do.

An everyday analogy is sending postcards: each one travels on its own, might arrive out of order, and occasionally gets lost, but you don't wait for a reply before sending the next. UDP is used where fresh data matters more than perfect data, such as live voice and video calls, online multiplayer games, DNS lookups, and HTTP/3, which runs over QUIC.

A common confusion is thinking UDP is simply a worse TCP. It is a different trade-off: in a video call, a late packet is useless, so waiting for a retransmission as TCP does would cause more stutter than just skipping it. Because it is connectionless, UDP also supports sending one message to many receivers at once through broadcast and multicast, which TCP cannot do.

## Key takeaways

- UDP is connectionless: there is no handshake before data is sent.
- It does not guarantee delivery or order, and it does not prevent duplicates.
- Low overhead makes it fast and well suited to real-time applications.
- DNS, voice and video calls, online games, and QUIC (used by HTTP/3) rely on UDP.
- Applications that need reliability over UDP must implement it themselves.

## Example: Sending a UDP datagram in Python

```python
import socket

# Create a UDP socket (SOCK_DGRAM means datagrams)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# Send a message with no connection or handshake
sock.sendto(b"player:42 x=10 y=20", ("127.0.0.1", 9999))

# Wait up to 1 second for a reply; it may never come
sock.settimeout(1.0)
try:
    data, sender = sock.recvfrom(1024)
    print("Reply from", sender, data)
except TimeoutError:
    print("No reply: UDP does not guarantee delivery")
```

## Frequently asked questions

**Why would anyone use UDP if it is unreliable?**

Because it is faster and simpler. In real-time uses like video calls or games, getting new data quickly matters more than recovering old data, and applications can add only the reliability they actually need.

**Does DNS use UDP or TCP?**

Most DNS queries use UDP on port `53` because they are small and need quick answers. DNS falls back to TCP for large responses and for transfers between DNS servers, and encrypted variants such as DNS over HTTPS use TCP or QUIC.

**Is UDP faster than TCP?**

Usually, yes, because it skips the handshake, acknowledgments, and retransmissions. The real difference depends on the network, and on an unreliable network an application may still need to add its own recovery logic.

## Sources

- [RFC 768: User Datagram Protocol](https://www.rfc-editor.org/rfc/rfc768.html)

---

Software Dictionary: https://softwaredictionary.org/ · https://softwaredictionary.org/llms.txt
