lesson 1.2 · chapter 1 of 5: the pieces · 20 min
The OSI model: seven layers
objective
Name the seven layers of the OSI model, say what job each one does, and watch a message get wrapped up layer by layer on the way out and unwrapped on the way in.
Lots of jobs, one at a time
Sending a birthday present
Think about posting a birthday present to a friend in another town. Lots of people help, and each does one job:
- You choose the present and write the card.
- You wrap it, so nobody can peek.
- You write part 1 of 2 on the box, because there’s a second parcel coming.
- You write for Sam and ask for recorded delivery, so you’ll know it arrived.
- You write the full street address: town, street, house number.
- The post office puts a label on it for the local van: next stop, the sorting office.
- The van drives it down the road.
Nobody needs to know how the others do their job. The van driver doesn’t care what the present is; you don’t care which road the van takes.
in one sentence Sending something is lots of small jobs, and each helper only does their own.
Layers
Networks work the same way. Sending one message takes lots of jobs, so they’re split into layers. A layer is one job in a stack of jobs, like one floor of a building. Each layer only talks to the floor just above it and the floor just below it.
The most famous way of splitting the jobs is called the OSI model. A model is a simple picture of how something works, the way a map is a simple picture of a town. OSI stands for Open Systems Interconnection, which means a shared plan so computers made by different companies can connect. It has seven layers, and network engineers use the numbers all the time: “it’s a layer 1 problem” means check the cable.
in one sentence The OSI model splits networking into seven layers, each with one job.
The seven layers
Here they are, matched to the birthday present. Some words in the last column are new; each one gets its own lesson later, so just notice where it sits for now.
| # | Layer | Its job, in plain words | The birthday present | Examples you’ll meet later |
|---|---|---|---|---|
| 7 | Application | what the program wants to say | the present and the card | web pages, games, DHCP (lesson 4.1) |
| 6 | Presentation | get it in the right format, and scramble it so only the right person can read it | the wrapping paper | the padlock in your web browser |
| 5 | Session | keep track of a conversation that’s going on | part 1 of 2 | staying logged in to a website |
| 4 | Transport | which program it’s for, and make sure nothing’s lost | for Sam, recorded delivery | port numbers |
| 3 | Network | the address anywhere in the world, and the way to get there | the full street address | IP addresses (lesson 3.1), routers |
| 2 | Data link | get it to the next stop on this network | the label for the local van | MAC addresses (lesson 1.1), switches |
| 1 | Physical | the actual signal | the road and the van’s wheels | cables, Wi-Fi radio waves |
A port number is a number that says which program on a computer a message is for, like the name of the person in a house who should open the parcel. Lesson 5.1 covers ports, and the common numbers, in full.
Remember the layers from the bottom up with Please Do Not Throw Sausage Pizza Away: Physical, Data link, Network, Transport, Session, Presentation, Application.
in one sentence From the bottom: Physical, Data link, Network, Transport, Session, Presentation, Application.
Wrapping and unwrapping
On the way out of a computer, a message starts at the top, layer 7, and goes down. Each layer sticks a small label on the front, called a header, with the information that layer needs, like the address label on a parcel. Putting a message inside another layer’s wrapping like this is called encapsulation (it means putting into a capsule).
At the bottom, layer 1 sends it as bits. A bit is the smallest piece of computer data there is: a 1 or a 0, like a light switch that’s on or off. Down a cable, bits are pulses of electricity.
On the way in to the other computer, it goes up the layers, and each layer reads its own label and takes it off, until layer 7 has the original message.
The message has a different name depending on where it is: segment at layer 4, packet at layer 3, frame at layer 2 (a frame is a packet in its local-delivery envelope), and bits at layer 1. They’re all the same message, just wrapped differently.
in one sentence Going down, every layer adds a label; going up the other side, every layer takes its label off.
One honest note
The internet doesn’t really use all seven layers separately. It uses a simpler plan called TCP/IP (named after two of its rules: Transmission Control Protocol and Internet Protocol; a protocol is just an agreed set of rules, like everyone agreeing to write the address on the front of an envelope). TCP/IP squashes layers 5, 6 and 7 into one. People still use the OSI numbers when they talk, so learn them; just don’t be surprised when, in the DHCP lesson, layer 7 comes straight after layer 4.
in one sentence The real internet squashes layers 5 to 7 together, but everyone still talks in OSI layer numbers.
The two stacks
Every host has all seven layers. Here’s your laptop on the left and a web server on the right (a server is a computer whose job is to answer other computers; a web server sends out web pages), with a cable between their layer 1s. Messages can only cross over at the bottom: everything has to go down one side and up the other.
The colours stay the same through the whole course: layer 1 grey, layer 2 blue, layer 3 amber, layer 4 green, layers 5 to 7 purple. You’ll see them in every inside the frame box.
in one sentence Both computers have the same seven layers, and messages can only cross between them at layer 1.
Watch a message go down, across and up
You click a link to a page of cat pictures. Step through and watch the box under the picture: each layer adds its header on the way down (highlighted), and takes it off on the way up.
What to notice:
- Going down, the message gets bigger: every layer adds a header. Going up, it gets smaller again.
- Each layer only reads its own header. The switch in lesson 2.1 only ever reads the layer 2 header; a router reads layer 3.
- The message only touches the cable at layer 1.
Which layer? A quick practice
Cover the right-hand column and guess.
| Thing | Layer |
|---|---|
| The Wi-Fi radio waves | 1, physical |
AA:AA:AA:11:11:11 | 2, data link (a MAC address) |
192.168.1.10 | 3, network (an IP address) |
| Port 443 | 4, transport |
| The padlock: encryption | 6, presentation |
| The web page itself | 7, application |
in one sentence A message goes down one computer’s layers getting wrapped, crosses the cable as bits, and goes up the other’s getting unwrapped.
Which layer is broken?
When something stops working, network engineers start at layer 1 and work up. For each problem, which layer is it?
- The cat chewed through the Ethernet cable.
- Your laptop has an IP address, but it’s for the wrong network, so it can’t reach anything outside the house.
- The website loads, but shows 404 page not found.
- You’re too far from the Wi-Fi router and the signal keeps dropping.
- Two laptops on the same switch, and one has accidentally been given the other’s MAC address. Frames for one keep going to the other.
hint
Anything you could touch or measure, like a cable or a signal, is layer 1.
hint
MAC addresses are layer 2, IP addresses are layer 3, and page not found is the web server program talking.
show the solution
- Layer 1: the cable is physical.
- Layer 3: IP addresses and getting to other networks.
- Layer 7: the network delivered everything perfectly; the web server says the page doesn’t exist.
- Layer 1: radio signal strength is physical.
- Layer 2: MAC addresses and switches.
If layer 1 is broken, nothing above it works either. That’s why is it plugged in? is the first question every network engineer asks.
5 check: test yourself
Pick an answer for each question. You'll see straight away whether it's right, and why. Questions marked what happens next? are about the animations.
Which layer uses MAC addresses to get a frame to the next stop on the same network?
Layer 2 is the label for the local van: MAC addresses and the next stop. Layer 3 is the full street address.
On the way out of the laptop, what does each layer do to the message?
Going down, each layer wraps the message with its own header. Going up the other side, each layer takes its own header off.
what happens next?In the animation, the message has just reached layer 1 on the laptop, as bits. What happens next?
Layer 1 is the only place a message actually leaves the computer: as bits on the cable.
A port number, like 443 for secure websites, belongs to which layer?
Layer 4 says which program on the computer the message is for: the for Sam on the parcel.
The cat chews through the network cable. Which layer is broken?
The cable is the road itself: layer 1. When it’s broken, nothing above it can work either.