Computer Networking › Section F · The link layer and LANs › Topic F.7

A day in the life of a web page request

Typing a web address looks like one action, yet it sets off a chain of protocols from every layer. Following one request from a bare laptop to a loaded page shows how DHCP, ARP, DNS, TCP and HTTP depend on each other.

The scenario

A student plugs a laptop into a campus Ethernet socket and opens http://www.example.org/. The laptop has a MAC address, 02:00:00:00:00:0a, but no IP address, no gateway and no idea where the DNS server is. We assume this layout. The LAN is 203.0.113.0/24, and its router, 203.0.113.1, is the default gateway and also runs DHCP. The campus DNS resolver is 192.0.2.53, and the web server is 198.51.100.7. These are documentation address ranges, so no real hosts are involved. The campus uses public addresses, so no address translation occurs. The page is plain HTTP/1.1 for simplicity.

Step 1: getting an address with DHCP

The laptop must configure itself, which is the job of the protocol in DHCP and network address translation. It broadcasts a DHCP Discover message: an Ethernet frame to ff:ff:ff:ff:ff:ff, carrying an IP datagram from 0.0.0.0 to 255.255.255.255 and a UDP segment from port 68 to port 67, as in Connectionless transport: UDP. The switch learns the laptop's MAC address from this first frame. The DHCP server answers with an Offer; the laptop sends a Request and receives an ACK. The reply supplies an IP address, the subnet mask, the default gateway, the DNS server's address and a lease time. Four messages, two exchanges.

Step 2: ARP for the gateway

The browser must resolve www.example.org, and the resolver at 192.0.2.53 lies outside the laptop's subnet, so the DNS query has to go through the gateway. The laptop knows the gateway's IP address but not its MAC address, so it broadcasts an ARP request, as described in Switched LANs: MAC addresses, ARP, switches, and VLANs: who has 203.0.113.1? The switch floods the broadcast to every port. The gateway replies directly to the laptop, and the switch forwards the reply to the right port only. The laptop caches the gateway's MAC address for later frames.

Step 3: resolving the name with DNS

The laptop sends a UDP datagram to port 53 of 192.0.2.53, inside a frame addressed to the gateway's MAC. This asks for the address of www.example.org, as explained in DNS: the internet's directory service. If the resolver has no cached answer, it asks a root server, then a server for the top-level domain, then the authoritative server for the domain, and returns the A record 198.51.100.7. The routers along the way forward each datagram by its destination prefix, using tables built by protocols such as Intra-AS routing: OSPF inside a network and Routing among ISPs: BGP between networks.

Step 4: connecting with TCP

Now the browser asks the operating system for a TCP connection to 198.51.100.7, port 80. As Connection-oriented transport: TCP describes, the laptop sends a SYN from a freshly chosen source port, the server answers SYN-ACK, and the laptop replies ACK. The frames on the LAN are addressed to the gateway's MAC address, because the server is off-subnet, while the IP destination is the server. Every router on the path rebuilds the frame for the next hop. The handshake costs one round trip before any data can flow.

Step 5: the HTTP exchange

With the connection open, the browser sends GET / HTTP/1.1 and a Host header naming www.example.org, as in The web and HTTP. The server replies 200 OK with a response of 8,000 bytes, headers included. TCP carries it in 6 segments, since each holds at most 1,460 bytes of data, which is 1,500 minus 20 bytes each of IP and TCP header with no options. The browser reads the HTML and then fetches images and scripts in the same way. Real browsers usually use encrypted HTTPS, and increasingly HTTP/3 over QUIC; the story here stays plain so each step is visible.

Worked example: what each frame carries

Compare the destinations in five frames. 1. DHCP Discover: Ethernet destination ff:ff:ff:ff:ff:ff, IP destination 255.255.255.255, UDP port 67. 2. ARP request: Ethernet destination ff:ff:ff:ff:ff:ff, and no IP header at all, only the ARP message. 3. DNS query: Ethernet destination the gateway's MAC, IP destination 192.0.2.53, UDP port 53. 4. TCP SYN: Ethernet destination the gateway's MAC, IP destination 198.51.100.7, TCP port 80. 5. HTTP GET: the same addresses as the SYN. The pattern: the Ethernet destination is the next hop on this link, and the IP destination is the final target. The first two use broadcast because the laptop knows nothing yet.

Worked example: where the time goes

Assume 1 ms round trip to the LAN and campus resolver, 20 ms to each of the three DNS servers it must ask, 40 ms to the web server, and a 100 Mbit/s access link. 1. DHCP takes two round trips: 2 ms. 2. ARP takes one: 1 ms. 3. DNS with an empty cache takes 1 + 3 x 20 = 61 ms. 4. The TCP handshake takes 40 ms. 5. The request and the first byte of reply take another 40 ms, and, since an initial window of 10 segments (TCP congestion control) lets all 6 leave at once, 8,000 bytes take \(8000 \times 8 / 10^8 = 0.64\) ms to send. 6. The total is about 144.6 ms, of which DNS is 42%. With the DNS answer cached it falls to about 84.6 ms. Switching to HTTPS with TLS 1.3 would add another round trip, 40 ms.

Common mistakes to avoid

First, thinking ARP is used to find the web server's MAC address; ARP only reaches hosts on the same subnet, so the laptop ARPs for the gateway. Second, putting the gateway's IP address in the IP destination field: the datagram still names the final server. Third, assuming the steps are optional. Without DHCP there is no address, without DNS there is no server address, and without the TCP handshake there is no connection. Fourth, forgetting that DNS queries and DHCP messages use UDP, not TCP. Fifth, counting only the HTTP round trip when estimating page load time.

Key takeaways

A page request chains many protocols. DHCP supplies the address, mask, gateway and DNS server using broadcast UDP. ARP finds the gateway's MAC address. DNS turns the name into an IP address. TCP opens a connection, and HTTP fetches the page over it. At each hop, the frame's MAC addresses name the next hop, while the IP destination stays the final target. For this example the total delay is the sum of a few round trips, with DNS often the largest part, and each layer's protocol relies on the one below it.

Flashcards

Flashcard

Request sequence

DHCP, ARP, DNS, TCP handshake, HTTP

Each step depends on the one before.

Test your understanding

Question 1 of 5

A laptop with no IP address has just joined a LAN. What is the first message it sends on the way to fetching a web page?

Question 2 of 5

For the TCP SYN sent to a web server on another network, what is the Ethernet destination address?

Question 3 of 5

A configured laptop looks up a name the resolver has cached (1 ms round trip) and then fetches a page from a server 60 ms away. About how long until the first byte of the reply arrives?

Question 4 of 5

Why does the laptop send an ARP request for 203.0.113.1 rather than for the web server's address?

Question 5 of 5

Why does the DHCP Discover use source IP 0.0.0.0 and destination 255.255.255.255?

← Previous topicNext topic →