The OSI and TCP/IP Models
Two layered models for describing how data travels between computers: what each layer does, how encapsulation wraps your data on the way down, and why engineers talk about 'layer 2' and 'layer 3' problems.
Why networks are described in layers
Sending a web page from a server in another country to your phone involves dozens of separate problems: turning bits into electrical, light or radio signals; deciding which device on the local link should receive a frame; finding a path across many networks; making sure missing pieces are re-sent; and finally presenting the content to an application. No single protocol does all of that.
Engineers split the job into layers. Each layer solves one problem, offers a simple service to the layer above it, and relies on the layer below. That separation has a practical payoff: you can replace Wi-Fi with Ethernet (a lower-layer change) without rewriting your web browser, and you can replace the browser without touching the cables.
Two models are in everyday use.
The OSI reference model (seven layers)
The Open Systems Interconnection (OSI) model was published by the International Organization for Standardization (ISO). It is mainly used today as a shared vocabulary.
| Layer | Name | What it is responsible for | Examples |
|---|---|---|---|
| 7 | Application | Services that applications use directly | HTTP, DNS, SMTP |
| 6 | Presentation | Data format, encoding, encryption | TLS (often discussed here), character encodings |
| 5 | Session | Starting, maintaining and ending conversations | Session handling inside protocols |
| 4 | Transport | End-to-end delivery between processes, ports, reliability | TCP, UDP |
| 3 | Network | Logical addressing and routing between networks | IP, ICMP |
| 2 | Data link | Delivery between devices on the same link, using hardware addresses | Ethernet, Wi-Fi (802.11) |
| 1 | Physical | Moving bits as signals over a medium | Copper, fibre, radio |
A common memory aid, bottom to top, is Please Do Not Throw Sausage Pizza Away. Use any sentence you will remember.
The TCP/IP model
The protocols of the internet were designed around a simpler model, defined in the IETF’s RFC 1122. It groups the layers like this:
| TCP/IP layer | Roughly covers OSI layers | Examples |
|---|---|---|
| Application | 5, 6, 7 | HTTP, DNS, SMTP, TLS |
| Transport | 4 | TCP, UDP |
| Internet | 3 | IP, ICMP |
| Link | 1, 2 | Ethernet, Wi-Fi |
Many textbooks split the link layer into two, giving a five-layer model (physical, data link, network, transport, application). Do not worry about which count your course or exam uses: what matters is knowing which job belongs to which layer.
Encapsulation: how data is wrapped on the way down
When your browser sends an HTTP request, the data goes down through the layers and each one adds its own header:
- Application data: the HTTP request itself.
- Transport layer adds a TCP header (source and destination port, sequence numbers). The unit is called a segment (for UDP it is a datagram).
- Network layer adds an IP header (source and destination IP address). The unit is a packet.
- Data link layer adds an Ethernet header (source and destination MAC address) and a trailer containing a checksum. The unit is a frame.
- Physical layer sends the frame as bits.
The receiving host does the reverse. The network card checks the frame, strips the Ethernet header and trailer, hands the packet to IP, which strips its header and hands the segment to TCP, which uses the port number to deliver the data to the right application. This is de-encapsulation.
An important consequence: different devices read different layers. A switch reads the Ethernet header. A router reads the IP header and builds a brand-new Ethernet header for the next link. A firewall may read all the way up to the transport ports or even the application. You will see this in the next lessons.
Using the layers to troubleshoot
Engineers use the layers as a checklist, usually bottom-up:
- Layer 1: Is the cable plugged in? Is the link light on? Is Wi-Fi signal present?
- Layer 2: Is the device connected to the right switch port or Wi-Fi network? Does it see the other devices on its local network?
- Layer 3: Does it have a correct IP address, mask and gateway? Can it ping the gateway, then a remote address?
- Layer 4: Is the right port open and the service listening? Is a firewall blocking the port?
- Layer 7: Is the application configured correctly? Is the name resolving?
Working bottom-up avoids the classic mistake of reconfiguring a web server when the real problem is an unplugged cable.
A laptop shows 'connected' to Wi-Fi, but cannot open any website. Pinging the router's address works, but pinging a public IP address fails. Which layer would you investigate next?
Layer 3, and the path beyond the router. The laptop reached the router (layers 1 to 3 on the local network are fine), but traffic is not getting out. Check the router’s route to the internet, NAT, and whether the ISP link is up. DNS (layer 7) would only be suspected if pinging a public IP address worked but names failed.
Can You Explain It?
Close the lesson and answer these without looking back. The goal isn't the wording — it's whether you've formed a usable mental model.
- In your own words, what does a layer offer to the layer above it?
- Walk through what happens to an HTTP request as it moves down the stack, naming the unit of data at each layer.
- Why would a switch and a router look at different parts of the same frame?
🧪 Want to practise this on your own computer? See how to set up your lab →