› Module 6: The Transport Layer › 6.2 The TCP Three-Way Handshake & Connection Teardown
M O D U L E

Module 6: The Transport Layer

End-to-end process-to-process delivery, TCP vs UDP, 3-way handshake, and congestion control

6.1 TCP vs UDP: Protocols & Characteristics

The Transport Layer (Layer 4) provides direct logical communication between application processes running on distinct hosts using 16-bit Port Numbers.

Figure 6.1: TCP (Reliable Connection) vs UDP (Fast Connectionless) TCP (Transmission Control Protocol) • Connection-oriented: 3-way handshake • Reliable: ACKs & automatic retransmissions • In-order delivery: Byte sequence numbers • Congestion & Flow Control: Built-in cwnd & rwnd • Header Size: 20 - 60 bytes Ideal for: HTTP, HTTPS, FTP, SSH, SMTP (Where data correctness is paramount) UDP (User Datagram Protocol) • Connectionless: Fire-and-forget datagrams • Unreliable: No acknowledgments or retries • No ordering: Datagrams can arrive out of order • Zero flow control: Blazingly fast, lowest latency • Header Size: Exactly 8 bytes fixed Ideal for: DNS, VoIP, Video Streaming, Gaming (Where real-time speed beats retransmission)

Figure 6.1: Technical comparison between connection-oriented TCP and lightweight connectionless UDP.

6.2 The TCP Three-Way Handshake & Connection Teardown

Before exchanging payload data, TCP establishes a virtual connection using a Three-Way Handshake to synchronize Initial Sequence Numbers (ISNs) and negotiate buffer window sizes.

Figure 6.2: The TCP Three-Way Handshake (SYN → SYN-ACK → ACK) Client Host Server Host 1. SYN (seq = x) 2. SYN-ACK (seq = y, ack = x + 1) 3. ACK (ack = y + 1) Connection ESTABLISHED • Full-Duplex Data Transfer

Figure 6.2: The classic TCP 3-way handshake establishing bidirectional sequence synchronization between client and server.

6.3 TCP Congestion Control (Slow Start & Sawtooth Curve)

While TCP Flow Control protects the receiver from buffer overflow, TCP Congestion Control protects the intermediate routers and network fabric from collapse due to excessive load.

Figure 6.3: TCP Congestion Control Sawtooth Curve (Slow Start vs Congestion Avoidance) Time (RTTs) → cwnd ssthresh Packet Loss! Packet Loss! Slow Start (2^x) Avoidance (+1/RTT)

Figure 6.3: TCP AIMD (Additive Increase, Multiplicative Decrease) producing the characteristic sawtooth throughput profile.

MODULE COMPREHENSIVE QUIZ

Module 6 Final Quiz

Test your understanding across all 3 topics of this module with interview-grade questions, tricky edge cases, and code output predictions.

Take Module 6 Final Quiz →
Yukti Mascot