- Published on
User Datagram Protocol
💡 What is UDP?
UDP is one of the core protocols of the Internet Protocol Suite, used to send messages called datagrams between computers.
It is part of the transport layer (Layer 4) of the OSI model, just like TCP. But unlike TCP, UDP is connectionless and unreliable—meaning it sends data without establishing a connection or guaranteeing delivery.
🔑 Key Features
| Feature | Description |
|---|---|
| Connectionless | No handshake or setup between sender and receiver before sending data |
| Unreliable | No guarantee the data will arrive or arrive in order |
| Lightweight | Minimal overhead (faster than TCP) |
| No congestion control | Sends as fast as the application allows (can lead to packet loss) |
🧱 UDP Packet Structure
A UDP packet (datagram) contains:
- Source Port
- Destination Port
- Length (header + data)
- Checksum (optional integrity check)
- Data
📦 Use Cases
Because UDP is fast and doesn't wait for acknowledgments, it’s ideal for time-sensitive or high-speed applications:
- Streaming media (video/audio)
- Online gaming
- VoIP (Voice over IP)
- DNS (Domain Name System)
- TFTP (Trivial File Transfer Protocol)
🆚 UDP vs TCP
| Feature | UDP | TCP |
|---|---|---|
| Connection | No (connectionless) | Yes (connection-oriented) |
| Reliability | No (packets may be lost) | Yes (guarantees delivery) |
| Order | No | Yes |
| Speed | Faster | Slower due to acknowledgments |
| Use Case | Streaming, gaming | Web browsing, file transfer |
Let me know if you want a diagram or analogy to help visualize how UDP works!