0% found this document useful (0 votes)
64 views15 pages

Data Link Layer

The Data Link Layer (DLL) provides reliable communication between directly connected machines, ensuring data is transmitted in frames and delivered in order. Key design issues include error control, flow control, and framing, with various protocols like Go-Back-N and Selective Repeat addressing these challenges. The DLL offers services such as unacknowledged, acknowledged connectionless, and acknowledged connection-oriented services to manage data transmission effectively.

Uploaded by

rushildbce07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views15 pages

Data Link Layer

The Data Link Layer (DLL) provides reliable communication between directly connected machines, ensuring data is transmitted in frames and delivered in order. Key design issues include error control, flow control, and framing, with various protocols like Go-Back-N and Selective Repeat addressing these challenges. The DLL offers services such as unacknowledged, acknowledged connectionless, and acknowledged connection-oriented services to manage data transmission effectively.

Uploaded by

rushildbce07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

2.

Data Link Layer (DLL)


Subtopics: Framing, error/flow control, protocols (sliding window).​
Frequency: 5+​
Questions:
●​ May 2024 (Q1C): Go-back-N protocol (advantages, error handling).
●​ June 2023 (Q1C): Design issues (framing, error/flow control).
●​ Jan 2023 (Q1A): Services provided by DLL to the network layer.
●​ July 2022 (Q1B): Pseudocode for one-bit sliding window.
●​ Dec 2023 (Q1C): Analyze sliding window ARQ protocols.
Variations:
●​ Protocol-specific (e.g., Go-back-N vs. Selective Repeat).
●​ Pseudocode implementation (e.g., sliding window).

Data Link Layer: Design Principles

1. Purpose of the Data Link Layer


●​Provides reliable, efficient communication between two adjacent machines (directly connected).
●​Transmits data in units called frames (not individual bits like the Physical Layer).
●​Ensures frames are delivered in order (same order as sent).

2. Communication Channel Properties


●​Acts like a wire (e.g., coaxial cable, telephone line, wireless).
●​Key Limitations:
○​Errors (bits may get corrupted).
○​Finite data rate (limited speed).
○​Non-zero propagation delay (time lag between sending and receiving).

3. Key Design Issues


1.​Error Control
○​Detection: Checksums, CRC (Cyclic Redundancy Check).
○​Correction: Retransmission (ARQ), Forward Error Correction (FEC).
2.​Flow Control
○​Prevents sender from overwhelming receiver (e.g., Stop-and-Wait, Sliding Window).
3.​Framing
○​How to mark the start & end of frames (e.g., byte stuffing, bit stuffing).

4. Challenges in Data Link Protocols


●​Noise & Errors → Need error detection/correction.
●​Limited Bandwidth → Efficient use of channel capacity.
●​Propagation Delay → Affects timing & acknowledgments.

5. Example Protocols
●​Simple Protocol: No error/flow control (unrealistic).
●​Stop-and-Wait ARQ: Handles errors but inefficient.
●​Sliding Window: Improves efficiency (e.g., Go-Back-N, Selective Repeat).
Design Issues in the Data Link Layer

1. Services Provided to the Network Layer

The Data Link Layer (DLL) functions as a service interface between the Network Layer of the sending
and receiving machines. Its primary responsibility is to transfer data from the Network Layer of the
source to the Network Layer of the destination. This transmission occurs through the Data Link Layer
and includes essential mechanisms such as framing, error control, and flow control.

The Data Link Layer offers three types of services:

a. Unacknowledged and Connectionless Services

●​ Independent frames are sent by the sender without expecting acknowledgements from the receiver.​

●​ There is no logical connection established between sender and receiver.​

●​ This service is simple and fast, but there is no guarantee of delivery.​

●​ Suitable for error-tolerant applications where speed is more critical than reliability.​

b. Acknowledged and Connectionless Services

●​ Frames are sent without establishing a logical connection, similar to the previous type.​

●​ However, each frame is individually acknowledged by the receiver.​

●​ If a frame is not acknowledged within a certain time, it is retransmitted by the sender.​

●​ This service is especially useful in unreliable communication environments, such as wireless


systems.​

c. Acknowledged and Connection-Oriented Services

●​ A logical connection is first established between the sender and the receiver before data transfer
begins.​

●​ Frames are numbered, allowing the receiver to detect any loss or duplication and ensure in-order
delivery.​

●​ The service guarantees that each frame is received exactly once and in the correct sequence.​

●​ It is suitable for applications that require high reliability and accurate data transfer.

SERVICES PROVIDED BY DATA LINK LAYER

Framing: Frames are the streams of bits received from the network layer into manageable data units. This division
of the stream of bits is done by the Data Link Layer.

Physical Addressing: The Data Link layer adds a header to the frame in order to define the physical address of the
sender or receiver of the frame, if the frames are to be distributed to different systems on the network.

Flow Control: A receiving node can receive the frames at a faster rate than it can process the frame. Without flow
control, the receiver's buffer can overflow, and frames can get lost. To overcome this problem, the data link layer
uses the flow control to prevent the sending node on one side of the link from overwhelming the receiving node on
another side of the link. This prevents traffic jams at the receiver side.

Error Control: Error control is achieved by adding a trailer at the end of the frame. Duplication of frames is also
prevented by using this mechanism. Data Link Layers adds a mechanism to prevent duplication of frames. Error
detection: Errors can be introduced by signal attenuation and noise. Data Link Layer protocol provides a mechanism
to detect one or more errors. This is achieved by adding error detection bits in the frame and then receiving nodes can
perform an error check. Error correction: Error correction is similar to the Error detection, except that the receiving
node not only detects the errors but also determines where the errors have occurred in the frame.

Access Control: Protocols of this layer determine which of the devices has control over the link at any given time,
when two or more devices are connected to the same link.

Reliable delivery: Data Link Layer provides a reliable delivery service, i.e., transmits the network layer datagram
without any error. A reliable delivery service is accomplished with transmissions and acknowledgements. A data link
layer mainly provides the reliable delivery service over the links as they have higher error rates and they can be
corrected locally, link at which an error occurs rather than forcing to retransmit the data.

Half-Duplex & Full-Duplex: In a Full-Duplex mode, both the nodes can transmit the data at the same time. In a
Half-Duplex mode, only one node can transmit the data at the same time.


Framing in the Data Link Layer

To ensure reliable data transfer, the Data Link Layer must divide the raw bit stream received from the
Physical Layer into distinct, manageable frames. These frames enable error detection and recovery,
synchronization, and structured communication between the sender and receiver.

1. Character Count Method

●​ This method uses a field in the header to specify the number of characters (bytes) in the frame.​

●​ When the receiver sees the character count, it knows how many characters follow, thus determining
the frame boundary.​

Example: For frames of sizes 5, 5, 8, and 8 characters, the count helps in identifying the end of each
frame.

Limitation:

●​ If the character count field is corrupted, the receiver gets out of synchronization and cannot
determine where the next frame begins.​

●​ Even if the frame is detected as bad (via a checksum), the receiver cannot realign itself for
subsequent frames.​

●​ Retransmission is ineffective unless the start of the next valid frame is known.​
●​ Due to this vulnerability, this method is rarely used in modern protocols.​

2. Flag Bytes with Byte Stuffing

●​ Each frame begins and ends with a special byte, called the flag byte (commonly 01111110).​

●​ If the receiver loses synchronization, it can scan for the next flag byte to regain alignment.​

●​ Two consecutive flag bytes indicate the end of one frame and the start of another.​

Problem:

●​ The flag byte's pattern might appear in the actual data, which can confuse the framing.​

Solution – Byte Stuffing:

●​ The sender inserts a special escape byte (ESC) before every accidental flag byte in the data.​

●​ The receiver removes the ESC byte during reception, restoring the original data.​

●​ If an ESC byte appears in the data, it too is prefixed by another ESC byte.​

●​ Thus, any single ESC indicates an escape, while two ESCs represent a literal ESC in the data.​

Limitation:

●​ Tied to 8-bit characters, making it unsuitable for systems like UNICODE that use 16-bit characters.​

3. Starting and Ending Flags with Bit Stuffing


●​ Designed for systems with arbitrary bit-length characters.​

●​ Frames begin and end with a specific bit pattern (01111110, same as flag byte).​

●​ To prevent this flag from appearing in the data, bit stuffing is used:​

○​ When the sender detects five consecutive 1s, it inserts a 0 afterward.​

○​ At the receiving end, upon detecting five 1s followed by a 0, the 0 is removed.​

Advantages:

●​ The flag pattern is unique, allowing unambiguous frame boundaries.​

●​ Fully transparent to higher layers; original data is preserved after de-stuffing.​

●​ Helps resynchronize in case of errors by scanning for the next valid flag.​

4. Physical Layer Coding Violations

●​ This method uses coding violations to indicate frame boundaries.​

●​ Only applicable in specific encoding schemes where redundancy exists in physical bit
representation.​

Example:

●​In some LANs, each logical bit is encoded using 2 physical bits:​

○​A 1 is encoded as high-low, and a 0 as low-high.​

○​High-high or low-low combinations are reserved to signal frame boundaries.​

Hybrid Approaches

●​ Some robust data link protocols combine character count with flag-based framing for enhanced
reliability.​

●​ When a frame is received:​

○​ The count field is checked to locate the frame end.​


○​ The presence of the flag and valid checksum are also verified.​

○​ If any mismatch occurs, the input is scanned for the next valid flag to re-establish synchronization.​

Let me know if you'd like a summary chart comparing all four methods, or visual illustrations to
accompany this content for teaching or presentation purposes.

Flow Control in the Data Link Layer

One of the critical design issues in the Data Link Layer (and in higher layers as well) is managing
situations where the sender transmits frames faster than the receiver can process them. This
commonly occurs when a high-performance sender (e.g., a server) communicates with a low-capacity
receiver (e.g., a smartphone). Even if the transmission is error-free, the receiver might be overwhelmed
and drop frames simply due to lack of processing capacity or buffer space.

Why Flow Control is Needed

●​ Without flow control, a powerful sender can overload a slower receiver, causing data loss even
when the link itself is reliable.​

●​ Example: A smartphone requesting a webpage from a powerful server may be "flooded" with data
it cannot handle in time.

Two Main Approaches to Flow Control

1.​ Feedback-Based Flow Control​

○​ The receiver provides feedback to the sender about its current state.​

○​ The sender adjusts its transmission based on permissions or status reports from the receiver.​

○​ This approach is commonly implemented in the Data Link Layer and upper layers (like the
Transport Layer).​

○​ Example: The receiver may say, “You may send ‘n’ frames now, then wait for further
instructions.”​

2.​ Rate-Based Flow Control​

○​ No feedback is used.​

○​ The sender transmits data at a predefined, limited rate, regardless of receiver status.​

○​ This method is more commonly used at the Transport Layer rather than the Data Link Layer.​

Focus in the Data Link Layer: Feedback-Based Control

●​ Most Data Link Layer protocols rely on feedback-based mechanisms to regulate flow.​

●​ These protocols implement rules specifying when and how many frames can be sent.​

●​ Often, a frame cannot be transmitted unless the receiver grants permission, either explicitly
(with control messages) or implicitly (e.g., through acknowledgments).​
Real-World Implementation

●​ Many modern Network Interface Cards (NICs) operate at "wire speed", meaning they are fast
enough to process frames as quickly as they arrive.​

●​ As a result, flow control at the link layer is often handled in hardware, reducing the need for
higher-layer intervention.​

●​ However, if an overrun does occur, higher layers (like TCP in the Transport Layer) step in to
manage flow.

ERROR CONTROL

Error Control in Data-Link Layer


●​The data-link layer employs error control techniques to ensure and verify that all data frames or packets
(bit streams) are accurately transmitted from sender to receiver.​

●​Implementing error control at this layer is an optimization, not a requirement.​

●​Error control involves detecting and retransmitting data frames that might have been lost or corrupted
during transmission.​

●​In cases of data loss or corruption, the receiver does not get the correct data, and the sender remains
unaware unless notified.​

●​To handle such issues, protocols are provided to both sender and receiver for detecting and handling
these errors.​

●​The data-link layer uses a method called retransmission of frames to identify and fix transit errors.​

●​When an error is detected, the specific frame is retransmitted — a process known as ARQ (Automatic
Repeat Request).​

Ways of Performing Error Control


1.​ Error Detection : Error detection, as the name suggests, simply means detection or
identification of errors. These errors may occur due to noise or any other impairments during
transmission from transmitter to the receiver, in the communication system. It is a class of techniques for
detecting garbled i.e. unclear and distorted data or messages.
2.​ Error Correction : Error correction, as the name suggests, simply means correction or solving
or fixing of errors. It simply means reconstruction and rehabilitation of original data that is error-free.
But the error correction method is very costly and very hard.

Various Techniques for Error Control : There are various techniques of error control as given below :​
1. Stop-and-Wait ARQ : Stop-and-Wait ARQ is also known as alternating bit protocol. It is one of the
simplest flow and error control techniques or mechanisms. This mechanism is generally required in
telecommunications to transmit data or information between two connected devices. Receiver simply
indicates its readiness to receive data for each frame. In these, the sender sends information or data
packets to the receiver. Sender then stops and waits for ACK (Acknowledgement) from the receiver.
Further, if ACK does not arrive within a given time period i.e., time-out, sender then again resends
frame and waits for ACK. But, if sender receives ACK, then it will transmit the next data packet to
receiver and then again wait for ACK from receiver. This process to stop and wait continues until the
sender has no data frame or packet to send. ​
2. Sliding Window ARQ : This technique is generally used for continuous transmission error control. It
is further categorized into two categories as given below :

●​ Go-Back-N ARQ : Go-Back-N ARQ is a form of ARQ protocol in which the transmission
process continues to send or transmit a total number of frames that are specified by window size even
without receiving an ACK (Acknowledgement) packet from the receiver. It uses a sliding window flow
control protocol. If no errors occur, then operation is identical to sliding window.
●​ Selective Repeat ARQ : Selective Repeat ARQ is also a form of ARQ protocol in which only
suspected or damaged or lost data frames are only retransmitted. This technique is similar to Go-Back-N
ARQ though much more efficient than the Go-Back-N ARQ technique due to the reason that it reduces
the number of retransmissions. In this, the sender only retransmits frames for which NAK is received.
But this technique is used less because of more complexity between sender and receiver and each frame
must be needed to be acknowledged individually.

The main difference between Go Back ARQ and Selective Repeat ARQ is that in Go Back ARQ, the
sender has to retransmit the whole window of frame again if any of the frame is lost but in Selective
Repeat ARQ only the data frame that is lost is retransmitted.
Stop-and-Wait ARQ Protocol

1. Definition:Stop-and-Wait Automatic Repeat reQuest (ARQ) is an error control protocol commonly used
in noisy communication channels to ensure reliable data transfer. It operates on a simple principle: the
sender transmits one data frame at a time and then waits for an acknowledgment (ACK) from the receiver
before sending the next frame. This method ensures that each frame is successfully received before the
transmission continues, reducing the risk of undetected errors.

2. Working Mechanism:In the Stop-and-Wait ARQ protocol, the sender begins by transmitting a frame
labeled with a sequence number, typically either 0 or 1. The receiver then checks the frame for errors using
a checksum. If the frame is found to be correct, the receiver responds with an acknowledgment (ACK),
allowing the sender to proceed with the next frame. If the sender does not receive an ACK within a
predetermined timeout period, it assumes the frame was lost or corrupted and retransmits it. Additionally, if
the receiver detects a duplicate frame—possibly due to a lost ACK—it discards the duplicate and resends
the last ACK to prevent processing the same data twice.

3. Error Handling:Error handling in Stop-and-Wait ARQ covers frame loss, ACK loss, and frame
corruption. In the case of frame loss, the receiver does not receive the frame and therefore does not send an
ACK. The sender, upon timing out, retransmits the lost frame. For ACK loss, if the acknowledgment is lost
after the receiver has correctly received a frame, the sender times out and retransmits the same frame. The
receiver identifies it as a duplicate and resends the ACK. When frame corruption occurs, the receiver
discards the faulty frame without sending an ACK. This again leads the sender to retransmit the frame after
timeout. In each scenario, the protocol ensures eventual successful delivery of the frame, even if
duplication and retransmission are necessary.

4. Advantages:One of the main advantages of the Stop-and-Wait ARQ protocol is its simplicity. Its
straightforward implementation makes it easy to use and manage, especially in basic or low-speed
communication systems. It guarantees reliable data transmission even in noisy environments by ensuring
each frame is acknowledged before moving on to the next. Additionally, by allowing only one frame to be
in transit at a time, it prevents the receiver from becoming overloaded with too much incoming data.

5. Disadvantages:Despite its reliability, Stop-and-Wait ARQ suffers from low efficiency. Since only one
frame is sent and acknowledged at a time, the sender often remains idle while waiting for the ACK, leading
to significant delays. This waiting period increases the overall transmission time, especially over
long-distance or high-speed links. Consequently, it is not suitable for modern networks where bandwidth
needs to be utilized more effectively, and where delays can impact performance.

6. Conclusion:In conclusion, Stop-and-Wait ARQ is a reliable and effective protocol for basic error
control, especially suitable for simple or noisy network environments. Its design ensures accuracy and
order in data transmission. However, due to its low efficiency and high delay, it is not ideal for high-speed
or long-distance communications. In such scenarios, more advanced protocols like Go-Back-N ARQ or
Selective Repeat ARQ are preferred, as they offer better performance and higher throughput.

Sliding Window ARQ ​

GO BACK N:The Go-Back-N protocol is a sliding window protocol used for reliable data transfer in
computer networks. It is a sender-based protocol that allows the sender to transmit multiple packets without
waiting for an acknowledgement for each packet. The receiver sends a cumulative acknowledgement for a
sequence of packets, indicating the last correctly received packet. If any packet is lost, the receiver sends a
negative acknowledgement (NACK) for the lost packet, and the sender retransmits all the packets in the
window starting from the lost packet. The sender also maintains a timer for each packet, and if an
acknowledgement is not received within the timer's timeout period, the sender retransmits all packets in the
window.

1. Go-Back-N ARQ with Damaged Data Frame

In this scenario, the sender transmits a sequence of


frames from DATA0 to DATA4. However, DATA3 is
received in a corrupted state and is discarded by the
receiver. Upon detecting the error, the receiver sends a
NAK3 (Negative Acknowledgment) to inform the
sender about the damaged frame. According to the
Go-Back-N ARQ protocol rules, the sender must
retransmit DATA3 along with all subsequent frames,
even if those frames (DATA4 and DATA5) were
originally transmitted correctly. Once the
retransmission is complete, the receiver accepts the
corrected frames in order. This behavior demonstrates
how a single damaged frame causes the retransmission
of multiple frames, leading to inefficiency.
Nevertheless, the protocol remains simpler than
Selective Repeat, as it avoids buffering and reordering
by the receiver.
2. Go-Back-N ARQ with Lost Data Frame

In this case, the sender begins transmission


with DATA0 and DATA1, which are
received successfully. However, DATA2 is
lost during transmission. Despite this, the
sender proceeds to transmit DATA3 and
DATA4, which are discarded by the
receiver since DATA2 was never received.
The receiver detects the missing frame
based on sequence number and sends a
NAK2. In response, the sender retransmits
all frames from DATA2 onward, including
DATA2, DATA3, and DATA4. Once
retransmitted, the receiver processes them
correctly and sends a cumulative ACK5,
indicating all frames up to DATA4 have
been accepted. This scenario highlights the
"go back" mechanism of the protocol,
where the sender returns to the last
unacknowledged frame and retransmits
from that point. Although efficient in
detecting errors early through NAKs, it still
results in unnecessary retransmission of
correctly received frames.

3. Go-Back-N ARQ with Lost Acknowledgment

Here, the sender transmits DATA0 and DATA1,


both of which are received correctly by the
receiver. However, the ACK2 sent by the
receiver is lost during transmission. Without
receiving the acknowledgment, the sender's
timer expires and it assumes a failure occurred.
Consequently, it retransmits DATA0 and
DATA1, even though these frames were already
received successfully. The receiver identifies
these retransmissions as duplicates, discards
them, and resends ACK2 to confirm receipt.
This scenario illustrates how Go-Back-N ARQ
handles lost acknowledgments using a timeout
mechanism and emphasizes the need for the
receiver to detect and manage duplicate frames.
Though the protocol ensures reliability, the
retransmission of already acknowledged data
reflects its lower efficiency compared to
Selective Repeat ARQ.

SELECTIVE REPEAT ARQ


What is Selective Repeat Protocol?
The Selective Repeat protocol is another that is used for reliable data transfer in computer networks. It is a
receiver-based protocol that allows the receiver to acknowledge each packet individually, rather than a
cumulative acknowledgement of a sequence of packets. The sender sends packets in a window and waits for
acknowledgements for each packet in the window. If a packet is lost, the receiver sends a NACK for the lost
packet, and the sender retransmits only that packet. The sender also maintains a timer for each packet, and if
an acknowledgement is not received within the timer's timeout period, the sender retransmits only that
packet.

Receiver-Based Protocol: The receiver plays a bigger role by keeping track of which packets are received
and which are missing.​

Individual Acknowledgment: Each packet is acknowledged separately, allowing the sender to know
exactly which packets were received successfully.​

Selective Retransmission: Only the lost or corrupted packets are resent, which helps reduce unnecessary
network traffic and improves efficiency.​

Buffering of Out-of-Order Packets:The receiver stores packets that arrive out of order until the missing
ones arrive, ensuring proper data reassembly.​

Higher Memory and Processing Requirement:Due to buffering and tracking each packet, it needs more
memory and logic compared to Go-Back-N.​

Efficient Transmission: It makes better use of bandwidth and time by avoiding full-window
retransmissions, making it ideal for high-error or high-latency networks.

1. Selective Reject ARQ with Damaged Data


FrameIn this scenario, the sender transmits
frames DATA0 to DATA2, all of which are
successfully received and accepted by the
receiver. However, DATA3 is received with
errors and is therefore discarded. The sender,
unaware of the issue, continues transmitting
DATA4 and DATA5, which are correctly
received and processed by the receiver. Once the
receiver detects the damaged DATA3, it sends a
NAK3, specifically requesting its retransmission.
The sender retransmits DATA3, which is now
received correctly and accepted. To complete the
process, the receiver sends an ACK5,
acknowledging the successful reception of all
frames up to DATA5. This scenario highlights
the strength of Selective Reject ARQ, where only
the damaged frame (DATA3) is retransmitted,
and correctly received frames such as DATA4
and DATA5 are not delayed. This improves
transmission efficiency by avoiding unnecessary
retransmissions and making better use of
bandwidth compared to Go-Back-N.
2A. Selective Reject ARQ with Lost Data Frame

In this case, the sender transmits DATA0 and


DATA1, which are received and accepted
successfully. However, DATA2 is lost during
transmission. The sender continues to send
DATA3 and DATA4, which are received
without issue and buffered by the receiver since
DATA2 is missing. The receiver identifies a gap
in the sequence numbers and responds by
sending a NAK2, specifically requesting the
retransmission of the missing DATA2. Upon
receiving the NAK, the sender retransmits
DATA2, which is now accepted by the receiver.
With the sequence now complete, the receiver
sends an ACK4 to acknowledge the successful
receipt of all frames up to DATA4. This
scenario demonstrates Selective Reject ARQ’s
ability to handle lost frames efficiently by
buffering out-of-order frames and retransmitting
only the missing frame, preserving network
resources and maintaining order without delay.

2B. Selective Reject ARQ with Timer-Based Recovery

This scenario illustrates how the protocol


handles lost or delayed acknowledgments.
Here, the sender transmits DATA0 through
DATA4, but due to network issues, the
acknowledgments are either delayed or lost.
As a result, the sender’s timer expires,
prompting it to retransmit all unacknowledged
frames. Meanwhile, the receiver has already
received the original frames and, upon
receiving the duplicates, uses its logic to
detect and discard repeated frames, processing
only the first copy of each. Eventually, after
all frames are accounted for, the receiver
sends an ACK4 to acknowledge the complete
sequence. This timer-based recovery method
acts as a fallback mechanism when NAKs are
lost or not received. Although effective, it is
less efficient than NAK-based recovery, as it
may result in retransmitting frames
unnecessarily. The scenario also underscores
the importance of the receiver’s ability to
handle duplicate detection and suppression.
3. Selective Reject ARQ with Lost Acknowledgement

In this scenario, the sender sends DATA0, which


is received and acknowledged normally. It then
sends DATA1, which is also received
successfully, but the corresponding ACK is lost in
transmission. With no acknowledgment received,
the sender’s timer expires, prompting it to
retransmit both DATA0 and DATA1. The
receiver, having already accepted these frames,
recognizes them as duplicates and discards them
appropriately. To resolve the situation, the
receiver resends ACK1 to confirm that it has
successfully received all data up to that point.
This case highlights how Selective Reject ARQ
handles lost acknowledgments effectively
through timer-based retransmission and
duplicate recognition. Importantly, it avoids
triggering retransmission of all subsequent
frames, maintaining overall efficiency while
ensuring reliable communication.

Difference Between Go-Back-N and Selective Repeat Protocol

Go-Back-N Protocol Selective Repeat Protocol

In Go-Back-N Protocol, if the sent frame are find


In selective Repeat protocol, only those frames are
suspected then all the frames are re-transmitted from th
re-transmitted which are found suspected.
lost packet to the last packet transmitted.

Sender window size of Go-Back-N Protocol is N. Sender window size of selective Repeat protocol is also N.

Receiver window size of Go-Back-N Protocol is 1. Receiver window size of selective Repeat protocol is N.

Go-Back-N Protocol is less complex. Selective Repeat protocol is more complex.

In Go-Back-N Protocol, neither sender nor at receiver In selective Repeat protocol, receiver side needs sorting to sor
need sorting. the frames.

In Go-Back-N Protocol, type of Acknowledgement is In Selective Repeat protocol, type of Acknowledgement is


cumulative. individual.

In Go-Back-N Protocol, Out-of-Order packets are NOT


In selective Repeat protocol, Out-of-Order packets are
Accepted (discarded) and the entire window is
Accepted.
re-transmitted.

In selective Repeat protocol, if Receives a corrupt packet, it


In Go-Back-N Protocol, if Receives a corrupt packet,
immediately sends a negative acknowledgement and hence
then also, the entire window is re-transmitted.
only the selective packet is retransmitted.
Here's the pseudocode for the One-Bit Sliding Window Protocol, which is essentially the basis of
the Stop-and-Wait ARQ protocol. This protocol uses a 1-bit sequence number (0 or 1) to manage
frames and acknowledgments.

Sender Side Pseudocode

initialize seq_num = 0

while there are frames to send:

frame = get_next_frame()

send(frame, seq_num)

start_timer()

wait until (ACK received or timeout occurs)

if ACK received and ACK == seq_num:

stop_timer()

seq_num = 1 - seq_num // toggle sequence number

else if timeout:

// resend the same frame

send(frame, seq_num)

restart_timer()

Receiver Side Pseudocode

expected_seq = 0

while true:

if frame received:

if no error and frame.seq == expected_seq:

deliver_data(frame.data)

send_ack(expected_seq)

expected_seq = 1 - expected_seq // toggle expected sequence

else:

// frame is duplicate or has error

send_ack(1 - expected_seq) // resend last correct ACK

You might also like