OSI model is a conceptual model means it’s a concept-based model, which describes how applications can communicate over a network.
It is a reference model means this model is not actually implemented in network communication instead this model is used as a reference for understanding and designing the network architecture. Actually, the whole computer network is used by standard protocols and all these networking protocols are defined in the OSI model.
In the OSI model, the whole network is defined in layers and each layer helps to understand the network architecture. This model helps to understand the network by separating functions into different layers.
Layer 7: Application Layer
This is the application layer, where the users interact with the applications, provide network services to the end-users. This layer interacts with all those software applications, which helps the users to access the network services. These applications use protocols, work with the data, based on client and servers.
When a user wants to send files or pictures on a network, this layer helps to interact with the application, communicate with the network.
For example- To open a website, a user uses an application called a browser (can be chrome, firefox, opera, etc.) and these browsers use HTTP protocol, which is a network service, helps to deliver the HTML files to the web servers.
Some application layer protocols:
HTTP, HTTPS, SMTP, POP3, FTP, DNS, DHCP, TFTP, Telnet, etc.
Layer 6: Presentation Layer
This layer is a translation layer, which acts as a translator means it translates the data for the application layer.
Presentation layer is responsible for translation, encryption/decryption and compression/decompression of data.
This layer mainly works as a data translator. Two devices want to communicate on a network may be using different encoding methods, so the presentation layer is responsible for translating the incoming data into a syntax that the application layer of the receiving device can understand.
For example: if there are two machines M1 and M2, want to communicate, but machine M1 is using an application based on ASCII code and Machine M2 is using an application based on EBCDIC code. So when machine M1 sends data to machine M2 then the presentation layer is responsible for translating the incoming data into syntax that the application layer of the receiving device can understand.
Encryption / Decryption:
This layer is also responsible for the encryption and decryption of data to maintain privacy.
Encryption is the process of converting the actual message (plain text) into different random and meaningless text (called ciphertext).
Decryption is the process to convert back random and meaningless text (ciphertext) into its original text (plain text).
It provides security to the message so even if hackers access the message, but they cannot understand the message.
Compression / Decompression:
The presentation layer is also responsible for data compression and decompression.
Compression is the process to reduce the number of bits of data files so the data can easily and efficiently transmit to the network.
Decompression is the process to restore the data files to their original form.
Layer 5: Session Layer
Session layer is used to establish, manage and terminate the connection between two communication hosts.
This layer controls the connection between multiple computers. when two devices want to communicate or want to share some data, then the application they are using must first create a session.
Session Layer is responsible for session management, authentication, and authorization.
Before creating a session (or a connection), the server first has to authenticate the device after authentication, a session is established between the device and the server. After authentication, the server gives authorization to the user to access the server data.
For example: To access Facebook, the server first authenticates the user by providing the correct username and password, after that it creates a session between the user and the servers. After that, it gives the authorization to access the Facebook servers.
This layer ensures that the session stays open long enough to exchange all the data, and then immediately closes the session in order to avoid wasting the resources.
The session layer is also responsible for the session’s restoration by creating checkpoints. So if a large amount of data are transferred, the session layer is responsible for creating a checkpoint after some amount of data. These checkpoints help to transfer the complete file and if there is any problem or disconnect after some amount of data then the session helps to resume the last checkpoint.
For example: If a 500 Mb file is transferred, the session layer could set a checkpoint after every 5 Mb. So in any case the connection is disconnected or any crash happened after 104 Mb, the session could be resumed after 100 Mb. So by using the checkpoint we do not have to send the full file again.
Layer 4: Transport Layer
The next layer is the transport layer is the fourth layer of the OSI model, which takes the data from the application and passes it on to the network layer.
Basic Functionality of transport layer:
- End-to-end delivery (port-to-port delivery)
- Data Segmentation
- Error Control
- Flow Control
- Multiplexing / Demultiplexing
End-to-end delivery (port-to-port delivery):
The transport layer is responsible for the end-to-end delivery of data from source-to-destination. End-to-end delivery means port-to-port delivery. When a packet is sent to the destination machine by the router in the network layer, after that the transport layer sends the data to the application by using the port number because every application has a port number and these port numbers help to identify each application. So the transport layer is responsible to send data to the correct application using the application’s port number.
Actually, the network layer is responsible to transmit data from one computer to another computer in the network and the transport layer is responsible to transmit the data to the correct application process using the port number.
The transport layer is also responsible for data segmentation. Data received from the upper layer is divided into small data units called segments. Each segment contains a source and destination port number, and also contains a sequence number. Port number is used to direct each data segment to the correct application. Sequence number helps to reassemble the data segments in the correct order to form the correct message at the receiver end.
Transport layer is also responsible for error control used in the TCP protocol.
Error control means if any error occurs or any data does not arrive at the receiving end, transport layer retransmits the lost or corrupted data. This is done by checksum. Checksum is a group of bits, added to each segment by the transport layer, used to check the error at the receiving end.
Transport layer is also responsible for data flow control from source to destination.
To understand this Let’s take a scenario: Mobile is connected to a server and wants to download a file, but the server can transmit the data up to 1000 Mbps and our mobile can receive data up to 10 Mbps. So the problem is our mobile cannot handle data up to 1000 Mbps. So to control this flow of data between mobile and server, the transport layer of the receiver’s machine (mobile) informs its receiving capacity to the sender’s machine. So the sender’s machine can slow down its data transmission rate up to the receiver’s machine capacity.
Multiplexing / Demultiplexing:
Transport layer is also used multiplexing and demultiplexing techniques. There can be multiple applications open on a computer, who wants to send data on a single media channel. The transport layer uses a multiplexing technique (like many-to-one) for sending multiple application data on a single media channel. On the receiver’s side, there can also be open multiple applications and all those applications want to receive data. So now the transport layer uses a demultiplexing technique, where it knows which data comes from which application.
Layer 3: Network Layer
Network layer is the third layer of the OSI model, which is responsible to transfer the data packets from one network to another network. Network Layer is used when we have to transfer the data on different networks. If data transfer between two devices on the same network, then the network layer is unnecessary.
When a data unit (data segment) comes from the transport layer to the network layer, then it is called a packet, where network layer added some extra information like source IP address and destination IP address, etc.
Network layer determines the data routing path from the source to the destination computer and manages traffic problems such as switching, routing, and controlling the congestion of data packets.
The network layer maintains logical address such as IP address for devices on the network. It selects and manages the best possible path for data transfer between source and destination.
Logical addresses are created and used by network layer protocol such as IP or IPx.
Basic functionality of Network layer:
- Host-to-host delivery (source-to-destination-delivery)
- Logical Addressing
Host-to-host delivery (source-to-destination-delivery)
Network layer is responsible to identify the host by using the IP addresses and deliver the data packet from one host to another host on different networks.
For example: On a network computer (A1) wants to transfer the data to the computer (B1) on another network. The network layer use the IP addresses to find each host on networks.
To identify each device on every network, the network layer use logical addressing called IP addresses. Every device on a network has a unique IP address.
As you know, there are two types of addressing, Logical Addressing and physical addressing. The physical addressing implemented by the data link layer handles the addressing problems locally on the local network. But if a packet passes the network boundary, then we need another addressing system (logical addressing) to help distinguish the source and destination system.
Logical addresses are the IP addresses contain two types of information, network id and host id. Network id helps to identify the particular network, and there can be multiple hosts on a network so the host id helps to identify the particular host on the network.
Network Layer is also responsible for routing the data packet from the source-to-destination device.
Routing is a method of moving data packets from source-to-destination and it is based on logical addresses (IP addresses). It is a process of selecting the best logical path on networks from source-to-destination.
Routing involves two basic activities:-
- Determine optimal routing paths and
- Transporting the packets through internetworking.
Routing is usually performed by a router. When a data packet sends from source-to-destination, then the packet travels through router-to-router, and the router decides the best route for a packet to reach its destination device.
Layer 2: Data Link Layer
Data link layer takes packets from the network layer and encapsulates them into frames by adding some extra information like MAC addresses of the source and destination machines. When a data packet arrives at the destination network, then the data link layer is responsible to direct the data to its correct host by using its MAC address.
As we already discussed, there are two types of addressing used in computer networks, logical addressing and physical addressing. Logical addressing is used in the network layer, where IP addresses are used to find the host network. Physical addressing is used in the data link layer, where MAC addresses are used to find the host device on the network.
For example: Computer A1 sends the data to computer B1 on another network. Now the router is used to find the host network by using its IP addresses (Logical addressing), after finding the host network the switch devices are used to find the correct host device on the network by using its MAC addresses.
Basic functions of data link layer
- Physical Addressing
- Flow Control
- Error Control
- Access Control
Data link layer use physical addresses to transfer the data on the network. Physical addresses are the MAC addresses, it’s a hardware identification number that uniquely identifies each device on a network.
When a packet comes from the network layer to the data link layer, it adds header and tailor to the packet and encapsulated them into frames, then each frame sends bit-by-bit on the hardware. At the receiving end, the data link layer picks up the signals from the hardware and assembles them into frames.
Header contains MAC addresses of source and destination NIC’s devices and tailor contains some bits, which are used to detect errors on the network.
Data link layer is responsible for data flow control. Data transfer rate must be at the same speed else the data may be corrupted, the data link layer use methods to control the flow of data on both sides.
This layer also provides an error control mechanism, it detects errors from the frames and retransmits frames that are damaged, duplicated, or lost.
Another function of the data link layer is access control, when two or more devices are attached to the same link, the data link layer protocols determine which device has control over the link at any given time.
Layer 1: Physical Layer
Physical layer receives the frames from the data link layer and converts them into electrical pulses, which represent binary data (0’s and 1’s) and send over the wired or wireless media.
Physical layer converts binary sequence into signals and transmits over the local media. Signals can be electrical signals in the case of copper cables, can be light signals in the case of optical fibers, or can be radio signals in the case of wirelessly. So signals are generated by the physical layer depending on the type of media used to connect two devices. At the receiver side, the physical layer receives signals converts it into bits, and passes it into the data link layer as a frame.
Physical layer includes cables- Twisted pair cables, Coaxial cables, Fiber optic cables.
It used physical devices like- NIC cards, Repeaters, Hubs, Transmitters, Multiplexers, etc.
Physical layer also specifies the physical topologies or layout like- BUS, STAR, RING, MESH, and TREE.
Physical Layer includes and its functionality
- Cables and Connectors
- Hardware’s (NIC, Repeaters, Hubs)
- Physical Topologies (BUS, STAR, RING, MESH, and TREE)
- Transmission Modes (Simplex, Half-duplex, Full-duplex)