~/posts/networking/how-tcp-really-works.md
How TCP Really Works

How TCP Really Works

Most developers know TCP is 'reliable' — but what does that actually mean under the hood? Sequence numbers, SYN floods, slow start, and the three-way handshake demystified.

2 min read by admin fundamentals networking protocols tcp
~/posts/networking/how-tcp-really-works.md $ cat how-tcp-really-works.md
How TCP Really Works

The Three-Way Handshake

Before any data flows, TCP performs a three-way handshake: SYN → SYN-ACK → ACK. This establishes sequence numbers on both sides and confirms bidirectional reachability.

Sequence Numbers

Every byte of data is numbered. The receiver sends ACKs that say 'I've received everything up to byte N, send me N+1 next.' This is how TCP guarantees ordering and detects loss.

Slow Start

TCP doesn't blast data at line rate from byte one. It starts with a small congestion window and doubles it each round trip until it hits a threshold or detects loss. This is slow start — a deliberate ramp-up to probe available bandwidth.

CPP
#include 
using namespace std;

int main() {    
    int number;

    cout << "Enter an integer: ";
    cin >> number;

    cout << "You entered " << number;    
    return 0;
}

Head-of-Line Blocking

Because TCP guarantees order, a single lost packet blocks all subsequent packets from being delivered to the application — even if they've already arrived. This is the fundamental tension HTTP/3 + QUIC was designed to solve.

Some caption