OSI model layers explanation and Functions
For the explanation of OSI model layers, the first question that comes to mind, what is the OSI, and where it came from? The OSI full form is Open Systems Interconnection. An open system means any device can communicate to other devices, using a standard format and procedures. OSI model is a reference model developed by the International Organization for Standardization (ISO).
The reference model means guidelines on how a communication system can be developed. It does not mention any underlying technologies or any other specific protocol. This is a suggested framework, to which an actual implementation can refer. In this OSI model tutorial, we will cover the following and functions of each OSI model layer.
- What is a layer?
- What is a Layered Architecture?
- Peer to Peer communication.
- Layer addressing in the OSI model.
- What is the Physical Layer?
- What is the Data Link Layer?
- What is Network Layer?
- What is the Transport Layer?
- What is the session layer?
- What is the presentation layer?
- What is the application layer?
- Example Message Flow
Why there are layers in the OSI Model?
There are two important building blocks of the OSI model. First, the model is based on layered architecture, and another there are primitives between the layers for communication. The primitives could be based on function calls or message passing. The former is called tightly coupled while the latter is called loosely coupled.
What is a layer in the OSI model? A layer is an independent entity that implements a fixed set of functionalities. A layer provides services to the upper layer and uses the services of the lower layer. For the upper layer, it is a service provider while the lower layer a service user.
What are primitives? Communication between the layers is defined in terms of primitives. E.g a transport layer sends the message when there is a send data request from its user. This means the send request is a primitive of the transport layer.
In a layered architecture, a layer provides services to the user of the layer and uses services from another layer. There can be multiple users and multiple service providers for the same layer.
Layers can be loosely coupled or tightly coupled.
In a loosely coupled system, communication between layers is message-based.
In tightly coupled, communication between layers is function-based. This means if layer 2 wants to use the functionality of layer 1 then, it will directly invoke the primitive function in layer 1.
Layers In the OSI Model
There are seven logical layers in the OSI model. Or you can say logical demarcation of functionalities for achieving computer network communication. Each layer defines a set of functionalities. In actual implementation, the actual protocol stack implementation for communication may break a layer into several independent layers or it can combine multiple layers into a single layer.
Peer to peer Communication in OSI Model:
First, we will explain what peer-to-peer communication is? What is a peer in the OSI model? A peer is a remote layer at the same level. For example. The transport layer of the remote protocol stack is the peer of the local transport layer. When a local peer sends a message to the remote, it adds its address and peer address in the header. For the lower layer, the header is user data only. The remote peer uses the header to handle the message.
Addressing In OSI Model:
For communication, addressing is mandatory. Mainly in a case, if the remote application is not present on the local machine. In the OSI reference model, until layer four, there is an address for each layer. For upper layers, there is no address. The address format depends on the actual protocol implementation and underlying technologies.
PDU in the OSI model:
Protocol data unit or PDU in networking is the information unit exchange between the two layers. There is a one-to-one relationship between a primitive and protocol data unit. A PDU contains a header part and the data part. The header part is optional. In the OSI model till layer 4 a PDU has a header and data. From layers 4 to 7 there is only user data.
A header may contain the following parts:
- Source Address, this is the address of the sending layer.
- Destination Address is the address of the peer layer.
- Control Flags is the information present in the header for controlling the behavior of the message over the network. For example, a flag may convey that the message is a management message, not the user data message. So that the receiving peer layer process the message locally. Do no transfer message to the upper layer.
This is the lowest layer in the OSI model. The functionality of this layer to communicate with the peer physical layer over a wired/wireless. Physical media understand the electrical signals. In 0 and 1 format. Zero means low current and 1 means high current. For example, if one end wants to send a byte value 0x56. Its binary equivalent will be 01010110. Now there will be low, high, high, low, high, low, high, low will be the sequence for electric current. There will be a separate details tutorial for the physical layer.
The second layer is the OSI model. It provides error-free and in-sequence delivery of frames between directly contented machines. The data link layer has two sub-layers.
MAC or Medium Access Control
LLC or Logical Link Control
The details of the layer are explained in a separate tutorial.
The third layer is the OSI model. It does the routing of packets received from the upper layer. The upper layer is the user of the Network Layer. In the OSI model, the user is the transport layer. The routing is end to end. What does end to end means? This means the source to the destination IP layer. There can be multiple IP layers in the path from source to destination nodes. The layers in the path, check if the packet destination address is the address of the current IP layer or Host? If yes then the layer sends the packet is to the user else forwarded to the next hope for further routing. For example, if you are browsing yahoo.com. Then the source IP layer is in your Computer or Laptop, and the destination is on the yahoo server.
The intermediate IP layers are in the router you are connected via LAN cable of WiFi and in the ISP network.
Fourth Layer In the OSI model. Responsible for delivering user messages to the destination. The destination is the user of the peer transport layer user. It also does end-to-end routing. So only end node transport will receive the message. On intermediate nodes, the message will be routed from the network layer only. The layer also does error correction and sequencing. SCTP protocol is an example of transport layer implementation.
Fifth layer in the OSI model. A session is a logical connection with the peer. The same session layer may have multiple sessions with a remote peer. A session is useful to correlate requests and responses. For example, the HTTP protocol uses a session. If a response comes and there is no session, then the response is dropped. Why is the session layer needed? User layer can not so the session management? The answer is yes. The user layer can do. But like other layers, this is a functionality. Which saves time and errors in session or dialogue control.
Computer network runs with multiple computers with different machine architectures. A computer may be a big-endian or little-endian etc. It is not only the machine but there are other factors also, like character set, etc. The presentation layer converts from the local application format to the network format and vice versa. It does the data encryption, translation a compression for the user application layer.
As the name suggests, which implements user application logic rather than focusing data transfer over the network. FTP, SSH, SCP are a few examples of an application layer. There can be already defined as applications or a user-developed new application.
Example Message Flow In OSI Model tutorial
This section of the OSI model tutorial includes the sample protocol data unit flow. The upper three layers don’t have a specific header for routing. Following is the flow from layer 4.
Transport Layer Add its header in user data. User data is the data from the Session Layer.
Flow sender side:
Upon receiving primitives from the transport layer. The network layer adds its header to the data received from the transport layer.
Network User (NU)- Data = Transport header + session data.
Network layers issue the primitive to the data link layer. The Data Link layer adds its header to the data from Network Layer.
Data Link User (DU)- Data = Network header + Transport header + session data.
Data Link uses the service of the physical layer. The physical layer adds its information and sends a message to the peer physical layer.
Flow receiver side:
On the receiving side, actions are opposite as compare to the sender.
Physical layer remover the header and sends the renaming data to the Data Link.
Data Link removes the data-link header and sends the remaining data to the network layer.
Network Layer removes the header and sends the remaining data to the transport layer.
The transport layer removers its header and sends the remaining data to the session layer.
Now the other layers transfer to the application layer.
We can see in the example, that the receiving OSI application layer got the same data or message, which was initiated by the sender application layer.