The Open System Interconncetion Model is a conceptual model that defines a set of protocols that allows any device even if they have different architectures to form a computer network. It was created by Internation Organization for Standardization in 1983. It can be seen as a universal langauge for the computer networks to communicate.
The OSI Model consists of seven layers and each layer defines the part of the process of sharing information accross the network.
7. Application Layer
6. Presentation Layer
5. Session Layer
4. Transport Layer
3. Network Layer
2. Data Link Layer
1. Physical Layer
Each layer performs a specific task that is different from other layers and by using the services of the layer below it. When two deviecs communicate, one layer on one device communicate with the same layer on the other device. This communication takes place according to the protocols. Now on to what each layers actually does.
Layer 7 - Application Layer
The Application Layer is the layer that the user directly contacts with. It provides services through application on the users device connected to a network. For example the web-browser relies on the Application Layer to provide data for the user to interact with.
Example - You type google.com
in the browser's URL bar and hit enter. The Application Layer will get the query google.com
from the browser and selects a protocol for it (HTTP in this case) and passes the data to the Presentaiton Layer to furthur process.
Layer 6 - Presentation Layer
The Presentation Layer is the layer that translates, compresses and encrypts the user data that it receives from the Application Layer. Common protocols that are used in Layer 6 are NFS and SMB etc. Example - After receiving data from the Application Layer the Presentation Layer will compresses the data or encrypts it if needed and then pass it to the Session Layer below it.
Layer 5 - Session Layer
The Session Layer establishes and manages the connections between the devices on the network. A Sessoion is an exchange of messages between computers. It maintains connections and control ports and sessions. It also ensures to open the connection for long enough to for all the data to be exchange without any loss and then closes the connection. Example - After receiving the compressed data from the Layer 6, the Session Layer will open the connection or session between the sender and receiver's device and closes it when all exchange is successfully done.
Layer 4 - Transport Layer
The Transport Layer is responsible for end-to-end communication and tranfer of data between two devices.This Layer will divide the data into smaller units called segments for easy and lossless transfer. It performs error checks to ensure all the segments are reveiced or sent and if not it will ask for the lost segments. Some popular protocols that operate on Transport Layer are TCP and UDP etc. Example - After receiveing data from the Layer 5, Transport Layer will divide the data into smaller chunks and will select the protocol for it. These segments are then passed to Network Layer.
Layer 3 - Network Layer
The Network Layer decides the physical path the packets will take to reach their destination. The network layer furthur divides the segments from Layer 4 to smaller units called packets. Network Layer manages the packets and find the best path for the data to take to reach it destinatio called routing. Common protocols that operate on Network Layer are IP and X.25 etc. Example - After receiving segments of the browser's query from the Transport Layer, Network Layer will divide them into smaller packets and will the find the best path for the packets to pass through to reach thier destination. Passing through Data Link Layer.
Layer 2 - Data Link Layer
The Data Link Layer works simmilary to Network Layer but for the devices on the SAME network. It will furthur divide the packets into even smaller units called frames and just like Network Layer it will control flow and check for errors during the data transfer between the devices on the same network. Example - After receiving packets from the Network Layer, Data Link layer breaks them into frames and pass them to Physical Layer.
Layer 1 - Physical Layer
The Physical Layer is the physical connection between the devices on the network. This includes all the cables and switches, routers etc. At Physical Layer the frames are convert to bits of 1s and 0s and then trasnmits raw stream of bits to the other device.
Example - After receiving frames from the Data Link Layer, The Physical Layer converts them into a stream of bits and transmits them to the googel.com
server. The server as a response sends the HTML document which will follow all the same rules as above to reach your device and after reaching your device, all the steps will be followed again but oppositely and you will see this in your browser window.