Glossary

TCP (Transmission Control Protocol)

TCP is the transport protocol that turns the unreliable packet delivery of IP into an ordered, error-checked byte stream between two programs, which is why web, mail, SSH and databases are built on it.

What does TCP add on top of IP?

IP moves individual packets and promises nothing: they can be lost, duplicated, reordered or delayed. TCP numbers every byte it sends, waits for the receiver to acknowledge them, resends whatever is missing, and hands the data to the application in the original order. It also paces the sender so it neither overwhelms the receiver nor floods the network. Programs just write to and read from a socket; all the bookkeeping happens in the kernel. UDP describes the lighter alternative that skips these guarantees.

How does the three-way handshake work?

Before any data flows, the two sides agree on starting sequence numbers:

  • The client sends a SYN with its initial sequence number and options such as maximum segment size and window scaling.
  • The server replies with SYN-ACK, acknowledging the client number and offering its own.
  • The client answers with ACK, and the connection is established.

That costs one round trip before the first byte of a request, which is why latency matters so much for short web requests; a visitor 150 ms away pays it on every new connection unless keep-alive or connection reuse is in play. Closing takes a FIN from each side, and the side that closes first waits in TIME_WAIT to catch stray late packets.

What are windows, and why do they matter on fast links?

The receive window tells the sender how many unacknowledged bytes it may have in flight. To fill a link, that amount must at least equal bandwidth times round-trip time. A 10 Gbps port to a peer 80 ms away needs about 100 MB in flight; the original 64 KB window would cap that path at a few megabits. Window scaling, negotiated during the handshake, lifts the limit, and Linux grows buffers automatically within the bounds set by net.ipv4.tcp_rmem and tcp_wmem. With the 2x 10 Gbps ports on single CPU models, raising the maximums helps long-distance transfers:

cat > /etc/sysctl.d/60-tcp-longhaul.conf <<'EOF'
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.ipv4.tcp_rmem = 4096 131072 134217728
net.ipv4.tcp_wmem = 4096 65536 134217728
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
EOF
sysctl --system | grep -E 'tcp_(r|w)mem|congestion'

What does congestion control do?

It guesses how much the network path can carry and adjusts the sending rate. Loss-based algorithms such as CUBIC, the Linux default, grow the rate until packets drop, then back off. BBR instead models the path's bottleneck bandwidth and round-trip time, which keeps queues shorter and often moves more data on long, slightly lossy paths, for example between Phoenix and Singapore. Check what is available with sysctl net.ipv4.tcp_available_congestion_control; the BBR module ships with the kernels in all our Linux images.

Which connection states will I see on a server?

StateMeaningWhen to worry
LISTENA service waiting for connectionsWhen the port should not be public
SYN-RECVHandshake started, final ACK pendingThousands at once can mean a SYN flood
ESTABLISHEDActive connectionRarely; it is normal traffic
TIME-WAITClosed, waiting out late packetsTens of thousands on a proxy making many short upstream calls
CLOSE-WAITPeer closed, our app has notA growing count usually points to an application bug

Count them with ss -tan | awk 'NR>1{print $1}' | sort | uniq -c | sort -rn. The ss command explains the filters.

How does TCP behave under attack?

The classic attack is a SYN flood: many handshakes started and never finished, filling the queue of half-open connections. Linux answers with SYN cookies, enabled by default, which encode the connection details in the sequence number so no memory is held until the final ACK arrives. Large floods are absorbed before they reach the machine by edge filtering on our network, described on Edge DDoS filtering.

What is the maximum segment size?

The MSS is the largest chunk of payload one TCP segment carries, announced by each side in its SYN. On a standard 1500-byte Ethernet path it is 1460 bytes for IPv4, after 20 bytes of IP header and 20 of TCP header. Tunnels shrink it: WireGuard adds about 60 bytes of overhead, so traffic inside a tunnel needs a smaller MSS or the interface MTU set to 1420. When large transfers stall while small requests work, a mismatched MTU combined with blocked ICMP is the usual cause, and clamping the MSS on the tunnel interface fixes it.

How can I measure TCP throughput between two machines?

Run iperf3 -s on one box and iperf3 -c 203.0.113.90 -P 4 -t 20 on the other. Parallel streams show what the path can carry; a single stream shows what one connection reaches with the current buffers and congestion algorithm. Compare before and after tuning, and test in both directions with -R, since routes are not always symmetric.

Machines With 10 and 25 Gbps Ports

ServerProcessorCores / threadsMemoryStorageNetworkPer monthSmallest order
S1Intel Xeon E-2276G6 / 1264 GB DDR41x 1 TB NVMe2x 10 Gbps$53.32$53.32 (1 month)
S6Intel Xeon E-2288G8 / 1664 GB DDR42x 1 TB NVMe2x 10 Gbps$89.92$89.92 (1 month)
S13AMD EPYC 4345P8 / 16128 GB DDR52x 2 TB NVMe2x 25 Gbps$237.92$237.92 (1 month)
D22x Intel Xeon Gold 531724 / 48128 GB DDR42x 1 TB NVMe2x 25 Gbps$223.57$223.57 (1 month)

Keep Reading

UDP

The connectionless transport behind DNS, games, voice and QUIC, what it trades away compared with TCP, and how to run UDP services well.

Open

Latency

Why distance sets the floor for ping time, how to estimate round trips between our six cities and how to choose a location.

Open

Port speed

What 1, 10 and 25 Gbps network ports mean in real transfer times, and which of our 68 machines carry each speed.

Open

The ss command

List sockets fast with ss: listening ports, filters by state, port and address, TCP internals like RTT, summaries and killing stuck sockets.

Open

FAQ

Quick Answers

It numbers and acknowledges every byte, retransmits anything lost and delivers data in order, so applications receive exactly what was sent.

SYN, SYN-ACK and ACK. The exchange sets up sequence numbers and options before data flows, costing one round trip.

It often improves throughput on long or lossy paths. It is safe to try with fq queuing and easy to switch back to CUBIC.

The remote side closed the connection but the local application never closed its socket, which usually indicates a bug in that application.

Linux SYN cookies handle moderate floods on the host, and edge DDoS filtering on the network absorbs large ones.