Networking
Follow a request across the internet: packets and addresses, TCP and UDP, DNS and HTTP, then TLS and caching. You finish able to read a curl transcript and say which layer is broken.
- Beginner
- 4 units, 12 lessons, 154 exercises
- Text, a little shell
- Builds on Linux & the Shell helps
Unit 01 · 3 lessons
Packets and addresses
Follow a small labelled envelope from your laptop to a server, one hop at a time
- 01Layers
Envelopes inside envelopes: what each layer adds
- 02Addresses and routes
IP addresses, prefixes, NAT and hop-by-hop routing
- BOSSFollow one packet
Ports, sockets, ARP and NAT: one request traced end to end
Read the unit guide
The internet does not reserve a line between you and a server. It cuts your data into packets of about 1,500 bytes, labels each with a source and a destination address, and lets every packet find its own way. One cable carries millions of conversations because no conversation owns it.
The work is split into four layers, each trusting the one below. Application (HTTP, DNS) decides what to say. Transport (TCP, UDP) decides which program gets it, using port numbers. Internet (IP) decides which machine, using IP addresses. Link (Wi-Fi, Ethernet) carries it to the next hop, using MAC addresses. Each layer wraps the data from the layer above in its own header: envelopes inside envelopes.
An IPv4 address is 32 bits, written as four numbers from 0 to 255. A prefix such as /24 says how many leading bits name the network; the rest name the host, so a /24 holds 2⁸ = 256 addresses and a /26 holds 64. Anything outside your own network goes to the default gateway, your router.
Routers forward hop by hop. Each one reads only the destination IP, picks the next hop from its routing table, and subtracts 1 from the packet's TTL. A packet whose TTL reaches 0 is thrown away, which stops loops and is the trick traceroute uses to list the path.
Addresses starting 10., 172.16. to 172.31. and 192.168. are private: every home reuses them. Your router swaps in its one public address on the way out and keeps a table to hand replies back. That is NAT. IPv6, with 128-bit addresses, removes the shortage that made NAT necessary.
A connection is named by four values: source IP, source port, destination IP, destination port. Servers listen on well-known ports (443 HTTPS, 80 HTTP, 22 SSH, 53 DNS); your side gets a random high port. On the way, the IP addresses stay put while the MAC addresses change at every hop.
Unit 02 · 3 lessons
TCP and UDP
Know the two promises you can ask the network for, and what each one costs
- 01TCP: a reliable stream
Handshake, sequence numbers, acks and resends
- 02UDP: fire and forget
No handshake, no order, no retries, and why that is useful
- BOSSWhy is it slow
Latency, bandwidth, windows and the cost of a round trip
Read the unit guide
IP makes no promises: a packet can be lost, duplicated, delayed or arrive out of order. The transport layer sits on top and offers two deals. TCP gives you a reliable, ordered stream of bytes. UDP gives you IP plus port numbers and gets out of the way.
TCP starts with a three-way handshake (SYN, SYN-ACK, ACK), which costs one round trip before any data moves. After that every byte is numbered. The receiver acknowledges with the number of the next byte it expects, the sender keeps a copy of everything unacknowledged and resends when a timer runs out, and the receiver reorders and drops duplicates. A "connection" is nothing but this state, held at the two ends.
UDP has no handshake, no acks, no ordering and no retries: an 8-byte header and off it goes. That suits one-shot questions like DNS, and live traffic like calls and games where a late packet is worse than a missing one. Whatever reliability the application needs, it adds itself. QUIC, which carries HTTP/3, is exactly that: a reliable protocol built on UDP.
TCP also paces itself. The receive window stops a fast sender flooding a slow receiver. The congestion window stops all senders together flooding the network: it starts small, doubles every round trip (slow start), and is cut when a packet is lost, because loss usually means a router's queue overflowed.
When something is slow, ask which number is the problem. Latency is the time for one trip, bandwidth is how much fits per second, throughput is what you actually get. Small transfers are dominated by round trips, so a nearer server beats a fatter line. And because TCP delivers strictly in order, one lost packet holds up everything behind it: head-of-line blocking.
Unit 03 · 3 lessons
Names and the web
Trace a URL from a name you can remember to a page on screen
- 01DNS
From a name to an address: the hierarchy, records and TTLs
- 02HTTP
Requests and responses as plain text: methods, status codes, cookies
- BOSSWhat happens when you press Enter
One URL, every step: DNS, TCP, TLS, HTTP, and three HTTP versions
Read the unit guide
Packets need IP addresses, people remember names, and DNS translates. It is a tree read right to left: root servers know who runs .com, the .com servers know who runs example.com, and that domain's own authoritative servers hold the records. Your laptop asks a recursive resolver, which walks the tree for you and caches what it learns.
Every record has a type and a TTL. A maps a name to an IPv4 address, AAAA to IPv6, CNAME makes one name an alias of another, MX says where mail goes, NS names the authoritative servers, TXT holds free text. The TTL is how many seconds a resolver may reuse the answer, which is why a change "takes time": old answers live on in caches until they expire. Lower the TTL before a planned move.
HTTP is plain text over a connection. A request is a method, a path and headers; a response is a status line, headers, a blank line and a body. Status codes come in families: 2xx worked, 3xx look elsewhere, 4xx you got it wrong, 5xx the server did.
Methods carry promises. GET is safe: it changes nothing. GET, PUT and DELETE are idempotent: doing them twice equals doing them once, so they are safe to retry. POST is neither. HTTP itself is stateless, so sites hand the browser a cookie and recognise it when it comes back.
Loading https://example.com/ is a chain: DNS lookup, TCP handshake, TLS handshake, HTTP request, response, then more requests for everything the page names. Each link costs a round trip, so browsers reuse connections. HTTP/1.1 sends one request at a time per connection, HTTP/2 multiplexes many streams over one TCP connection, and HTTP/3 moves those streams onto QUIC over UDP so that a lost packet stalls only its own stream.
Unit 04 · 3 lessons
Secure and fast
Lock the conversation with TLS, shorten it with caches, and find the layer that broke
- 01TLS
What HTTPS protects, how certificates build trust, what the padlock leaves out
- 02Caches and CDNs
Cache-Control, ETags and 304s, and copies kept close to users
- BOSSIt works on my machine
A diagnosis ladder: dig, ping, curl -v, status codes and CORS
Read the unit guide
HTTPS is HTTP sent through TLS. TLS promises three things: nobody on the path can read the traffic, nobody can change it unnoticed, and the server really is the site named in the address bar. The third promise rests on certificates: a certificate ties a name to a public key and is signed by a certificate authority your browser already trusts.
In the handshake the two sides swap key shares, the server presents its certificate, and both derive the same session key. Slow public-key maths is used only for that; the data itself is encrypted with the fast shared key. TLS 1.3 adds one round trip. What the padlock does not promise: that the site is honest, or that nobody can see which site you visited.
A cache is a stored copy of a response. Cache-Control: max-age=600 lets a copy be reused for 600 seconds without asking. A stale copy is revalidated: the browser sends If-None-Match with the copy's ETag, and a 304 Not Modified reply costs a few hundred bytes instead of the whole file. no-store is for things that must never be saved; private keeps them out of shared caches.
A CDN is a shared cache with machines near your users, which shortens every round trip. The standard recipe: give assets a hash in their filename and cache them for a year, and keep the HTML that names them on a short leash so a deploy is seen at once.
Debug from the bottom up and let each tool answer one question. dig: does the name resolve? ping: do packets reach the machine? curl -v: does TCP connect, does TLS finish, which status comes back? "Could not resolve" is DNS, "refused" means nothing is listening, a timeout means packets are vanishing, a 502 means a proxy could not get a good answer from the server behind it. And a CORS error is the browser enforcing the same-origin policy, not the network failing.
Learn Networking on your phone.
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.