Layered Architecture
In computer science, a layered architecture is a design pattern that breaks down a complex system into a series of distinct, manageable layers. Each layer has a specific responsibility and provides services to the layer directly above it while using services from the layer below.
This model is fundamental to computer networking and is also widely used in software engineering.
Purpose of Layered Architecture
Modularity: It divides a complex problem into smaller, more manageable parts. This allows different teams to work on different layers simultaneously.
Abstraction: Each layer hides the complex details of its implementation from the other layers. A layer only needs to know how to interact with the layers immediately above and below it.
Standardization: It promotes the creation of standard interfaces between layers. This ensures that a layer from one vendor can work with a layer from another vendor, fostering interoperability.
Flexibility and Maintainability: A single layer can be modified or updated without affecting the entire system, as long as its interface with adjacent layers remains unchanged.
Simplified Troubleshooting: When a problem occurs, it can be isolated to a specific layer, making debugging much easier.
OSI Reference Model
The Open Systems Interconnection (OSI) Reference Model is a conceptual framework created by the International Organization for Standardization (ISO). It standardizes the functions of a telecommunication or computing system into seven distinct layers.
While the OSI model is a foundational tool for understanding network communication, most modern networks, including the Internet, are built on the more practical TCP/IP model. However, the OSI model remains an invaluable educational and diagnostic tool for its clear separation of functions.
The 7 Layers of the OSI Model
A common mnemonic to remember the layers from top to bottom is: "All People Seem To Need Data Processing."
Layer 7: Application Layer
Layer 6: Presentation Layer
Layer 5: Session Layer
Layer 4: Transport Layer
Layer 3: Network Layer
Layer 2: Data Link Layer
Layer 1: Physical Layer
OSI Model Layer Details
Layer 7: Application Layer
Provides network services directly to end-user applications.
Serves as the interface between the user's application and the network. Translates user requests and application data into network operations.
Handles tasks like user authentication, identifying communication partners, and determining resource availability.
Examples: Web browsers (HTTP/HTTPS), email clients (SMTP, POP3), and file transfer programs (FTP).
Layer 6: Presentation Layer
Acts as the "translator" for the network, ensuring that data sent from the application layer of one system can be understood by the application layer of another system.
Data Translation: Translates data between the format the application uses and a common network format (e.g., converting character encoding from ASCII to EBCDIC).
Encryption and Decryption: Manages the encryption of data for security and its decryption upon receipt.
Compression: Compresses data to reduce the amount of bandwidth required for transmission.
Examples: SSL/TLS encryption, data compression (e.g., GZIP), and data formatting for file types like JPEG and GIF.
Layer 5: Session Layer
Establishes, manages, and terminates communication sessions between applications oh different hosts.
Dialogue Control: Determines which device can transmit at any given time (half-duplex or full-duplex).
Synchronization: Inserts checkpoints into the data stream, allowing a session to resume from the last checkpoint in case of a failure.
Examples: APIs that manage remote procedure calls (RPCs), NetBIOS.
Layer 4: Transport Layer
Provides end-to-end data delivery and error recovery between processes on different hosts.
Process-to-Process Communication: Uses port numbers to direct data to the correct application on a host.
Segmentation and Reassembly: Breaks large data chunks from the upper layers into smaller segments for transmission and reassembles them at the destination.
Connection Control: Can be either connection-oriented (TCP), which provides reliable, ordered delivery, or connectionless (UDP), which offers a faster but less reliable service.
Flow Control and Error Control: Manages the rate of data transmission to prevent overwhelming the receiver and ensures data integrity (primarily with TCP).
Data Unit: Segment (TCP) or Datagram (UDP)
Examples: TCP (Transmission Control Protocol), UDP (User Datagram Protocol).
Layer 3: Network Layer
Manages logical addressing and routing of data across multiple networks to determine the best path from source to destination.
Logical Addressing: Assigns and uses logical addresses, such as IP addresses, to identify devices on the network.
Routing: Determines the best path for data to travel from the source to the destination across an internetwork.
Packet Forwarding: Moves packets from an incoming link to the appropriate outgoing link on a router.
- Provides services like fragmentation of packets if they are too large for an underlying network and reassembly at the destination.
Data Unit: Packet
Examples: IP (Internet Protocol), ICMP (Internet Control Message Protocol), and routing protocols like OSPF and BGP.
Layer 2: Data Link Layer
Manages the transfer of data between two directly connected nodes on the same physical link. (Node to Node delivery)
Physical Addressing: Uses MAC addresses to identify devices on a local network segment.
Framing: Packages bits from the physical layer into frames and adds a header and trailer.
Error Detection: Adds a checksum to the frame to detect if the data was corrupted during transmission.
Flow Control: Manages the rate of data transmission on a specific link.
Sublayers: Often divided into two sublayers: the Logical Link Control (LLC) and the Media Access Control (MAC).
Data Unit: Frame
Examples: Ethernet, Wi-Fi (802.11), PPP.
Layer 1: Physical Layer
Manages the transmission and reception of raw, unstructured bits over a physical medium.
Defines the physical characteristics of the network, such as the type of cables, connectors, and signaling methods used.
Converts digital bits into electrical, radio, or optical signals for transmission.
Manages bit synchronization to ensure the sender and receiver are aligned.
Modulation, physical data rate
Data Unit: Bit
Examples: Ethernet cables (copper), fiber optic cables, radio waves (Wi-Fi), and hardware like network interface cards (NICs), hubs, and repeaters.