PracticeLabs
Week 1Lesson 5Required9 min estimated0% progress

TCP vs UDP

Decide when a flow needs TCP's guarantees and when it is better off with UDP's speed, and understand the handshake and port numbers that make Layer 4 delivery work.

Lesson orientation

What you'll learn (4 objectives)~9 min: video → lesson → check → apply → lab prep

Learning objectives

  • Contrast TCP and UDP on reliability, ordering, overhead, and typical applications
  • Describe the three-way handshake and what each segment establishes
  • Explain how port numbers let one host run many services on one IP address
  • Match common services to TCP or UDP and to their well-known ports

Terms you will see

TCPUDPConnection-orientedConnectionlessThree-way handshakeSequence numberAcknowledgmentRetransmissionWindowPortWell-known portEphemeral port

Time breakdown

  • Read the notes5 min
  • TCP Handshake Timeline tool4 min

Assigned video

Opens on YouTube
Recommended video

TCP & UDP (Day 30)

By Jeremy's IT Lab · Opens externally on YouTube

Watch time not yet confirmed for this video — the notes below cover everything this lesson requires.

The link opens in a new browser tab. Return here when you finish watching.

Watch for these concepts

  • The handshake drawn out segment by segment
  • How sequence and acknowledgment numbers relate to each other
  • Why some applications actively prefer to lose data rather than wait for it
  • Where port numbers appear in the header

Go beyond the video

The assigned video introduces the idea. CCNA Practice Labs completes the learning path: clarify core concepts, explore how each device behaves, visualize the communication path, check your understanding, and prepare for hands-on lab work.

Watch the concept → understand it → visualize it → practice it → apply it.

Two transports, one job, opposite trade-offs

Lesson 2 put a segment at Layer 4, between the application's data and the IP packet that carries it. Layer 4's job is to hand data from one process to another, and there are two protocols that do it in opposite ways. TCP guarantees the data arrives, in order and intact, and pays for that guarantee in setup time and overhead. UDP simply sends, with no promises at all — which makes it smaller and faster.

Neither is better. They are answers to different questions, and choosing between them is the point of this lesson.

TCP: reliable and connection-oriented

Before TCP sends any data at all, the two ends establish a connection with a three-way handshake:

  1. SYN — the client proposes a connection and states the sequence number it will start counting from.
  2. SYN-ACK — the server agrees, acknowledges the client's number, and states its own starting number.
  3. ACK — the client acknowledges the server's number. The connection is established and data can flow.

From then on every byte is numbered with a sequence number and confirmed with an acknowledgment. Anything that goes unacknowledged is retransmitted. A window size controls how much data may be in flight before the sender has to stop and wait, which keeps a fast sender from swamping a slow receiver. All of that machinery exists for one reason: to make sure what arrives is exactly what was sent. That is why web pages, remote shell sessions, and file transfers use TCP — a single missing byte would corrupt the result.

UDP: fast and connectionless

UDP has no handshake, no acknowledgments, and no retransmission. A datagram is addressed and sent, and the sender moves on without waiting to hear anything back.

That sounds like a disadvantage until you consider what TCP's guarantees actually cost. In a voice call, a lost audio sample retransmitted half a second later is useless — the conversation has moved on, and stopping to wait for it would be worse than the gap. The same reasoning applies to live video. Quick request-and-response services such as DNS and DHCP use UDP for a different reason: the exchange is so short that setting up a connection would cost more than simply asking again. Where an application does need reliability over UDP, it has to provide that itself.

Ports keep the flows apart

One host runs many things at once — a browser, a mail client, a file sync, each with traffic in flight. The IP address gets data to the right host, but something has to get it to the right process. That is what a port number does. Both TCP and UDP tag every flow with a 16-bit port number, giving a range of 0 to 65535.

Servers listen on well-known ports so clients know where to find them. Clients pick a temporary ephemeral port as the source of each new connection, so replies can be matched back to the right conversation. Put simply: the IP address finds the host, and the port finds the process.

TCP and UDP compared
PropertyTCPUDP
Connection setupThree-way handshake firstNone — send and forget
ReliabilityAcknowledged and retransmittedBest effort
OrderingReassembled by sequence numberNot guaranteed
Header overheadHigher — 20 bytes or moreLower — 8 bytes
SuitsWeb, SSH, email, file transferVoice, video, DNS, DHCP
Well-known ports80, 443, 22, 2553, 67/68, 69
Keep the three ideas separate
“Port 443” is not a protocol. HTTPS is the protocol, TCP is the transport carrying it, and 443 is the port number the server listens on. Exam questions routinely mix these up on purpose.

What you should retain

  • TCP is connection-oriented and reliable: handshake, sequencing, acknowledgments, retransmission — at the cost of overhead.
  • UDP is connectionless and best-effort: no handshake, no acknowledgments, minimal delay. Reliability becomes the application's problem.
  • The handshake is SYN → SYN-ACK → ACK, and it completes before any data moves.
  • Ports are 16-bit. Servers use well-known ports; clients use ephemeral ones.
  • Choose TCP when correctness matters and UDP when timeliness matters.
Pause and predictNot scored — nothing is recorded

Before you read on

A client opens a connection by sending a SYN with sequence number 1000. What acknowledgment number does the server put in its SYN-ACK, and what is it actually saying by choosing that number?

Interactive tool
Required~4 min

TCP Handshake Timeline

Step through the handshake and predict each sequence and acknowledgment value before you reveal it. The numbers are much easier to trust once you have had to work one out yourself.

Study deeper

Topic guides extend this lesson — they do not replace the first-party walkthrough above.

OSI Model & Packet Flow

For the full well-known port table and the transport-layer protocol reference — this lesson lists only the handful you need to recognise