Skip to content

Layered Architecture

Layered architecture is an approach where complex systems are broken down into multiple, manageable layers. Each layer is designed to handle a well-defined task.

Each layer interacts with adjacent layers in a specific manner:

  • Provides services to the layer directly above it.
  • Uses services from the layer directly below it.

This architectural model is widely employed in networking and software systems to simplify design, enhance modularity, and promote flexibility.

Purpose of Layered Architecture:

  • Standardization: Standardizes communication protocols and interfaces, enabling interoperability between different devices, vendors, and technologies.

  • Modularity: Allows for easier design, implementation, and maintenance by breaking the system into independent components.

  • Abstraction: Each layer hides its internal implementation details and exposes only necessary interfaces or services to the layers above and below it.

  • Simplified Troubleshooting: Facilitates easier debugging and problem isolation, as issues can often be pinpointed to a specific layer.

  • Flexibility and Maintainability: Enables individual layers to be upgraded, modified, or replaced without affecting the entire system, provided the interfaces remain consistent.

Reference Models

OSI Reference Model

The OSI (Open Systems Interconnection) Reference Model is a conceptual framework developed by the International Organization for Standardization (ISO).

OSI standardizes the functions of a telecommunication or computing system by dividing them into seven distinct, hierarchical layers. This layered architecture helps systems from different vendors to communicate efficiently and in a structured manner.

Key Characteristics of the OSI Model:

  • The OSI model is not a network architecture itself:

    • It does not define specific protocols or services (e.g., it doesn't define HTTP or TCP).
    • It is a theoretical framework or blueprint for understanding network functionality and how different tasks are logically separated.
  • While rarely used for direct practical implementation in modern networks (TCP/IP is more common), it remains conceptually important for understanding network operations, education and troubleshooting.

Why the OSI Model is Required/Beneficial:

  • Provides a standard reference, promoting interoperability between different networks and systems.

  • Simplifies the design, development, and troubleshooting of complex network environments.

  • Promotes modular engineering by clearly separating distinct networking functionalities into layers.

  • Acts as an educational guide for developing and understanding network protocols and their interactions.

OSI Layers (Top to Bottom)

  1. Application Layer
  2. Presentation Layer
  3. Session Layer
  4. Transport Layer
  5. Network Layer
  6. Data Link Layer
  7. Physical Layer

OSI Model Layer Details

7. Application Layer

Provides service to user application software that are "network-aware" (e.g., web browsing with HTTP, file transfer with FTP, email with SMTP).

Functions:

  • Manages network-based communication for end-user processes.
  • Supports user authentication, data privacy, and service advertisement.
  • Translates user requests and application data into network operations.

6. Presentation Layer

Handles data format translation, encryption, and compression to ensure that data sent from the application layer of one system can be understood by the application layer of another system.

Functions:

  • Translates data between the application-specific format and a common network format.
  • Manages data encryption and decryption for secure transmission.
  • Performs data compression to reduce the amount of data to be transmitted, improving efficiency.
  • Ensures compatibility in data representation formats (e.g., character encoding like ASCII or Unicode, image formats like JPEG or GIF).

5. Session Layer

Establishes, manages, and terminates communication sessions between applications running on different hosts.

Functions:

  • Controls dialogue and manages data exchange between two communicating systems (e.g., determining whose turn it is to transmit).
  • Synchronizes sessions by inserting checkpoints into the data stream, allowing for session recovery if a connection is lost.
  • Supports session recovery after disconnections.

4. Transport Layer

Provides reliable or unreliable end-to-end data delivery between processes running on different hosts. It also handles port number selection for process-to-process communication.

Data Unit: Segment (for TCP) or Datagram (for UDP)

Functions:

  • Ensures reliable (e.g., using TCP - Transmission Control Protocol) or unreliable (e.g., using UDP - User Datagram Protocol) end-to-end data delivery.
  • Performs segmentation of data from upper layers into smaller units (segments/datagrams) for transmission and reassembles them at the destination.
  • Manages flow control to prevent overwhelming the receiver.
  • Provides error detection and correction mechanisms (primarily with TCP).
  • Uses port numbers for addressing specific applications/processes on a host.

3. Network Layer

Responsible for logical addressing (e.g., IP addresses) and routing packets across multiple networks to determine the best path from source to destination.

Data Unit: Packet

Functions:

  • Handles logical addressing (e.g., assigning and using IP addresses) to identify hosts on a network.
  • Performs routing of packets by determining the optimal path through an internet, works using routing algorithms.
  • Provides services like fragmentation of packets if they are too large for an underlying network and reassembly at the destination.
  • Uses protocols such as IP (Internet Protocol), ICMP (Internet Control Message Protocol), and routing protocols (e.g., OSPF, BGP).

2. Data Link Layer

Provides reliable node-to-node delivery. It handles physical addressing (MAC addresses) and error detection for the link.

Data Unit: Frame

Functions:

  • Adds MAC (Media Access Control) addresses to frames for physical addressing on a local network.
  • Packages bits received from the Physical Layer into frames.
  • Performs error detection (and sometimes correction) for data transmitted over the physical link.
  • Uses protocols like Ethernet, Wi-Fi (802.11), PPP (Point-to-Point Protocol), and HDLC (High-Level Data Link Control).

1. Physical Layer

Deals with the actual transmission and reception of raw individual bits (0s and 1s) over a physical medium (e.g., copper wire, fiber optic cable, wireless signals).

Data Unit: Bit

Functions:

  • Defines hardware elements such as cables, connectors, network interface cards (NICs), voltages, and signal timing.
  • Converts binary data (bits) into appropriate signals (electrical, optical, or radio waves) for transmission and vice-versa.
  • Handles aspects like modulation, demodulation, bit synchronization, and defining the physical data rate.

TCP/IP Reference Model

The TCP/IP Reference Model, also known as the Internet Protocol Suite, is a practical and implementation-driven framework.

It was initially developed by the U.S. Department of Defense Advanced Research Projects Agency (DARPA) as part of the ARPANET project.

This model defines how data should be packetized, addressed, transmitted, routed, and received over the Internet and other computer networks.

Unlike the more theoretical OSI model, the TCP/IP model is the foundation of the actual Internet and is widely used in all modern networks.

Why the TCP/IP Model is Required/Beneficial:

  • Provides a robust, scalable, and interoperable communication framework for global internetworking.

  • Allows seamless communication across heterogeneous hardware platforms and software systems.

  • Simplifies the implementation of network protocols with fewer, more broadly defined functional layers compared to OSI.

  • Serves as the core architectural model used in the real-world Internet.


The Layers of the TCP/IP Reference Model (Common 4-Layer Model)

The TCP/IP model is often described with four layers, though variations exist.

1. Application Layer

  • Primary Role: Provides services directly to end-user applications and defines how these applications interact with the network. It effectively combines the functionalities of the OSI model's Application, Presentation, and Session layers.
  • Functions:
    • Supports various network applications (e.g., web browsing with HTTP/HTTPS, file transfer with FTP, email with SMTP/POP3/IMAP, domain name resolution with DNS).
    • Handles data formatting, presentation (e.g., character encoding), and potentially encryption/decryption (often via libraries or OS services).
    • Manages user interface interactions related to network services.
    • Often supports a client-server model of communication.

2. Transport Layer

  • Primary Role: Provides end-to-end communication services between processes running on different hosts. It ensures that data is delivered reliably or unreliably, as required by the application.
  • Key Protocols: TCP (Transmission Control Protocol), UDP (User Datagram Protocol)
  • Functions:
    • TCP: Provides reliable, ordered, connection-oriented, and error-checked delivery of a stream of bytes.
    • UDP: Offers a faster, connectionless, but unreliable datagram service (no guarantee of delivery, order, or error checking beyond a basic checksum).
    • Handles segmentation of application data into smaller units for transmission and reassembly at the destination.
    • Manages flow control (especially TCP) to prevent network congestion and overwhelming the receiver.
    • Handles retransmission of lost packets (primarily TCP).
    • Uses port numbers to direct data to the correct application process on the destination host.

3. Internet Layer (or Network Layer)

  • Primary Role: Responsible for logical addressing (IP addresses), routing packets across multiple networks (internetworking), and packet forwarding to ensure data reaches its ultimate destination.
  • Key Protocols: IP (Internet Protocol), ICMP (Internet Control Message Protocol), ARP (Address Resolution Protocol - sometimes considered part of the Link Layer too)
  • Functions:
    • Defines the structure of IP packets (datagrams) and their addressing scheme using IP addresses (IPv4 or IPv6).
    • Routes packets from source to destination across one or more networks, selecting paths based on routing protocols (e.g., OSPF, BGP, RIP).
    • Handles fragmentation of packets if they are too large for an underlying network segment and reassembly at the destination.
    • Provides diagnostic capabilities through ICMP (e.g., ping, traceroute).

4. Network Access Layer (or Link Layer / Network Interface Layer)

  • Primary Role: Handles all aspects related to the physical transmission of data over a specific network medium. It interfaces with the actual network hardware and is responsible for transmitting IP packets over the physical network. This layer combines functionalities of the OSI model's Data Link and Physical layers.
  • Key Technologies/Protocols: Ethernet, Wi-Fi (802.11), PPP, Token Ring, FDDI, device drivers for network interface cards (NICs).
  • Functions:
    • Handles communication between a host and the physical network hardware.
    • Manages physical addressing (e.g., MAC addresses for Ethernet and Wi-Fi).
    • Encapsulates IP packets into frames suitable for transmission over the specific network technology.
    • Performs error detection (and sometimes correction) for transmissions on the local network link.
    • Defines how bits are to be signaled over the physical medium (e.g., voltage levels, light pulses).

TCP/IP Internet Protocol Stack (Alternative 5-Layer View)

Sometimes, the TCP/IP model is presented with five layers, explicitly separating the Data Link and Physical layers, similar to the OSI model's lower layers.

TCP/IP LayerExample ProtocolsOSI Layer(s) Equivalence (Approx.)
ApplicationHTTP, SMTP, FTP, DNS, RTP, SSH, TelnetApplication, Presentation, Session
TransportTCP, UDPTransport
Internet (Network)IP (IPv4, IPv6), ICMP, IGMPNetwork
Data LinkEthernet, Wi-Fi (802.11), PPP, ARP*, Frame RelayData Link
PhysicalEthernet (physical), Wi-Fi (physical), DSL, SONET, Bluetooth (physical), Cable, Fiber OpticsPhysical

*Note: ARP (Address Resolution Protocol) operates between the Internet and Data Link layers, mapping IP addresses to MAC addresses.

Important Note: The most common conceptualization of the TCP/IP model for general discussion is the 4-layer model where the Network Access Layer (or Link Layer) encompasses both Data Link and Physical layer functionalities. The 5-layer model provides more granularity, aligning closer to the OSI model's lower layers.

Comparison Table: OSI Model vs TCP/IP Model vs Protocol Stack

Protocol Stack (refers here to real-world implementation of TCP/IP)

AspectsOSI ModelTCP/IP ModelProtocol Stack (Real-world)
Developed ByISO (International Organization for Standardization)DARPA (U.S. Department of Defense)Built on TCP/IP by various organizations and vendors
PurposeConceptual framework for understanding networkingStandardize internetworking via protocols like TCP/IPPractical implementation of networking protocols (TCP/IP)
TypeTheoretical (reference model)Theoretical + practicalPractical Software/Hardware implementation of protocols
Number of Layers7 layers4 layers (originally), sometimes seen as 54 or 5 layers depending on vendor/system design
Layer NamesApplication, Presentation, Session, Transport, Network, Data Link, PhysicalApplication, Transport, Internet, Network AccessApplication, Transport, Internet, Link (or Physical + Data Link)
UsageUsed for teaching, design referenceUsed for developing internet protocolsUsed in real-world networking (e.g., Internet, Routers, OS Kernals)
Protocol ExamplesNo actual protocols definedHTTP, TCP, IP, FTP, SMTP, DNSTCP, IP, UDP, HTTP, HTTPS, DNS, DHCP, etc.
StatusNot implemented directlyFoundation of InternetActively used and implemented in systems
Interoperability RoleHelps standardize device/vendor communicationEnables cross-network communicationProvides actual communication handling over the Internet

Encapsulation in Network Communication

Encapsulation is a fundamental process in layered network architectures (like the OSI or TCP/IP models). It refers to the method of packaging data with protocol-specific control information as it moves down the layers of the network stack on the sender's side. Essentially, each layer adds its own "wrapper" (header, and sometimes a trailer) to the data received from the layer above it.

The Process of Encapsulation (Sender's Side):

  1. Application Layer: The process begins when a user application creates the original message or data.

  2. Transport Layer:

    • The original message is passed down to the Transport Layer.
    • This layer adds its own header (e.g., a TCP or UDP header). This header contains important information such as source and destination port numbers (to identify the applications), sequence numbers (for TCP), and error-checking data (checksum).
    • The data unit at this stage is often called a Segment (for TCP) or Datagram (for UDP).
  3. Network Layer (or Internet Layer):

    • The segment/datagram from the Transport Layer is handed down.
    • The Network Layer adds its own header (e.g., an IP header). This header includes logical addressing information like source and destination IP addresses, which are crucial for routing the data across different networks.
    • The data unit at this stage is called a Packet (or IP Datagram).
  4. Data Link Layer:

    • The packet from the Network Layer is passed down.
    • The Data Link Layer attaches its own header and often a trailer. The header includes physical addressing information like source and destination MAC addresses (for communication on the local network segment). The trailer might contain error-checking information (like a Frame Check Sequence - FCS).
    • The data unit at this stage is called a Frame.
  5. Physical Layer:

    • Finally, the frame is passed to the Physical Layer.
    • This layer converts the frame into a stream of bits (0s and 1s) and transmits these bits as electrical, optical, or radio signals over the physical communication medium.

Key Aspects of Encapsulation:

  • Payload: At each layer, the entire data unit received from the layer above (including its headers) is treated as the "payload" or "data" by the current layer.
  • Modularity: This layered approach allows for modular communication. Each layer performs a specific set of functions and operates independently of the others, as long as the interfaces between layers are maintained.
  • Control Information: The headers added at each layer contain vital control information that enables the protocols at that layer to perform their functions correctly (e.g., addressing, error control, flow control, routing).

At each layer the resulting unit of data at each layer is known by a different name:

  • Segment at the Transport layer

  • Packet at the Network layer

  • Frame at the Data Link layer

  • Bits at the Physical layer

By the time the data reaches the Physical layer, it has been converted into binary (bits) for transmission over the physical medium.


Decapsulation in Network Communication

Decapsulation is the reverse process of encapsulation. It occurs at the receiver's side (or at intermediate devices like routers and switches) as data moves up the network stack. Each layer strips off the header (and trailer, if any) added by its corresponding peer layer on the sender's side, processing the control information and passing the remaining payload up to the next higher layer.

The Process of Decapsulation (Receiver's Side):

  1. Physical Layer: Receives the raw bits from the physical medium and converts them back into a frame.

  2. Data Link Layer:

    • Examines the Data Link Layer header (e.g., checks the destination MAC address).
    • Performs error checking using the trailer (if present).
    • If the frame is valid and addressed to this device (or needs to be forwarded by a switch), it strips off the Data Link Layer header and trailer.
    • Passes the enclosed packet up to the Network Layer.
  3. Network Layer:

    • Examines the Network Layer header (e.g., checks the destination IP address).
    • If the packet is addressed to this host (or needs to be routed by a router), it strips off the Network Layer header.
    • Passes the enclosed segment/datagram up to the Transport Layer.
  4. Transport Layer:

    • Examines the Transport Layer header (e.g., checks the destination port number to identify the target application).
    • Performs error checking, reassembles segments if necessary (for TCP).
    • Strips off the Transport Layer header.
    • Passes the original data up to the Application Layer.
  5. Application Layer: Receives the original message/data and processes it according to the specific application protocol.

Role of Intermediate Devices:

  • Switches (Layer 2 devices): Typically decapsulate up to the Data Link Layer. They examine the MAC addresses in the frame header to make forwarding decisions within the local network. They then re-encapsulate (usually with a new L2 header if forwarding out a different port) the frame.
  • Routers (Layer 3 devices): Decapsulate up to the Network Layer. They examine the IP addresses in the packet header to make routing decisions and determine the next hop towards the final destination. They then re-encapsulate the packet into a new frame (with appropriate L2 headers for the next link) before forwarding it.

Significance of Encapsulation/Decapsulation:

This layered encapsulation and decapsulation process is fundamental to how modern networks operate. It ensures that:

  • Data is transmitted efficiently and correctly from the sender to the receiver.
  • Communication can occur across diverse network technologies and between devices from different vendors.
  • Each layer can focus on its specific tasks without needing to know the details of other layers.

Made with ❤️ for students, by a fellow learner.