Computerphile
June 13, 2026
TL;DR
TCP creates a reliable connection between applications by using sequence numbers, acknowledgments, and a three-way handshake to ensure data arrives in order despite potential loss or corruption on the underlying network.
“What we want is a nice reliable pipe that we can pour bytes into. But actually what we've got underneath is a leaky pipe which we can have data loss, data corruption and packets might get out of order.”
— Host
“The job of our transport control protocol is to pretend that this manky leaky pipe that's corrupting and dropping our data, pretend that doesn't exist and pretend we've got a nice reliable pipeline.”
— Host
“If I get an acknowledgement for every packet and send a packet and get an acknowledgement it's just going to be painfully horribly slow.”
— Host
1. Introduction & Motivation
TCP operates on the transport layer to provide reliable delivery above the unreliable network layer. It masks the 'leaky pipe' of the internet by simulating a reliable connection between applications on different computers.
2. TCP Header Structure
TCP packets include headers with source/destination ports, sequence numbers, acknowledgment numbers, flags (SYN, FIN, ACK), and checksums to manage connection state and data integrity.
3. Three-Way Handshake
Connection establishment requires three steps: client sends SYN, server responds with SYN-ACK, client sends ACK. This creates matching sockets on both ends that persist for the duration of communication.
4. Handling Packet Loss & Ordering
Sequence numbers track data bytes sent, while acknowledgments confirm receipt. When packets are lost or arrive out of order, the receiver buffers out-of-sequence data and resends acknowledgments for missing packets to trigger retransmission.
5. Retransmission Mechanisms
TCP uses timeouts and duplicate acknowledgment detection to identify lost packets. Receiving the same ACK three times (triple duplicate) indicates loss, triggering immediate resend without waiting for timeout.
6. Window Size & Efficiency
Rather than waiting for acknowledgment after each packet, TCP allows multiple packets in flight simultaneously via a configurable window size, improving throughput while maintaining ordered delivery.
7. Security: SYN Flood Attack
Attackers can exhaust server resources by flooding with SYN packets, forcing the server to allocate memory for half-open connections. This denies service to legitimate users without requiring large payloads.