🟣 Phase 5 · Transport & Application 🟡 Intermediate MODULE 14

Transport Layer

⏱️ 4 hours
📖 8 sections
🧩 10 Questions
🏗️ Intermediate
CCNA Module 14 progress82%
🎯 What you'll learn: The role of the Transport Layer, TCP vs UDP and when each is used, TCP and UDP header fields, port numbers and socket pairs, the TCP three-way handshake and session termination, TCP reliability and flow control, and how UDP handles communication without those guarantees.

Role of the Transport Layer

The Transport Layer (Layer 4) sits between the Application Layer and the Network Layer. Its job is to manage the actual transport of data between applications running on source and destination hosts — not just between devices, but between specific processes running on those devices.

Tracking
Multiple Conversations
A single host can have many simultaneous conversations (browser tabs, email, chat) — the Transport Layer keeps each one separate using port numbers.
Segmentation
Breaking Data into Pieces
Application data is segmented into manageable chunks that fit within the constraints of the lower layers, then reassembled correctly at the destination.
Identifying Apps
Port Numbers
Each segment/datagram is tagged with source and destination port numbers, identifying exactly which application or service it belongs to.

The Transport Layer offers two very different protocols, and choosing between them is one of the most important design decisions an application makes:

TCP
Reliable, connection-oriented
UDP
Fast, connectionless
L4
OSI Layer 4 — Transport
65,535
Max port number (16-bit field)

TCP Overview

TCP (Transmission Control Protocol) is a connection-oriented protocol that guarantees reliable, ordered, and error-checked delivery. It is used whenever data integrity matters more than speed — web browsing, email, file transfer.

Connection-Oriented
Three-Way Handshake
A session is established before any data is sent, and formally closed afterward.
Reliable
Guaranteed Delivery
Lost segments are detected and retransmitted automatically using sequence numbers and acknowledgments.
Ordered
Sequencing
Segments arriving out of order are reassembled in the correct order before being passed to the application.
Flow Control
Window Size
TCP paces transmission so a fast sender doesn't overwhelm a slow receiver.
TCP Header Fields (simplified)
TCP
Key TCP header fields:
Source Port        16 bits — identifies sending application
Destination Port   16 bits — identifies receiving application
Sequence Number    32 bits — tracks byte order for reassembly
Acknowledgment Number 32 bits — next byte the receiver expects
Window Size        16 bits — how much data the receiver can accept
Flags              SYN, ACK, FIN, RST, PSH, URG — control the connection
Checksum           16 bits — error detection

Applications that rely on TCP include HTTP/HTTPS (web), SMTP/IMAP/POP3 (email), and FTP (file transfer) — anywhere a missing or corrupted byte would break the result.

UDP Overview

UDP (User Datagram Protocol) is connectionless and provides no reliability, ordering, or flow control. It simply sends datagrams and moves on — making it far faster and lower-overhead than TCP, at the cost of any delivery guarantee.

Connectionless
No Handshake
No session setup or teardown — the sender just transmits, with no negotiation beforehand.
Unreliable
Best-Effort Delivery
Lost datagrams are not detected or retransmitted by UDP itself — if reliability is needed, the application must handle it.
Low Overhead
Minimal Header
Just 8 bytes (source port, destination port, length, checksum) versus TCP's 20+ bytes — far less processing per packet.
UDP Header Fields
UDP
UDP header — only 4 fields, 8 bytes total:
Source Port        16 bits
Destination Port   16 bits
Length             16 bits — size of header + data
Checksum           16 bits — error detection only, no recovery

UDP is the right choice when speed matters more than perfection — DNS lookups, DHCP, streaming video/audio, and VoIP all use UDP. A dropped video frame or a missed voice packet is far less disruptive than the delay TCP's retransmission would introduce.

Why VoIP Prefers UDP Over TCP
If a TCP retransmission delayed a lost voice packet by even half a second, the conversation would already have moved past that point — the late packet is worthless once it arrives. UDP simply drops it and moves on, keeping the call flowing in near real-time, even if a tiny gap is occasionally audible.

Port Numbers

Port numbers let a single IP address support many simultaneous conversations. Combined with the IP address, a port number forms a socket — and a pair of sockets (source + destination) forms a socket pair, which uniquely identifies one specific conversation.

Socket and Socket Pair
Example
Socket = IP address : Port number
192.168.1.10:51422   (client socket — random high port)
93.184.216.34:443    (server socket — well-known HTTPS port)

Socket Pair = source socket + destination socket — uniquely identifies ONE conversation
192.168.1.10:51422 ↔ 93.184.216.34:443

Port numbers are divided into three ranges:

0–1023
Well-Known Ports
Reserved for common services: 80 (HTTP), 443 (HTTPS), 53 (DNS), 25 (SMTP), 22 (SSH).
1024–49151
Registered Ports
Assigned to specific applications by vendors, e.g. 3306 (MySQL), 1433 (SQL Server).
49152–65535
Dynamic/Private Ports
Temporarily assigned by the client OS for the duration of a conversation — also called ephemeral ports.
View Active Connections — netstat
Windows/Linux
C:\> netstat -n
Proto  Local Address          Foreign Address        State
TCP    192.168.1.10:51422    93.184.216.34:443     ESTABLISHED
TCP    192.168.1.10:51500    142.250.80.46:443     ESTABLISHED

TCP Communication Process

Before any data flows, TCP establishes a session with the three-way handshake — a synchronized exchange that confirms both sides are ready and agrees on starting sequence numbers.

🤝 TCP Three-Way Handshake
Client
SYN (seq=100) →
Server
← SYN-ACK (seq=300, ack=101)
Client
ACK (ack=301) →
Connection Established — data transfer begins

Session termination uses a similar but distinct exchange — each side sends a FIN to signal it's done sending, and the other acknowledges it. Because each direction is closed independently, a full graceful close takes four messages (FIN/ACK from each side).

💡
Why Three Steps, Not Two?
Two steps would only confirm one direction works. The third step (the client's final ACK) confirms the client received the server's SYN-ACK — proving both directions of the connection are functional before any application data is sent.

Reliability and Flow Control

TCP's reliability comes from sequence numbers and acknowledgments. Every byte sent is numbered; the receiver acknowledges the next byte it expects, letting the sender know exactly what arrived and what needs to be resent.

Sequence Numbers and Retransmission
TCP
Sender transmits 3 segments:
Segment 1: seq=1000, 500 bytes  →  received, ACK=1500 sent
Segment 2: seq=1500, 500 bytes  →  LOST in transit
Segment 3: seq=2000, 500 bytes  →  received, but ACK=1500 sent again (duplicate)

Sender sees duplicate ACK=1500 → knows Segment 2 was lost
Sender retransmits Segment 2 (seq=1500)
Receiver now has 1000-2500 contiguous → sends ACK=2500

Flow control prevents a fast sender from overwhelming a slow receiver. The receiver advertises a window size — the amount of data it can accept before needing an acknowledgment — and the sender respects that limit, adjusting dynamically as conditions change.

Window Size
Receiver-Advertised Limit
How many unacknowledged bytes the sender may have in flight at once. Shrinks if the receiver's buffer fills up.
MSS
Maximum Segment Size
The largest amount of data TCP will put in a single segment, negotiated during the handshake to avoid fragmentation.
Congestion Avoidance
Adapting to Network Conditions
TCP reduces its sending rate when it detects packet loss (a sign of congestion), then gradually increases it again.

UDP Communication

Because UDP has no concept of a session, the server process must be ready to listen continuously, and the client simply sends a datagram whenever it has data — no setup, no teardown. There is no window size, no sequence numbers, no retransmission.

UDP Client/Server Flow — DNS Example
UDP
! Client sends a single DNS query datagram — no handshake
Client (192.168.1.10:52000)  →  DNS query for "example.com"  →  Server (8.8.8.8:53)

! Server responds with a single datagram — also no handshake
Server (8.8.8.8:53)  →  DNS answer: 93.184.216.34  →  Client (192.168.1.10:52000)

! If the query or response is lost, the application (not UDP) decides whether to retry

UDP datagrams that arrive out of order are simply delivered in the order they arrive — reassembly into the correct sequence, if it matters at all, is left entirely to the application. This is why streaming applications often build their own light reordering buffer on top of UDP rather than relying on TCP's heavier mechanism.

⚠️
UDP's Simplicity Is the Whole Point
It's tempting to think of UDP as "TCP but worse" — but for the right application, UDP's lack of overhead is a feature, not a flaw. The choice between TCP and UDP should always be driven by whether perfect delivery matters more than low latency for that specific use case.

The Right Protocol for the Right Application

Every application developer makes a deliberate choice between TCP and UDP based on what the application actually needs.

TCP — Port 80/443
Web Browsing (HTTP/HTTPS)
A web page must arrive completely and correctly — a missing byte could break the rendered page.
TCP — Port 21
File Transfer (FTP)
A corrupted file is useless — reliability is non-negotiable here.
UDP — Port 53
DNS Lookups
Queries are small and fast; if one is lost, the client just asks again — TCP's overhead would slow every lookup.
UDP — Port 67/68
DHCP
Broadcast-based address assignment happens before a device even has an IP — TCP's connection setup isn't practical yet.
UDP — Various
Streaming Video/Audio, VoIP
Real-time delivery matters more than perfect delivery — a late packet is worse than a dropped one.
TCP — Port 22/23
SSH / Telnet (Remote Access)
Every keystroke and command output must arrive intact and in order for the session to function correctly.
🔬
Challenge — TCP or UDP?
Apply the decision criteria to real applications
Task: For each application below, decide whether TCP or UDP is the better fit, and justify why in one sentence:

   1. A live multiplayer game sending player position updates 30 times per second
   2. An online banking application transferring funds between accounts
   3. A network time sync client checking the current time once per hour
   4. A software update tool downloading a 2 GB installer file
💡 Show suggested answers
  • 1. UDP — a slightly stale position update is fine; waiting for retransmission would feel laggy
  • 2. TCP — a financial transaction absolutely must arrive completely and correctly, every time
  • 3. UDP (NTP uses it) — fast, low-overhead, and the client can simply retry if a packet is lost
  • 4. TCP — a corrupted or incomplete installer file is unusable; integrity matters far more than speed
🧩 Knowledge Check
10 questions — Transport Layer
1. Which Transport Layer protocol guarantees ordered, reliable delivery?
2. How many bytes does a standard UDP header occupy?
3. Which port range is reserved for well-known services like HTTP and DNS?
4. What is the correct order of flags in a TCP three-way handshake?
5. A socket pair uniquely identifies:
6. Which application protocol typically uses UDP rather than TCP?
7. TCP flow control uses the receiver's advertised window size to:
8. How does TCP detect that a segment was lost in transit?
9. Ephemeral (dynamic/private) ports are typically used by:
10. Why do real-time applications like VoIP typically prefer UDP over TCP?
Finished this module?
Mark it complete to track your CCNA progress.
🎉
Module 14 Complete!
You now understand TCP vs UDP, port numbers, the three-way handshake, and how reliability and flow control actually work. Next — Application Layer!
← Course Home
Phase 5 · CCNAModule 14 of 17
🗒 Cheat Sheet 📝 Worksheet