OSI Model
Tags: osi, networkstack, tutorial, linux
Published: 2021-11-26 21:54:49


#History of Internet
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qokht5s22or18hp1vgr.png)
It was a need to share information. But the computers at those times were large and immobile and in order to make use of information stored in any one computer, one had to either travel to the site of the computer or have magnetic computer tapes sent through the conventional postal system.
Another reason was the cold war which acted as a catalyst to the formation of the Internet. At that time this Internet was known as ARPANET.
To share information it was decided to create networks between different computers which was present in different university over a wide range of area. And that where the the ARPANET arises.


#ARPANET ??
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xlfkuihnjgzmf43am0a.jpg)
Advanced Research Projects Agency Network, ARPANET or ARPAnet began development in 1966 by the United States ARPA. ARPANET was a Wide Area Network (collection of computers connected by a communications network over a wide geographic area) linking many Universities and research centers, was first to use packet switching (information is broken into small segments of data known as packets and then reassembled when received at the destination), and was the beginning of what we consider the Internet today. ARPANET was created to make it easier for people to access computers, improve computer equipment, and to have a more effective communication method for the military. 
In short ARPANET was a concept of connecting two or more computers to share information between them. It becames possible after protocols came into existance.

###FACT: 
January 1, 1983 is considered the official birthday of the Internet.

#Protocols
You can think of a protocol as a language, which allows  communication between two or more people.. Let’s say, people can only be able to share information among themselves if they speak the same language. As we all know every language has its own set of rules and grammar. In a similar way protocols also have a set of rules to communicate.
Let's come to the bookish definition of protocol. A protocol is a standard set of rules that allow electronic devices to communicate with each other. These rules include what type of data may be transmitted, what commands are used to send and receive data, and how data transfers are confirmed.  


##Types of Protocols
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/meh8i4slj622ss5390q4.jpg)
Post office Protocol (POP)  ---> designed for receiving incoming Emails.
Simple mail transport Protocol (SMTP) ---> designed to send and distribute outgoing EMail.
File Transfer Protocol (FTP)  ---> to move files from one computer to another.
HyperText Transfer Protocol (HTTP) ---> designed for transferring a hypertext among two or more systems.
Transmission Control Protocol (TCP) ---> It divides any message into series of packets that are sent from source to destination and there it gets reassembled at the destination.
Internet Protocol (IP) ---> The IP addresses in packets help in routing them through different nodes in a network until it reaches the destination system. 

Let’s get back to the topic ARPANET, the communication between these computers was not completed until 1970, but as they began using the Network Control Protocol (NCP). NCP led to the development and use of the first computer-to-computer protocols like Telnet and File Transfer Protocol (FTP).




#Fall of NCP and rise of TCP
NCP’s could not keep up with the demands of the network and the variety of networks connected. Due to which it’s downfall started and to fulfill this demand TCP came into picture. TCP allowed different kinds of computers on different networks to "talk" to each other. By 1983, TCP/IP had become the only approved protocol on ARPANET, replacing the earlier NCP because of its versatility and modularity. Hence, ARPANET and the Defense Data Network officially changed to the TCP/IP standard on January 1, 1983, hence the birth of the Internet.

#OSI Model
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30qe0amqs1n5corcovt5.jpeg)
The OSI model is a learning tool for understanding step by step networking. 
It describes how information or data from an application of one computer transfers through a physical medium to an application in another computer. It is considered as an architectural model for inter-computer communications.
For Example:- Much like a car is composed of independent functions which combine to accomplish the end-goal of moving the car forward: A battery powers the electronics, an alternator recharges the battery, an engine rotates a driveshaft, an axle transfers the driveshaft’s rotation to the wheels, and so on and so forth.
Similarly, OSI model is divided into seven different layers, each of which fulfills a very specific function.
            


#Characteristics of OSI Model
The OSI model divides the whole task into seven layers. Each layer differs in terms of Protocol Data Unit(PDU). Each layer deals with the data. Before proceding further get familar with terminologies encapsulation and decapsulation . 

The OSI model breaks the responsibilities of the network into seven distinct layers.
Each layer takes data from the previous layer and encapsulates it to make its Protocol Data Unit (PDU). The PDU is used to describe the data at each layer. PDUs are also part of TCP/IP. The applications of the Session layer are considered “data” for the PDU, preparing the application information for communication. Transport uses ports to distinguish what process on the local system is responsible for the data. The Network layer PDU is the packet. Packets are distinct pieces of data routed between networks. The Data Link layer is the frame or segment. Each packet is broken up into frames, checked for errors, and sent out on the local network. The Physical layer transmits the frame in bits over the medium.


















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

#Application Layer (PDU ---> data or message) → 7th 
The Application layer is the top layer of the OSI model and is the one the end user interacts with every day. This layer is not where actual applications live, but it provides the interface for applications that use it like a web browser
L7 has PDU as [data]

#Presentation Layer (PDU ---> data or message) → 6th Layer
It translates the data from sender-dependent format into a common format and changes the common format into receiver-dependent format. It acts as a data translator for a network. It also helps in compressing the data.
L6  has PDU as [data]

#Session Layer (PDU ---> data or message) → 5th layer
It is the 5th layer of the OSI model. It establishes a connection to send and receive data. 
L5  has PDU as [data]

#Transport Layer ( PDU ---> segment ) → 4th Layer
It is the 4th layer. It transfers the data between applications. It receives the data from the upper layer and converts it into smaller units known as segments. It is also known as an end-to-end layer because it provides point-to-point connection between  source and destination. Two protocols can be used in this layer: TCP and UDP.
####NOTE: 
The responsibility of the network layer is to transmit the data from one computer to another computer. Whereas the responsibility of the transport layer is to transmit the message to the correct process(i.e. correct port )

L4  has PDU as segment. Consisting of port + data of previous layer.

#Network Layer ( PDU ---> packet) → 3rd Layer
It is the 3rd layer of the osi model which manages device addressing, tracks the location of devices on the network. It determines the best path to move data from source to destination based on network conditions. 
The protocols used to route the network traffic are known as Network Layer Protocols.
It also adds source and destination address to the header of the frame which helps in identifying the device on the internet.

L3  has PDU as packet. Consisting of IP Address + data of previous layer.

#Data-Link Layer ( PDU ---> frame) → 2nd Layer
It is responsible for putting 1’s and 0’s on the wire, and pulling 1’s and 0’s from the wire. It groups together those 1’s and 0’s into chunks known as Frames. The data Link layer also adds the header and trailer to the frame. The header contains the destination and source hardware address. These frames are transmitted to the destination address mentioned in the header. 

This layer also maintains the rate at which data is transferred with the help of processing speed of the computer.
It is also responsible for routing and forwarding packets.

L2  has PDU as frame consisting of MAC Address + data of previous layer.

#Physical Layer ( PDU ---> bit ) → 1st Layer
It is responsible for the transfer of bits. It carries 1’s and 0’s between two nodes. These bits are transferred in the form of electric pulses, pulses of light, radio waves, etc depending on the type of medium used. Because at the end computer/machine/nodes understand only bits( “0” or “1”  format) 

L1  has  PDU as bits

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

Medium (wire)     ---------       data(bits)
Ethernet             -------->  electric pulses
Wifi                     -------->  radio waves
Fiber               -------->  pulses of light.

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



#Conclusion
There was need to share information or data between computers(at those times computers were immobile) during the time of cold war. Birth of ARPANET took place, it's a group of computers connected through wire over wide range of area. After computer connected through medium like wire, cable, etc. Now to send data computer should understand the common set of rules and grammers to send data. Therefore first protocol NCP was created. And with the help of NCP protocol,  it becames possible to share information or data. But due to limitation in NCP, TCP was formed. 
And the study of how data transfers flow from one computers to another is known as OSI MODEL. Model has 7 different layers. Each layers has Protocol Data Unit(PDU), recieving data from previous layer and adding more info to it like Port, IP Address, MAC Address. And this concept is known as encaptulation.