Menu
Coddy logo textTech

TCP vs UDP

Lesson 18 of 32 in Coddy's The OSI Model course.

Layer 4 offers two services. TCP: connection, ordering, retransmission of anything lost; you pay for the guarantee with latency. UDP: fire single datagrams and hope; nothing is guaranteed, nothing is waited for.

The choice follows one question: is a late packet still useful? A file download must be complete, so TCP. A frame of a video call that arrives late is garbage, better to drop it and show the next one, so UDP. DNS queries are tiny one-shot questions where a retry is cheaper than a connection, so UDP.

challenge icon

Challenge

Beginner

Pick the right protocol for each job. Print one per line, uppercase, in this order:

  1. A live video call
  2. Downloading a zip file
  3. A DNS lookup

Expected output:

UDP
TCP
UDP

Try it yourself

Terminal

All lessons in The OSI Model

Practice on your own: Terminal playground