Card 03/ 09
Encapsulation Example: One HTTP Request, Wrapped Three Times
A request for a web page becomes a segment, a packet and a frame before it leaves the laptop.
Encapsulation is easiest to see on one real request: a laptop on a home network asks www.example.com for its front page over plain HTTP. Before the request leaves the laptop it gains three headers, TCP, IP and Ethernet, and each one carries the address that its own layer needs. The values are illustrative, from documentation and private address ranges.
The browser writes the request itself, two short lines of text: GET /index.html HTTP/1.1 and Host: www.example.com. The operating system then wraps it.
| Header | Layer | Main fields | Values in this request |
|---|---|---|---|
| HTTP request | 7 | Method, path, host | GET /index.html, Host: www.example.com |
| TCP | 4 | Source port, destination port, sequence number | 51514 to 80 |
| IP | 3 | Source address, destination address, time to live | 192.168.1.20 to 203.0.113.10, TTL 64 |
| Ethernet | 2 | Source MAC, destination MAC, type | laptop's card to the home router's card, type IPv4 |
Three things are worth noticing.
Each layer names a different kind of destination. Port 80 names the web server program, 203.0.113.10 names the machine it runs on, and the MAC address names the next device on the cable. The laptop's port, 51514, is a number the operating system picked for this one connection.
The Ethernet destination is the router, not the server. The server is several networks away, so the frame only has to reach the first device on the path. The IP header still names the server, and it is the IP header that every router reads to choose the next step.
The request is the smallest part. The HTTP lines are a few dozen bytes; the TCP and IP headers are 20 bytes each, and Ethernet adds 14 bytes in front and 4 behind. For a large download the headers are noise, but for a stream of tiny messages they are a real share of every packet.
With HTTPS, a fourth wrapping sits between HTTP and TCP: a TLS record that encrypts the request, so a router on the way sees the addresses and ports but not the path.
← → move through sections and cards