The stack on one page
Shows one parcel tracked from a laptop to a website. This lesson is the map of the whole trip, and every later lesson in the track zooms into one stop on it.
You tap a link on your phone and a page appears in about a second. Between the tap and the page, four different jobs are done by four different kinds of software and hardware. None of them knows how the others work. Learned as one big pile, networking feels impossible. Learned as four jobs in a row, each one is small.
By the end of this lesson you will be able to name the layers of the internet, say what each one adds, and follow one web request through all of them with real byte counts.
Before you start. Nothing is assumed. You only need to have opened a web page. Every word is explained the first time it appears.
The problem: one machine cannot do everything
Take one request: your browser asks example.com for its home page. Four different things must be true for the page to arrive.
- Your browser must say what it wants, in words the website understands.
- The words must arrive complete and in order, even if the network loses some of them.
- The words must find one machine among billions.
- The words must cross the actual wire or radio signal next to you.
Nobody builds one program that does all four, so the internet splits the work into layers. A layer is one job, done by one kind of software or hardware. It takes something from the layer above, adds its own small note, and hands the result to the layer below.
Think of sending a book by courier in India. You write a letter and put it in an envelope. You put the envelope in a packet that has the address and PIN code of the receiver. The courier puts the packet in a bag for one delivery van. Each person only reads their own wrapping. The van driver never opens your letter. The receiver unwraps the bags in reverse order. That is all a layer stack is. The rest of this lesson uses only the real words.
The history (optional)
Before 1983, computers on the ARPANET, the American research network that the internet grew from, talked with an older protocol called NCP. The deadline for hosts to move to TCP/IP was 1 January 1983. Sources differ on how sudden the change was. Some accounts describe a hard cutover that day, and others say hosts could speak both protocols for a while. Either way, the move was possible because TCP/IP was built in layers. The wires underneath did not change. Only one job was replaced. In October 1989, RFC 1122, edited by Robert Braden, wrote down the host rules for the link, internet and transport layers. A companion document covered the application layer. That is the four-layer model used in this lesson.
Layer by layer: what each one adds
Here are the four layers, from the top, where your browser lives, to the bottom, where the signal travels. For each one, the job comes first, and then its name.
The words themselves. Your browser writes a short text: “give me the home page of example.com.” The rules for how this text is written are a protocol. A protocol is an agreed format that two sides follow, the way two people agree to write a postal address with the PIN code last. The protocol for web pages is HTTP. This layer is called the application layer, because it is the part the application, your browser, talks to.
The promise. The words are cut into pieces. Each piece is numbered, so the other side can put them back in order and ask again for any that went missing. The piece also carries a port, a number that says which program on the receiving machine should get it. Web servers listen on port 443 for secure pages. This is the transport layer, and the protocol here is TCP. A TCP note that sits at the front of each piece is a header: a short block of numbers, in a fixed format, that the layer adds in front of what it was given.
The address. Each piece gets a second header with the address of the sender and the address of the receiver. Now routers, the machines that pass pieces along toward the right place, can handle it. A piece with its address header on is a packet. This is the internet layer, and the protocol is IP. Its one promise is small: each router sends the packet one step closer.
The next hop. A router is not reachable by magic. Your laptop is connected to a Wi-Fi box or a cable, and that wire or radio has its own rules and its own addresses, used only for the next machine along. One more header goes on, valid for this one hop only. This is the link layer. At home it is usually Wi-Fi or Ethernet, the wired kind. At every router the old link header is thrown away and a new one is made for the next hop.
flowchart TD A["Application: HTTP, the words"] -->|"adds nothing yet, this is the order"| T T["Transport: TCP, numbers the pieces and picks the port"] -->|"adds a 20 byte header"| I I["Internet: IP, addresses the packet"] -->|"adds a 20 byte header"| L L["Link: Ethernet or Wi-Fi, one hop"] -->|"adds a 14 byte header and a 4 byte check"| W["The wire"]
Read it as a staircase. Going down, every layer wraps. At the receiving machine, going up, every layer unwraps and passes the inside to the layer above.
One request, wrapped: counting the bytes
Here is a real request. A byte is one character’s worth of data, a number from 0 to 255. This is the whole HTTP request a small program sends for the home page:
GET / HTTP/1.1
Host: example.com
Connection: close
Counting the characters, with the end-of-line marks and one empty line at the end, gives 56 bytes. This number was computed by running the code in the second read on 2026-11-28.
Now wrap it, one step per line. The header sizes are fixed by the protocols when no optional extras are used. TCP is 20 bytes, IP is 20 bytes, and Ethernet is 14 bytes at the front and a 4 byte check at the end.
56 bytes the HTTP request
56 + 20 = 76 add the TCP header
76 + 20 = 96 add the IP header
96 + 14 = 110 add the Ethernet header
110 + 4 = 114 add the Ethernet check
How many bytes of headers does the network wrap around a 56 byte request?
20 for TCP, 20 for IP, 14 for the Ethernet header and 4 for the Ethernet check. 20 + 20 + 14 + 4 = 58.
The wrapping is 114 - 56 = 58 bytes. In words: the three lower layers add 58 bytes to a 56 byte order, so the order is a little less than half of what travels on the wire.
What percent of the 114 bytes on the wire is the order itself?
56 divided by 114 is 0.491, which is 49.1 percent.
The share that is the order is 56 ÷ 114 = 0.491, which is 49.1 percent. This is a tiny request, chosen so the arithmetic is easy. For a large page the wrapping is a small share, and the second read works out how small.
The trip: who reads which header
The wrapped piece leaves your laptop and passes through machines that each read only some of the wrapping. This is why the layers can be built by different people.
sequenceDiagram
participant L as Your laptop
participant R as Home router
participant X as Routers on the way
participant S as example.com
L->>R: link header for hop 1, IP header, TCP header, request
R->>X: new link header for hop 2, same IP header, same TCP header
X->>S: new link header for the last hop, same IP and TCP headers
Note over S: reads TCP, then HTTP, and sends the page back the same way
The home router unwraps the link header, reads the IP header to see where the packet is going, and builds a new link header for the next hop. It never reads the TCP header or the request. The routers on the way do the same. Only the machine at the far end reads the TCP header, finds port 443, and gives the request to the web server program.
Before the request can start, two other jobs happen. Your laptop knows only the name, so it asks a resolver, a machine that turns names into addresses. That lookup is DNS. Then the laptop and the server open a TCP connection, which costs one round trip, the time for a message to reach the far side and the reply to come back. For secure pages, one more exchange makes the line private. Measured from a small Linux machine on 2026-11-28, one request to https://example.com/ printed these stopwatch readings, in seconds since the start:
dns=0.001366 connect=0.002973 tls=0.020136 ttfb=0.029022
Subtract each reading from the next to get each stop. Name found took 0.001366 s. Connect took 0.002973 - 0.001366 = 0.001607 s. The private line took 0.020136 - 0.002973 = 0.017163 s. The first byte of the page came 0.029022 - 0.020136 = 0.008886 s later. The DNS answer here was already stored nearby, so one reading does not show a typical first visit, and your own numbers will differ.
The map: one page
flowchart LR
subgraph You
A1["Application: HTTP, DNS"] --> T1["Transport: TCP, port 443"] --> I1["Internet: IP address"] --> L1["Link: Wi-Fi or Ethernet"]
end
L1 -->|"hop by hop, each router rewrites the link header"| L2
subgraph Server
L2["Link"] --> I2["Internet"] --> T2["Transport"] --> A2["Application"]
end
Every lesson in this track sits on one box of this picture. Names becoming addresses is the application layer. Lost and reordered pieces are the transport layer. Finding a way across the world is the internet layer. The router and cable in your own building are the link layer.
You now know
- A layer is one job. It adds a header in front of what the layer above gave it and hands it down.
- The four layers are application (the words), transport (order, retries and ports), internet (addresses and routing) and link (one hop).
- A protocol is an agreed format, and a header is the block of numbers a layer adds.
- Going down, every layer wraps. Going up at the far end, every layer unwraps.
- A 56 byte request becomes 114 bytes on the wire, and 58 of those are headers.
- Routers read the IP header and rewrite the link header at every hop. Only the far end reads the TCP header.
Stop here if you want. What follows is the same stack with the code, the limits and the places where the layers leak.
Second read: the numbers, the limits and the leaks
The code that counted
This script builds the request, wraps it in the header sizes, and then sends the same request to a small server on the same machine to show it is a real request. Its printed output, run 2026-11-28:
Show the working as code
req = "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n".encode()
http = len(req)
tcp_h, ip_h, eth_h, fcs = 20, 20, 14, 4
seg = http + tcp_h
pkt = seg + ip_h
frame = pkt + eth_h
print("HTTP request bytes :", http)
print("+ TCP header 20 :", seg)
print("+ IP header 20 :", pkt)
print("+ Ethernet header 14 :", frame)
print("+ Ethernet check 4 :", frame + fcs)
print("share that is the order : %.1f %%" % (100 * http / (frame + fcs)))
HTTP request bytes : 56
+ TCP header 20 : 76
+ IP header 20 : 96
+ Ethernet header 14 : 110
+ Ethernet check 4 : 114
share that is the order : 49.1 %
The names have precise forms. The TCP piece is a segment. The IP piece is a packet. The link piece is a frame. People say “packet” for all three in casual talk. The 4 byte Ethernet check is a checksum, a number computed from the frame so the receiver can spot damage.
The size limit: why a big page becomes many packets
An Ethernet frame carries at most 1,500 bytes of payload by default. This limit is the MTU, maximum transmission unit. The IP and TCP headers live inside that 1,500, so the room left for your data is:
1500 - 20 - 20 = 1460 bytes per segment
That 1,460 is the MSS, maximum segment size. In words: of each 1,500 byte payload, 40 bytes are headers and 1,460 are yours. For a page of 100,000 bytes (a teaching value, not a measured page) the transport layer cuts it into pieces, rounding up because a partial piece still needs a whole segment:
100,000 / 1,460 = 68.49 -> 69 segments
header bytes = 69 * 58 = 4,002
share = 4,002 / (100,000 + 4,002) = 3.8 %
The wrapping cost is 3.8 percent for the large page against 50.9 percent for the tiny request. This is why tiny messages are expensive per byte, and why protocols try to send fewer, fuller messages.
Where the layers leak
The layer picture is a rule for design, not a law of physics. Real systems bend it.
- TCP reads IP addresses. The TCP checksum covers a pseudo header with the IP addresses in it. A box that rewrites an address, such as the NAT in a home router, must fix the TCP checksum too. NAT is why Inside your building (your router's life) exists as a lesson.
- TLS sits in the gap. It encrypts the application data before TCP numbers it. It is neither a clean application nor a clean transport protocol, and the track gives it its own lesson, The whisper code (how a call goes private).
- QUIC moves a layer. HTTP/3 runs over QUIC, which runs over UDP, a transport protocol with no ordering or retries. QUIC brings its own ordering, retries and encryption, written inside the application, so it can improve without waiting for operating systems to update. QUIC was standardised as RFC 9000 in May 2021.
- Seven or four. An older reference model, OSI, splits the same work into seven layers, and many courses teach it. The internet itself follows the four layer shape of RFC 1122. When someone says “layer 7” or “layer 4 load balancer”, they mean the OSI numbering: layer 7 is the application, layer 4 is the transport.
What each device reads
| Device | Reads up to | Why it stops there |
|---|---|---|
| Switch in a building | link header | It only chooses which cable inside one building |
| Router | IP header | It only chooses the next hop toward the address |
| Load balancer, layer 4 | TCP header | It balances by connection and port |
| Load balancer, layer 7 | HTTP request | It balances by path or by name |
| Firewall | any of the above | Depends on what it is told to block |
The higher a box reads, the more it can decide, and the more work it does per packet.
Try it
- Run the script in the second read. Change the request to one with a longer path, such as
GET /some/long/path HTTP/1.1, and write down the new byte counts on each line. - Run
curl -s -o /dev/null -w "dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer}\n" https://example.com/and subtract each reading from the next. Which stop was slowest on your network? - Pick any web page size you know, such as 250,000 bytes. Work out the segments with 1,460 bytes each, rounding up, then the header bytes at 58 per segment, then the share.
Go deeper
- RFC 1122, Requirements for Internet Hosts: Communication Layers, the October 1989 text that names the link, internet and transport layers.
- Wikipedia, Internet protocol suite, a short tour of the layers and how they relate to the OSI model.
- Internet History list, the 1 January 1983 cutover to TCP/IP on the ARPANET, first hand discussion of how sudden the change really was.
Related
- DNS Resolution: the application layer job of turning a name into an address, the first stop of every request.
- DNS on the wire: the exact bytes of one application layer message.
- TCP vs UDP, and the 3-way handshake: the transport layer, its promise and the opening round trip.
- How a parcel finds any house on earth: the internet layer, routers and how a packet finds a house on earth.
- Inside your building (your router's life): the link layer in your home and the NAT that bends the layers.
- The whisper code (how a call goes private): the secure line that sits between application and transport.
- What a request actually says (HTTP): the words of an HTTP request, line by line.
- One click, every layer (what happens when you load a page): the same trip timed stop by stop, once you know every layer.
- It won't load: the ladder (network debugging): the five questions that find which layer failed.
Retrieval practice
8 questions. Answer each one before you open it.
What is a layer, in one sentence?
A layer is one job in the stack. It takes data from the layer above, adds its own header in front, and hands it down. At the far end it does the reverse.
Name the four layers in order from the browser down to the wire, and what each adds.
Application: the words of the request, with no wrapping of its own here. Transport: numbered pieces and a port. Internet: the sender and receiver addresses. Link: a header and check for the next hop only.
A 56 byte request is wrapped by TCP, IP and Ethernet. How many bytes travel, and how many are headers?
56 + 20 + 20 + 14 + 4 = 114 bytes travel. 114 - 56 = 58 of them are headers and the check.
Which header does a router read, and which does it throw away and rebuild?
It reads the IP header to choose the next hop. It throws away the old link header and builds a new one for the next hop. It does not read the TCP header.
What is a port, and which layer adds it?
A port is a number that tells the receiving machine which program should get the piece, such as 443 for secure web pages. The transport layer adds it in the TCP header.
Why is the MSS 1,460 bytes on an ordinary Ethernet link?
The MTU is 1,500 bytes. The IP header takes 20 and the TCP header takes 20, so 1,500 - 20 - 20 = 1,460 bytes remain for data.
Why is the wrapping 3.8 percent of a 100,000 byte page but about 51 percent of a 56 byte request?
The headers are a nearly fixed cost per packet, 58 bytes each. A big page spreads it over 69 packets of mostly data. A tiny request pays the full 58 bytes for only 56 bytes of data.
What does QUIC change about the layers?
It runs over UDP and does its own ordering, retries and encryption inside the application. That lets it be updated without waiting for operating systems to change their transport software.
