bastion

How Web Communication Works

Build this skill

Put the steps of loading a website in order, from DNS lookup to the routed HTTPS response, and point out where each step is protected.

The second between tapping Go and seeing the page

Mrs. Gokhale's grandson has set up the Tulsi Health website on her new phone. She types tulsihealth.in into the browser, taps Go, and in about a second the page with her saved prescriptions appears. In that second her phone found the server's address, opened a connection, checked that the server was genuine, set up encryption, asked for the page, and received it in hundreds of small pieces that travelled through several cities. This sequence is the website request lifecycle, and every step in it is either a protection that keeps her safe or a place an attacker would like to interfere. Knowing the order of the steps lets you see which protection guards which moment.

The steps always come in the same order, because each one needs what the one before it produced. Before reading the details, try to put them in order yourself; the feedback will tell you what each step hands on to the next.

Finding the address: DNS resolution

People remember names; networks deliver to numbers. DNS resolution is the process of turning a name like tulsihealth.in into the IP address of the server that hosts it (an IP address being the number that identifies a device on the internet). Mrs. Gokhale's phone first checks its own memory, called a cache, in case it looked the name up recently. If not, it asks a DNS resolver, a lookup service usually run by her mobile company. The resolver does the legwork: it asks a root server which servers handle names ending in .in, asks one of those which server handles tulsihealth.in, and finally asks Tulsi Health's own DNS server for the address.

PhoneResolverRoot server.in serverTulsi DNStulsihealth.in?1Who handles .in?2Who handles tulsihealth.in?3Address of tulsihealth.in?4198.51.100.205198.51.100.206

Each server only knows who to ask next, like a chain of enquiry counters. The resolver and the phone then remember the answer for a while, so the next visit skips the whole chain.

It works like finding a shop in an unfamiliar town. You ask the bus-stand enquiry counter, which sends you to the right area, where a local points you to the right lane, and the shopkeeper confirms the door number. Each helper knows only the next step. Answers are remembered for a set time, so most lookups take a few milliseconds.

DNS is also a favourite target, because whoever controls the answer controls where you go. A tampered Wi-Fi router or a fake resolver can reply with an attacker's address instead of the real one, while the address bar still shows tulsihealth.in. The defence that catches this is the HTTPS certificate check, which comes a moment later.

The browser and the server talk

With the address in hand, the browser opens a TCP connection to port 443 on the server; TCP being the protocol that confirms every piece arrives, and 443 the port, or numbered service window, used for secure websites. Next comes the HTTPS handshake. The server presents its certificate, a digital identity document for the name tulsihealth.in, signed by a trusted issuer, and the browser checks that the name matches and the signature is genuine. Both sides then agree on secret keys, and from that moment everything they exchange is encrypted.

Only now does the real conversation start. The browser sends an HTTP request: a short message naming what it wants and carrying a cookie, a small note the site gave the browser earlier so it can recognise Mrs. Gokhale as logged in. The server replies with an HTTP response: a status code saying how things went (200 means OK, 404 means not found, 301 means the page has moved), followed by the page itself.

Request (phone to server)GET /my-prescriptionsHost: tulsihealth.inCookie: session=7f3a…Response (server to phone)200 OKType: web page (HTML)<h1>Your prescriptions</h1>…

Inside the encrypted channel, the conversation is plain and short. Without HTTPS, anyone on the path could read that cookie and use it to act as Mrs. Gokhale.

One page usually needs many requests: the page text, then the images, styles and scripts it lists, each fetched the same way over the same connection. The cookie in every request is valuable, because whoever holds it is treated as the logged-in customer. That is the biggest reason the whole conversation must travel inside HTTPS.

Follow Mrs. Gokhale's visit message by message below. The second situation shows the same visit from a café Wi-Fi whose DNS has been tampered with; at the steps that pause, predict what happens before revealing it.

Packets: a big delivery in numbered boxes

The page does not travel as one piece. Data on a network is cut into packets, small pieces of roughly 1,500 bytes each, so a page with a few photos can easily be over a thousand packets. Every packet carries a label, called a header, with the sender's IP address, the destination's IP address, the port number and a sequence number, followed by its slice of the content. With HTTPS the slice is encrypted, but the label must stay readable so that the network can deliver it.

Shifting house from Pune to Nashik works the same way. Nobody moves a whole household in one crate; it goes in numbered cartons, perhaps on two different tempos, and at the new flat you unpack in number order and notice if carton 17 is missing. TCP does the counting: the receiver puts packets back in order and asks for any that went missing to be sent again. Splitting data this way lets many conversations share the same cables fairly, and lets one lost packet be resent instead of the whole page.

Routing: one hop at a time

Packets reach the server through a chain of routers, the devices that join networks together and pass traffic between them. Routing is how each router decides where to send a packet next. A router does not know the whole path; it reads the packet's destination address, looks it up in its own table of directions, and passes the packet to the next router that is closer to that address. Each handover is called a hop, and a request from Pune to a data centre in Mumbai typically takes ten or more.

Phone Pune tower router Pune router Lonavala router Thane Tulsi Health server Mumbai data centre 3 1 2 Inside every packet from: her phone to: 198.51.100.20 port: 443 number: 2 of 1,180 contents locked by HTTPS Each router only picks the next hop. If one road is blocked, packets take another.

Packets from one page can take different paths and still arrive. The label on each packet stays readable for the routers, while HTTPS keeps the contents locked.

A courier company works exactly this way. The Pune hub does not plan the parcel's whole journey; it sees "Mumbai" and puts it on the next truck to the Mumbai hub, which sends it to the local office for that area. If a road is blocked, the hub sends the next truck by another highway. Routers do the same: if a link fails, they quietly choose another, which is why the internet keeps working when individual cables are cut.

Every hop is equipment run by some other company, in some other building. Any of them could, in principle, look at the packets passing through, and on rare occasions routes on the internet have been misdirected so that traffic took a path it should not have. You cannot choose the route your packets take, so you protect what is inside them instead: HTTPS makes the contents unreadable to every hop, and the certificate check makes sure that whichever path the packets took, they ended at the real tulsihealth.in.

Follow your curiosity.

↑ ↓ to explore · Enter to open · Escape to close