The OSI Reference Model
1. Introduction to Layered Architecture
The Open Systems Interconnection (OSI) model was developed by the International Organization for Standardization (ISO) in 1984 as a conceptual framework for understanding and standardizing network communications between heterogeneous computer systems.
Why Layering?
- Modularity & Abstraction: Decomposes complex network tasks into 7 discrete, manageable layers.
- Interoperability: Standardized interfaces allow hardware and software from different vendors to work together seamlessly.
- Independent Evolution: Modifying or upgrading protocols in one layer does not affect adjacent layers as long as the interfaces remain intact.
2. The 7 Layers and Protocol Data Units (PDUs)
Mnemonic to remember top-to-bottom: All People Seem To Need Data Processing.
Mnemonic to remember bottom-to-top: Please Do Not Throw Sausage Pizza Away.
3. Data Encapsulation and Decapsulation
When an application transmits data, it moves down through the protocol stack. Each layer prepends a Header (and the Data Link layer appends a Trailer) containing control information for its peer layer at the receiving host.
- Encapsulation: Moving down the stack (Sender adds and ).
- Decapsulation: Moving up the stack (Receiver strips headers after verifying integrity and routing).
4. Detailed Functionality of Each Layer
Layer 1: Physical Layer
- Responsibility: Transmitting unstructured raw bit streams over a physical communication channel.
- Key Functions:
- Physical Characteristics of Interfaces: Mechanical specifications of plugs/connectors (RJ-45) and transmission medium.
- Representation of Bits: Defines voltage levels, optical wavelengths, or RF modulation representing 0s and 1s.
- Data Rate (Signaling Rate): Transmission speed in bits per second (bps).
- Synchronization of Bits: Clock synchronization between sender and receiver.
- Line Configuration: Point-to-point or multipoint.
- Physical Topology: Mesh, Star, Bus, or Ring.
- Transmission Mode: Simplex, Half-Duplex, or Full-Duplex.
- Hardware: Hubs, Repeaters, Cables (UTP, Fiber), Modems.
Layer 2: Data Link Layer (DLL)
- Responsibility: Transforming a raw physical transmission facility into a reliable, error-free link for Hop-to-Hop (Node-to-Node) delivery.
- Sublayers:
- LLC (Logical Link Control): Manages frame synchronization, flow control, and multiplexing network layer protocols.
- MAC (Media Access Control): Controls how devices share access to the physical transmission medium.
- Key Functions:
- Framing: Packages network layer packets into discrete frames with headers and trailers.
- Physical Addressing: Adds sender and receiver MAC addresses (48-bit hex, e.g.,
AA:BB:CC:DD:EE:FF). - Flow Control: Prevents a fast sender from swamping a slow receiver (Stop-and-Wait, Sliding Window).
- Error Control: Detects and retransmits damaged/lost frames via CRC (Cyclic Redundancy Check) and ARQ.
- Access Control: Resolves channel contention when two or more devices attempt to transmit simultaneously (CSMA/CD, CSMA/CA).
- Hardware: Switches, Bridges, Network Interface Cards (NICs).
Layer 3: Network Layer
- Responsibility: Delivering packets from Source-to-Destination (Host-to-Host) across multiple interconnected networks.
- Key Functions:
- Logical Addressing: Assigns global IP addresses (IPv4: 32-bit, IPv6: 128-bit) that transcend local subnet boundaries.
- Routing: Determines the optimal path from source to destination using routing algorithms (OSPF, BGP, RIP).
- Packetizing & Fragmentation: Encapsulates transport segments; fragments large packets to conform to the Maximum Transmission Unit (MTU) of intermediate links.
- Hardware: Routers, Layer 3 Switches.
Layer 4: Transport Layer
- Responsibility: Reliable, End-to-End (Process-to-Process) delivery of complete messages between specific applications.
- Key Functions:
- Service-Point (Port) Addressing: Uses 16-bit Port numbers (e.g., HTTP = 80, HTTPS = 443, DNS = 53) to direct data to the exact executing process.
- Segmentation and Reassembly: Divides application messages into segments with sequence numbers, reassembling them in exact order at the receiver.
- Connection Control:
- Connection-oriented (TCP): 3-way handshake, guaranteed in-order delivery.
- Connectionless (UDP): Fast, best-effort delivery without connection setup.
- End-to-End Flow & Error Control: Windowing mechanisms across the entire network path (unlike DLL which operates hop-by-hop).
Layer 5: Session Layer
- Responsibility: Establishing, managing, synchronizing, and terminating dialogs between communicating systems.
- Key Functions:
- Dialog Control: Decides whether communication is half-duplex or full-duplex.
- Synchronization & Checkpointing: Inserts checkpoints into long data streams. If a crash occurs at byte 8,000 in a 10,000-byte file, only bytes 8,001–10,000 need retransmission rather than the whole file.
Layer 6: Presentation Layer
- Responsibility: Ensuring semantic and syntactic compatibility of exchanged data between different computer architectures.
- Key Functions:
- Translation: Converts between different character encodings (e.g., EBCDIC to ASCII/UTF-8, endianness conversions).
- Encryption / Decryption: Secures confidential data before transmission (e.g., TLS/SSL).
- Data Compression: Reduces bit volume for efficient transmission (Lossless or Lossy).
Layer 7: Application Layer
- Responsibility: Providing user interfaces and software applications access to network services.
- Key Services:
- Network Virtual Terminal (TELNET, SSH).
- File Transfer, Access, and Management (FTAM, FTP, SFTP).
- Mail Services (SMTP, IMAP, POP3).
- Web Browsing (HTTP, HTTPS).
- Directory Services (DNS, LDAP).
5. Summary: OSI vs. TCP/IP Model
| OSI Layer (7 Layers) | TCP/IP Layer (4/5 Layers) | Primary Protocols | Addressing Type | Scope of Delivery |
|---|---|---|---|---|
| Application (7) | Application Layer | HTTP, DNS, SMTP, FTP | Uniform Resource Identifier (URI) | Application-to-Application |
| Presentation (6) | (Merged into Application) | SSL/TLS, JPEG, ASCII | — | — |
| Session (5) | (Merged into Application) | Sockets, NetBIOS, RPC | Session ID | — |
| Transport (4) | Transport Layer | TCP, UDP, SCTP | Port Number (16-bit) | Process-to-Process |
| Network (3) | Internet Layer | IPv4, IPv6, ICMP, ARP | IP Address (32/128-bit) | Host-to-Host (Source-to-Dest) |
| Data Link (2) | Network Access / Link Layer | Ethernet, Wi-Fi, PPP | MAC Address (48-bit) | Hop-to-Hop (Node-to-Node) |
| Physical (1) | Physical Layer | Cat6, 802.11 PHY, Optical | Bits / Wavelength / Voltage | Physical interface |
Frequently Asked Questions
QDistinguish between Hop-to-Hop, Host-to-Host, and Process-to-Process Delivery.
- Hop-to-Hop (Data Link Layer): Moves a frame from one intermediate device (node/router) to the next physical adjacent node using MAC addresses.
- Host-to-Host (Network Layer): Moves a packet from the original sender host to the final destination host across multiple intermediate networks using IP addresses.
- Process-to-Process (Transport Layer): Delivers data to the specific application/program running on the host using Port numbers.
QWhat is the function of checkpoints in the Session Layer?
Checkpoints allow long file transmissions to recover from mid-stream failures without re-transmitting the entire file from the start.
QWhy did the TCP/IP model succeed over the OSI model commercially?
TCP/IP was implemented in Berkeley UNIX and widely tested before standardization, whereas the OSI model was designed theoretically by committee before extensive software implementation.
QWhat is the PDU at each of the lower OSI layers?
Physical: bits. Data Link: frame. Network: packet. Transport: segment (TCP) or datagram (UDP).