OSI 7 Layers

RoadmapsCore CS

Scenario

Imagine writing a physical letter. You write the content, put it in an envelope, write the address, hand it to the post office, who loads it onto a truck, which drives on a road. When the letter arrives, the process reverses. The OSI model is the internet's version of this postal system.

Mental model

The OSI model is a 7-step assembly line for packaging data to be sent across the world.

Each layer has a specific, isolated job. Top layers deal with applications and data, middle layers handle routing and connections, and bottom layers handle physical electrical signals. As data goes down the stack, it gets wrapped in new envelopes (encapsulation). As it goes up, envelopes are opened (decapsulation).

Explanation

The Open Systems Interconnection (OSI) model is a conceptual framework used to describe the functions of a networking system. Created in the late 1970s, it standardizes how different computer systems communicate with each other regardless of their underlying architecture. Think of it as a universal language for computer networking.

The model is divided into seven distinct layers: Physical (1), Data Link (2), Network (3), Transport (4), Session (5), Presentation (6), and Application (7). A common mnemonic to remember them from bottom to top is 'Please Do Not Throw Sausage Pizza Away'. Each layer provides services to the layer directly above it and receives services from the layer directly below it.

When you send data (like clicking 'send' on an email), the data starts at Layer 7 and travels down to Layer 1. At each step, the layer adds its own specific header (and sometimes trailer) to the data, a process called encapsulation. It's like putting a letter in an envelope, putting that envelope in a larger packet, and putting that packet in a shipping crate.

Once the data reaches the Physical layer, it is transmitted as raw bits (1s and 0s) over a physical medium like a copper wire, fiber optic cable, or Wi-Fi radio waves. When it reaches the destination computer, the data travels back up the layers from 1 to 7. Each layer reads its corresponding header, strips it off, and passes the remaining data up. This is called decapsulation.

While the OSI model is largely theoretical and the modern internet actually uses the simpler TCP/IP model, OSI remains the standard vocabulary for networking. When an engineer says they are troubleshooting a 'Layer 3 issue', everyone immediately knows they are talking about IP routing, not physical cables or application bugs. Understanding OSI is the absolute foundation for all network troubleshooting and design.

Key points

Common mistakes

Glossary

Open Systems Interconnection (OSI) model
A theoretical seven-layer blueprint used to teach and understand how data travels from a software app on one computer across wires to an app on another computer.
conceptual framework
A structured way of thinking about a complex system by breaking it down into smaller, easier-to-understand logical pieces.
standardize
To establish a common, universally agreed-upon set of rules so that technology made by completely different companies can still work together perfectly.

Recall questions

Questions & answers

An engineer says there is a 'Layer 2 issue'. Which device and addressing scheme are they likely investigating?

A Switch and MAC addresses.

Approach: Recall that Layer 2 is the Data Link layer, which handles local network node-to-node delivery using MAC addresses, typically managed by network switches.

Which OSI layer is responsible for end-to-end reliability and flow control?

The Transport Layer (Layer 4).

Approach: Remember that Layer 4 (TCP/UDP) handles the end-to-end delivery of data segments, with TCP providing reliability and flow control.

Continue learning

Next: TCP/IP Model & Layer Functions

Return to Core CS Roadmap