Why layers?
Sending a web page across the world involves apps, encryption, reliable delivery, addressing, routing, Wi-Fi radio and fibre optics. Instead of one giant program doing everything, networking is split into layers. Each layer:
- does one job,
- uses the services of the layer below, and
- offers services to the layer above.
You can replace one layer (e.g. Wi-Fi instead of Ethernet) without touching the others.
The OSI model (7 layers)
Remember top-down with “All People Seem To Need Data Processing”:
| # | Layer | Job | Examples | Data unit |
|---|---|---|---|---|
| 7 | Application | Network services for apps | HTTP, DNS, SMTP, FTP | Data |
| 6 | Presentation | Format, encode, encrypt, compress | TLS, JPEG, UTF-8 | Data |
| 5 | Session | Open, manage, close sessions | RPC, sockets | Data |
| 4 | Transport | End-to-end delivery, ports, reliability | TCP, UDP | Segment |
| 3 | Network | Logical addressing and routing | IP, ICMP | Packet |
| 2 | Data Link | Delivery on one link, MAC addresses, error detection | Ethernet, Wi-Fi | Frame |
| 1 | Physical | Bits as signals | Cables, radio, fibre | Bits |
Encapsulation and decapsulation
On the sender, data travels down the stack. Each layer adds its own header (and the data link layer also adds a trailer):
[ data ] Application
[ TCP | data ] Transport → segment
[ IP | TCP | data ] Network → packet
[ MAC | IP | TCP | data | FCS ] Data Link → frame
0101101001110… Physical → bits
On the receiver, the data travels up and each layer reads and removes the header added by its peer layer. That’s exactly the animation in the 3D model.
Each layer “talks” only to the same layer on the other machine (via headers), even though physically everything passes through the layers below.
The TCP/IP model (4 layers)
The internet actually uses the simpler TCP/IP model:
| TCP/IP layer | OSI layers | Protocols |
|---|---|---|
| Application | 7, 6, 5 | HTTP, DNS, SMTP, TLS |
| Transport | 4 | TCP, UDP |
| Internet | 3 | IP, ICMP |
| Network Access (Link) | 2, 1 | Ethernet, Wi-Fi |
OSI is the reference model used for teaching and troubleshooting (“is it a layer 2 or layer 3 problem?”); TCP/IP is the implementation.
Devices and layers
| Device | Layer | Looks at |
|---|---|---|
| Hub, repeater | 1 | Just signals |
| Switch | 2 | MAC addresses |
| Router | 3 | IP addresses |
| Firewall / load balancer | 3–7 | IPs, ports, sometimes content |
What happens when you open a website?
- DNS (application) turns
example.cominto an IP address. - TCP opens a connection with a 3-way handshake.
- TLS encrypts the conversation.
- The browser sends an HTTP request; it is encapsulated down the layers and sent.
- Routers forward the packets hop by hop using routing algorithms.
- The server decapsulates the request, sends back the page, and the process repeats in reverse.
Common mistakes
- Mixing up the order of layers — use the mnemonic.
- Saying switches route packets — they forward frames within one network; routers move packets between networks.
- Thinking TCP and IP are the same layer: TCP is transport (4), IP is network (3).
Complexity at a glance
| Case / operation | Time | Why |
|---|---|---|
| OSI layers | 7 | Reference model for teaching and troubleshooting. |
| TCP/IP layers | 4 | The model the internet actually uses. |
Quick check
Test yourself — pick an answer to see if you got it.
1. Which layer adds the source and destination IP addresses?
The Network layer (IP) handles logical addressing and routing between networks.
2. What is the PDU (data unit) called at the Transport layer?
Data → Segment (L4) → Packet (L3) → Frame (L2) → Bits (L1).
3. Encapsulation means…
The receiver does the reverse (decapsulation), removing one header per layer.
4. Which device works mainly at the Network layer?
Routers forward packets using IP addresses. Switches work at layer 2 (MAC addresses); hubs at layer 1.