Networking7h estimated

TCP & UDP

Difficulty
Importance

The problem

Raw packets can arrive out of order, get duplicated, or vanish entirely — some applications (file transfer, web pages) need a guarantee that data arrives complete and in order, while others (video calls, gaming) would rather drop old data than wait for a guarantee. Two different transport protocols serve these two different needs.

Why now

The layered network model named the transport layer but not what it actually does; this topic fills that in with the two dominant answers — TCP's guarantee versus UDP's speed — and the tradeoff between them is a direct, practical instance of a tradeoff every engineer eventually has to make explicitly.

Mental model

TCP is a phone call: it sets up a connection, confirms every piece arrived (acknowledgments and retransmission), and hangs up cleanly — reliable, but with overhead. UDP is dropping a postcard in the mail: fire and forget, no confirmation, no guaranteed order, but fast and cheap. Choosing between them is choosing whether a lost message is worth resending or worth simply ignoring.

Requires

Unlocks

Used in

Projects

  • Use a packet capture tool (Wireshark or tcpdump) to observe a TCP three-way handshake for a real connection
  • Write a simple UDP client/server pair and deliberately demonstrate a dropped or out-of-order packet, contrasting it with TCP's guarantee

Examples

  • A slow or lossy network makes a TCP-based web page hang while it retransmits, rather than showing corrupted content
  • A video call using UDP would rather show one skipped frame than pause the entire call waiting to retransmit it

Resources

Mastery checklist