Guide

Every API call your service makes rides the same stack. Your bytes are cut into packets, stamped with addresses, carried across routers you do not control, and reassembled by a kernel that must guess how fast it may send. When an endpoint is slow for no visible reason, the cause is often down here. A new connection pays an extra round trip. A congestion window starts small. A lost packet stalls everything queued behind it.

Each layer wraps the one above it in its own header, and only the matching layer on the other side reads that header. Routers look only at the IP header. The endpoints look at TCP and above.

Concepts in this section

Read them in order. The first page covers the vocabulary, and the rest cover behavior and measurement.

StepConceptWhat it answers
1Packets, layers and addressesWhat is a packet, and how do addresses and subnets work?
2TCP handshake and reliabilityHow does TCP set up and recover a reliable stream?
3Congestion control and BDPWhy is a new connection slow, and how much data must be in flight?
4TCP latency traps and UDPWhen does TCP's ordering hurt, and when should you use UDP?
5Network toolsHow do you see the network for yourself?

Common mistakes

  • Treating every slow request as a bandwidth problem. For small API responses, round trips dominate.
  • Leaving connection timeouts unset. A TCP connection to a dead host can hang for minutes by default.
  • Opening a new connection per request. Each one pays the handshake and slow start again.
  • Overlapping VPC address ranges. Overlaps block peering and cause painful migrations later.

Key takeaways

  • A /n block holds 2^(32 − n) addresses. NAT lets private hosts share public addresses, and it has port and idle-timeout limits.
  • The TCP handshake costs one round trip before any request. Slow start means a new connection needs several more round trips to deliver even 100 KB.
  • Throughput is capped at window ÷ RTT. For small requests, round trips matter more than bandwidth.
  • UDP has no handshake or retransmission, so it fits when stale data is worthless, as with DNS and live video.

Further learning

Ben Eater's networking series builds the stack up from bits on a wire. His final episode decodes a real TCP connection packet by packet.

TCP connection walkthrough | Networking tutorial (13 of 13)Ben Eater

High Performance Browser Networking (Ilya Grigorik) covers TCP, UDP and HTTP performance in depth.

Cloudflare Learning Center has short explainers for most of these topics.