UDP (User Datagram Protocol) is a connectionless, lightweight transport protocol that provides fast data transmission with minimal overhead. It's ideal for real-time applications where speed is more important than reliability.
Minimal overhead and no connection establishment delays. Data is sent immediately.
No handshake required — data is sent immediately without establishing a connection first.
No guarantee of delivery, ordering, or duplicate protection. Fire and forget.
Unlike TCP which requires a 3-way handshake, UDP simply fires packets at the destination. No connection setup, no teardown.
|
CLIENT
|
SERVER
|
|
| Send data immediately No connection setup |
UDP Packet (Data) ➡
|
Receives if lucky No acknowledgment |
| No retransmission if packet lost |
⬅ UDP Response (Optional)
|
Response is optional Not required by protocol |
|
No handshake. No acknowledgment. No retransmission. Just speed.
|
||
UDP has a tiny 8-byte header — compared to TCP's 20+ bytes. This is one reason UDP is so fast and efficient.
| Feature | UDP | TCP |
|---|---|---|
| Connection | Connectionless | Connection-oriented |
| Reliability | Best effort | Guaranteed |
| Ordering | Not guaranteed | Guaranteed |
| Speed | Very fast | Slower (overhead) |
| Header Size | 8 bytes | 20+ bytes |
| Error Checking | Optional checksum | Full error detection |
| Handshake | None | 3-way handshake |
| Use Cases | Gaming, streaming, DNS | Web, email, file transfer |
Domain name resolution — fast lookups are more important than reliability. Client retries if no response.
Real-time multiplayer games — low latency is critical. A few dropped packets is acceptable.
Video/audio streaming — missing frames are acceptable. Better to skip than freeze.
Here's a minimal Python UDP server and client demonstrating how simple UDP communication is: