7. OSI Model — Open Systems Interconnection
The OSI Model is a 7-layer conceptual framework developed by the International Organization for Standardization (ISO) to describe how data communication occurs between networked devices.
It divides network communication into seven layers, where each layer has a specific responsibility.
The seven layers are:
7. Application 6. Presentation 5. Session 4. Transport 3. Network 2. Data Link 1. Physical
A very important memory trick:
A P S T N D P
All People Seem To Need Data Processing
Or from Layer 1 upward:
Please Do Not Throw Sausage Pizza Away
1. Why Do We Need the OSI Model?
Imagine networking without a standard model.
A computer manufacturer might design one communication system, while another manufacturer uses a completely different system.
It would become difficult for different systems to communicate.
The OSI model divides communication into manageable layers.
Application ↓ Presentation ↓ Session ↓ Transport ↓ Network ↓ Data Link ↓ Physical
Each layer:
- Has specific responsibilities
- Provides services to the layer above
- Uses services from the layer below
- Communicates conceptually with the corresponding layer on another device
2. The Seven OSI Layers
| Layer | Name | Main Responsibility | Common Examples |
|---|---|---|---|
| 7 | Application | Network services for applications | HTTP, DNS, SMTP, FTP |
| 6 | Presentation | Data representation, encryption, compression | TLS/SSL concepts, encoding |
| 5 | Session | Establish/manage communication sessions | Session management |
| 4 | Transport | End-to-end delivery, reliability, ports | TCP, UDP |
| 3 | Network | Logical addressing and routing | IP, routers |
| 2 | Data Link | Frames, MAC addresses, local delivery | Ethernet, Wi-Fi |
| 1 | Physical | Bits and physical signals | Cables, radio, fiber |
Layer 7 — Application Layer
The Application Layer is the top layer of the OSI model.
It provides network-related services to applications.
User ↓ Application ↓ Layer 7
Examples include protocols used by applications such as:
- HTTP
- HTTPS
- DNS
- FTP
- SMTP
- IMAP
- SSH
Example
When you open a website:
Browser ↓ HTTP/HTTPS ↓ Network communication
HTTP operates at the application layer in the OSI conceptual model.
Important
The Application Layer does not mean the entire application itself.
For example:
Chrome Firefox WhatsApp
are applications.
Protocols such as:
HTTP DNS SMTP
provide network services used by applications.
Layer 6 — Presentation Layer
The Presentation Layer is responsible for how data is represented.
It can handle concepts such as:
- Data formatting
- Encoding/decoding
- Encryption/decryption
- Compression/decompression
The goal is to make sure that data can be represented in a form that the receiving system understands.
Example
Suppose an application needs to send:
Hello
The data may need to be represented using an encoding such as:
UTF-8
The Presentation Layer conceptually handles data representation.
Encryption
Encryption can also be associated with the Presentation Layer in the traditional OSI model.
For example:
Plaintext ↓ Encryption ↓ Ciphertext
However, in real-world networks, encryption such as TLS doesn't map perfectly to only one OSI layer.
This distinction is important:
The OSI model is a conceptual framework, while real protocols often span or don't fit neatly into a single layer.
Compression
Data can be compressed:
Original Data ↓ Compression ↓ Smaller Data
This can reduce the amount of data that needs to be transmitted.
Layer 5 — Session Layer
The Session Layer is responsible for establishing, managing, and terminating communication sessions between applications.
Think of a session as a logical conversation.
Start Session ↓ Communication ↓ Manage Session ↓ End Session
Responsibilities
- Session establishment
- Session management
- Session termination
- Synchronization/checkpoints
Example
Imagine a long data transfer.
A session mechanism could conceptually establish:
Start ↓ Data Part 1 ↓ Checkpoint ↓ Data Part 2 ↓ Checkpoint ↓ End
If something fails, checkpoints can help with recovery in systems that support such mechanisms.
Important
In modern TCP/IP networking, the Session and Presentation functions are often implemented within applications or other protocol layers rather than as separate protocol layers.
Layer 4 — Transport Layer
The Transport Layer provides end-to-end communication between applications/processes.
This is one of the most important layers for networking.
Main protocols:
- TCP
- UDP
Main Responsibilities
1. Segmentation
Large application data can be divided into smaller units.
Large Data ↓ Segment 1 Segment 2 Segment 3
2. Reliability
TCP can provide reliable delivery using mechanisms such as:
- Sequence numbers
- Acknowledgments
- Retransmissions
- Flow control
3. Port Numbers
Ports identify application/service endpoints.
Example:
Server IP: 192.168.1.10 Port 80 → HTTP Port 443 → HTTPS Port 22 → SSH
4. Flow Control
TCP can regulate how much data is sent so the receiver isn't overwhelmed.
5. Error Recovery
TCP can detect missing data and retransmit it.
TCP vs UDP
TCP
Reliable Connection-oriented Ordered delivery Acknowledgments Retransmission
UDP
Connectionless Lower overhead No built-in guarantee of delivery No built-in ordering guarantee
Examples:
TCP → Web, SSH, many application protocols UDP → DNS queries, streaming/real-time applications, QUIC transport
You'll study TCP and UDP separately later.
Layer 3 — Network Layer
The Network Layer handles logical addressing and routing between networks.
The most important protocol associated with this layer is:
IP — Internet Protocol
Main responsibilities:
- Logical addressing
- Routing
- Packet forwarding
- Inter-network communication
IP Address
Example:
192.168.1.10
An IP address helps identify an interface in an IP network.
IPv6 example:
2001:db8::10
Routing
Suppose:
Computer A Network A │ ↓ Router │ ↓ Network B │ ↓ Computer B
The router determines where the IP packet should be forwarded.
Conceptually:
Source IP ↓ Router ↓ Destination IP
Router and Layer 3
A traditional router primarily operates at Layer 3.
LAN 1 │ ↓ Router │ ↓ LAN 2
It examines Layer 3 information, such as destination IP addresses, to make forwarding decisions.
Layer 2 — Data Link Layer
The Data Link Layer handles communication over a local network/link.
Important concepts include:
- MAC addresses
- Ethernet frames
- Wi-Fi frames
- Local delivery
- Error detection
- Switching
MAC Address
Example:
A4:5E:60:12:AB:91
A MAC address identifies a network interface at Layer 2.
Frame
At Layer 2, data is typically organized into a frame.
Simplified:
┌──────────┬──────────┬──────────┐ │ Header │ Data │ Trailer │ └──────────┴──────────┴──────────┘
An Ethernet frame includes information such as:
- Source MAC
- Destination MAC
- Payload
- Error-detection information
Switch and Layer 2
A typical Ethernet switch operates primarily at Layer 2.
PC1 │ ↓ Switch │ ↓ PC2
The switch uses MAC addresses to make forwarding decisions.
Layer 1 — Physical Layer
The Physical Layer is the lowest OSI layer.
It deals with transmitting raw bits as physical signals.
101101001010 ↓ Physical Signals ↓ Cable / Fiber / Radio
Examples
- Ethernet cables
- Fiber-optic cables
- Radio waves
- Connectors
- Electrical signals
- Optical signals
- Physical transmission characteristics
What Does Layer 1 Actually Send?
Layer 1 deals with physical representation of bits.
For example:
10110010
may be represented using electrical, optical, or radio signals depending on the transmission technology.
Repeater and Layer 1
A traditional repeater works primarily at Layer 1.
Signal ↓ Repeater ↓ Regenerated Signal
It doesn't understand IP addresses or TCP ports.
How the Seven Layers Work Together
Suppose you open:
https://example.com
Your data moves down the layers when being transmitted.
Sender ──────────────────────────── Layer 7 Application HTTP/HTTPS ↓ Layer 6 Presentation Data representation ↓ Layer 5 Session Session functions ↓ Layer 4 Transport TCP/UDP ↓ Layer 3 Network IP ↓ Layer 2 Data Link Ethernet/Wi-Fi ↓ Layer 1 Physical Bits/signals
Then the receiving device processes the data upward:
Receiver Layer 1 Physical ↓ Layer 2 Data Link ↓ Layer 3 Network ↓ Layer 4 Transport ↓ Layer 5 Session ↓ Layer 6 Presentation ↓ Layer 7 Application
Encapsulation
One of the most important OSI concepts is encapsulation.
As data moves down the stack, each layer adds information needed by that layer.
Conceptually:
Application Data ↓ Segment ↓ Packet ↓ Frame ↓ Bits
More detailed:
┌─────────────────────────────────────┐ │ Application Data │ └─────────────────────────────────────┘ ↓ ┌──────────┬──────────────────────────┐ │ TCP/UDP │ Application Data │ └──────────┴──────────────────────────┘ ↓ ┌──────────┬──────────────────────────┐ │ IP │ TCP/UDP + Data │ └──────────┴──────────────────────────┘ ↓ ┌────────┬────────────────────────────┬────────┐ │ MAC │ IP + TCP/UDP + Data │ FCS │ └────────┴────────────────────────────┴────────┘ ↓ Bits
Decapsulation
At the receiver, the reverse process occurs.
Bits ↓ Frame ↓ Packet ↓ Segment ↓ Application Data
Each layer processes/removes the information relevant to it.
This process is called decapsulation.
PDU — Protocol Data Unit
Each layer has a commonly used name for its data unit.
| OSI Layer | PDU |
|---|---|
| 7 Application | Data |
| 6 Presentation | Data |
| 5 Session | Data |
| 4 Transport | Segment (TCP) / Datagram (UDP) |
| 3 Network | Packet |
| 2 Data Link | Frame |
| 1 Physical | Bits |
A simplified memory chain:
Data ↓ Segment ↓ Packet ↓ Frame ↓ Bits
Addressing at Different Layers
Different layers use different kinds of identifiers.
Layer 2 → MAC Address Layer 3 → IP Address Layer 4 → Port Number
Example:
MAC: AA:BB:CC:DD:EE:FF IP: 192.168.1.10 Port: 443
These identify different things:
- MAC → local network interface
- IP → IP-layer source/destination
- Port → application/service endpoint
Example: Opening an HTTPS Website
Suppose:
Client IP: 192.168.1.10 Server IP: 203.0.113.10 Server Port: 443
A simplified conceptual stack:
Application HTTPS ↓ Transport TCP ↓ Network IP ↓ Data Link Ethernet ↓ Physical Cable/Wi-Fi
The packet may conceptually contain:
Ethernet Header ↓ IP Header ↓ TCP Header ↓ HTTPS/Application Data ↓ Ethernet Trailer
OSI Model and Network Devices
A useful simplified mapping:
Layer 7 ─ Application Layer 6 ─ Presentation Layer 5 ─ Session Layer 4 ─ Transport Layer 3 ─ Router Layer 2 ─ Switch / Bridge Layer 1 ─ Hub / Repeater
Important
This is a simplified educational mapping.
Modern devices are often multifunctional.
For example:
Firewall Load Balancer Layer-3 Switch Proxy
can operate across multiple layers.
OSI Model Example: Sending a Message
Suppose your application sends:
Hello
Layer 7
Application generates the data:
Hello
Layer 6
Data representation/encryption may occur:
Encoded/Encrypted Data
Layer 5
Session-related mechanisms manage the communication.
Layer 4
TCP may add transport information:
TCP Header + Data
Layer 3
IP adds source and destination information:
IP Header + TCP Segment
Layer 2
Ethernet adds local delivery information:
MAC Header + IP Packet + FCS
Layer 1
The frame is transmitted as physical signals/bits.
OSI Model and Troubleshooting
The OSI model is extremely useful when troubleshooting networks.
Suppose your computer cannot access the Internet.
You can troubleshoot layer by layer.
Layer 1 — Physical
Check:
- Cable connected?
- Wi-Fi enabled?
- Link light?
- Network interface working?
- Power?
PC ───X─── Switch
Layer 2 — Data Link
Check:
- Ethernet/Wi-Fi association
- MAC-level connectivity
- VLAN configuration
- Switch port
Layer 3 — Network
Check:
- IP address
- Subnet mask/prefix
- Default gateway
- Routing
For example:
ip addr ip route
Layer 4 — Transport
Check:
- Is the destination port reachable?
- Is a firewall blocking the connection?
- Is the service listening?
Example:
TCP 443 TCP 22
Layer 7 — Application
Check:
- Is the web service working?
- Is DNS working?
- Is the application configured correctly?
This approach helps isolate problems systematically.
OSI vs TCP/IP Model
The OSI model has 7 layers.
The TCP/IP model is commonly represented using 4 layers or sometimes 5 layers, depending on the textbook.
A common 4-layer mapping:
OSI TCP/IP Application ─────┐ Presentation ────┼── Application Session ──────────┘ Transport ───────── Transport Network ─────────── Internet Data Link ───────┐ Physical ────────┴── Network Access
So:
OSI: 7 layers TCP/IP: 4 layers
We'll cover the TCP/IP model separately.
Important Differences Between OSI Layers
Layer 1 vs Layer 2
Layer 1:
Bits + physical signals
Layer 2:
Frames + MAC addresses
Layer 2 vs Layer 3
Layer 2:
MAC Local network Switch
Layer 3:
IP Different networks Router
Layer 3 vs Layer 4
Layer 3:
Where should the packet go?
Layer 4:
Which application/service should receive it?
Example:
IP: 192.168.1.10 Port: 443
IP gets the packet to the host/network destination.
Port identifies the service/application endpoint.
Easy Real-World Analogy
Imagine sending a parcel.
Layer 7 — Application
You decide what you want to send.
"Hello"
Layer 6 — Presentation
You format/package the contents appropriately.
Layer 5 — Session
You manage the conversation/session.
Layer 4 — Transport
You organize the delivery and ensure appropriate end-to-end transport behavior.
Layer 3 — Network
You put the destination address on the route.
Destination: City B
Layer 2 — Data Link
You handle delivery over the current local link.
Next local hop
Layer 1 — Physical
The actual truck/road/physical movement.
This analogy is simplified, but it helps remember the basic purpose of each layer.
OSI Model — Complete Revision Table
| Layer | Name | Main Job | Address/Unit | Examples |
|---|---|---|---|---|
| 7 | Application | Network services for applications | Data | HTTP, DNS, SMTP, SSH |
| 6 | Presentation | Representation, encryption, compression | Data | Encoding, TLS-related functions |
| 5 | Session | Session management | Data | Session mechanisms |
| 4 | Transport | End-to-end transport | Port / Segment | TCP, UDP |
| 3 | Network | Routing & logical addressing | IP / Packet | IP, routers |
| 2 | Data Link | Local delivery | MAC / Frame | Ethernet, Wi-Fi |
| 1 | Physical | Physical transmission | Bits | Cable, fiber, radio |
The Most Important Things to Memorize
Seven layers
7 → Application 6 → Presentation 5 → Session 4 → Transport 3 → Network 2 → Data Link 1 → Physical
Mnemonic
All People Seem To Need Data Processing
Devices
Layer 1 → Hub / Repeater Layer 2 → Switch / Bridge Layer 3 → Router
Addresses
Layer 2 → MAC Layer 3 → IP Layer 4 → Port
Data units
L7-L5 → Data L4 → Segment / Datagram L3 → Packet L2 → Frame L1 → Bits
Communication flow
Sender Receiver Application Application ↓ ↑ Presentation Presentation ↓ ↑ Session Session ↓ ↑ Transport Transport ↓ ↑ Network Network ↓ ↑ Data Link Data Link ↓ ↑ Physical ───────────────────> Physical
Core idea: The OSI model doesn't mean that every real protocol maps perfectly to exactly one layer. It is primarily a standard conceptual framework for understanding, designing, and troubleshooting network communication.