Unpacking The OSI Model
Tags: network, networking, backend, beginners
Published: 2023-08-19 05:40:36


![cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gruqyavomgh5ss21inmw.jpg)


## Introduction

At a cursory glance, the Open Systems Interconnection (OSI) model can appear daunting with its myriad layers and intricate details. Yet, these layers ingeniously simplify what's essentially a complex dance of computer communication. By segmenting the process into seven distinct layers, the OSI model offers a clear roadmap for understanding how devices talk to each other. In this blog post, I intend to break it down so you can grasp these concepts with ease, I will illustrate this through using a post office as our guiding analogy. 

---

### Physical Layer 1 (Infrastructure)

The Physical Layer is like the foundation of a house in the world of computer networking. It's all about the actual stuff you can touch – like wires, cables, and some devices. This layer makes sure that when two computers want to 'talk', they have a set way to do it, no matter what kind of wire or connection they use. It ensures that the message gets through in a smooth and dependable manner.

<figure>
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7byf9kg56lqwtlvshixa.jpg"
       alt="physical layer image">
  <figcaption>_Meet Sam, our dedicated OSI Post Office worker. At Layer 1, or the Physical Layer, Sam represents the hands-on, tangible side of things. Just as a mailbox, post office, and mail are physical entities in our world, the Physical Layer is all about the actual hardware and cables in networking. It's where the real, touchable parts of communication take place._</figcaption>
</figure>

---

### Data Link Layer 2 (Sorting)

The Data Link Layer is like a sorting room for computer data. It makes sure data goes to the right place using something called a MAC address. This address is like a name tag, ensuring the data reaches the right computer. It also uses Ethertype to tell the computer what kind of data it's getting. So, when the data arrives, the computer knows what to do with it.



<figure>
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u8ycfjh23zkg9qa7t0l1.jpg"
       alt="data link image">
  <figcaption>_In our post office story, think of the Data Link Layer as the part where Sam sorts the mail. The MAC address is like the name on the envelope, making sure each letter goes to the right home. And the Ethertype? It's how Sam knows if the mail is a simple letter, a bigger box, or a package. Just like how mail needs sorting, computers use these 'labels' to understand their data._</figcaption>
</figure>

---

### Network Layer 3 (Routing)

When our computer wants to send information, it needs a way to make sure it gets to the right place. This is where the Network Layer comes in. It adds special tags to our information, sort of like labels on a package in the post office.

These labels or 'tags' have details like:

- Version: Is it an old or new type of label?
- Time To Live (TTL): A timer that ensures our package doesn't wander around lost for too long.
- Protocol: A special rule that helps the receiver understand and open our package correctly.
- Source and Destination IP: The 'from' and 'to' addresses for our package.

With these tags, our information can find its way easily to its destination.

<figure>
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oypwo2g0neb0pwlztqr6.jpg"
       alt="network layer image">
  <figcaption>_Sam, with his trusty route map, prepares each piece of mail by adding essential labels. These ensure every mail finds its right path and reaches its destination seamlessly._</figcaption>
</figure>


---


### Transport Layer 4 (Transport)

When data comes to the Transport Layer, it's like checking the delivery method on a package.

- If it's TCP: Think of this like a careful delivery service. The system checks a special label (called the port number) to figure out which app should get the data. TCP also double-checks to make sure everything arrived in the right order and nothing is missing. It's thorough, making sure the data delivery is just right before sending it to its final spot.

- If it's UDP: This is more like express delivery. It's quick and doesn't wait around. The system still checks where the data should go using that port number label, but it doesn't spend time making sure everything is perfect. It gets the data to its destination fast.

So, in a nutshell, TCP is the careful, thorough method, and UDP is the speedy one.

<figure>
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/94huz4yl6d3a62vv40xb.jpg"
       alt="transport layer image">
  <figcaption>_Sam stands at a sorting table with two bins labeled 'TCP' and 'UDP'. He's intently examining labels on each package, placing them in their respective bins._</figcaption>
</figure>
---



### Session Layer 5 (Connection Established)

The Session Layer is like a manager for a chat between two devices. Here's how it works:

- Starting the chat (Establishment): It sets up the chat and decides if both devices will talk back-and-forth (two-way) or if one will just listen (one-way).

- Keeping the chat smooth (Maintenance): While they talk, it ensures messages are sent and received clearly and that both devices are on the same page.

- Ending the chat (Termination): When they're done talking, it wraps things up neatly so both devices know the conversation is over.


<figure>
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nznscys8mnbcv4kge9vb.jpg"
       alt="session layer image">
  <figcaption>_Sam's Delivery Steps: First, he sends a notification about the upcoming package. Next, we see him diligently biking, making sure the package stays safe. Finally, the package rests on the doorstep, signifying a completed delivery and termination of the session._</figcaption>
</figure>
---

### Presentation Layer 6 (Interpreter)

Once the packets arrive, the Presentation Layer steps in to make sure our computer understands the data. It changes the data into a format the system recognizes. However, not all data types need this change. This layer's main jobs are to convert the data, adjust its size, and secure or unlock it if needed.

---


### Application Layer 7 (The Recipient)

The Application Layer is where users directly interact with the data. Think of it as a user's personal desk where they access websites, send emails, or transfer files. This layer offers the right tools and ensures the data is presented in a user-friendly manner. Some of the key tools available on this "desk" are:

- HTTP/HTTPS for websites.
- FTP for moving files.
- SMTP for sending emails.
- DNS for finding websites by name.

At the end of this journey, when someone gets their data, they might not think about the complicated process it took. They're just happy to see what they asked for.


---

### Conclusion

Just like a post office guarantees each letter reaches its intended recipient, the OSI model directs our digital data flawlessly to its end point. By following Sam’s journey, we've unraveled the layers behind our daily online activities.

The next time you open a website or send a text, imagine Sam diligently sorting and delivering behind the scenes. Remember, every intricate system breaks down into simple steps, and grasping these basics is the pathway to expertise. Dive deep and keep exploring!