Skip to content

OSI Model

OSI stands for Open Systems Interconnection.

The OSI model is a framework (a kind of plan or guide) that explains how data travels from one computer to another over a network. It breaks the whole journey down into 7 layers, and each layer has its own specific job.

Different Makers

Different companies build different networking equipment and software.

Compatibility Problems

Without a shared standard, a router made by one company might not work well with a switch made by another.

One Common Language

The OSI model gives everyone the same structure and language to follow.

Easier Troubleshooting

If something goes wrong, you know exactly which layer to check first.

Think of sending a letter through the post office. There are several steps involved: writing the letter, putting it in an envelope, addressing it, handing it to the post office, transporting it, delivering it, and finally the receiver opening it. Each of these steps is like one layer.

The 7 OSI Layers (Physical to Application)

Section titled “The 7 OSI Layers (Physical to Application)”

The OSI model has 7 layers. Data moves down these layers on the sender’s side, and up these layers on the receiver’s side.

What it does: This is the actual physical connection – the cables, wires, and signals that carry the data.

  • Deals with raw bits (0s and 1s) being sent over a physical medium.
  • Defines the hardware: cables (twisted pair, fibre optic), connectors, hubs, repeaters.
  • Decides things like how many volts represent a 1 or a 0, and how fast the bits are sent.
  • It does NOT understand what the data means, it just carries the electrical or light signals.

Real-world example: The Ethernet cable plugged into your computer, or the Wi-Fi signals in the air.

Key devices: Hub, Repeater, Cable, NIC (at the physical signal level)

How the Layers Work Together: The Full Picture

Section titled “How the Layers Work Together: The Full Picture”

When data is sent, it travels down through all 7 layers on the sender’s side. When it reaches the destination, it travels back up through all 7 layers on the receiver’s side.

graph TD subgraph Sender["SENDER (Your Computer)"] S7["7. Application Layer<br/>HTTP request created"] --> S6["6. Presentation Layer<br/>Encrypt, compress"] S6 --> S5["5. Session Layer<br/>Session opened"] S5 --> S4["4. Transport Layer<br/>Segments, ports, TCP/UDP"] S4 --> S3["3. Network Layer<br/>Add IP addresses, packets"] S3 --> S2["2. Data Link Layer<br/>Add MAC addresses, frames"] S2 --> S1["1. Physical Layer<br/>Convert to bits/signals"] end subgraph Receiver["RECEIVER (Web Server)"] R1["1. Physical Layer<br/>Receive bits/signals"] --> R2["2. Data Link Layer<br/>Read MAC, remove frame"] R2 --> R3["3. Network Layer<br/>Read IP, decide next hop"] R3 --> R4["4. Transport Layer<br/>Reassemble segments, check errors"] R4 --> R5["5. Session Layer<br/>Session managed"] R5 --> R6["6. Presentation Layer<br/>Decrypt, decompress"] R6 --> R7["7. Application Layer<br/>HTTP request received"] end S1 -. "travels through cables, Wi-Fi, routers" .-> R1

The key idea: As data goes down the layers, each layer adds its own header (a small piece of extra information) to it. This is called encapsulation. When the data reaches the receiver and goes back up, each layer removes its own header. This is called decapsulation.

This is one of the most important ideas in networking. Let’s walk through what actually happens when you type www.google.com into your browser.

  1. You type www.google.com in your browser

    • Your browser (Application Layer) creates an HTTP GET request.
  2. DNS Resolution

    • Your computer doesn’t know Google’s IP address yet, so it asks DNS: “What is the IP of google.com?”
    • DNS replies: “It is 142.250.182.46
    • Now your computer knows where to send the request.
  3. Data is prepared and sent down through the OSI layers

    • Application Layer: The HTTP request is created.
    • Transport Layer: The data is broken into segments. A TCP connection is set up with Google’s server first, using a 3-way handshake (SYN, SYN-ACK, ACK). Port 443 (HTTPS) is used.
    • Network Layer: An IP packet is created. Your IP is the source, Google’s IP is the destination.
    • Data Link Layer: A frame is created with MAC addresses. The source MAC is your computer’s NIC. The destination MAC is your router’s MAC.
    • Physical Layer: The data is converted into electrical signals (or Wi-Fi radio waves).
  4. The packet leaves your computer and goes to your router

    • Your router receives the frame.
    • It removes the Data Link Layer frame, since that part was only meant for the local hop.
    • The router reads the IP packet and checks its routing table to find the best path to Google’s IP.
    • It creates a new frame for the next hop and sends it out.
  5. The packet hops through the internet

    • The packet passes through many routers, and each one is called a hop.
    • Each router reads the destination IP and forwards the packet a step closer to Google.
    • You can actually see these hops using the traceroute command.
  6. The packet arrives at Google’s server

    • Google’s server receives the packet.
    • The data travels back UP through the OSI layers, with each step removing its header.
    • The HTTP request is finally handed to Google’s web application.
  7. Google sends back the response

    • The same process happens again, but in reverse.
    • Google’s server sends the web page data back to your IP address.
  8. Your browser receives the response

    • Your browser reads the HTML, CSS, and JavaScript files it gets back.
    • It renders the Google homepage on your screen.