The OSI and TCP/IP Models
Understand why networking is split into layers, what each OSI and TCP/IP layer does, and how encapsulation wraps data in headers as it travels.
Welcome back!
Step 1 of 11Learn
Why layers?
Sending a message across the internet involves wildly different problems: turning bits into electrical pulses or radio waves, getting a frame to the next device on the same link, finding a route across continents, making sure nothing is lost, and formatting a web page. No single protocol could handle all of that well.
So networking is split into layers. Each layer solves one problem, uses the services of the layer below and offers services to the layer above. The big benefit is independence: your browser doesn't care whether you are on Wi-Fi, fiber or a phone network, and Wi-Fi doesn't care whether it is carrying a web page or a video call. Engineers can improve one layer, say a faster Wi-Fi standard, without rewriting the others.
Two models describe these layers:
- The OSI model has seven layers. It was designed as a teaching and reference model, and its layer numbers became the vocabulary of the industry. You will hear people say "that's a Layer 2 problem" or "a Layer 7 load balancer".
- The TCP/IP model has four layers and matches how the internet's protocols are actually built.
You don't need to memorize every detail. You need to know what each layer is responsible for, so you can describe where a problem lives and understand which device or protocol is involved.
Step 2 of 11Learn
The seven OSI layers
From the bottom up:
| # | Layer | Job | Examples |
|---|---|---|---|
| 7 | Application | Network services that programs use | HTTP, DNS, SMTP |
| 6 | Presentation | Data formats, encryption, compression | TLS encryption, character encoding |
| 5 | Session | Opening, managing and closing conversations | session setup in some protocols |
| 4 | Transport | End-to-end delivery between programs, using ports | TCP, UDP |
| 3 | Network | Logical addressing and routing between networks | IP, routers |
| 2 | Data link | Delivery to the next device on the same link, using MAC addresses | Ethernet, Wi-Fi, switches |
| 1 | Physical | Bits as signals on a medium | cables, fiber, radio, connectors |
A popular memory aid from Layer 1 upward is "Please Do Not Throw Sausage Pizza Away": Physical, Data link, Network, Transport, Session, Presentation, Application.
In practice, layers 5 and 6 are thin and usually handled inside applications, which is why the TCP/IP model folds them into one Application layer. The layers that come up most in troubleshooting are 1 (is it plugged in?), 2 (is it on the right local network?), 3 (does it have a correct IP address and route?), 4 (is the port open?) and 7 (is the service itself working?).
Step 3 of 11Practice · Put in order
Put the OSI layers in order from Layer 1 (bottom) to Layer 7 (top).
Drag the items, or use the arrow buttons, to put them in order.
- Physical
- Session
- Application
- Data link
- Network
- Presentation
- Transport
Step 4 of 11Practice · Match the pairs
Match each item to its OSI layer.
Tap an answer, then tap the place where it belongs (or drag it there).
- Fiber optic cable
- Ethernet switch forwarding by MAC address
- Router choosing a path by IP address
- TCP port 443
- A web browser's HTTP request
Step 5 of 11Diagram
The OSI stack, top to bottom
Tap a layer to see a real example of something that lives there.
Tap a shape with to see more.
- 7 Application
HTTP, DNS, SMTP: what programs speak.
- 6 Presentation
Formats and encryption, such as TLS and character encodings.
- 5 Session
Starting, keeping and ending conversations.
- 4 Transport
TCP and UDP, with port numbers.
- 3 Network
IP addresses and routers.
- 2 Data link
MAC addresses, switches, Wi-Fi association.
- 1 Physical
Cables, connectors, radio signals, light pulses.
Step 6 of 11Learn
Encapsulation: envelopes inside envelopes
As data moves down the layers on the sending computer, each layer adds its own header with the information it needs. This is encapsulation.
- The browser creates an HTTP request (application data).
- TCP adds a header with source and destination ports and a sequence number. The result is a segment.
- IP adds a header with source and destination IP addresses. Now it is a packet.
- Ethernet or Wi-Fi adds a header with MAC addresses and a trailer with an error check. Now it is a frame.
- The physical layer sends the frame as bits: voltages, light pulses or radio waves.
At each router along the way, the frame is unwrapped to read the IP header, then rewrapped in a new frame for the next link, because MAC addresses only matter on one link while IP addresses stay the same end to end (except where NAT rewrites them, which you'll see later). At the destination, each layer strips its header and passes the rest up, until the web server receives the original HTTP request.
The names of the wrapped units are worth knowing because they hint at the layer being discussed: frame (Layer 2), packet (Layer 3), segment (Layer 4 TCP; a UDP unit is called a datagram).
Step 7 of 11Practice · Fill in the blanks
Fill in the blanks
At Layer 2 the unit of data is called a , at Layer 3 it is called a , and a TCP unit at Layer 4 is called a .
Step 8 of 11Compare
OSI vs. TCP/IP
| Aspect | OSI model | TCP/IP model |
|---|---|---|
| Number of layers | 7 | 4 (some books use 5, splitting the bottom layer in two) |
| Top | Application, Presentation, Session | Application (covers all three) |
| Middle | Transport; Network | Transport; Internet |
| Bottom | Data link; Physical | Link (network access) |
| Main use today | Shared vocabulary and troubleshooting language | Describes how real internet protocols are built |
Step 9 of 11Note
Step 10 of 11Practice · Choose one
A user reports "the network is broken". You find the cable unplugged from the wall jack. Which OSI layer did the problem live at?
Step 11 of 11Practice · What would you do?
What would you do?
A coworker says, "My laptop shows it's connected to Wi-Fi with a strong signal, it has a valid IP address and can ping the router, but one particular website shows an error page from the site itself." Where is the problem most likely?
Lesson complete!