OSI Model and it's layers
Tags: cloud, azure, computerscience, beginners
Published: 2022-02-20 05:43:54

A network  both contains hardware and software that sends data from one location to another. The end goal of the networking is to allow two devices share the data.

The hardware part of networking, consists of physical equipment that carries signal from one point of the network to another. While the software consist of instructions sets that make possible the services that we expect from a network.

The task of sending data from one point in the another can be performed by different layers in the network. 

There are two popular network models:

- **OSI Model**
- **TCP/IP**

In OSI Model, the rules for networking are divided into seven different layers.

### OSI Model 
The **Open Systems Interconnection (OSI) Model** is an ISO standard that describes the functions of networking system.

The OSI model is a layered architecture that allows communication between all types of computer systems regardless of their underlying architecture.

In the OSI model, the communications between a computing system are divided into seven different  layers: **Physical, Data Link, Network, Transport, Session, Presentation, and Application.**

![application.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1644930430674/kIkbCbg-k.png)
### Physical Layer

The physical layer is the layer 1 of the OSI, responsible for sending bits from one computer to another through a physical medium. It deals with the setup of physical connection to the network and with transmission and reception of signals.

![application(1).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1644931554429/9_k3h2Y9w.png)

#### Functions of Physical Layer
  
- **Representation of Bits** - defines how the stream of bits is encoded into signals for transmission i.e. how 0s and 1s are changes to signal.
   
-  **Data Rate** - defines the rate of transmission i.e. the number of bits sent per second.
   
- **Synchronization** - does the synchronization of bits by providing a clock. The clock controls both sender and receiver thus providing synchronization at a bit level. One bit is transmitted or received during each clock cycle.
 
-  **Interface** - defines the transmission interface between devices and transmission medium. For example which electrical connectors and cables to use are defined by the physical layer.
    
- **Topologies** - defines the topology to use - bus, star, mesh, or ring.

-  **Transmission Modes** - defines the direction of transmission between two devices: Simplex(One-way communication), Half Duplex(Two-way communication but one at a time), Full Duplex(Two-way simultaneous communication).

### Data Link Layer (DLL)

The data link layer is responsible for the node to node(or hop to hope) delivery of the message. It makes sure data transfer is error-free from one node to another, over the physical layer. This is also where we introduce or first see MAC addresses.


![application(2).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1644931564751/ZNjHOtVC6.png)
#### Functions of the Data Link Layer:

- 
 **Framing **- The data link layer divides the stream of bits received from the network layer into manageable data units called frames.

- 
**Physical Addressing** - After creating frames, DLL adds physical addresses(MAC address) of the sender and receiver in the header of each frame.

- 
**Error Control** - The Datalink layer adds reliability to the physical layer by adding mechanisms to detect and retransmit damaged or lost frames. It also uses a mechanism to recognize duplicate frames.

- 
**Access Control** - When two or more devices are connected to the same link, data link layer protocols are necessary to determine which device has control over the link at any given time.

### Network layer
The network layer is responsible for receiving frames from the data link layer, and delivering them to their destinations among based on the addresses contained inside the frame. 

The network layer finds the destination by using logical addresses, such as IP (internet protocol). At this layer, routers are a crucial component used to quite literally route information where it needs to go between networks.

![application(3).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1644933397361/mBGxshVQC.png)
#### Functions of Network Layer:
The network layer is responsible for the source to destination delivery of a packet across multiple networks.

   
- **Logical addressing** - Network layers allocate a unique address called IP address to the header of the packet to distinguish each device.

      

  
-   **Routing** - The network layer determines which route is suitable from source to destination across multiple networks.

In Layer 2 MAC Address is introduced, but in Layer 3 IP address is introduced. The difference between MAC and IP address is that MAC Address is used to ensure the physical address of the computer. It uniquely identifies the devices on a network. 
While IP addresses are used to uniquely identifies the connection of the network with that device takes part in a network.

### Transport Layer

The transport layer is responsible for service to service delivery of the entire message.

A Service is an application program running on a host. The network layer oversees source to destination delivery of individual packets, it does not recognize any relationship between those packets and treats them individually as though each piece belonged to a separate application, whether or not it does. The transport layer, on the other hand, ensures that the whole message arrives intact.


![application(4).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1644934198525/HA9utLf3-.png)
Functions of Transport Layer:  
-  **Port Addressing** - The transport layer header includes the port address(a 16-bit address allocated to every process) which delivers a message from a specific process on one computer to another process on another computer.
    
- **Segmentation and Reassembly** - A message is divided into transmittable segments, with each segment containing a sequence number. The receiver transport layer uses these numbers to reassembles segments and replace packets that were lost in the transmission.
    
- **Connection Control** - The transport layer can be either connectionless or connection-oriented.
### Session Layer
The session later is responsible for dialog control and synchronization.

![application(5).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1644944535154/qUB6wvjFq.png)
#### Functions of Session Layer -

- ** Session maintainence**: The session layer is respnsible to establish, use and terminate a connection.
 
- **Dialog Control** - The session layer allows two systems to enter into a dialog. It allows the communication between two processes to take place in either half-duplex(one way at a time) or full-duplex(two ways at a time) mode.

-   **Synchronization** - The session layer allows a process to add synchronization points to a stream of data.

### Presentation layer
The Presentation Layer deals with the syntax and semantics of the information transmitted between two systems. The Presentation Layer is responsible for translation, compression, and encryption.

![application(6).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1644944545766/_POQLXclQ.png)

#### Functions of Presentation Layer -

  
- **Translation** - This Layer translates the exchanging information into a compatible format between the sender and receiver.
 
-  **Encryption** - The presentation Layer uses some algorithms for encrypting the information before sending it to the receiver, and decryption on the receiver side reverses the original process to transform the message back to its original form.
 
- **Compression** - Presentation Layer compresses the number of bits contained in the information using some algorithms. It maybe of either lossy or lossless compression.

### Application Layer
The application layer enables the user, whether human or software, to access the network. 

![application(7).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1644944553563/Gq79tk3YM.png)

### Overview of layers
![overview](https://www.guru99.com/images/1/092119_0729_LayersofOSI1.png)