OSI Model Layers Explained – Functions, Protocols and Real-World Examples
What You Will Learn
- What the OSI model is and why it was created
- All 7 OSI layers with functions, protocols, and real examples
- How data flows through the stack (encapsulation and decapsulation)
- The TCP/IP model and its 4 layers
- Key differences between OSI and TCP/IP models
- How devices like switches, routers, and firewalls map to OSI layers
1. What is the OSI Model?
The OSI model (Open Systems Interconnection model) is a conceptual framework that describes how data communication works between two devices over a network. It was developed by the International Organisation for Standardisation (ISO) in 1984.
Think of it like the postal system. When you send a letter, it goes through several steps — writing the letter, putting it in an envelope, addressing it, dropping it at the post office, sorting it, transporting it, delivering it. Each step is handled independently, and each step only needs to know what the step below it does. The OSI model works the same way for network communication.
The model divides the complex problem of “how do two computers talk to each other?” into 7 manageable layers, each with a specific job. This separation makes it easier to design, troubleshoot, and replace individual components without affecting the entire system.
2. The 7 OSI Layers
A helpful mnemonic to remember the layers from top to bottom: “All People Seem To Need Data Processing” (Application, Presentation, Session, Transport, Network, Data Link, Physical).
Layer 7 – Application Layer
The topmost layer is the one closest to the end user. It provides the interface between the network and the application software.
- Function: Provides network services directly to applications; handles resource sharing, remote file access, directory services
- Protocols: HTTP, HTTPS (web), FTP (file transfer), SMTP/POP3/IMAP (email), DNS (domain names), DHCP (IP assignment), SSH (secure shell)
- Real example: When you type a URL in your browser, the browser uses HTTP/HTTPS at this layer to request the webpage
- PDU (Protocol Data Unit): Data / Message
Layer 6 – Presentation Layer
This layer acts as a translator. It ensures that data sent from one system’s application layer can be read by another system’s application layer, regardless of how the data is formatted internally.
- Function: Data translation (e.g., ASCII to EBCDIC), encryption/decryption, compression/decompression
- Protocols/Standards: SSL/TLS (encryption), JPEG, PNG, MP3, MP4 (media formats), ASCII, Unicode
- Real example: When you visit a banking website, TLS encryption happens at this layer — your credit card number is encrypted before transmission
- PDU: Data
Layer 5 – Session Layer
This layer manages communication sessions — it establishes, maintains, and terminates connections between applications on different computers.
- Function: Session establishment, maintenance, and termination; dialog control (half-duplex or full-duplex); synchronisation (checkpoints for long transfers)
- Protocols: NetBIOS, RPC (Remote Procedure Call), PPTP
- Real example: When you log into a website, the session layer manages the continuous connection between your browser and the server for the duration of your session
- PDU: Data
Layer 4 – Transport Layer
The transport layer is responsible for end-to-end communication between two applications (not just two computers). It ensures complete data transfer.
- Function: Segmentation and reassembly of data, error control, flow control, multiplexing (using port numbers to identify applications)
- Protocols: TCP (Transmission Control Protocol — reliable), UDP (User Datagram Protocol — fast, unreliable)
- Real example: When you download a file, TCP breaks it into segments, numbers them, and guarantees they all arrive correctly. When you watch a live stream, UDP sends packets without waiting for confirmation (speed over reliability)
- PDU: Segment (TCP) or Datagram (UDP)
Layer 3 – Network Layer
The network layer handles logical addressing and routing — it determines the best path for data to travel from source to destination across multiple networks.
- Function: Logical addressing (IP addresses), routing (choosing the best path), fragmentation of packets when needed
- Protocols: IP (IPv4, IPv6), ICMP (ping, error messages), OSPF, BGP, RIP (routing protocols), ARP (address resolution)
- Real example: When you send an email from India to the USA, the Network layer determines the route your data packets take — through multiple routers, potentially across submarine cables
- PDU: Packet
- Device: Router
Layer 2 – Data Link Layer
The data link layer provides reliable transfer of frames between two directly connected nodes (e.g., your computer and your Wi-Fi router). It handles physical addressing using MAC addresses.
- Function: Framing, physical addressing (MAC addresses), error detection and correction, media access control (who can transmit when)
- Sub-layers: LLC (Logical Link Control — upper) and MAC (Medium Access Control — lower)
- Protocols: Ethernet (802.3), Wi-Fi (802.11), PPP, HDLC
- Real example: Your laptop sending data to your Wi-Fi router — the data link layer puts your laptop’s MAC address and the router’s MAC address in the frame header
- PDU: Frame
- Device: Switch, Bridge, Network Interface Card (NIC)
Layer 1 – Physical Layer
The lowest layer deals with the actual physical transmission of raw bits over a physical medium. It defines the hardware specifications — voltages, cable types, pin layouts, frequencies.
- Function: Bit-by-bit transmission of raw data; defines electrical/optical/radio signals, transmission rates, physical connectors
- Standards: Ethernet (cabling specs), USB, Bluetooth, Wi-Fi (802.11 physical), DSL, Fibre optic
- Real example: The Cat6 Ethernet cable running from your router to your PC, or the Wi-Fi radio waves carrying data through the air
- PDU: Bits
- Device: Hub, Repeater, Modem, Cable
OSI Layers Summary Table
| # | Layer | Key Function | PDU | Key Protocols | Device |
|---|---|---|---|---|---|
| 7 | Application | Network services to apps | Data | HTTP, FTP, DNS, SMTP | — |
| 6 | Presentation | Translation, encryption | Data | TLS, JPEG, ASCII | — |
| 5 | Session | Session management | Data | NetBIOS, RPC | — |
| 4 | Transport | End-to-end delivery, ports | Segment/Datagram | TCP, UDP | — |
| 3 | Network | Logical addressing, routing | Packet | IP, ICMP, OSPF | Router |
| 2 | Data Link | Physical addressing, framing | Frame | Ethernet, Wi-Fi | Switch |
| 1 | Physical | Raw bit transmission | Bits | Ethernet (physical), USB | Hub |
3. Encapsulation and Data Flow
Encapsulation is the process of wrapping data with header information as it moves down the OSI layers from sender to receiver.
How Encapsulation Works (Sender Side)
- Application layer: Creates the original message (e.g., an HTTP request for a webpage)
- Presentation layer: Encrypts/compresses the data → still called “data”
- Session layer: Adds session identifiers → still “data”
- Transport layer: Adds TCP/UDP header (source port, destination port, sequence number) → becomes a Segment
- Network layer: Adds IP header (source IP, destination IP) → becomes a Packet
- Data Link layer: Adds Ethernet frame header (source MAC, destination MAC) and trailer (CRC for error detection) → becomes a Frame
- Physical layer: Converts frame to electrical/optical/radio signals → transmitted as Bits
Decapsulation (Receiver Side)
At the destination, the process reverses. Each layer reads and strips its own header, then passes the remaining data up to the next layer. The application eventually receives the original message.
Think of sending a letter internationally:
You write the letter (Application)
You seal it in an envelope and write the address (Transport/Network)
The post office puts it in a mail bag for the next sorting facility (Data Link)
It travels by plane/truck (Physical)
At each stop, the outer bag is opened, the correct letters sorted out, and repackaged for the next leg — exactly like decapsulation at each network hop.
4. Network Devices and OSI Layers
Different networking devices operate at different OSI layers, which determines what they can “understand” and act upon.
| Device | OSI Layer | What It Processes | How It Makes Decisions |
|---|---|---|---|
| Hub / Repeater | Layer 1 (Physical) | Bits only | Broadcasts all bits to all ports — no intelligence |
| Bridge | Layer 2 (Data Link) | Frames | Forwards frames based on MAC address table; reduces collisions |
| Switch | Layer 2 (Data Link) | Frames | Learns MAC addresses; forwards frames only to the correct port |
| Router | Layer 3 (Network) | Packets | Routes packets between different networks using IP addresses and routing tables |
| Layer 3 Switch | Layer 2 + 3 | Frames + Packets | Switching speed with routing capability |
| Firewall | Layer 3–7 | Packets to Application data | Filters based on IP, port, protocol, or application content |
| Load Balancer | Layer 4 or 7 | Segments or HTTP requests | Distributes connections across multiple servers |
5. The TCP/IP Model
The TCP/IP model (also called the Internet model or DoD model) is the practical protocol suite that powers the internet. It was developed in the 1970s for ARPANET, the predecessor to the internet.
Unlike the 7-layer OSI model, TCP/IP has 4 layers (some sources describe 5 layers — splitting the bottom layer into Physical and Data Link):
| TCP/IP Layer | Corresponding OSI Layers | Key Protocols |
|---|---|---|
| Application | OSI Layers 5, 6, 7 | HTTP, FTP, DNS, SMTP, SSH, DHCP |
| Transport | OSI Layer 4 | TCP, UDP |
| Internet (Network) | OSI Layer 3 | IP (v4/v6), ICMP, ARP, OSPF, BGP |
| Network Access (Link) | OSI Layers 1 and 2 | Ethernet, Wi-Fi (802.11), PPP |
Why Does TCP/IP Combine Layers?
The OSI model’s Session and Presentation layers were rarely implemented as distinct layers in practice. Most real applications handle their own session management and data formatting. TCP/IP merged these into the Application layer for simplicity. Similarly, Physical and Data Link are so tightly coupled in most hardware (e.g., a network card handles both) that they’re often treated as one.
6. OSI vs TCP/IP – Key Differences
| Feature | OSI Model | TCP/IP Model |
|---|---|---|
| Layers | 7 layers | 4 layers (or 5) |
| Developed by | ISO (International Standards Organisation) | US Department of Defense (DoD) |
| Year | 1984 | 1970s |
| Purpose | Reference/theoretical model | Practical, implemented model |
| Protocol independence | Protocol-independent (generic) | Tied to TCP/IP protocols |
| Session & Presentation | Separate layers (5 and 6) | Merged into Application layer |
| Physical & Data Link | Separate layers (1 and 2) | Combined as Network Access layer |
| Real-world use | Teaching and troubleshooting framework | Powers the actual internet |
| Adoption | Never fully implemented as-is | Universal — every device on the internet uses it |
7. Packet, Circuit and Virtual Circuit Switching
Before data can be sent across a network, a communication path must be established. Three approaches exist:
Circuit Switching
A dedicated physical path is established between sender and receiver for the entire duration of the communication. Resources are reserved end-to-end.
- How it works: Call setup → data transfer → call teardown
- Example: Traditional telephone network (PSTN)
- Advantages: Guaranteed bandwidth; consistent delay; no congestion once connected
- Disadvantages: Inefficient — resources are reserved even during silence/idle periods; long setup time
Packet Switching
Data is broken into small packets. Each packet is routed independently through the network and may take different paths. Packets are reassembled at the destination.
- How it works: Data → packets → routed independently → reassembled
- Example: The internet (IP-based networks)
- Advantages: Efficient use of network resources; no setup time; handles variable traffic well
- Disadvantages: Variable delay (jitter); packets can arrive out of order
- Types: Datagram (connectionless, like IP) and Virtual Circuit (connection-oriented)
Virtual Circuit Switching
A logical path is established before data transfer (like circuit switching), but the resources are not fully dedicated — packets still share links (like packet switching). A Virtual Circuit Identifier (VCI) is used instead of full routing per packet.
- Example: ATM (Asynchronous Transfer Mode), Frame Relay, MPLS
- Advantages: Lower per-packet overhead (no full routing decision per packet); ordered delivery
- Disadvantages: Requires setup; VCI table management at each switch
| Feature | Circuit Switching | Packet Switching | Virtual Circuit |
|---|---|---|---|
| Dedicated path | Yes | No | Logical (not physical) |
| Resource reservation | Yes | No | Partial |
| Delay | Fixed | Variable | Low, consistent |
| Setup required | Yes | No | Yes |
| Packet order | Maintained | May vary | Maintained |
| Example | Phone network | Internet | ATM, MPLS |
8. Common Misconceptions
- “OSI is what the internet uses”: The internet actually runs on the TCP/IP protocol suite. The OSI model is a conceptual reference model — it describes how networking should be structured, but real devices implement TCP/IP, not OSI as a literal standard.
- “Switches operate at Layer 3”: Standard switches operate at Layer 2 (Data Link) using MAC addresses. Layer 3 switches are special devices that also perform routing. Basic switches do NOT understand IP addresses.
- “SSL/TLS is only a Presentation layer protocol”: TLS actually spans multiple layers. It handles encryption (Presentation), session negotiation (Session), and operates over TCP (Transport). In TCP/IP, it’s all just called Application layer security.
- “The Application layer is where applications live”: Applications themselves (like Chrome or Outlook) are NOT part of the network model. The Application layer is the interface between the application and the network — it’s the protocols (HTTP, SMTP) those applications use to communicate over the network.
- “Packets and frames are the same thing”: Packets are Layer 3 (Network) PDUs — they contain IP addresses. Frames are Layer 2 (Data Link) PDUs — they contain MAC addresses. A packet is wrapped inside a frame for local transmission; the frame changes at each hop (router), but the packet stays the same.
9. Frequently Asked Questions
What are the 7 layers of the OSI model?
Bottom to top: Physical (bit transmission), Data Link (frames, MAC addresses), Network (packets, IP routing), Transport (end-to-end delivery, TCP/UDP), Session (session management), Presentation (encryption, data format), Application (user-facing protocols like HTTP, DNS). Mnemonic top-to-bottom: “All People Seem To Need Data Processing.”
What is the difference between OSI model and TCP/IP model?
OSI has 7 layers and is a theoretical reference model developed by ISO for standardisation. TCP/IP has 4 layers and is the practical protocol suite that runs the internet. TCP/IP combines OSI’s Session, Presentation, and Application into one Application layer, and merges Physical and Data Link into Network Access. OSI was designed after TCP/IP to provide a vendor-neutral standard; TCP/IP actually powers all internet communication today.
What is encapsulation in networking?
Encapsulation is the process of adding headers (and trailers) to data as it travels down the OSI layers. Application data gets a Transport header (→ segment), then a Network header (→ packet), then a Data Link header + trailer (→ frame), then converted to bits. At the receiver, each layer reads and removes its own header (decapsulation), passing data upward until the original message reaches the application.
What protocols work at each OSI layer?
Physical: Ethernet specs, USB, Bluetooth signals. Data Link: Ethernet MAC, Wi-Fi (802.11), PPP. Network: IPv4, IPv6, ICMP, ARP, OSPF, BGP. Transport: TCP, UDP. Session: NetBIOS, RPC. Presentation: TLS/SSL, JPEG, ASCII. Application: HTTP, HTTPS, FTP, SMTP, DNS, DHCP, SSH. In TCP/IP practice, all upper-layer protocols (Session + Presentation + Application) are treated as Application layer.
Why was the OSI model created if TCP/IP already existed?
TCP/IP was developed in the 1970s for a specific use case (ARPANET military network) and was already deployed when OSI was published in 1984. ISO created OSI as a vendor-neutral, technology-independent reference model to standardise how any network technology should be structured — not tied to TCP/IP’s specific implementation. OSI was meant to replace TCP/IP with a universal standard, but TCP/IP’s widespread adoption made that impossible. Today, OSI serves as the conceptual framework for understanding networking; TCP/IP is what actually runs.