Understanding Computer Networking: Part 1 - The OSI Model✨
Tags: networking, computerscience, tutorial, beginners
Published: 2023-11-11 19:01:29


Hey Coders!
In this article, we're diving into a super important topic in Computer Science and programming - the OSI model. When I say it's important, I really mean it! Understanding this model is like unlocking the secrets of how data moves between computers and how networking actually works. Plus, it's a hot topic in interviews.

I remember struggling with this concept back in High School, and it even came up in my college viva and interviews. I asked questions, tried to grasp it, and finally got why it's so important.

So, let's get ready to unravel the mysteries of the OSI model together! 🚀

### Understanding the OSI Model
OSI stands for Open Systems Interconnection. It's like a blueprint for how computers talk to each other. Imagine it as a tower with seven floors. Each floor, or layer, has its own job, working together to make sure information travels between computers smoothly and reliably. This way, the whole communication process becomes organized and efficient.

The OSI model has defined the common terminology used in networking discussions and documentation. The model is important as :
1. It makes fixing problems easier and lets us find potential issues in all parts of the communication process. 
2. The OSI model encourages companies that make computer parts to create products that can easily communicate to each other on a network. 
3. It's like having a guidebook that breaks down a big job into smaller, manageable tasks.

### The Seven Layers
All 7 layer plays a distinct role, contributing to the overall efficiency and reliability of data transfer.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tg5dg84sofj9k6e1nofo.png)

### The Host Layers or Upper Layer
The upper layers, also known as host layers, in the OSI model, are responsible for managing tasks related to software, applications, and user interactions. These layers focus on how data is presented to users and how communication is established between different software applications. There are three upper layers in the OSI model:

**1. Application Layer (Layer 7):**

This is the only layer that directly interacts with data from the user. Software applications like web browsers and email clients rely on the application layer to initiate communication.

- Provides services directly to end-users or applications
- Deals with application-specific protocols such as HTTP, SMTP, FTP, Telnet, etc.
- Provides services such as file transfer
- Ensures an application can effectively communicate with other applications on different computer systems and networks
- Specifies the shared communications protocols and interface methods used by hosts in a communications network
- Defines the format of the data on the network
- Provides reliable and efficient communication between two or more devices
- Is mainly responsible for the unique identification of each device that resides on a local network.

**2. Presentation Layer (Layer 6):**

The Presentation layer is involved in translating data between the application layer and the lower layers. It handles tasks such as data encryption, compression, and formatting. Its goal is to ensure that data sent from one system can be understood by the application layer of another system.

- Translates one data format into another data format
- Establishes context between application-layer entities
- Formats data so that data representation in the application layer and across the system is acceptable and compatible
- Ensures that communications that pass through it are in the appropriate form for the recipient application
- Serializes complex data structures into flat byte-strings

The presentation layer's functions include: 

- Translation
- Encryption & decryption
- Compression & decompression
- Structure representation

Two common examples of the presentation layer are: 

- Objects in object-oriented programming
- The exact way that streaming video is transmitted

**3. Session Layer (Layer 5):**

The Session layer manages the establishment, maintenance, and termination of communication sessions between different applications. It coordinates the communication exchange between devices, making sure that data is exchanged smoothly. This layer is particularly important in scenarios involving multiple communication channels.

- Establishing, maintaining, synchronizing, and terminating sessions between end-user applications
- Controlling and maintaining connections between systems to share data
- Allowing the systems to communicate in either half-duplex or full-duplex mode of communication
- Helping a protocol to be more consistent and reliable

**The Lower Layers or Media Layers**

The lower layers, also known as the media layers, in the OSI model, handle the more fundamental aspects of network communication, primarily focusing on the physical transmission of data and the reliable transfer of information between adjacent nodes. These layers ensure that data can be sent and received accurately across the physical network infrastructure. There are four lower layers in the OSI model:

**1. Transport Layer (Layer 4):**

The Transport layer ensures end-to-end communication reliability. It manages issues like segmentation and reassembly of data, flow control, and error recovery. Protocols like TCP (Transmission Control Protocol) operate at this layer, providing reliable and ordered delivery of data.

- Managing network traffic between hosts and end systems
- Ensuring complete data transfers
- Controlling the volume of data, where it is sent, and at what rate
- Providing reliable data transfer services to the upper layers
- Controlling the reliability of a given link through flow control, segmentation and desegmentation, and error control
- Ensuring that the data packets arrive accurately and reliably between sender and receiver
- Delivering an entire message from an application program on the source device to a similar application program on the destination device

**2. Network Layer (Layer 3):**

The Network layer is responsible for routing and forwarding data across interconnected networks. It deals with logical addressing, such as IP addresses, and determines the best path for data to travel from the source to the destination. Routers operate at this layer, making decisions about the most efficient route for data transmission.

- The network layer handles service requests from the transport layer and forwards them to the data link layer.
- The network layer translates logical addresses into physical addresses.
- The network layer breaks down data segments into data packets and reassembles them on the receiver side.
- The network layer delivers packets from source to destination across multiple links (networks).
- The network layer finds destinations by using logical addresses, such as IP (internet protocol).

The network layer is composed of two parts: 

- Logical Link Control (LLC)
Identifies network protocols, performs error checking, and synchronizes frames.

- Media Access Control (MAC)
Uses MAC addresses to connect devices and define permissions to transmit and receive data.

The network layer uses several protocols, including: 

- Internet Protocol (IP)
- Routing
- Testing
- Encryption

**3. Data Link Layer (Layer 2):**

The Data Link layer creates a reliable link between adjacent nodes in a network. It handles tasks such as framing, error detection, and flow control. Devices like switches and network interface cards operate at this layer, ensuring that data is efficiently and accurately transferred between connected devices.

- Encoding, decoding, and organizing data bits
- Hiding the details of underlying hardware
- Detecting errors in transmitted data
- Correcting errors using error detection and correction techniques
- Splitting data into chunks called frames
- Handling each frame separately

**4. Physical Layer (Layer 1):**                                                           

The Physical layer deals with the physical connection between devices. It includes aspects such as cables, connectors, and the transmission of raw bits over a physical medium like copper wires or optical fibers. This layer is concerned with the actual hardware that enables data transmission.

- The setup of physical connection to the network
- Transmission and reception of signals
- Transporting data using electrical, mechanical, or procedural interfaces

The physical layer consists of various network components such as: Power plugs, Connectors, Receivers, Cable types. 

The physical layer is also responsible for: 

- Maintaining the data quality by applying necessary protocols
- Maintaining the bit rate through the data transfer using wired and wireless medium
- Converting frames received from the data link layer into bits

### Wrapping Up

I hope you've learned at least a couple of things from this article, thank you for reading till the end! And let me know if I should change or add anything to this article.
For daily web development threads, updates, and content follow me on Twitter.
Happy Coding🌼

![gif](https://media.giphy.com/media/zOvBKUUEERdNm/giphy.gif)