Networking
Networking: IP, TCP and UDP
Packets, addresses, ports, and the handshakes and congestion control that decide how fast your bytes arrive. Explains why a new connection is slow and how to check it on the wire.
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.
| Step | Concept | What it answers |
|---|---|---|
| 1 | Packets, layers and addresses | What is a packet, and how do addresses and subnets work? |
| 2 | TCP handshake and reliability | How does TCP set up and recover a reliable stream? |
| 3 | Congestion control and BDP | Why is a new connection slow, and how much data must be in flight? |
| 4 | TCP latency traps and UDP | When does TCP's ordering hurt, and when should you use UDP? |
| 5 | Network tools | How 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
/nblock holds2^(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.
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.
Related
DNS
How names become addresses, which record types matter, how caching and TTLs shape change speed, and why DNS failures look like outages of everything else.
HTTP/1.1, HTTP/2 and HTTP/3
The protocol of the web. Separates HTTP's meaning (methods, status codes, caching) from its wire format, and shows how each version fixes the latency problem of the one before.
Cloud networking and VPCs
VPCs, subnets, routing, NAT, security groups and private connectivity in AWS and GCP, plus a three-AZ reference architecture and how to debug when A cannot reach B.