When a web page loads, seven layers of work happen, from the cable in the wall to the words on your screen. The OSI model names those layers, bottom to top, and gives every engineer the same map. This lesson walks the map, one layer at a time, and pins each layer to a real thing.
Difficulty: Beginner · Know this first: F17 — IPv6: The Address Space That Does Not Run Out
Start at the cable and climb. Each layer adds one job, and no layer can skip the one below it.
In one web request, the seven layers do different amounts of work, and the split is not even. The bar below is a teaching example for this lesson, not a measurement from a live system. It shows where 100 units of work go across the layers, from the cable to the browser. The application layer does the most, because it is the layer that understands what the user asked for.
Extra diagram · from scratch to master
Start with the cable. Add one layer at a time until the browser shows a page. Each layer does one job, and no layer can skip the one below it.
Extra diagram · from scratch to master
Follow one click from the browser down to the cable and back up again. The trip down adds one layer at a time. The trip back strips them off.
The simulator below is a layer picker. Click a real thing, a cable, a switch, an IP address, TCP, TLS, HTTP, and it tells you which layer it lives on, what that layer does, and what breaks when that layer fails. Every mapping is the standard one engineers use.
Try this: (1) Click Cable. Layer 1, Physical. If it breaks, nothing moves at all. (2) Click Switch. Layer 2, Data Link. If it breaks, the room goes quiet but other networks are fine. (3) Click IP address. Layer 3, Network. If it breaks, packets cannot leave the network. (4) Click HTTP. Layer 7, Application. If it breaks, the page does not load, but the network below is fine.
Three questions. No score is saved anywhere — this is just you against the material.
I take the same idea four times here. First I name the seven layers. Then I trace one request through them. Then I debug with the map. Last I run it for the world.
Definition: The OSI model is a map of seven layers, bottom to top: Physical, Data Link, Network, Transport, Session, Presentation, Application. Each layer does one job and uses the layer below it. The map gives every engineer the same words for the same work.
Types:
Uses: I use this map every time something breaks and I do not know where. I start at the bottom and climb, checking each layer in order, instead of guessing.
Dimensions: At seven layers the map fits on one page and in one head. What breaks first is my memory of the order, and I notice it when I check layer 7 before layer 1. It costs nothing to learn the order. It costs real time to debug from the top down. The trade is simple: the map is a simplification, and a simplification that points at the right layer is worth more than a perfect model that points nowhere.
Definition: At this level I trace one request through all seven layers, down on the way out and up on the way back. The browser writes HTTP at layer 7. TLS encrypts it at layer 6. TCP splits it at layer 4. IP addresses it at layer 3. The switch frames it at layer 2. The cable carries it at layer 1. The server strips the layers off in reverse.
Types:
Uses: I use this trace when a request fails halfway. The layer where the trace stops is the layer that broke, and the map tells me what to check there.
Dimensions: As the trace gets longer, the layers blur together, because real systems merge some of them. What breaks is my insistence on a perfect match between the map and the system, and I notice it when I argue about which layer TLS belongs to instead of fixing the certificate. It costs the humility to use the map as a guide, not a law. The trade is that the map buys a shared language, and it costs the acceptance that real systems do not fit it perfectly.
Definition: At this level the map is a debugging method. Start at layer 1: is the cable plugged in, is the link light on? Then layer 2: does the switch see the machine? Then layer 3: does the router know the road? Then layer 4: does TCP connect? Then layer 6: is the certificate valid? Then layer 7: does the app answer? Each question rules out one layer, and the first layer that fails is the one to fix.
Types:
Uses: I use this on every network problem that is not obvious. The map turns a vague symptom, the site is down, into a specific question, which layer is down, and the specific question has a specific check.
Dimensions: At ten times the complexity the map is still seven layers, and the systems are still built from them. What breaks is a problem that spans layers, like a slow network that is really a bad cable, and I notice it when fixing layer 7 does nothing because the fault is at layer 1. It costs the discipline to check the bottom first, every time, even when the symptom looks like the top. The trade is that bottom-up is slow and boring, and it finds the fault faster than guessing.
Name the layer of a failure. A failure lives at one layer, and the fix lives there too. I test the layers from the bottom up. The interface is up. The name resolves. The request fails. That narrows the fault to the layers above the name, and it stops me from fixing the wrong thing.
$ ip addr show lo | grep inet
inet 127.0.0.1/8 scope host lo
$ getent hosts example.com
198.18.48.185 example.com
$ curl -s -o /dev/null -w "%{http_code}\n" --max-time 3 http://127.0.0.1:9/
000
Every flag in the commands above, letter by letter.
ip addr show lo: addr picks addresses, show lists them, lo limits the answer to loopback.grep inet keeps only lines with the word inet. No flag. The pattern is the argument. Without a pattern, grep has nothing to match.getent hosts looks a name up the way the system does, files first, then DNS.curl -s -o /dev/null -w "%{http_code}\n" --max-time 3: -s hides progress. -o /dev/null throws the body away. -w prints the status code. --max-time 3 gives up after 3 seconds.grep -v inverts the match. It prints lines that do NOT contain the pattern. grep -v inet shows everything except the address lines.Check it: run ip addr show lo | grep inet, then ip addr show lo | grep -v inet. The first prints the address lines. The second prints the rest.
Try it: run the three commands in order. The first proves the interface is up. The second proves the name resolves. The third proves nothing is listening on port 9. The fault is at the top, not the bottom, and the bottom two tests proved it.
The map is not the territory. The model says seven layers, but real traffic does not stop at each layer to announce itself. I use the model to ask where to look, not to describe what is happening. A proxy can answer for a server, and the model will not tell you that. The test will.
$ curl -s -o /dev/null -w "%{http_code} %{time_total}s\n" https://example.com
200 0.239243s
Every flag in the commands above, letter by letter.
curl -w takes a format string. %{http_code} is the status code. %{time_total} is the whole request in seconds. The s after it is just the letter s, printed as is.%{time_connect} is the time to open the connection. When the total is slow and connect is fast, the server was slow, not the network. I add it to the same -w string to split the wait into parts.Check it: run the command above twice. The two totals differ, like 0.35s and 0.29s. The network is not a metronome. Then add %{time_connect} to the -w string and run it again.
Try it: run the command above. It returns 200, so the top layer works. If it had returned 000, the failure could be at any layer below, and I would walk down the model one layer at a time until a test passed.
Definition: At this level the map is how a whole organisation talks about its systems. Every incident report names the layer that broke. Every design review asks which layer each piece lives on. Every runbook is ordered by layer, bottom to top. The map is not a lesson any more. It is the language the team thinks in.
Types:
Uses: I use this when a system is big enough that no one person knows all of it. The map is the shared language that lets a network engineer and an app engineer talk about the same failure without talking past each other.
Dimensions: At a hundred times the scale the map is still seven layers, and the teams are still organised around them. What breaks is a failure nobody can place on the map, usually a problem between teams, and I notice it when two teams each prove their layer is fine while the system stays broken. It costs a culture of naming the layer, honestly, even when the layer is yours. The trade is that the shared language costs effort to maintain, and it buys a team that can find a fault together instead of blaming each other.
Troubleshoot bottom-up, every time. I start at layer 1 and climb. Is the interface up. Does the name resolve. Does the connection open. Does the request get an answer. The first test that fails is the layer with the fault. The tests above it never ran, and the tests below it already passed.
$ ip addr show lo | grep inet
inet 127.0.0.1/8 scope host lo
$ getent hosts example.com
198.18.48.185 example.com
$ curl -s -o /dev/null -w "%{http_code}\n" https://example.com
200
Try it: run the ladder above on your own machine. Three commands, three layers, three passes. Now break one layer on purpose, for example by asking for a port with nothing on it, and watch the ladder stop at that layer. The ladder is the debug method. The model is just the list of rungs.
Two helpers live here in the model. ARP maps an IP address to a MAC address on the local network. It works at the link layer, layer 2. When your machine asks who has an address on the local wire, that question is ARP. ICMP carries error and test messages. It works at the network layer, layer 3. When ping says a host is unreachable, that message is ICMP. The full hands-on for both is in the next lesson, where TCP and UDP travel.
The OSI model is a map, not a machine. No real system implements all seven layers exactly as the model describes. The internet runs on TCP/IP, which merges some layers and skips others. The model is still useful, because it gives every engineer the same words, and the same order to check things in when they break.
The mnemonic for the layers, bottom to top, is: Please Do Not Throw Sausage Pizza Away. Physical, Data Link, Network, Transport, Session, Presentation, Application. Top to bottom, it is: All People Seem To Need Data Processing. Pick one, learn it, and the order will stay with you.
Encapsulation is the idea that makes the stack work. Each layer takes the work of the layer above, wraps it in its own header, and hands it down. The packet grows as it goes down and shrinks as it comes back up. The wrapping is the overhead, and the overhead is the price of the structure.
TLS sits between layers 5 and 6 depending on which map you read, and engineers argue about it. The argument does not matter. What matters is that TLS encrypts the conversation, and that an expired certificate stops the trip at the presentation layer, whatever number you give it.
At 10x the systems, the map is still seven layers, and the debugging is still bottom-up. The tools get better, but the order does not change: cable, switch, router, transport, encryption, app. The tools check faster. The map still decides what to check.
At 100x, the design changes. The layers are implemented by different teams, on different systems, in different places. The map becomes the contract between them: this team owns layers 1 to 3, that team owns 4 to 7, and the boundary between them is written down. When the boundary is clear, failures get found. When it is not, they get bounced between teams.
Try it: the three-rung ladder. Run the three commands above in order. Interface, name, request. All three pass. That is a healthy path from bottom to top. When a real failure happens, run the same ladder. The rung that fails is the layer to fix, and the rungs below it are already proven good.
$ ip addr show lo | grep inet
inet 127.0.0.1/8 scope host lo
$ getent hosts example.com
198.18.48.185 example.com
$ curl -s -o /dev/null -w "%{http_code}\n" https://example.com
200
A server went unreachable one morning, and the whole team debugged the wrong layers for an hour. We checked the firewall rules at layer 3, restarted the app at layer 7, and reloaded the TLS certificate at layer 6. Nothing helped. The server was fine. The app was fine. The certificate was fine. A cleaner had unplugged the network cable to plug in a vacuum, and nobody had looked at the cable. Layer 1 was the fault, and we spent an hour everywhere except layer 1.
Three things. First, a rule: layer 1 is checked first, in person, before any remote debugging starts. Second, the server room sockets are labelled, and the cleaning crew knows which ones are not for vacuums. Third, a habit I now follow on every outage: if an hour of debugging has found nothing, I go and look at the machine. The map says to start at the bottom. The bottom is a cable, and a cable is checked with eyes, not with software.
Write a troubleshooting checklist for a web page that will not load. Order it by layer, bottom to top, with one check per layer. Then say what you do when every layer checks out fine but the page still does not load.
Seven layers, seven checks, and I allow five minutes per layer, which is 35 minutes for a full pass. In practice the fault is usually found in the first three layers, in under ten minutes. The checklist fits on one page. The page lives next to the on-call runbook, because a checklist you have to search for is a checklist you will not use.
Bottom-up buys certainty and costs time: checking the cable first feels slow when the symptom looks like the app. Top-down buys speed when the symptom really is the app, and costs an hour when it is not. The rule I follow is bottom-up for network symptoms and top-down for app symptoms, and when I am not sure which it is, bottom-up wins, because the bottom is cheaper to check. And when every layer checks out fine, I check my own assumptions: the wrong server, the wrong address, the wrong tab. The map cannot fix a mistake in what I think I am looking at.