UDP vs TCP - Two Ways Computers Send Data
Fast and loose vs slow and reliable
The Two Delivery Methods
When computers send data over a network, they use one of two main methods (called protocols). Think of them as two different postal services:
UDP - The Postcard
UDP (User Datagram Protocol) is like dropping a postcard in a letterbox. You send it and move on. You don't know if it arrived. There's no tracking, no confirmation.
Characteristics:
- Fast - No waiting for confirmation
- No guaranteed delivery - Packets can get lost
- No order guarantee - Packets might arrive out of sequence
- Lightweight - Less overhead, less data used
Used for:
- DHCPHas to use UDP because your device doesn't have an IP address yet to establish a TCP connection. More Info… - Getting your IP address when you first connect
- DNS lookups - Quick question-and-answer exchanges
- Video streaming - A dropped frame doesn't matter, just keep playing
- Online gaming - Speed matters more than perfection
- Voice calls (VoIP) - Slight quality loss is better than delay
- Broadcasts - Sending a message to every device at once
TCP - The Registered Mail
TCP (Transmission Control Protocol) is like sending registered mail. Before sending, both sides agree to communicate (a "handshake"). Every packet is tracked, confirmed received, and resent if lost.
Characteristics:
- Reliable - Guaranteed delivery
- Ordered - Packets arrive in the correct sequence
- Error-checked - Corrupted data is detected and resent
- Slower - All that checking takes time
Used for:
- Web browsing (HTTP/HTTPS) - Web pages must load completely and correctly
- Email - You need the full message, not parts of it
- File downloads - A missing byte would corrupt the file
- Online banking - Every transaction must be complete and accurate
Why DHCP Uses UDP
This is an interesting case. TCP requires both sides to establish a connection first (a "three-way handshake"). But when your device first joins a network, it doesn't have an IP address yet - so it can't establish a TCP connection with anyone.
UDP doesn't need a connection. Your device can just broadcastSend a message to every device on the network at once. a message saying "I need an IP address!" without needing one first. It's a chicken-and-egg problem that UDP solves.
Side by Side
Speed Fast Slower
Reliability No guarantee Guaranteed
Order No Yes
Connection Not needed Required
Best for Speed Accuracy