UDP (User Datagram Protocol) Basics
UDP (User Datagram Protocol) operates on top of the Internet Protocol (IP) and is a connectionless and unreliable protocol, prioritizing speed and efficiency over guaranteed delivery, unlike TCP.
It is used when speed and low latency are more important than accuracy (e.g., real-time streaming, online gaming, DNS queries).
1. Core Principle: Simplicity and Speed
UDP maximizes communication speed by eliminating all reliability mechanisms (handshakes, acknowledgements, retransmissions, etc.) found in TCP.
- Connectionless: It does not perform a 3-Way Handshake before communication. The sender unilaterally sends the data to the recipient.
- Unreliable: It does not verify if a packet arrived, is in the correct order, or was lost. The datagram is sent on a best-effort basis without guarantee of delivery to the recipient.
Key Difference: UDP is much lighter and faster than TCP, but it risks data loss or out-of-order arrival.
2. Key Features of UDP
| Feature | Description |
|---|---|
| Connectionless | There is no setup or termination procedure; data is simply transmitted. |
| Unreliable | Does not guarantee successful delivery of data. |
| Low Overhead | Its header is very simple, resulting in less overhead and faster speed compared to TCP. |
| Datagram | The unit of data transfer is called a 'datagram,' which is treated as an independent message. |
3. Key Applications of UDP
- Real-Time Services: Cases where a momentary data drop is preferable to delaying the entire stream. (e.g., VoIP, live video streaming).
- Online Gaming: Input and position data require low latency, and minor packet loss can often be corrected by the next packet.
- DNS (Domain Name System): Domain name-to-IP resolution is a quick, single request-response, making UDP efficient for this task.