How Does a Web Request Travel? Unpacking the Full HTTP/TCP/IP Journey
This article walks through the complete lifecycle of a web request, from entering a URL and DNS resolution, through HTTP and TCP processing, IP routing, ARP resolution, and Ethernet framing, explaining each protocol layer's role in encapsulation and de‑encapsulation.
From a Classic Interview Question
When a user types a URL, the browser first resolves the domain name to an IP address, then sends an HTTP request over a TCP connection, which is carried by IP packets across the network and finally rendered by the browser.
Four Main Steps
Domain name resolution (hosts file → local DNS → root DNS → authoritative DNS).
Browser sends an HTTP request, establishing a TCP/IP connection.
Server builds a response, which travels back through the same layered stack.
Browser renders the page by parsing HTML, building a render tree, laying out, and painting.
The article focuses on steps 2 and 3, i.e., how data is transmitted between two physical endpoints.
Layered Protocol Stack
An HTTP request passes through four layers, each with its own protocols.
A protocol is a mutually agreed set of rules that each layer follows to interpret and process data.
Application Layer : HTTP, FTP, SMTP, SNMP, etc.
Transport Layer : TCP, UDP.
Network Layer : IP, ICMP, IGMP.
Link Layer : ARP, RARP.
Encapsulation and De‑encapsulation
Data is wrapped with protocol headers at each layer (encapsulation) when sent, and each layer strips its header (de‑encapsulation) when received.
Encapsulation
The source creates an HTTP message, which is placed into a TCP segment, then an IP packet, and finally an Ethernet frame before being transmitted.
De‑encapsulation
At the destination, the Ethernet frame is stripped, the IP packet is processed, the TCP segment is reassembled, and the HTTP message is finally handed to the application.
Layer‑by‑Layer Details
HTTP (Application Layer)
HTTP packages user actions into request messages and server responses into response messages. The request line, headers, and optional body form the structure of a request; the status line, headers, and optional body form a response.
<code><method> <request‑url> <version> // start line</code>
<code><headers></code>
<code><body></code> <code><version> <status‑code> <reason‑phrase> // start line</code>
<code><headers></code>
<code><body></code>Common methods (GET, POST, PUT, DELETE, etc.) and status‑code ranges (1xx‑5xx) are described.
TCP (Transport Layer)
TCP provides reliable, ordered delivery. It adds a header with flags (URG, ACK, PSH, RST, SYN, FIN), sequence numbers, acknowledgments, checksums, and window size. The three‑way handshake (SYN, SYN‑ACK, ACK) establishes a connection, and a four‑step termination (FIN/ACK) closes it.
IP (Network Layer)
IP routes packets between nodes. Its header contains version, header length, TOS, total length, identification, flags, fragment offset, TTL, checksum, protocol, source and destination IPs. Routing decisions are made using the destination IP and a routing table (default route, specific networks, etc.).
ARP (Link Layer)
ARP maps IP addresses to MAC addresses. When a MAC address is unknown, the host broadcasts an ARP request; the owner of the IP replies with its MAC, which is then cached for future use.
Ethernet Frame (Link Layer)
An Ethernet frame consists of a preamble, start‑of‑frame delimiter, destination MAC, source MAC, EtherType, payload (the IP packet), and a frame‑check sequence (FCS) for error detection.
Conclusion
The request is encapsulated layer by layer at the source, traverses the network, and is de‑encapsulated layer by layer at the destination. The article covers the core HTTP‑TCP‑IP flow; additional topics such as Ethernet trailer encapsulation, dynamic routing, RARP, and UDP are left for further reading.
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.