TCP vs. UDP: The 'Registered Mail' Mental Model
Why does video calling glitch but file downloads pause? A mastery guide to the 3-Way Handshake, Head-of-Line Blocking, and why UDP is winning (HTTP/3).

TL;DR
Quick Answer Box (Google Search Featured Snippet):
- What is the difference between TCP and UDP? TCP (Transmission Control Protocol) is connection-oriented and guarantees delivery, packet order, and data integrity via a 3-way handshake (
SYN$\rightarrow$SYN-ACK$\rightarrow$ACK). UDP (User Datagram Protocol) is connectionless, sending datagrams with zero handshake latency and no retransmission.- When to use TCP vs UDP? Use TCP when every byte matters (REST APIs, file downloads, banking transactions). Use UDP when low latency trumps minor packet loss (live video streaming, gaming coordinates, DNS queries, and modern HTTP/3 QUIC).
- Why does HTTP/3 use UDP instead of TCP? To eliminate TCP’s head-of-line (HoL) blocking, where a single lost packet freezes all concurrent multiplexed streams in the same connection.
Beginner Map: Transport Protocols at a Glance
| Metric | TCP (Transmission Control Protocol) | UDP (User Datagram Protocol) |
|---|---|---|
| Connection | Connection-oriented (3-way handshake) | Connectionless (fire and forget) |
| Reliability | Guaranteed (acknowledgments + retransmits) | Unreliable (best-effort delivery) |
| Packet Ordering | Strictly ordered by sequence numbers | Packets may arrive out of order |
| Head-of-Line Blocking | Yes (lost packet stalls whole stream) | No (each packet handled independently) |
| Typical Protocols | HTTP/1.1, HTTP/2, SSH, FTP, SMTP | DNS, DHCP, WebRTC, VoIP, HTTP/3 (QUIC) |
Networking interviews always ask: “What’s the difference between TCP and UDP?”
The textbook answer: “TCP is reliable; UDP is unreliable.”
The Senior Engineer answer: “TCP is courteous but slow; UDP is rude but fast. And ironically, the web is moving back to UDP (HTTP/3) to fix TCP’s obsession with politeness.”
This is the Mastery Guide to Transport Protocols.
Part 1: Foundations (The Mental Model)
TCP = Registered Mail (Certified Letter)
Think of TCP (Transmission Control Protocol) as sending important legal documents via FedEx with Signature Required.
- Connection Oriented: You have to call the person first to make sure they are home.
- Reliable: If the truck crashes, FedEx sends another truck. You will get the letter eventually.
- Ordered: Page 1 always comes before Page 2.
- Heavy: All this checking takes time and paperwork.
UDP = Shouting Across a Crowded Room
Think of UDP (User Datagram Protocol) as Shouting at your friend in a bar.
- Connectionless: You just start yelling. You don’t know if they are listening.
- Unreliable: If someone walks between you, your friend might miss a word. You don’t repeat yourself.
- Unordered: They might hear “Beer!” before “Want a?”.
- Fast: Immediate. No paperwork.
Part 2: The Investigation (Debug Like a Pro)
1. The 3-Way Handshake (TCP)
Before TCP sends a single byte of data (like a webpage), it wastes time shaking hands.
- SYN (Client): “Hello? Are you there?”
- SYN-ACK (Server): “Yes, I am here. Are you there?”
- ACK (Client): “Yes, I am here. Let’s talk.”
- Cost: 1 Round Trip Time (RTT). If the server is in London and you are in Sydney, you just wasted 300ms doing nothing but saying hello.
- UDP: Zero handshake. Just sends data.
2. The Packet Loss Glitch
- File Download (TCP): If Packet 50 goes missing, your computer pauses the download and asks the server “Resend Packet 50!”. The whole stream stops. This is why downloads pause but never have “glitches” (corruputed data).
- Video Call (UDP): If a packet with your face goes missing, UDP doesn’t care. It just shows the next frame. This is why Zoom calls include weird green artifacts or robotic audio. It’s better to show a glitchy frame now than a perfect frame 3 seconds later.
Part 3: The Diagnosis (Head-of-Line Blocking)
This is the fatal flaw of TCP that led to HTTP/3.
Imagine a single lane highway (TCP Connection). You are driving 5 cars (Web requests: HTML, CSS, JS, Image 1, Image 2).
If Car #1 (HTML) breaks down (Packet Loss):
- TCP: All cars behind it MUST STOP. Even though the CSS car is perfectly fine, it cannot pass. The Highway is blocked.
- Result: The webpage spins.
The Fix: HTTP/3 (QUIC) Google realized this sucks. So they built QUIC on top of UDP.
- It handles reliability in the application layer, not the kernel.
- It allows Car #2 to drive around a broken Car #1.
- Result: UDP is the future of the reliable web.
Part 4: The Resolution (When to use What)
Don’t overthink it. Use this decision tree:
Use TCP If:
- Accuracy is critical. missing a single bit destroys the file.
- Examples: Web Browseing (HTTP/1, HTTP/2), File Transfers (FTP), Email (SMTP), APIs (REST/JSON).
Use UDP If:
- Speed is critical. Late data is useless data.
- Examples: Video Streaming (Live), VOIP (Skype/Zoom), Online Gaming (Counter-Strike positions).
- Why: If I tell you “Enemy is at X:50, Y:50” and that packet is lost, it is useless to resend it 200ms later. The enemy has already moved. I need the new position, not the old one.
Final Mental Model
TCP (HTTP/REST) -> The Accountant. Slow, meticulous, guarantees every penny is counted.
UDP (Zoom/Gaming) -> The Sportscaster. Fast, loud, if you miss a word, just keep listening.
HTTP/3 (QUIC) -> Building an Accountant on top of a Sportscaster. (Best of both worlds).
If you need every byte: TCP. If you need real-time human interaction: UDP.
TCP vs. UDP Frequently Asked Questions (FAQ)
1. What happens during a TCP 3-Way Handshake?
A TCP 3-way handshake establishes a reliable full-duplex connection before application data can flow:
- SYN: The client sends a synchronize packet with an initial sequence number (ISN).
- SYN-ACK: The server acknowledges the client’s ISN (
ACK) and sends its own sequence number (SYN). - ACK: The client acknowledges the server’s sequence number. Once this round-trip completes, data transfer begins.
2. Why is HTTP/3 built on top of UDP (QUIC) instead of TCP?
HTTP/2 multiplexed multiple logical request streams over a single TCP connection. However, when a single TCP packet was dropped on the physical network, TCP’s kernel-level retransmission mechanism blocked all streams until that packet was recovered (known as TCP Head-of-Line Blocking). HTTP/3 replaces TCP with QUIC over UDP, managing stream multiplexing and packet recovery independently in user-space so one lost image packet never freezes the HTML or CSS parser.
3. Can an application built on UDP achieve 100% reliability?
Yes. UDP itself does not provide reliability, but applications or transport layers built on top of UDP (like QUIC, WebRTC SCTP, or gaming protocols) can implement custom selective acknowledgment, forward error correction (FEC), and packet reordering algorithms in user space without incurring OS kernel TCP overhead.
4. Why does DNS use UDP by default?
A DNS lookup is typically a single request and a single response datagram. Using UDP avoids the overhead of a 3-way handshake (saving 1 full RTT of latency). If a query drops, the DNS resolver simply retries after a short timeout. For responses larger than 512 bytes (or DNSSEC records), DNS automatically falls back to TCP.
Related Systems & Network Deep Dives
- REST vs. GraphQL vs. gRPC: API Protocols Compared: See how HTTP/2 binary framing and multiplexing power high-throughput gRPC microservices.
- Load Balancer, Reverse Proxy & API Gateway: Learn how L4 (TCP/UDP) and L7 (HTTP/gRPC) proxies distribute global traffic without latency spikes.
- OmniRoute: Dynamic AI Traffic Gateway: Explore how proxy routing layers handle upstream connection fallbacks and rate limits.
Related posts
CDN: The 'Local Convenience Store' Mental Model
Why does your image load instantly for users in the US but crawls in Vietnam? A mastery guide to CDN Edge Nodes, Cache-Control headers, and cache busting.
Load Balancer, Reverse Proxy, API Gateway: The Grand Hotel Mental Model
Confused by the 'Traffic Trio'? A mastery-level guide to Load Balancers, Reverse Proxies, and API Gateways - from mental models to Nginx configs.
Tencent BrowserSkill Explained: How AI Uses Your Logged-In Browser
Tencent BrowserSkill lets AI agents use your logged-in Chrome without stealing focus. Explore tab borrowing, captcha handling, and local daemon architecture.
Zero-Dollar AI Agent Farming: Turning Broken Hardware into a 24/7 Autonomous Dev Engine
Turn a cracked-screen laptop into a 24/7 autonomous homelab server: sudden power cut protection, Bubblewrap quota relay, and phone-driven vibe coding with 0 dollars.