Data Link Layer
Data Link Layer
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
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.
● Independent frames are sent by the sender without expecting acknowledgements from the receiver.
● Suitable for error-tolerant applications where speed is more critical than reliability.
● Frames are sent without establishing a logical connection, similar to the previous type.
● 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.
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.
● 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.
● 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.
● 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.
● 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:
Advantages:
● Helps resynchronize in case of errors by scanning for the next valid flag.
● 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:
Hybrid Approaches
● Some robust data link protocols combine character count with flag-based framing for enhanced
reliability.
○ 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.
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.
● 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.
○ 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.”
○ 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.
● 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 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).
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.
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.
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.
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.
In Go-Back-N Protocol, neither sender nor at receiver In selective Repeat protocol, receiver side needs sorting to sor
need sorting. the frames.
initialize seq_num = 0
frame = get_next_frame()
send(frame, seq_num)
start_timer()
stop_timer()
else if timeout:
send(frame, seq_num)
restart_timer()
expected_seq = 0
while true:
if frame received:
deliver_data(frame.data)
send_ack(expected_seq)
else: