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.
Data link layer is divided into two sub-layers, each with distinct functions that help in managing data flow, error correction, and medium access.
Important: At the sender side, the network layer communicates with the data link layer, starting with the Logical Link Control (LLC) sublayer and then followed by the Media Access Control (MAC) sublayer.
Both sublayers fully explain the functionality of the data link layer. Let’s explain one by one
1. Logical Link Control (LLC)
The LLC sub-layer is the upper part of the Data Link Layer. It primarily provides logical communication, error control, and flow management. Let’s explain all key functions of LLC
I. Framing of Data
The data link layer receives data from the network layer in the form of Packets/datagrams, converts it into Frames by adding a Header and Trailer, and sends it to the Physical layer. Very basic framing structure at data link layer is given below
II. 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 details of node-to-node delivery at data link layer.
Note: Node is also known as hop.
III. Error Control
Errors may occur when sending data due to several reasons: hardware issues, software failures (such as bugs in the code), background radiation, and head crashes. The data link layer manages these errors at each node.
Important: Both Data Link Layer (under LLC) and Transport layers perform error and flow control functions, but for different scopes:
|
Error detection and correction are two basic terms are used to handle the error control at data link layer
A. Error Detection
Error detection means the identification of errors. There are different ways to identify the errors at each node in the data link layer listed under,
B. 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
IV. 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.
Flow control protocols at data link layer uses the Stop and wait and Sliding window protocols to control the flow of data.
2. Media Access Control (MAC)
The MAC sub-layer is the lower part of the Data Link Layer. It focuses on how devices access and share the physical medium (the actual communication channel, such as Ethernet cables or wireless spectrum). let explain key functions of MAC.
I. Addressing
-
The MAC sub-layer uses MAC addressing (a unique identifier assigned to each network interface card, or NIC) to ensure that data is sent to the correct device on the local network.
-
Each frame contains the source and destination MAC addresses assigned by MAC sub layer.
II. Medium Access Control (MAC)
-
The MAC sub-layer is responsible for determining how devices gain access to the shared physical medium (whether wired or wireless).
-
It prevents multiple devices from transmitting at the same time, which would cause a collision. It does this using access control methods like:
-
CSMA/CD (Carrier Sense Multiple Access with Collision Detection) for Ethernet, where devices listen to the channel before transmitting and stop if they detect a collision.
-
CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance) for Wi-Fi, where devices avoid collisions by waiting for a clear channel before transmitting.
-
III. Frame Start/End Indicators
The MAC sub-layer defines the boundaries of the data frames by adding start and end indicators in the frame. It encapsulates the data into frames that can be transmitted over the physical medium.
IV. Collision Detection/Resolution
-
In Ethernet networks, it detects if two devices transmit at the same time (causing a collision) and handles the retransmission of the data.
-
For wireless networks (e.g., Wi-Fi), CSMA/CA helps avoid collisions by making devices wait until the channel is clear before transmitting.
Both sub-layers work together to ensure that data can be transmitted reliably between two devices on the same network while minimizing errors, managing access to the transmission medium, and ensuring data integrity.