UDP Communication
UDP (User Datagram Protocol) is a connectionless transport-layer protocol known for its simplicity and speed. It is widely used in scenarios where low latency is crucial, such as real-time applications.
Key Points
- Connectionless Protocol: UDP does not require a connection setup, session state, or handshake between sender and receiver.
- Datagram: An independent UDP packet sent without guarantees of delivery, order, or duplication.
- Port Number: Identifies the application or service on a host that should receive the datagram.
- Best-Effort Delivery: UDP does its best to deliver packets but provides no guarantees.
Detailed Explanations
UDP Is Not Connection-Oriented
Unlike TCP, UDP does not establish a connection or maintain a session state. Each UDP datagram is sent independently without the need for a handshake (SYN / SYN-ACK / ACK).
UDP Header Simplicity
The UDP header is only 8 bytes, making it lightweight and fast. It contains:
- Source port
- Destination port
- Length
- Checksum
This simplicity contributes to UDP’s low latency.
No Reliability Mechanisms
UDP does not provide:
- Retransmission of lost packets
- Packet ordering
- Flow control
- Congestion control
If a datagram is lost or received out of order, UDP does not handle these issues. The application must manage these aspects if needed.
Datagram Delivery Behavior
Datagrams are sent sequentially but may take different network paths, arrive out of order, be duplicated, or be lost. Applications using UDP must tolerate this behavior.
Example scenario:
- Sent:
1 → 2 → 3 → 4 → 5 - Received:
1 → 2 → 4 → 5(3 lost)
Schemas / Visual Explanations
UDP Communication Model
Client Application
|
| UDP Datagram
v
Network (IP)
|
v
Server Application (Listening on Port)
TCP vs UDP Comparison
| Feature | TCP | UDP |
|---|---|---|
| Connection-oriented | Yes | No |
| Handshake | Yes (3-way) | No |
| Reliability | Guaranteed | Best-effort |
| Packet ordering | Yes | No |
| Flow control | Yes | No |
| Header size | 20+ bytes | 8 bytes |
| Speed | Slower | Faster |
Points of Attention / Common Mistakes
- Thinking UDP is “worse” than TCP
- Expecting UDP to retransmit lost packets
- Assuming packets arrive in order
- Forgetting that applications must handle loss and order
- Confusing connectionless with stateless applications
Practical Examples
DNS Query
- Client sends a UDP request to
port 53 - Server replies with a UDP response
- If the packet is lost, the application retries, not UDP
VoIP (Voice over IP)
- Real-time audio transmission
- Late packets are useless
- UDP is preferred over TCP to avoid delays
Other Common UDP Services
| Service | Port |
|---|---|
| DNS | 53 |
| RADIUS | 1812 |
| DHCP | 67 / 68 |
| NTP | 123 |
Key Takeaways
- UDP is a connectionless protocol
- No handshake, no session
- Very simple and fast
- No retransmission or ordering
- Uses datagrams
- Packet loss is acceptable for some applications
- Widely used for real-time services
Learn More
- RFC 768 — User Datagram Protocol
- RFC 8085 — UDP Usage Guidelines
- IETF Transport Layer Documentation
- Cisco Networking Fundamentals
- Cloudflare Learning Center (UDP)