Data Link Layer
Data link layer is the layer No 6 from sender and layer No 2 of receiving side in the OSI model. This layer is a little bit complex and complicated as compared to other layers. It provides host to host delivery.
At Sender Side, Data link layer receives packets/datagram from network layer and convert these packets/datagrams to frames and transmit these frames to physical layer.
At Receiver Side, Data link layer receives bits from physical layer and convert these bits to frames and transmit these frames to network layer.
Functionality of Data-link Layer
1. Framing of Data
Data link layer received data from network layer in the form of Packets/datagram and converts it into Frames by adding Header and Trailer it and send it towards Physical layer.
2. Node to Node Connection
To reach the data at destination it first pass through different intermediate nodes (i.e. Routers) which is done through data link layer. The following figure shows the detail,
Note: Node is also known as hop.
3. Flow Control
Sometimes, one node has higher speed and capacity than other nodes. Then sending speed may be higher than receiver node. So, flow control comes into the picture.
Thus, data link layer control the flow of data node to node. But the Transport layer deals with source to destination flow control.
It uses the Stop and wait and Sliding window protocols to control the flow of data.
4. Error Control
Sometimes, errors may occur when we send the data Due to the following reasons
- Software failure (due to bugs in the code)
- Background radiation,
- Head crashes
Then data-link layer control these errors at each node.
Ways of Doing Error Control
There are basically two ways of doing Error control, as given below:
I. Error Detection
Error detection means identification of errors. There are different ways to identify the errors at each node in the data link layer listed under,
II. Error Correction:
Error correction means fixing the errors. Our basic need is data should be error free. The error correction method is very costly and hard as well.
The best error correction technique at each node of the data link layer is the Hamming Code.
Note: The transport layer also controls the error but deals with only two ends, host and destination.
5. Medium / Multiple Access Control (MAC)
When a node on the shared link tries to transfer the data, it has a probability of collision.
For example, when multiple nodes in the bus topology try to send data at the same time, a collision may happen.
So, the Data-link layer uses the following protocols to eliminate collision.
5. Physical Address
It provides the MAC address to each node so that it can communicate within the same network. If we want to communicate with another network, then we have to use the IP address.
By using only the data link layer, communication can be done easily without using the network layer.
Sub Layers of Data Link Layer
The data link layer holds two sub-layers
1. Logical link control (LLC)
Logical Link Control deals with flow control from host to host.
2. Medium Access Control (MAC)
Medium Access Control deals with the following tasks
- Physical Addressing
- Error Control
- Access Control