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.
Start lesson 1- Layering
- Ethernet frames and MTU
- IP routing
- NAT
- Ports
- UDP and TCP
- The sockets API
- DNS resolution
- 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
- Reno to CUBIC to the BBR family
- Bufferbloat
- ECN and L4S
- Multipath TCP
- DNS over HTTPS
- HTTPS DNS records that advertise HTTP/3
Lessons
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
Module lab
- Capture a
curlwithtcpdumpand read it in Wireshark: handshake, TLS, data, close. - Use
tc netemto add 100 ms delay and 2% loss, then compare CUBIC and BBR withiperf3. - Reproduce a Nagle and delayed-ACK stall with two small writes, measure it, then fix it with one write and with
TCP_NODELAY. - 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.