Data Link Layer
Data Link Layer
Data Link Layer
• We observe from the above figure that the bit positions that includes 1 in
the first position are 1, 3, 5, 7. Now, we perform the even-parity check at
these bit positions. The total number of 1 at these bit positions
corresponding to r1 is even, therefore, the value of the r1 bit is 0.
Hamming code through an example
• Determining r2 bit
• The r2 bit is calculated by performing a parity check on the bit
positions whose binary representation includes 1 in the second
position.
• We observe from the above figure that the bit positions that
includes 1 in the second position are 2, 3, 6, 7. Now, we
perform the even-parity check at these bit positions. The total
number of 1 at these bit positions corresponding to r2 is odd,
therefore, the value of the r2 bit is 1.
Hamming code through an example
• The r4 bit is calculated by performing a parity check on the bit positions
whose binary representation includes 1 in the third position.
• We observe from the above figure that the bit positions that includes 1 in
the third position are 4, 5, 6, 7. Now, we perform the even-parity check at
these bit positions. The total number of 1 at these bit positions
corresponding to r4 is even, therefore, the value of the r4 bit is 0.
Hamming code through an example
• Data transferred is given below:
Hamming code through an example
• Suppose the 4th bit is changed from 0 to 1 at the receiving end, then parity
bits are recalculated.
• Therefore, the idea of stop and wait protocol in the sender's side is
very simple, i.e., send one packet at a time, and do not send another
packet before receiving the acknowledgment.
Techniques of Flow Control in Data Link
Layer
Receiver side
• Rule 1: Receive and then consume the data packet.
• Rule 2: When the data packet is consumed, receiver sends the
acknowledgment to the sender.
• Therefore, the idea of stop and wait protocol in the receiver's side is
also very simple, i.e., consume the packet, and once the packet is
consumed, the acknowledgment is sent. This is known as a flow
control mechanism.
Techniques of Flow Control in Data Link
Layer
Working of Stop and Wait protocol
Disadvantages of Stop and Wait
protocol
Problems occur due to lost data
• Suppose the sender sends the data and the data is lost. The receiver
is waiting for the data for a long time. Since the data is not received
by the receiver, so it does not send any acknowledgment. Since the
sender does not receive any acknowledgment so it will not send the
next packet. This problem occurs due to the lost data.
Disadvantages of Stop and Wait
protocol
In this case, two problems occur:
• Sender waits for an infinite amount of time for an acknowledgment.
• Receiver waits for an infinite amount of time for a data.
Disadvantages of Stop and Wait
protocol
Problems occur due to lost acknowledgment
• Suppose the sender sends the data and it has also been received by
the receiver. On receiving the packet, the receiver sends the
acknowledgment. In this case, the acknowledgment is lost in a
network, so there is no chance for the sender to receive the
acknowledgment.
• There is also no chance for the sender to send the next packet as in
stop and wait protocol, the next packet cannot be sent until the
acknowledgment of the previous packet is received.
Disadvantages of Stop and Wait
protocol
In this case, one problem occurs:
• Sender waits for an infinite amount of time for an
acknowledgment.
Disadvantages of Stop and Wait
protocol
Problem due to the delayed data or acknowledgment
Suppose the sender sends the data and it has also been received by the
receiver. The receiver then sends the acknowledgment but the
acknowledgment is received after the timeout period on the sender's
side. As the acknowledgment is received late, so acknowledgment can
be wrongly considered as the acknowledgment of some other data
packet.
Techniques of Flow Control in Data Link
Layer
2. Sliding Window Protocol
• The sliding window is a technique for sending multiple frames at a
time.
• It controls the data packets between the two devices where reliable
and gradual delivery of data frames is needed. It is also used in TCP
• In this technique, each frame has sent from the sequence number.
The sequence numbers are used to find the missing data in the
receiver end.
• The purpose of the sliding window technique is to avoid duplicate
data, so it uses the sequence number.
Sliding Window Protocol
• The sliding window protocol is the flow control protocol for noisy
channels that allows the sender to send multiple frames even before
acknowledgments are received
• It is called a Sliding window because the sender slides its window
upon receiving the acknowledgments for the sent frames.
Sliding Window Protocol
• The sliding window protocol is a communication protocol used to
manage the flow control and reliability of data transmission over a
network.
• It allows the sender to transmit a specified number of packets, known
as the window size, without waiting for an acknowledgment from the
receiver for each packet. This approach enhances efficiency by
minimizing the communication overhead.
Sliding Window Protocol
The protocol employs two primary components:
• The sender's sliding window and the receiver's sliding window.
• The sender's window keeps track of the packets that have been sent
but not yet acknowledged, while the receiver's window tracks the
expected sequence of packets to receive.
• As acknowledgments are received, both windows slide forward,
allowing for the continuous flow of data
Sliding Window Protocol
Working
• The sender and receiver have a “window” of frames. A window is a
space that consists of multiple bytes. The size of the window on the
receiver side is always 1.
• Each frame is sequentially numbered from 0 to n - 1, where n is the
window size at the sender side.
• The sender sends as many frames as would fit in a window.
• After receiving the desired number of frames, the receiver sends an
acknowledgment. The acknowledgment (ACK) includes the number
of the next expected frame.
Sliding Window Protocol
Sliding Window Protocol
Techniques of Flow Control in Data Link
Layer
Sliding window protocol has two types
• Go-Back-N ARQ
• Selective Repeat ARQ
Go-Back-N ARQ
Go-Back-N ARQ
• Go-Back-N ARQ protocol is also known as Go-Back-N Automatic
Repeat Request.
• Go – Back – N ARQ provides for sending multiple frames before
receiving the acknowledgment for the first frame.
• It uses the concept of sliding window, and so is also called sliding
window protocol.
• The frames are sequentially numbered and a finite number of frames
are sent.
Go-Back-N ARQ
• 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.
Selective Repeat ARQ
Selective Repeat ARQ
DLL
DLL is divided into two sublayers
• LLC sublayer
• MAC sublayer
DLL
• The main functionality of the LLC layer is that it multiplexes the
protocols over the MAC layer while sending and de-multiplex the
protocols while receiving. This layer controls the flow control.
DLL
• Data link layer is responsible for Framing, which is the division of a
stream of bits from the network layer into manageable units (called
frames).