Vol. I · No. 46The protocol sectionSat, 10 Oct 2026
Layer 4 · Transport protocol

TCP

the Transmission Control Protocol

TCP is how two programs get a reliable, ordered stream of bytes across an unreliable network. It opens a connection with a handshake, numbers every byte and acknowledges it, and resends anything that goes missing — the workhorse under the web, email and most of the internet.

TCP turns unreliable packets into a reliable, in-order byte stream — nothing lost, nothing out of order.

You can run this one

Open the TCP lab →

The three-way handshake, sequence and ACK numbers, and an honest four-way teardown.

Intermediate
Operates at
Layer 4
Transport
Protocol number
IP 6
rides on IP
Delivery
Reliable
ordered & acked
Connection
Stateful
3-way handshake

How it works

The three-way handshake, then the stream
ClientServer
SYNseq = x · “let’s talk”
SYN + ACKseq = y, ack = x+1
ACKack = y+1 · “agreed”
Connection established — bytes now flow both ways, each one acknowledged

Three messages agree on starting sequence numbers, so both sides can tell which byte is which and spot anything missing. Only then does data move.

Every segment carries this header
016 bits31
Source port
Destination port
Sequence number
Acknowledgement number
Offset
Flags · SYN ACK FIN RST
Window size
Checksum
Urgent pointer
Options (if any)
Data — the bytes being carried
The main points

What TCP does, step by step

1
Open with a handshake

SYN, SYN-ACK, ACK — both ends agree to talk and pick starting sequence numbers.

2
Number every byte

Data is split into segments, each byte given a sequence number so the far end can reassemble it in order.

3
Acknowledge & retransmit

The receiver ACKs what arrived; anything unacknowledged is resent, so nothing is lost.

4
Control the flow

A sliding window and congestion control tune the send rate to what the receiver and network can handle — then a FIN closes it.

In cybersecurity

TCP’s connection state makes it reliable — and gives attackers state to exhaust and a session to hijack. On its own it carries no encryption.

SYN flood

Half-open connections pile up to exhaust the server; SYN cookies defend against it.

Session hijacking

Guessing or sniffing sequence numbers lets an attacker inject into a live connection.

RST injection

A forged reset packet can tear a connection down — a classic censorship and DoS trick.

No confidentiality

TCP sends in the clear — wrap it in TLS for privacy and integrity.

Port scanning

The handshake’s responses reveal which ports are open — the first step of recon.

State exhaustion

Every connection costs memory; floods of them are a denial-of-service vector.

Rides in the stack

IPTCPHTTP, TLS, …

Works with

UDPTLSHTTPIPv4

See it on Linux

rsyncdigsscurlwgetsshscpncnetstattraceroutemtrnmaptcpdumpnftiptablesufw

The header, in brief

Source portwho sent it
Destination portwhich service
Sequence numberbyte position
Acknowledgementnext expected
FlagsSYN · ACK · FIN · RST
Window sizeflow control