Workspace

Packets & TCP

3 day streakD
Systems syllabus
PHASE 02 · MODULE 04

Networking from packets to TCP.

The internet delivers packets with no promises. TCP builds a reliable, ordered byte stream on top, and every protocol above it inherits its costs.

Latency is limited by distance and throughput by window size divided by round-trip time. TCP is a byte stream with no message boundaries, so one read may return half a message or three. And every TCP sender has to discover the network's capacity by probing it, which is why a new connection starts slow.

7 lessons136 minutes of reading7 illustrations
Start lesson 1
Basics
  • Layering
  • Ethernet frames and MTU
  • IP routing
  • NAT
  • Ports
  • UDP and TCP
  • The sockets API
  • DNS resolution
Depth
  • Three-way handshake
  • Sequence numbers
  • Flow and congestion windows
  • Retransmission and SACK
  • Slow start
  • Nagle and delayed ACK stalls
  • TCP_NODELAY
  • TIME_WAIT
  • Ephemeral port exhaustion
  • Path MTU discovery
  • NAT idle timeouts
Current
  • Reno to CUBIC to the BBR family
  • Bufferbloat
  • ECN and L4S
  • Multipath TCP
  • DNS over HTTPS
  • HTTPS DNS records that advertise HTTP/3

Lessons

  1. 01Layers, frames and packetsEvery message you send is wrapped in headers, one per layer, and cut to fit the smallest pipe on the path. Learn what each layer adds and why 1,500 bytes rules everything.Basics20 min
  2. 02Addresses, routing, ports and NATHow a packet finds one machine among billions, then one program on that machine, and why the box in the middle that rewrites addresses silently kills idle connections.Basics18 min
  3. 03DNS: from a name to an addressBefore any connection, a name must become an address. Learn the resolution chain, why caches make DNS fast and stale at once, and what HTTPS records add in 2026.Basics16 min
  4. 04UDP, TCP and the byte streamUDP sends datagrams and promises nothing. TCP promises an ordered, reliable stream of bytes, but not messages. Learn why every protocol on top of TCP must frame its own messages.Basics18 min
  5. 05The handshake, sequence numbers and retransmissionHow TCP turns lossy packets into a reliable stream: numbered bytes, acknowledgements, timers and selective repair. Then the leftovers: TIME_WAIT and running out of ports.Depth22 min
  6. 06Windows, bandwidth-delay and small-write stallsThroughput is window divided by round-trip time. Learn the bandwidth-delay product, why a fat pipe can feel slow, and the classic Nagle plus delayed-ACK stall.Depth20 min
  7. 07Congestion control: from Reno to BBRNobody tells a TCP sender how fast the network is. Learn how slow start and AIMD probe for capacity, why CUBIC and BBR changed the curve, and what bufferbloat and L4S are about.Current22 min

Module lab

  1. Capture a curl with tcpdump and read it in Wireshark: handshake, TLS, data, close.
  2. Use tc netem to add 100 ms delay and 2% loss, then compare CUBIC and BBR with iperf3.
  3. Reproduce a Nagle and delayed-ACK stall with two small writes, measure it, then fix it with one write and with TCP_NODELAY.
  4. Write a length-prefixed frame reader and fuzz it with random chunk sizes.

Interview questions

What happens when you type a URL?

DNS lookup, TCP handshake (1 RTT), TLS handshake (1 RTT for TLS 1.3), request and response (1 RTT), with slow start limiting the first response. Count the round trips.

A quiet five-minute stream died with no error. Why?

A NAT or proxy idle timeout dropped its state. Send heartbeats more often than the shortest idle timeout.

Why is a large download slow on a long link?

Throughput ≤ window ÷ RTT. If the window is below the bandwidth-delay product, the link is underused.

Read

  • High Performance Browser Networking, Ilya Grigorik (free online)
  • Beej's Guide to Network Programming
  • RFC 9293: Transmission Control Protocol
  • BBR: Congestion-Based Congestion Control, Cardwell et al.

A good place to start

Explore a pattern

A little guidance

Start with a pattern, read through a problem, and mark it solved when the idea clicks. Save anything you want to revisit.

New tutorials are added one at a time. Your bookmarks and solved checkmarks stay in this browser.

Explore the roadmap