Module 1.6 30 minBeginner

TCP, UDP, and well-known ports

Layer 4 picks one of two transport protocols. TCP is reliable and ordered; UDP is fast and lossy. This chapter explains the three-way handshake, sliding windows, port numbers, and the table of well-known ports worth knowing cold.

Sign up to read this chapter

What you'll learn

  • Describe the TCP three-way handshake and connection teardown.
  • Explain when an application chooses UDP over TCP.
  • Memorize the well-known ports for HTTP, HTTPS, SSH, DNS, DHCP, SMTP, FTP, Telnet, NTP, SNMP.

TCP — reliable, ordered, connection-oriented

TCP guarantees that bytes arrive in order with no losses. It does this with a connection setup (SYN, SYN-ACK, ACK), per-segment sequence numbers, acknowledgments, retransmissions, and a sliding window for flow control.

Cost: latency (the handshake adds a round trip) and overhead (20+ bytes of header per segment, plus state on both endpoints).

Client  ──SYN──────────▶  Server
Client  ◀──SYN, ACK───  Server
Client  ──ACK──────────▶  Server
        (connection established — data flows)

UDP — fast, lossy, connectionless

UDP just sends datagrams. No handshake, no retransmissions, no ordering guarantees. The header is only 8 bytes. If a datagram is lost, the application either accepts the loss or rebuilds reliability on top.

Under packet loss the two behave very differently. TCP detects loss ITSELF — from duplicate ACKs or a retransmission timeout, not from ICMP messages (routers that drop for congestion send none) — then retransmits and shrinks its congestion window, growing it back slowly, so even 2% loss collapses bulk-transfer throughput.

UDP never asks for retransmission (its checksum only lets the receiver discard a corrupt datagram), so a voice codec keeps sending at its fixed rate and losses are heard as gaps. Routers do not run congestion control per flow; that lives in the TCP endpoints.

When you choose UDP: real-time voice and video (a delayed packet is worse than a missing one), DNS queries (one tiny request, one tiny reply), and DHCP (the client doesn't even have an IP yet).

10 more sections in this chapter, plus a 4-question quiz.

Account required

Create a free account to read Chapter 1.6 — TCP, UDP, and well-known ports

You can see the title, summary, and learning objectives. To read the chapter and build the labs, create a free account — Module 1 is fully readable on the free plan.

  • Read every chapter in Module 1 — How Networks Work
  • Save labs of up to 5 devices
  • Save up to 3 topologies
  • See the full course syllabus + chapter titles

Free account · no card required · compare plans any time