Packet.School
HomeLevelsSandboxFreeAbout
XP0
L3 · Protocols
Level 3
5 lessons
  • 01HTTP/HTTPS
  • 02How DNS Works?
  • 03DHCP
  • 04TCP vs UDP
  • 05Level 3 Quiz
Levels/L3 · Protocols/Lesson 04
Simulation · 04

TCP vs UDP

The transport layer's two main protocols: TCP chooses reliability, UDP chooses speed. Knowing which application uses which is half of reading network traffic.

Duration
3min
Level
L3
Type
Simulation
Progress
4/ 5

01Core differences

FeatureTCPUDP
ConnectionConnection-orientedConnectionless
ReliabilityGuaranteed deliveryNo guarantee
OrderingIn-order deliveryUnordered
SpeedSlowerFast
OverheadHighLow

02TCP — like a phone call

First a connection is established, you confirm the other side is listening, then you talk.

Its features

  • 3-way handshake — connection setup
  • Sequence numbers — pieces are put back in order
  • Acknowledgments — every packet is confirmed
  • Retransmission — lost packets are sent again
  • Flow control — slows down to the receiver's pace

TCP connection setup

code
Client         Server
  |--- SYN --->|
  |<-- SYN+ACK-|
  |--- ACK --->|
  [Connection established]

TCP data transfer

code
Data 1 →→→ ACK 1
Data 2 →→→ ACK 2
Data 3 →→→ LOST!
Data 3 →→→ ACK 3   (noticed, retransmitted)

03UDP — like a letter

Drop the envelope in the box and move on. Did it arrive? In order? UDP doesn't care.

code
Data 1 →→→ arrived
Data 2 →→→ arrived
Data 3 →→→ lost (nobody noticed)
Data 4 →→→ arrived

That indifference isn't a flaw — it's a deliberate trade: a protocol that never waits for confirmation keeps latency at a minimum.

04When to use which?

Use TCP — when every byte matters

  • Websites (HTTP/HTTPS)
  • Email (SMTP, IMAP)
  • File transfer (FTP)
  • SSH connections

Use UDP — when speed is everything

  • Online games
  • Video streaming and live broadcasts
  • VoIP (voice calls)
  • DNS queries
  • DHCP

An online game uses both at once: your character's position flows over UDP (a lost frame is corrected by the next one), while a purchase goes over TCP (it absolutely must arrive).

Modern note: QUIC
HTTP/3 runs on QUIC, which rides on UDP — providing reliability and encryption in its own layer. "UDP is unreliable" still holds; QUIC simply builds reliability on top of it.

05Try it yourself

See what latency and packet loss actually look like by measuring them:

Sandbox · CommandPing & TracerouteCompare latency, packet loss, and hop counts across different destinations.Open tool

06Summary

  • TCP = reliable but costly: web, email, files
  • UDP = fast but no guarantees: games, video, DNS
  • One application can use both at the same time
  • HTTP/3 (QUIC) builds its own reliability on top of UDP
Previous
DHCP
Next
Level 3 Quiz
On this page
  • Core differences
  • TCP — like a phone call
  • UDP — like a letter
  • When to use which?
  • Try it yourself
  • Summary
Packet.School

An open, interactive curriculum for computer networking.

v3.0 · MIT22 lessons live

Learn

  • Lessons
  • Sandbox
  • Levels
  • Free
  • About

Simulations

  • Packet Journey
  • DNS Lookup
  • DHCP Simulator
  • Subnet Calc
  • Network Builder
  • Terminal

Project

  • About
  • Changelog
  • GitHub
  • Contributing
  • Style guide

Newsletter

One short email when a new level ships. No tracking pixels.

© 2026 Packet.School — MIT licensedSupport with a coffeebuilt in the open