B1. The OSI Model
| Level | Foundation and Intermediate |
| Prerequisites | None, this is a starting topic |
| Study time | About 6 hours (3 h reading and video, 3 h hands-on) |
| Source | Teach-the-Teachers fiche B1 |
| Next topics | B4 Network standards & protocols · B6 Attacks, threats, vulnerabilities |
Why this matters
Every message you send over a network (a chat message, a web page, a video stream) is chopped up, wrapped in several layers of control information, sent as electrical, light or radio signals and unwrapped again at the other side. The OSI model (Open Systems Interconnection) describes that process in seven layers. It is a reference model: no computer actually "runs" OSI. It is still the shared language of network and security professionals:
- Troubleshooting. "Is it a layer 1 problem (cable unplugged), a layer 3 problem (wrong IP address) or a layer 7 problem (the web server crashed)?" Thinking in layers lets you narrow down a fault quickly.
- Security. Attacks and defences are described by layer. A layer 7 DDoS floods a web application with valid-looking requests, an ARP spoofing attack happens at layer 2, a classic packet-filtering firewall works at layers 3 and 4 and a web application firewall (WAF) works at layer 7. If you know the layers, you know which defence fits which attack.
- Communication. Vendors, colleagues and job interviews use OSI terms. "This is a layer 2 switch" or "we terminate TLS at the load balancer" only makes sense if you know the model.
Learning objectives
Foundation. After this topic you can:
- Name the seven OSI layers in order and describe the purpose of each one.
- Explain how devices use the layers to communicate across the Internet (encapsulation and decapsulation).
- Distinguish between control information (headers, handshakes, addresses) and the data (payload) itself.
Intermediate. In addition you can:
- Explain the difference between TCP and UDP and choose the right one for a given application.
- Give at least one example of an attack and a matching defence for each layer.
- Map the OSI model onto the TCP/IP model that the Internet actually uses.
Foundation: what the OSI model is
The seven layers
The model was published by ISO in 1984 (ISO/IEC 7498-1). Layers are numbered from the bottom (the physical signal) to the top (the application you use).
| # | Layer | What it does | Unit of data (PDU) | Examples | Devices |
|---|---|---|---|---|---|
| 7 | Application | Gives applications access to the network: web, mail, name lookup | Data | HTTP, DNS, SMTP, SSH | Proxy, WAF |
| 6 | Presentation | Translates, compresses and encrypts data so both sides understand it | Data | Character encoding (UTF-8), JPEG, TLS encryption* | – |
| 5 | Session | Opens, maintains and closes conversations between applications | Data | Session set-up, RPC, NetBIOS | – |
| 4 | Transport | End-to-end delivery between processes, using port numbers; reliability (TCP) or speed (UDP) | Segment (TCP) / datagram (UDP) | TCP, UDP | Stateful firewall |
| 3 | Network | Logical addressing and routing between networks | Packet | IPv4, IPv6, ICMP | Router, layer 3 switch |
| 2 | Data link | Delivery between devices on the same local network, using MAC addresses; error detection | Frame | Ethernet, Wi-Fi (802.11), ARP* | Switch, access point |
| 1 | Physical | Sends raw bits as electrical, optical or radio signals | Bit | Copper cable (RJ45), fibre, radio | Cable, hub, repeater |
* Real protocols do not always fit neatly. TLS is often placed at layer 6, but it runs on top of TCP and below HTTP. ARP connects layer 3 addresses to layer 2 addresses and sits between both layers. Don't worry about this: the model is a thinking tool, not a law.
Mnemonics. From layer 1 up: "Please Do Not Throw Sausage Pizza Away" (Physical, Data link, Network, Transport, Session, Presentation, Application). The Teach-the-Teachers fiche uses "Peter Dances Near The Soft Pink Apples" for the same order. From layer 7 down: "All People Seem To Need Data Processing."
Encapsulation: how layers work together
When you open a web page, every layer on your computer adds its own header (control information) in front of the data it receives from the layer above. This is called encapsulation:
1 2 3 4 5 | |
Every device along the way only looks at the layers it needs. A switch reads the layer 2 header to decide which port to use. A router removes the layer 2 header, reads the layer 3 destination IP address, chooses the next hop and builds a new layer 2 header for the next link. Only the destination server unwraps all the way up to layer 7 (decapsulation).
Control information versus data
LO3 of the fiche asks you to distinguish two kinds of transmitted information:
- Control information tells the network how to deliver: addresses (MAC, IP), port numbers, sequence numbers, flags, checksums, and the messages of protocols that only exist to make the network work (ARP requests, routing updates, the TCP handshake).
- Data (the payload) is what you actually want to deliver: the web page, the e-mail, the video.
This distinction matters for security. Encryption such as TLS protects the payload, but much of the control information stays visible. Anyone who can observe the traffic still sees which IP addresses talk to each other, when and how much. This is called metadata, and it can reveal a lot.
The physical layer is more than a cable
Layer 1 can be twisted-pair copper (the familiar RJ45 network cable), fibre optic (light pulses, very fast, hard to tap), radio (Wi-Fi, 4G/5G, Bluetooth) or even satellite links. Each medium has its own risks. Radio can be received by anyone nearby and can be jammed, and a copper cable can be tapped or simply cut. That is why physical security (locked server rooms, cabinets) is part of cybersecurity.
Intermediate: going deeper
OSI versus TCP/IP
The Internet is built on the TCP/IP model (also called the Internet protocol suite), which has four layers. OSI is used to talk about networks; TCP/IP is what is actually implemented.
| TCP/IP layer | OSI layers | Main protocols |
|---|---|---|
| Application | 7, 6, 5 | HTTP, HTTPS/TLS, DNS, SMTP, IMAP, SSH, FTP |
| Transport | 4 | TCP, UDP (and QUIC, which runs on top of UDP) |
| Internet | 3 | IPv4, IPv6, ICMP |
| Link (network access) | 2, 1 | Ethernet, Wi-Fi, ARP |
TCP versus UDP
Both are layer 4 protocols that deliver data to the right process on a host, identified by a port number (for example 443 for HTTPS, 53 for DNS, 22 for SSH).
| TCP (Transmission Control Protocol) | UDP (User Datagram Protocol) | |
|---|---|---|
| Connection | Connection-oriented: a three-way handshake (SYN → SYN-ACK → ACK) before data flows | Connectionless: just send |
| Reliability | Sequence numbers, acknowledgements and retransmission guarantee complete, ordered delivery | No guarantee: datagrams can be lost, duplicated or arrive out of order |
| Speed / overhead | More overhead, extra round trip | Low overhead, low latency |
| Flow and congestion control | Yes | No (the application must handle it) |
| Typical use | Web (HTTP/1.1, HTTP/2), e-mail, file transfer, SSH | DNS queries, VoIP, online games, live video, DHCP, QUIC (HTTP/3) |
| Security notes | SYN flood attacks abuse the handshake; session hijacking needs correct sequence numbers | Easy to spoof the source address; used in amplification DDoS (DNS, NTP) |
Rule of thumb. If losing a bit of data is worse than a short delay (a bank transfer, a file download), use TCP. If a delay is worse than a small loss (a voice call, a game), use UDP.
Attacks and defences per layer
| Layer | Example attacks | Example defences |
|---|---|---|
| 7 Application | SQL injection, cross-site scripting, phishing, HTTP flood (layer 7 DDoS) | Secure coding, input validation, WAF, user awareness |
| 6 Presentation | SSL stripping (downgrading HTTPS to HTTP), malicious file formats | HSTS, up-to-date TLS libraries, file validation |
| 5 Session | Session hijacking (stealing a session cookie or token) | Secure and HttpOnly cookies, short session lifetimes, re-authentication |
| 4 Transport | SYN flood, port scanning | SYN cookies, stateful firewall, rate limiting |
| 3 Network | IP spoofing, ICMP flood, route hijacking (BGP) | Ingress/egress filtering, ACLs, IPsec/VPN, RPKI |
| 2 Data link | ARP spoofing (man-in-the-middle), MAC flooding, rogue access point | Dynamic ARP inspection, port security, 802.1X, WPA3 |
| 1 Physical | Wiretapping, jamming, cable cut, stealing a device | Physical access control, fibre, locked cabinets, redundancy |
Notice the man-in-the-middle (MITM) attack from fiche B1 (P2). An attacker on your Wi-Fi can use ARP spoofing at layer 2 to make your traffic flow through their laptop. From there they can read or change anything that is not encrypted at a higher layer. This is why end-to-end encryption (TLS at layer 6/7) matters even on a "trusted" network.
In practice
Exercise 1: see the layers in Wireshark (Foundation, 45 min)
- Install Wireshark and start a capture on your Wi-Fi or Ethernet interface.
- In your browser, open
http://neverssl.com(a site that deliberately uses plain HTTP), then stop the capture. - Type the display filter
httpand select theGET /packet. In the middle pane you see the layers from bottom to top: Frame (layer 1 information), Ethernet II (layer 2, MAC addresses), Internet Protocol (layer 3, IP addresses), Transmission Control Protocol (layer 4, ports) and Hypertext Transfer Protocol (layer 7). - Right-click → Follow → TCP Stream to see the full conversation as text.
- Now repeat with an
https://site. What can you still see, and what is hidden? (Hint: filter ontls.handshake.type == 1and look for the Server Name Indication.)
Only capture traffic on networks and devices you own or are allowed to monitor. Capturing other people's traffic without permission is illegal.
Exercise 2: TCP handshake and UDP (Intermediate, 30 min)
- In the same capture, filter
tcp.flags.syn == 1. Find a SYN, the matching SYN-ACK and the ACK that follows. Note the sequence numbers. - Filter
dns. DNS normally uses UDP: notice there is no handshake, just a query and a response. - Use Statistics → Protocol Hierarchy to see which protocols were used and how much.
Exercise 3: the layers on your own machine (Foundation, 20 min)
Open a terminal (Windows: PowerShell; macOS/Linux: Terminal) and run:
| Command (Windows / Linux-macOS) | Layer | What you learn |
|---|---|---|
ipconfig /all / ip addr |
2 + 3 | Your MAC address and IP address |
arp -a / ip neigh |
2 ↔ 3 | Which MAC address belongs to which IP on your LAN |
tracert example.com / traceroute example.com |
3 | The routers (hops) between you and a server |
nslookup example.com |
7 | DNS turning a name into an IP address |
netstat -ano / ss -tunap |
4 | Open TCP/UDP connections and ports |
Exercise 4: simulate a network (Intermediate, 1–2 h)
Install Cisco Packet Tracer (free with a Networking Academy account). Build two PCs, a switch and a router, and switch to Simulation mode. Packet Tracer shows each packet's "OSI Model" tab per device, so you can see exactly which layers a switch and a router look at.
Tools
| Tool | What you use it for | Cost |
|---|---|---|
| Wireshark | Capture and inspect packets layer by layer | Free, open source |
| Wireshark sample captures | Ready-made traffic captures to practise with | Free |
| Cisco Packet Tracer | Network simulator with an OSI view per device | Free (account needed) |
Built-in commands (ipconfig, arp, tracert, nslookup, netstat) |
Inspect your own network stack | Built in |
| OSI model quiz (Sam Bowne) | Test whether you know the layers | Free |
Videos
- 🎬 OSI model explained: real-world example – CertBros (Foundation)
- 🎬 OSI model animation – TechTerms (Foundation, short)
- 🎬 OSI model: a practical perspective – Practical Networking (Intermediate)
Handouts and reading
- 📄 What is the OSI model? – Cloudflare Learning Center
- 📄 TCP vs UDP: key differences – Guru99
- 📄 OSI model: a real-world example – InetDaemon
- 🎮 Matching game: map OSI and TCP/IP layers – Educaplay
Literature and courses
- Kurose, J. & Ross, K. Computer Networking: A Top-Down Approach (Pearson). The standard textbook; chapter 1 covers layering. Free Wireshark labs accompany the book.
- Tanenbaum, A., Feamster, N. & Wetherall, D. Computer Networks (Pearson). Chapter 1 compares the OSI and TCP/IP reference models.
- 🎓 Networking Basics – Cisco Networking Academy (free online course).
- CyBOK Network Security Knowledge Area and our summary CyBOK 19.1-3 Network goals, applications and protocols.
Common mistakes
- "OSI is a protocol." It is a model. Protocols such as TCP and IP implement functions that the model describes.
- Mixing up layer 2 and layer 3 addresses. A MAC address is only meaningful on the local network and is replaced at every router hop. The IP address stays the same end to end (unless NAT changes it).
- "HTTPS hides everything." TLS encrypts the payload but not the IP addresses, ports, timing or (often) the domain name in the TLS handshake.
- "Layer 8." People jokingly call the user "layer 8". It is a reminder that many attacks (phishing, social engineering) bypass all seven technical layers.
Check yourself
- Why is the OSI model split into separate layers?
- Which layer uses MAC addresses, and which uses IP addresses?
- A router receives a frame. Which headers does it remove, read and add?
- Name two applications that use UDP and explain why.
- Which layer does a SYN flood attack target, and which defence helps?
- You can reach
8.8.8.8withpingbut cannot open any website by name. At which layer do you start looking?
Answers
1. Layers separate concerns: each layer can change (for example from Wi-Fi to fibre) without changing the others, and you can troubleshoot and secure each layer separately.
2. Layer 2 (data link) uses MAC addresses; layer 3 (network) uses IP addresses.
3. It removes the layer 2 header, reads the layer 3 destination address to choose the next hop, and adds a new layer 2 header for the outgoing link.
4. DNS (a short query, where a retry is cheaper than a handshake) and voice or video calls or games (a late packet is useless, so speed matters more than completeness).
5. Layer 4 (transport). SYN cookies, rate limiting or a DDoS protection service.
6. Layer 7: name resolution (DNS) is probably failing, because layer 3 connectivity works.
Related topics
- B4 Network standards & protocols: the protocols at each layer in more detail.
- B6 Attacks, threats, vulnerabilities: attacks per layer.
- B5 Essentials in cyber security: firewalls and IPS in the network.