The Plain Picture#
A company sends a contract to a partner abroad:
The lawyer writes the contract. She only cares about the contract's words.
Her assistant puts it in an envelope marked "Attn: Legal Dept, Page 1 of 3".
The mailroom puts that envelope in a courier bag with the partner company's street address.
The courier puts the bag on a truck, then a plane, then a van.
Each person only deals with their own layer. The lawyer doesn't know which plane was used. The courier doesn't read the contract. At the other end, each layer unwraps its own envelope and passes the contents up.
This split means you can swap one layer (plane → ship) without changing any other.
The Real Names#
Networks are built in layers. Each layer adds its own header in front of what it received from the layer above — encapsulation. At the receiving end, each layer strips its header — decapsulation.
There are two layer models you'll hear about:
The OSI model: 7 layers. Mostly used as vocabulary ("that's a layer 7 load balancer").
The TCP/IP model: 4 layers. This is what the internet actually runs.
OSI (7 layers — vocabulary) TCP/IP (4 layers — what really runs) Examples ───────────────────────────── ────────────────────────────────────── ───────────────── 7 Application ┐ 6 Presentation ├─ Application HTTP, DNS, SSH 5 Session ┘ 4 Transport ── Transport TCP, UDP 3 Network ── Internet IP 2 Data Link ┐ 1 Physical ┘─ Link Ethernet, Wi-Fi
The numbers people actually say out loud: "layer 2" = local network (MAC addresses, Chapter 3), "layer 3" = IP (Chapter 4), "layer 4" = TCP/UDP (next file), "layer 7" = the application (HTTP).
Under the Hood#
When StudyBuddy sends the request "GET Priya's notes":
Application [ HTTP: GET /notes/priya ] ← what the app writes
Transport [ TCP header | HTTP: GET /notes/priya ] ← next file
Internet [ IP header | TCP header | HTTP: GET /notes/priya ] ← Chapter 4
Link [ Ethernet/Wi-Fi header | IP header | TCP | HTTP | trailer ] ← Chapter 3
Physical 101100101001... as radio waves (Wi-Fi) or light (fibre)Each layer only reads its own header:
| Layer | Header contains | Answers the question |
|---|---|---|
| Link | MAC addresses (Ch 3) | "Which device on this local network is next?" |
| Internet | IP addresses (Ch 4) | "Which computer in the whole internet is the destination?" |
| Transport | port numbers (next file) | "Which program on that computer?" |
| Application | HTTP method, path… | "What does the program want?" |
Where layers live: the link layer is mostly in the network hardware and its driver (Operating Systems Ch 1). IP and TCP/UDP live in the kernel. The application layer is in your program. So when StudyBuddy "sends a request", it hands bytes to the kernel with a system call (Operating Systems Ch 2), and the kernel adds the transport, IP and link headers.
Gotchas
The OSI model isn't "how it works". Real protocols don't split cleanly into 7 layers (TLS encryption, for example, sits awkwardly between 4 and 7). Use OSI numbers as shared vocabulary, and the 4-layer model to reason.
Each layer's header adds bytes. An IPv4 header is at least 20 bytes and a TCP header at least 20, so a 1,500-byte packet carries at most ~1,460 bytes of your data.
Check yourself
4 questionsWhat is encapsulation?
Show answerHide answer
Each layer wrapping the data from the layer above with its own header.
Name the four TCP/IP layers from bottom to top.
Show answerHide answer
Link, Internet, Transport, Application.
What question does each of the link, internet and transport headers answer?
Show answerHide answer
Link: which local device is next. Internet: which computer in the whole internet. Transport: which program on that computer.
What do people mean by a "layer 7" load balancer? (Guess from the layer name.)
Show answerHide answer
One that understands the application layer (HTTP) — it can route by URL path or headers, not just by address. (Covered properly in Load Balancing (coming soon).)