The OSI (Open Systems Interconnection) model is a conceptual framework developed by ISO in 1984 that standardizes how different network systems communicate. It divides network communication into 7 layers, each with specific responsibilities. The model helps understand how data travels from one computer to another across a network.
Mnemonic to remember layers (top to bottom): "All People Seem To Need Data Processing" (Application, Presentation, Session, Transport, Network, Data Link, Physical)
| # | Layer | PDU | Key Functions | Protocols/Examples |
|---|---|---|---|---|
| 7 | Application | Data | User interface, network services to applications, email, file transfer | HTTP, HTTPS, FTP, SMTP, DNS, DHCP, SSH, Telnet |
| 6 | Presentation | Data | Data translation, encryption/decryption, compression, format conversion | SSL/TLS, JPEG, MPEG, ASCII, EBCDIC, GIF |
| 5 | Session | Data | Establishes, manages, and terminates sessions between applications | NetBIOS, RPC, PPTP, SQL sessions |
| 4 | Transport | Segment | End-to-end communication, segmentation, flow control, error recovery, port numbers | TCP, UDP, SCTP |
| 3 | Network | Packet | Logical addressing (IP), routing, path determination, fragmentation | IP (IPv4/IPv6), ICMP, OSPF, BGP, RIP, ARP |
| 2 | Data Link | Frame | Physical addressing (MAC), error detection (CRC), flow control, access control | Ethernet, Wi-Fi (802.11), PPP, HDLC, ARP |
| 1 | Physical | Bit | Transmission of raw bits over physical medium, voltage levels, cable types, connectors | Ethernet cables, fiber optic, Wi-Fi radio, USB, Bluetooth |
Layer 7 - Application Layer: The topmost layer that provides network services directly to end-user applications. It defines protocols for specific applications like web browsing (HTTP), email (SMTP), and file transfer (FTP). This is the layer users interact with.
Layer 6 - Presentation Layer: Responsible for data translation between the application and network formats. It handles encryption/decryption (SSL/TLS), data compression, and character encoding (ASCII to EBCDIC). Ensures data is in a readable format for the application layer.
Layer 5 - Session Layer: Manages sessions (connections) between applications. It establishes, maintains, and terminates communication sessions. Provides checkpointing and recovery for long data transfers.
Layer 4 - Transport Layer: Provides reliable end-to-end data transfer. TCP provides connection-oriented, reliable delivery with flow control and error recovery. UDP provides connectionless, faster but unreliable delivery. Uses port numbers to identify applications.
Layer 3 - Network Layer: Handles logical addressing (IP addresses) and routing. Determines the best path for data to travel from source to destination across multiple networks. Routers operate at this layer.
Layer 2 - Data Link Layer: Provides node-to-node data transfer between directly connected nodes. Uses MAC addresses for physical addressing. Detects and corrects errors from the physical layer. Switches and bridges operate at this layer.
Layer 1 - Physical Layer: Transmits raw bits over a physical medium. Defines electrical, mechanical, and procedural specifications for activating, maintaining, and deactivating physical connections. Hubs and repeaters operate at this layer.
As data travels down the OSI layers from sender to receiver, each layer adds its own header (and sometimes trailer) - this is called encapsulation. At the receiver, each layer removes its header - this is called decapsulation.
| Layer | PDU Name | What's Added | Example |
|---|---|---|---|
| Application | Data | HTTP request message | GET /index.html HTTP/1.1 |
| Transport | Segment | TCP header (ports, seq numbers) | Source: 8080, Dest: 80 |
| Network | Packet | IP header (addresses, TTL) | Source: 192.168.1.100, Dest: 93.184.216.34 |
| Data Link | Frame | MAC header + CRC trailer | Source: 00:1A:2B:3C:4D:5E |
| Physical | Bits | Electrical/optical signals | 10110101 voltage levels |
While the OSI model is a theoretical framework, the TCP/IP model is the practical implementation used in modern networks. Here's how they compare:
| OSI Layers | TCP/IP Layers | Key Differences | Real-world Implementation |
|---|---|---|---|
| Application, Presentation, Session | Application | TCP/IP combines top 3 layers | HTTP, FTP, SMTP, DNS |
| Transport | Transport | Same functionality | TCP, UDP |
| Network | Internet | Same functionality | IP, ICMP, ARP |
| Data Link, Physical | Network Access | TCP/IP combines bottom 2 layers | Ethernet, Wi-Fi, PPP |
Layers communicate with adjacent layers through service access points (SAPs) and service data units (SDUs):
Layers use four types of service primitives to communicate:
Different network devices operate at specific OSI layers:
| Device | OSI Layer(s) | Function | Examples |
|---|---|---|---|
| Hub | Layer 1 | Repeats electrical signals | Passive hub, active hub |
| Repeater | Layer 1 | Regenerates and retransmits signals | Signal repeater, extender |
| Switch | Layer 2 | Filters and forwards frames based on MAC addresses | Managed switch, unmanaged switch |
| Bridge | Layer 2 | Connects and filters traffic between network segments | Network bridge, wireless bridge |
| Router | Layer 3 | Routes packets between different networks | Home router, enterprise router |
| Gateway | Layers 4-7 | Translates between different protocol architectures | Email gateway, application gateway |
| Firewall | Layers 3-7 | Filters traffic based on security rules | Packet filter, application firewall |
The OSI model provides a systematic approach to network troubleshooting by examining each layer:
| Layer | Common Issues | Troubleshooting Tools | Solutions |
|---|---|---|---|
| Physical | Cable faults, loose connections, power issues | Cable tester, multimeter, visual inspection | Replace cables, secure connections |
| Data Link | MAC address conflicts, switch port issues | ARP table, switch logs, packet capture | Clear ARP cache, restart switch |
| Network | IP addressing, routing problems | Ping, traceroute, route tables | Fix IP config, add routes |
| Transport | Port blocking, connection issues | Netstat, telnet, port scanner | Open ports, check firewall |
| Session | Session timeouts, authentication failures | Application logs, session tracking | Extend timeout, check credentials |
| Presentation | Encryption issues, data format problems | SSL/TLS tools, character encoding check | Update certificates, fix encoding |
| Application | Software bugs, configuration errors | Application logs, debugging tools | Patch software, fix config |
Several mnemonics help remember the OSI layers from top to bottom (7 to 1) or bottom to top (1 to 7):
Understanding how actual protocols map to OSI layers helps in practical network design:
| Layer | Protocol | Purpose | Key Features |
|---|---|---|---|
| Application | HTTP/HTTPS | Web browsing | Request/response, stateless, secure (HTTPS) |
| FTP/SFTP | File transfer | Binary/ASCII transfer, secure (SFTP) | |
| SMTP/POP3/IMAP | Send/receive email, mailbox management | ||
| Transport | TCP | Reliable data transfer | Connection-oriented, flow control, error recovery |
| UDP | Fast data transfer | Connectionless, low overhead, no guarantees | |
| Network | IPv4/IPv6 | Logical addressing | Routing, fragmentation, address resolution |
| ICMP | Error reporting | Ping, traceroute, error messages | |
| Data Link | Ethernet | LAN communication | CSMA/CD, MAC addressing, frame structure |
| Wi-Fi (802.11) | Wireless LAN | Radio transmission, encryption, roaming |
Explore 500+ free tutorials across 20+ languages and frameworks.