Data Link Layer
Data Link Layer
2nd Layer
Data Link layer
► The Data-link layer is the second layer from the bottom in the
TCP/IP model.
► Responsible for the node-to-node delivery of data
► Major role is to ensure error-free transmission of information
► Responsible to encode, decode and organize the outgoing and
incoming data
► most complex layer of the OSI model as it hides all the
underlying complexities of the hardware from the other above
layers
Sub Layers of Data Link Layers
Logical Link Control (LLC) Media Access Control (MAC)
This sublayer of the data link layer deals MAC sublayer manages the device’s
with multiplexing, the flow of data interaction, responsible for addressing
among applications and other services, frames, and also controls physical media
and LLC is responsible for providing error
access.
messages and acknowledgments as well.
The data link layer receives the
information in the form of packets from
the Network layer, it divides packets into
frames and sends those frames bit-by-bit
to the underlying physical layer.
Functions of the Data-link Layer:
► Framing
► The packet received from the Network layer is
known as a frame in the Data link layer. At the
sender’s side, DLL receives packets from the
Network layer and divides them into small
frames, then, sends each frame bit-by-bit to
the physical layer.
► It also attaches some special bits (for error
control and addressing) at the header and end
of the frame. At the receiver’s end, DLL takes
bits from the Physical layer organizes them
into the frame, and sends them to the Network
layer.
► Addressing
► The data link layer encapsulates the source
and destination’s MAC address/ physical
address in the header of each frame to ensure
node-to-node delivery. MAC address is the
unique hardware address that is assigned to
the device while manufacturing.
Functions of Data Link Layer
► Error Control
► Data can get corrupted due to various reasons like noise, attenuation, etc. So, it
is the responsibility of the data link layer, to detect the error in the transmitted
data and correct it using error detection and correction techniques
respectively. DLL adds error detection bits into the frame’s header, so that
receiver can check received data is correct or not.
► Flow Control
► If the receiver’s receiving speed is lower than the sender’s sending speed,
then this can lead to an overflow in the receiver’s buffer and some frames may
get lost. So, it’s the responsibility of DLL to synchronize the sender’s and
receiver’s speeds and establish flow control between them.
► Access Control
► When multiple devices share the same communication channel there is a
high probability of collision, so it’s the responsibility of DLL to check which
device has control over the channel and CSMA/CD and CSMA/CA can be used
to avoid collisions and loss of frames in the channel.
Services Provided By DLL
Services Provided By DLL
► It is a method of including the length of a frame in header so that we can be aware of the frame
length and end of frame where the count is over.
For example, if eight wires are used to send the eight bits of a byte, if one of the wire is
noisy, then single-bit is corrupted per byte.
Error Types
Burst Error
► The two or more bits are changed from 0 to 1 or from 1 to 0 is known as Burst Error.
► The Burst Error is determined from the first corrupted bit to the last corrupted bit.
► The duration of noise in Burst Error is more than the duration of noise in Single-Bit.
► Burst Errors are most likely to occurr in Serial Data Transmission.
► The number of affected bits depends on the duration of the noise and data rate.
Error Detecting Techniques
Single Parity Check
► Single Parity checking is the simple mechanism and inexpensive to detect the errors.
► In this technique, a redundant bit is also known as a parity bit which is appended at the
end of the data unit so that the number of 1s becomes even. Therefore, the total number
of transmitted bits would be 9 bits.
► If the number of 1s bits is odd, then parity bit 1 is appended and if the number of 1s bits is
even, then parity bit 0 is appended at the end of the data unit.
► At the receiving end, the parity bit is calculated from the received data bits and
compared with the received parity bit.
► This technique generates the total number of 1s even, so it is known as even-parity
checking.
In the case of even parity, for a given set In the case of odd parity, for a given set of
of bits, the number of 1’s are counted. If bits, the number of 1’s are counted. If that
that count is odd, the parity bit value is count is even, the parity bit value is set to 1,
set to 1, making the total count of making the total count of occurrences of 1’s
occurrences of 1’s an even number. If the an odd number. If the total number of 1’s in a
total number of 1’s in a given set of bits is given set of bits is already odd, the parity bit’s
already even, the parity bit’s value is 0. value is 0.
► Step 1 - The position of the data bits and the number of redundant bits in
the original data. The number of redundant bits is deduced from the
expression [2r >= d+r+1].
► Step 2 - Fill in the data bits and redundant bit, and find the parity bit value
using the expression [2p, where, p - {0,1,2, …… n}].
► Step 3 - Fill the parity bit obtained in the original data and transmit the
data to the receiver side.
► Step 4 - Check the received data using the parity bit and detect any error
in the data, and in case damage is present, use the parity bit value to
correct the error.
Features of Hamming Code
Error Detection and Correction: Hamming code is designed to detect and correct single-bit errors
that may occur during the transmission of data. This ensures that the recipient receives the same
data that was transmitted by the sender.
Redundancy: Hamming code uses redundant bits to add additional information to the data being
transmitted. This redundancy allows the recipient to detect and correct errors that may have
occurred during transmission.
Efficiency: Hamming code is a relatively simple and efficient error-correction technique that does
not require a lot of computational resources. This makes it ideal for use in low-power and
low-bandwidth communication networks.
Widely Used: Hamming code is a widely used error-correction technique and is used in a variety of
applications, including telecommunications, computer networks, and data storage systems.
Single Error Correction: Hamming code is capable of correcting a single-bit error, which makes it
ideal for use in applications where errors are likely to occur due to external factors such as
electromagnetic interference.
Limited Multiple Error Correction: Hamming code can only correct a limited number of multiple
errors. In applications where multiple errors are likely to occur, more advanced error-correction
techniques may be required.
Error Control in Stop and Wait Mechanism
► Before understanding the stop and Wait protocol, we first know about the error control
mechanism.
► The error control mechanism is used so that the received data should be exactly same
whatever sender has sent the data.
► The error control mechanism is divided into two categories, i.e., Stop and Wait ARQ and
sliding window.
► The sliding window is further divided into two categories, i.e., Go Back N, and Selective
Repeat.
► Based on the usage, the people select the error control mechanism whether it is stop and
wait or sliding window.
Error Control in Stop and Wait Mechanism
► For example, Go-Back-8, the size of the sender window, will be 8. The receiver
window size is always 1.
► The receiver does not accept a corrupted frame. When the timer expires, the sender
sends the correct frame again.
► Selective Repeat ARQ is also known as the Selective Repeat Automatic Repeat
Request.
► It is a data link layer protocol that uses a sliding window method.
► The Go-back-N ARQ protocol works well if it has fewer errors.
► But if there is a lot of error in the frame, lots of bandwidth loss in sending the
frames again.
► So, we use the Selective Repeat ARQ protocol.
► In this protocol, the size of the sender window is always equal to the size of the
receiver window.
► The size of the sliding window is always greater than 1.
► If the receiver receives a corrupt frame, it does not directly discard it. It sends a
negative acknowledgment to the sender.
► The sender sends that frame again as soon as on the receiving negative
acknowledgment.
► There is no waiting for any time-out to send that frame.
► The design of the Selective Repeat ARQ protocol is shown below.
Go-Back-N ARQ V/S Selective Repeat ARQ
Go-Back-N ARQ Selective Repeat ARQ
If a frame is corrupted or lost in it,all In this, only the frame is sent again, which is
subsequent frames have to be sent again. corrupted or lost.
If it has a high error rate,it wastes a lot of There is a loss of low bandwidth.
bandwidth.
It does not require sorting. In this, sorting is done to get the frames in the
correct order.