Loading…
Loading…
Charting your lesson…
Opening your lesson…
TCP vs UDP
Lesson 3 of 3
6 steps•about 12 min•12 flashcards
Step 1/ 61 min
At the transport layer you choose one of two protocols, and the choice shapes everything above it: TCP (reliable, ordered, slower) or UDP (fast, best-effort, lightweight). Comparing them is one of the most common networking interview questions.
Core idea: TCP (Transmission Control Protocol) is connection-oriented and reliable — it guarantees ordered, error-checked, complete delivery via handshakes, acknowledgements and retransmission. UDP (User Datagram Protocol) is connectionless and best-effort — it just fires datagrams with minimal overhead, trading reliability for speed.
Step 2/ 61 min
| Feature | TCP | UDP |
|---|---|---|
| Connection | connection-oriented (3-way handshake) | connectionless |
| Reliability | guaranteed (ACKs + retransmit) | best-effort (no guarantee) |
| Ordering | in-order (sequence numbers) | unordered |
| Speed / overhead | slower, 20-byte header | faster, 8-byte header |
| Flow/congestion control | yes | no |
| Use cases | web, email, file transfer | streaming, gaming, DNS, VoIP |
TCP achieves reliability with: sequence numbers (order + detect loss), acknowledgements + retransmission timers (resend lost data), flow control (a sliding window so a fast sender doesn't overwhelm a slow receiver), and congestion control (slow-start/AIMD to avoid collapsing the network). All of this adds latency and state. UDP deliberately omits it — no handshake, no ACKs, no ordering — so it's ideal when timeliness beats completeness: in live video a late-but-perfect packet is useless, so you'd rather drop it than wait for a retransmission. Applications needing reliability over UDP (like QUIC/HTTP-3) rebuild it themselves for finer control.
Step 3/ 61 min
Two scenarios:
Step 4/ 61 min
Guaranteed: "difference between TCP and UDP", "when would you use UDP over TCP", "why is UDP faster", "does UDP guarantee delivery/order" (no to both), and "which protocol does DNS/HTTP/video streaming use". The feature table and use-case reasoning are the graded content.
Step 5/ 61 min
Thinking UDP is "just a worse TCP" and should be avoided. UDP's lack of handshakes, ACKs and ordering is a feature for latency-sensitive applications — live streaming, gaming, VoIP and DNS — where waiting for retransmissions would hurt more than dropping a packet. The right protocol depends on whether completeness or timeliness matters more.
Step 6/ 6· Worked examples2 min
Problem
For each application, choose TCP or UDP and justify with the specific property that matters: (a) transferring a bank statement PDF, (b) a live video call, (c) a DNS lookup, (d) online multiplayer game position updates. Then explain what "reliability" costs in latency.
Try it on paper first.
Recall
Keep this
"TCP vs UDP" is a networking interview certainty — it tests whether you understand the reliability-vs-speed trade-off and can match protocols to use cases. Know the differences cold and which real protocols use each.
TCP (Transmission Control Protocol) is connection-oriented and reliable: it sets up a connection (3-way handshake), guarantees ordered, error-checked, retransmitted delivery, and provides flow and congestion control. UDP (User Datagram Protocol) is connectionless and unreliable: fire-and-forget datagrams with no handshake, ordering, or retransmission — but far lower overhead and latency.
| Aspect | TCP | UDP |
|---|---|---|
| Connection | connection-oriented | connectionless |
| Reliability | guaranteed | best-effort |
| Ordering | yes | no |
| Speed | slower | faster |
| Header | 20 bytes | 8 bytes |
| Flow/congestion control | yes | no |
"TCP vs UDP", "which uses UDP: DNS or FTP?", "why is UDP faster?", "header sizes", "what does TCP provide that UDP doesn't?", and matching protocols to their transport.
TCP: connection-oriented, reliable, ordered, flow/congestion control, 20-byte header — HTTP/email/FTP. UDP: connectionless, best-effort, unordered, 8-byte header, low latency — DNS/streaming/VoIP/gaming/DHCP. Choose TCP for correctness, UDP for speed. HTTP/3 uses QUIC over UDP.
You've read 0 of 6 steps
Now lock it in — questions straight after reading are what make it stick.