OSI Model

1. Introduction

The OSI (Open Systems Interconnection) model is a reference framework created by the ISO in the 1980s to describe how devices communicate over a network, step by step, from one layer to the next.

Its strength lies in its layered structure, which divides the communication process into seven distinct layers, each with specific responsibilities.

Illustration of the 7-layer OSI model showing Application, Presentation, Session, Transport, Network, Data Link, and Physical layers with an example of communication between two devices.
Figure 1 – OSI Model

While the OSI model is essential for understanding network communication and troubleshooting, it is mainly a theoretical reference. In real-world networking, the TCP/IP model has become the standard, as it defines the actual protocols used to transfer data between devices.

2. Encapsulation and Decapsulation

The OSI model is built on seven layers, each with its own role in the communication process.
To understand how data actually travels across a network, you need to know two key processes: encapsulation and decapsulation.

Encapsulation

When you send data (for example, a file or a message), it moves down the OSI layers on your device.
At each step, the layer adds specific information such as addresses or port numbers, so the data can reach its exact destination.

Diagram of encapsulation and de-encapsulation across the 7 OSI layers, helping explain what is the OSI model in networking
Figure 3 – Encapsulation Process in the OSI Model
  • Layer 7 – Application: Creates the original data to send.
  • Intermediate layers: Add headers (and sometimes trailers) containing control and addressing information.
  • Layer 1 – Physical: Converts the final frame into signals (electrical pulses, light, or radio waves) and transmits them over the network medium.

Decapsulation

When the data arrives at its destination, the process is reversed, it moves up the OSI layers on the receiving device.

Decapsulation process through the layers of the OSI model
Figure 3 – Decapsulation Process in the OSI Model
  • Layer 1 – Physical: Turns incoming signals into bits.
  • Intermediate layers: Remove their respective headers/trailers and interpret the information.
  • Layer 7 – Application: Delivers the original data to the application that requested it.

Why It Matters

  • Encapsulation: Ensures the data is packaged with all the details needed to reach its destination.
  • Decapsulation: Ensures the receiving device can interpret the data correctly and forward it to the right service.

3. OSI’s Seven Layers

The OSI model is made of seven layers, each with a specific function.
Let’s look at them from the top (closest to the user) down to the bottom (closest to the physical network).

Layer 7 – Application

The Application Layer is where you, the user, interact directly with the network through applications such as web browsers, email clients, or messaging apps.
When you access https://pingmynetwork.com, this layer initiates the request using the correct protocol.

Application layer of the OSI model showing user interface and communication services
Figure 4 – OSI Layer 7: Application Layer

Key points:

  • Closest to the end user.
  • Manages application-level protocols such as HTTPS, HTTP, FTP, and SMTP.

Layer 6 – Presentation

The Presentation Layer ensures that data is formatted correctly for the receiving application. It translates data between the application format and the network format, and can also handle encryption.

Presentation layer of the OSI model handling data formatting and encryption
Figure 5 – OSI Layer 6: Presentation Layer

Key points:

  • Translates and formats data for the application.
  • Encrypts and decrypts data for secure communication (e.g., TLS/SSL for HTTPS).
  • Example: Encrypting a message before sending it, then decrypting it upon receipt.

Layer 5 – Session

The Session Layer manages the start, maintenance, and closure of communication sessions between devices.

Session layer of the OSI model managing communication sessions between devices
Figure 6 – OSI Layer 5: Session Layer

Key points:

  • Establishes, maintains, and terminates communication sessions.
  • Allows multiple applications to run and communicate at the same time.

Upper Layers Overview

Layers 7, 6, and 5 are known as the Upper Layers. They focus on preparing data for transmission.

Data encapsulation process across the layers of the OSI model
Figure 7 – OSI Upper Layers (Layers 7, 6, 5)

The lower layers (4–1) are responsible for actually delivering the data across the network.

Layer 4 – Transport

The Transport Layer ensures end-to-end delivery of data between devices.
It splits large data streams into smaller segments and adds a Layer 4 header containing delivery details.

Encapsulation at the Transport layer of the OSI model with TCP and UDP segments
Figure 8 – OSI Layer 4: Transport Layer

KeKey points:

  • Segmentation: Divides large data into smaller segments.
  • Delivery methods: Uses TCP for reliable transmission and UDP for faster, connectionless delivery.
  • Host-to-host communication: Identifies services using port numbers (e.g., TCP 443 for HTTPS).

Example:
When streaming a video, TCP ensures all segments arrive in order without loss, while UDP favors speed, even if some segments are lost.

Layer 3 – Network

The Network Layer manages logical addressing and routing so data can travel between networks.

Encapsulation at the Network layer of the OSI model with IP packets
Figure 9 – OSI Layer 3: Network Layer

Key points:

  • Adds source and destination IP addresses.
  • Selects the best route for data delivery.
  • Routers operate here.
  • Segment + Layer 3 header = packet.

Analogy:
Like a postal service choosing the most efficient path for a package, the Network Layer selects the best route for the data.

Layer 2 – Data Link

The Data Link Layer handles node-to-node communication within the same local network using MAC addresses.

Encapsulation at the Data Link layer of the OSI model with frames
Figure 10 – OSI Layer 2: Data Link Layer

Key points:

  • Framing: Adds a Layer 2 header and trailer to create a frame.
  • Uses MAC addresses to identify devices on the same network.
  • Includes error detection with a Frame Check Sequence (FCS).
  • Switches operate here.

Layer 1 – Physical

The Physical Layer handles the actual transmission of raw bits over the network medium.

Encapsulation at the Physical layer of the OSI model with bits transmission
Figure 11 – OSI Layer 1: Physical Layer

Key points:

  • Defines the physical components such as cables, connectors, and wireless signals.
  • Converts frames into bits (1s and 0s) for transmission over the medium.

Example:
The Physical Layer is like the road carrying vehicles (frames) to their destination.

De-encapsulation Process

When the data arrives at the receiving device, the reverse of encapsulation takes place, this is called decapsulation.

The data moves up through the OSI layers, with each layer removing the information that its counterpart added on the sender’s side.

Layer 1 – Physical

At the Physical Layer, the incoming electrical, optical, or radio signals are converted back into raw bits so the frame can start being reconstructed.

Encapsulation at the Physical layer of the OSI model with bits transmission
Figure 12 – Start of the De-encapsulation Process
  • Receives signals from the transmission medium.
  • Converts them into raw bits for further processing.

Layer 2 – Data Link

The Data Link Layer takes the raw bits from Layer 1 and reassembles them into a complete frame before removing its own Layer 2 header.

Decapsulation at the Data Link layer of the OSI model extracting frames
Figure 13 – OSI Layer 2: Data Link Layer in De-encapsulation
  • Groups bits into a frame.
  • Removes the Layer 2 header (source/destination MAC addresses).

Layer 3 – Network

The Network Layer receives the packet from Layer 2 and removes its own Layer 3 header, which contains the source and destination IP addresses.

Decapsulation at the Network layer of the OSI model extracting IP packets
Figure 14 – OSI Layer 3: Network Layer in De-encapsulation
  • Processes the packet for delivery.
  • Removes the Layer 3 header containing IP addresses.

Layer 4 – Transport

The Transport Layer processes the segment and removes its Layer 4 header, which contains the port numbers and reassembly details for the data stream.

OSI Layer 4 Transport in de-encapsulation process removing segment header to deliver data
Figure 15 – OSI Layer 4: Transport Layer in De-encapsulation
  • Identifies the correct application service using port numbers.
  • Removes the Layer 4 header.
  • Handles reassembly of data segments if necessary.

Layers 5–7 – Upper Layers

Once the data has been processed by the lower layers, it moves into the upper layers of the OSI model: Session, Presentation, and Application. These layers ensure that the data is correctly prepared, formatted, and delivered to the application that requested it.

Layer 5 – Session

The Session Layer manages and terminates the communication session between the two devices. It ensures the session context is maintained until the transfer is complete.

Decapsulation at the Application layer of the OSI model delivering data to end users
Figure 16 – De-encapsulation in the Upper OSI Layers
  • Maintains and controls dialog between devices.
  • Ends the session once communication is complete.

Layer 6 – Presentation

The Presentation Layer ensures the data is in a usable format for the application. It may handle translation, compression, or encryption/decryption if necessary.

OSI model decapsulation at the Presentation layer showing data translation and optional decryption before delivery to the application.
Figure 19 – Decapsulation Presentation Layer
  • Translates data between network and application formats.
  • Decrypts or decompresses the data if required.

Layer 7 – Application

The Application Layer delivers the final, fully prepared data to the application software used by the end user (e.g., web browser, email client, file transfer tool).

OSI model decapsulation at the Application layer showing final data delivery to the end-user application.
Figure 20 – Decapsulation Application Layer
  • Passes the original data to the correct application.
  • Ensures the information is ready for immediate use.

4. Adjacent-Layer and Same-Layer Interaction

The OSI model describes not only the responsibilities of each layer but also how layers interact.
There are two main types of interaction: adjacent-layer and same-layer.

Adjacent-layer interaction

This occurs between two layers next to each other on the same device.
Each layer either passes data down to the one below or receives data up from the one above.

Adjacent layer interaction within the OSI model showing communication between neighboring layers
Figure 21 – Adjacent-Layer Interaction in the OSI Model
  • Example: The Transport Layer sends a segment down to the Network Layer.
  • Allows the upper layer to rely on the lower layer for specific delivery functions.

Same-layer interaction

This occurs between the same OSI layer on two different devices.
It ensures that both devices understand the data in the same way.

Same layer interaction in the OSI model showing communication between identical layers on different devices
Figure 22 – Same-Layer Interaction in the OSI Model
  • Example: The Transport Layer on one device communicates with the Transport Layer on another device to confirm segment delivery.
  • Maintains consistency and compatibility in communication protocols.

5. PDUs (Protocol Data Units)

When an application needs to send data to another system, it starts at the Application Layer (Layer 7) of the OSI model.

As the data moves down through the layers, each one adds its own header containing information needed for addressing, delivery, and error checking.

The result of adding this control information to the original data is called a Protocol Data Unit (PDU).

Protocol Data Units (PDUs) across the layers of the OSI model
Figure 23 – Protocol Data Units (PDUs) at Different OSI Layers

PDU Types Across OSI Layers

Layer 4 – Transport

When the Transport Layer adds its header, the data becomes a segment.

  • Contains port numbers and reliability information.
  • Example: TCP or UDP segment.

Layer 3 – Network

When the Network Layer adds its header (including IP addresses), the PDU becomes a packet.

  • Contains source and destination IP addresses.
  • Routed across multiple networks.

Layer 2 – Data Link

When the Data Link Layer adds its header, the PDU becomes a frame.

  • Contains source and destination MAC addresses.
  • Includes an FCS for error detection.

Layer 1 – Physical

At the Physical Layer, the PDU is simply a bitstream (1s and 0s) transmitted over the medium.

  • Represents the actual signals sent over copper, fiber, or wireless.

6. How to Remember OSI Layers

Memorizing the seven layers of the OSI model can be challenging at first.
Using mnemonics is a simple and effective way to make it easier.

From Layer 7 (Application) down to Layer 1 (Physical)

All People Seem To Need Data Processing

Common acronyms used to remember the layers of the OSI model
Figure 24 – Mnemonics to Remember the OSI Model Layers

From Layer 1 (Physical) up to Layer 7 (Application)

Please Do Not Teach Students Pointless Acronyms

In the next course, we will explore the TCP/IP Model and see how it works alongside the OSI model in real-world networking. This will help you understand not just the theory, but also the protocols actually used every day on the internet.