The OSI model
Place any protocol or device on the correct OSI layer and explain each layer's job.
By Invicly Tech, , in Computer Networking. About 10 minutes to read.
In short
The OSI model splits networking into seven layers, each with one responsibility and a clear interface to the layers above and below. Real networks run TCP/IP rather than OSI protocols, but the OSI layer numbers are the shared vocabulary engineers use. They also give you a systematic order for troubleshooting.
Explained simply
Sending data across a network involves many jobs: turning bits into signals, finding the right machine, making sure nothing is lost, and understanding what the data means. The OSI model splits these jobs into seven layers, stacked on top of each other, so you can think about one job at a time.
Each layer only talks to the layer directly above and below it on the same machine. But it acts as if it were talking to the same layer on the other machine. Your browser speaks HTTP to the web server; it does not care whether the bits travel over Wi-Fi or fibre.
Engineers use the layer numbers as shorthand. A layer 2 problem is about switches and MAC addresses. A layer 3 problem is about IP addresses and routing. A layer 7 load balancer understands HTTP. If you know the numbers, you can follow almost any networking conversation.
The model is also a checklist for fixing problems. Is the cable plugged in (layer 1)? Does the switch see the device (layer 2)? Does it have the right IP address (layer 3)? Is the port open (layer 4)? Is the app replying (layer 7)? Checking in order stops you from guessing.
Press Play on a diagram to walk through it one step at a time.
- 17 Application
HTTP, DNS, SMTP
- 26 Presentation
Encoding, compression, encryption
- 35 Session
Dialogue setup and teardown
- 44 Transport
TCP, UDP; ports
- 53 Network
IP, routing; routers
- 62 Data link
Ethernet, MAC; switches
- 71 Physical
Cables, radio, bits on the wire
- 17 Application
curl -v https://site returns 200
- 24 Transport
nc -zv host 443 says succeeded
- 33 Network
ping gateway and remote IP
- 42 Data link
ip neigh shows the gateway MAC
- 51 Physical
ethtool shows Link detected: yes
In depth
Services down, peers across
Two ideas make the model work. Vertically, each layer offers a service to the one above. TCP (layer 4) offers a reliable byte stream; it uses IP (layer 3), which only offers best-effort delivery of packets. Horizontally, each layer has a peer on the other machine, and the two follow a protocol with each other by reading and writing their own header.
This is why you can change one layer without touching the others. Moving from Wi-Fi to Ethernet changes layers 1 and 2, but TCP, TLS and HTTP keep working unchanged. Moving from HTTP/1.1 to HTTP/2 changes layer 7 without new cables. Clean boundaries are what let the internet evolve piece by piece for decades.
- Browser L7 to Client TCP L4: Hand down: send these HTTP bytes1Hand down: send these HTTP bytes
- Client TCP L4 to Server TCP L4: Segment with TCP header (ports, seq)2Segment with TCP header (ports, seq)
- Server TCP L4 to Web server L7: Hand up: HTTP bytes in order3Hand up: HTTP bytes in order
- Web server L7 to Server TCP L4: Hand down: HTTP response4Hand down: HTTP response
- Server TCP L4 to Client TCP L4: Segments plus ACKs5Segments plus ACKs
- Client TCP L4 to Browser L7: Hand up: response bytes6Hand up: response bytes
Protocols that refuse to sit in one box
Real protocols were designed for TCP/IP, not for OSI, so some sit awkwardly. ARP maps IP addresses (layer 3) to MAC addresses (layer 2) and is carried directly in Ethernet frames, so people call it layer 2.5. ICMP is carried inside IP packets but is part of the network layer's own control system. OSPF runs directly over IP as protocol number 89, while BGP runs over TCP port 179, yet both exist to serve layer 3 routing.
TLS is the classic puzzle: it encrypts (a layer 6 idea), keeps a session (layer 5) and runs over TCP. Most engineers simply say TLS sits between transport and application. The goal is clear thinking, not perfect boxes.
- ARP: between layers 2 and 3
- ICMP: layer 3 control messages
- OSPF: IP protocol 89; BGP: TCP port 179
- TLS: between layer 4 and layer 7
- DNS: layer 7, usually over UDP or TCP port 53
Mapping devices to layers
A device's layer is the highest header it reads to make a forwarding decision. A hub, repeater or media converter only regenerates bits: layer 1. A switch reads the Ethernet header and forwards by MAC address: layer 2. A router reads the IP header and forwards by destination IP: layer 3. A layer 3 switch does both in hardware and is common in office cores.
Higher up, a stateful firewall tracks layer 4 connections (addresses, ports and TCP state), and a next-generation firewall also inspects layer 7. A layer 4 load balancer spreads TCP or UDP flows by address and port; a layer 7 load balancer reads HTTP and can route by URL path or header. Asking which header a box reads tells you what it can and cannot do.
Troubleshooting by layer
There are three common strategies. Bottom-up starts at layer 1 and moves up; use it when nothing works at all, for example a new machine with no network. Top-down starts at the application and moves down; use it when most things work and only one app fails, since lower layers are probably fine. Divide-and-conquer starts in the middle, often with a ping at layer 3: if ping works, layers 1 to 3 are fine and you move up; if not, you move down.
Whatever you choose, test one layer at a time and write down what you proved. A successful ping to the gateway proves the cable, the switch port, the VLAN and the IP settings in one step.
- Start at cables and link lights
- Best when nothing works
- Thorough but slow
- Start at the failing app
- Best when only one app fails
- Fast when lower layers are fine
- Start with ping (layer 3)
- Go up if it works, down if not
- Usually the quickest
Learn it in 4 short steps
About 40m each. Track them with a timer in your plan.
- 1Name the seven layers in order~40m
- 2Give example protocols per layer~40m
- 3Map devices to layers~40m
- 4Use layers to structure troubleshooting~40m
Key points
- Each layer serves the one above and uses the one below.
- Switches work at layer 2, routers at layer 3, load balancers at 4 or 7.
- Layers 5 and 6 are folded into the application layer in TCP/IP.
- Troubleshoot from layer 1 upwards when nothing works at all.
Key terms
Tap a card to flip it. 0/4 known
Examples
A new desktop has no network at all
Nothing works, so go bottom-up. Layer 1: ethtool shows Link detected: no. The link light is off. You swap the patch cable and the link comes up at 1000Mb/s full duplex. Layer 2: ip neigh shows no gateway entry yet, so you ping the gateway, and now it appears as REACHABLE. Layer 3: ip addr shows a 169.254.x.x address, which means DHCP failed earlier; you renew the lease and get 10.0.10.57/24. Layer 7: the browser now loads pages. Each step proved one layer before moving on.
ethtool eth0 | grep -E 'Speed|Duplex|Link detected'
ip -br addr show eth0
sudo dhclient -r eth0 && sudo dhclient eth0 # or: nmcli device reapply eth0
ping -c 2 10.0.10.1
ip neigh show dev eth0Only one website fails
Everything else works, so go top-down. Layer 7: curl -v https://shop.example.com hangs after Connected to, then times out during the TLS handshake. Layer 4: nc -zv shop.example.com 443 succeeds, so the TCP port is open. That narrows the fault to TLS or the app. Trying curl with -4 and -6 shows IPv4 works but IPv6 hangs, so the real issue is a broken IPv6 path to that one site. You report it to the site owner with the exact test results.
curl -v --max-time 10 https://shop.example.com
nc -zv shop.example.com 443
curl -4 -sS -o /dev/null -w '%{http_code}\n' https://shop.example.com
curl -6 -sS -o /dev/null -w '%{http_code}\n' https://shop.example.comQuick reference
- Mnemonic, layers 1 to 7: Please Do Not Throw Sausage Pizza Away
- Hub = L1, switch = L2, router = L3, L4 and L7 for load balancers and firewalls
- PDUs: bits (L1), frame (L2), packet (L3), segment or datagram (L4), data (L5-7)
- A device's layer = the highest header it reads to forward traffic
- Nothing works: go bottom-up. One app fails: go top-down
- A ping to the gateway proves layers 1 to 3 on the local link in one step
Common mistakes
- Trying to place every protocol neatly; TLS and ARP sit between layers.
- Treating OSI as the protocols the internet actually runs.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Place each item on its OSI layer: Ethernet switch, HTTP, IP router, fibre cable, TCP, MAC address, port 443.
- Exercise 2medium
Write one Linux command that tests each of layers 1, 2, 3, 4 and 7 for the web server 10.0.20.15 on port 443.
- Exercise 3hard
A user reports: email works, websites by name fail, but ping 1.1.1.1 works. Using layers, list your next three tests and what each result would prove.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Do real networks use the OSI model?
- Not its protocols. The internet runs the TCP/IP suite, but everyone still uses OSI layer numbers to describe where a device or problem sits.
- What is the easiest way to remember the seven layers?
- From layer 1 up: Please Do Not Throw Sausage Pizza Away (Physical, Data link, Network, Transport, Session, Presentation, Application).
- Is a layer 3 switch a router?
- Functionally yes for routing between VLANs: it forwards by IP address in hardware. It usually has fewer WAN features than a dedicated router, such as advanced NAT or VPNs.
- Which layer is DNS?
- DNS is an application layer (layer 7) protocol. It normally uses UDP port 53 and falls back to TCP port 53 for large answers.