learninfra · Linux · Networking · Kubernetes · System Design · AI Infrastructure · Exam blueprints · Drills

What Happens When You Hit Enter

One URL, four conversations: DNS, TCP, TLS and HTTP, what each one costs, and which one failed when the page does not load.

An interactive Networking lesson: 21 steps, about 30 minutes, on a live simulation in your browser.

You are on your laptop at home. You type https://shop.example/ and press Enter. The page lives on web, a server in a data centre four links away. Watch every packet that has to move before the HTML arrives.

Follow where the packets go. The first two never leave the house: the laptop is finding its own router (the ARP exchange, explained in The OSI Model). The next batch goes up, to the DNS servers along the top, and not towards web at all. Only then do packets cross to web, three times there and back.

What you will learn

  1. One keypress, 466 milliseconds

    • One line, one keypress: Loading a page is four conversations in a fixed order: DNS finds the machine, TCP connects to it, TLS secures the connection, HTTP asks the question.
    • Read the URL the way the client does: A URL is three instructions: the scheme says how to talk and on which port, the host says who to find, the path says what to ask them for.
  2. Stage 1: find the machine

    • Which stage cost the most?
    • Ask again: the answer is remembered: DNS is slow once per TTL. The first lookup walks the hierarchy; every lookup after it, until the TTL runs out, is answered from somebody's memory.
  3. Stages 2 and 3: a pipe, then a private pipe

    • TCP: three packets before any data: A TCP connection costs one round trip before you can send anything, and a SYN-ACK proves the machine, the path and the port are all alive.
    • Who does web think called?: A private address never leaves the house. The router swaps in its public address and a port of its choosing on the way out, and uses that port to find you on the way back.
    • TLS: agree on keys, check the name: TLS adds one round trip and delivers two things: keys nobody else has, and proof that the server owns the name in your URL.
  4. Stage 4: ask, and count the cost

    • HTTP: the question you came to ask: Only the last round trip carries your request. DNS, TCP and TLS exist to make that one exchange possible, reliable and private.
    • The bill for a cold fetch: Latency is round trips multiplied by distance. Count the round trips first; that is the part you can remove.
    • The second click: An open connection has already paid for DNS, TCP and TLS. Every further request on it costs one round trip.
    • In between: warm name, new connection
    • Drill: make curl show the stages
  5. Which stage failed?

    • Break it: the name does not exist: Could not resolve host means the journey ended at stage one. No packet was ever sent to the server.
    • Break it: nobody is listening: Connection refused is a reply. The machine is reachable and said no: nothing is listening on that port.
    • The machine goes dark: A timeout is silence. Something on the path swallowed the packet or the far end is gone, and the only evidence is the wait.
    • Break it: the certificate expired: A certificate error means DNS and TCP worked. The client reached a server and declined to trust it.
    • A 404 means the network worked: If you got an HTTP status, DNS, TCP and TLS all worked. The problem is in the application, not on the path.
    • Read the error, name the stage: The error names the stage that failed, and clears every stage before it.
    • Drill: is the port open?
  6. Recap & playground

    • Cheat sheet
    • Playground