0% found this document useful (0 votes)
13 views6 pages

CN Unit 2

The document discusses the data link layer's role in error control, detailing the types of errors, error detection and correction methods, and the mechanisms of byte and bit stuffing. It also covers flow control techniques, including Stop and Wait ARQ, Go-Back-N ARQ, Selective Repeat ARQ, and the Sliding Window protocol. Key error detection techniques such as Parity Check, Checksum, and Cyclic Redundancy Check (CRC) are explained, along with error correction codes.

Uploaded by

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

CN Unit 2

The document discusses the data link layer's role in error control, detailing the types of errors, error detection and correction methods, and the mechanisms of byte and bit stuffing. It also covers flow control techniques, including Stop and Wait ARQ, Go-Back-N ARQ, Selective Repeat ARQ, and the Sliding Window protocol. Key error detection techniques such as Parity Check, Checksum, and Cyclic Redundancy Check (CRC) are explained, along with error correction codes.

Uploaded by

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

U NIT 2

U DATA LINK LAYER


 When bits are transmitted over the computer network, they are subject to get corrupted due to
interference and network problems. The corrupted bits leads to spurious data being received by
the destination and are called errors.
 Error control in data link layer is the process of detecting and correcting data frames that have
been corrupted or lost during transmission.
 In case of lost or corrupted frames, the receiver does not receive the correct data-frame and
sender is ignorant about the loss.
 Data link layer follows a technique to detect transit errors and take necessary actions, which is
retransmission of frames whenever error is detected or frame is lost. The process is called
Automatic Repeat Request (ARQ).

Types of Errors
Errors can be of three types, namely single bit errors, multiple bit errors, and burst errors.
 Single bit error − In the received frame, only one bit has been corrupted, i.e. either changed
from 0 to 1 or from 1 to 0.

 Multiple bits error − In the received frame, more than one bits are corrupted.

 Burst error − In the received frame, more than one consecutive bits are corrupted.

Error control can be done in two ways


 Error detection − Error detection involves checking whether any error has occurred or not.
The number of error bits and the type of error does not matter.
 Error correction − Error correction involves ascertaining the exact number of bits that has
been corrupted and the location of the corrupted bits.
For both error detection and error correction, the sender needs to send some additional bits along with
the data bits. The receiver performs necessary checks based upon the additional redundant bits. If it
finds that the data is free from errors, it removes the redundant bits before passing the message to the
upper layers.

Bit Stuffing and Byte Stuffing


 Byte stuffing is a mechanism to convert a message formed of a sequence of bytes that may
contain reserved values such as frame delimiter, into another byte sequence that does not
contain the reserved values.
 Bit stuffing is the mechanism of inserting one or more non-information bits into a message to
be transmitted, to break up the message sequence, for synchronization purpose.

Purposes of byte stuffing and bit stuffing


 In Data Link layer, the stream of bits from physical layer are divided into data frames.
 The data frames can be of fixed length or variable length.
 In variable - length framing, the size of each frame to be transmitted may be different. So, a
pattern of bits is used as a delimiter to mark the end of one frame and the beginning of the next
frame.
 However, if the pattern occurs in the message, then mechanisms needs to be incorporated so
that this situation is avoided.

The two common approaches are −


Byte - Stuffing − A byte is stuffed in the message to differentiate from the delimiter. This is also
called character-oriented framing.
Bit - Stuffing − A pattern of bits of arbitrary length is stuffed in the message to differentiate from
the delimiter. This is also called bit - oriented framing.

Data link layer frames in byte stuffing and bit stuffing A


data link frame has the following parts −
 Frame Header − It contains the source and the destination addresses of the frame.
 Payload field − It contains the message to be delivered. In bit stuffing it is a variable sequence
of bits, while in byte stuffing it is a variable sequence of data bytes.
 Trailer − It contains the error detection and error correction bits.
 Flags − Flags are the frame delimiters signalling the start and end of the frame. In bit stuffing,
flag comprises of a bit pattern that defines the beginning and end bits. It is generally of 8-bits
and comprises of six or more consecutive 1s. In byte stuffing, flag is of 1- byte denoting a
protocol - dependent special character.
Mechanisms of byte stuffing versus bit stuffing Byte
Stuffing Mechanism
If the pattern of the flag byte is present in the message byte sequence, there should be a strategy so
that the receiver does not consider the pattern as the end of the frame. Here, a special byte called the
escape character (ESC) is stuffed before every byte in the message with the same pattern as the flag
byte. If the ESC sequence is found in the message byte, then another ESC byte is stuffed before it.

Bit Stuffing Mechanism


Here, the delimiting flag sequence generally contains six or more consecutive 1s. Most protocols use
the 8-bit pattern 01111110 as flag. In order to differentiate the message from the flag in case of same
sequence, a single bit is stuffed in the message. Whenever a 0 bit is followed by five consecutive 1bits
in the message, an extra 0 bit is stuffed at the end of the five 1s. When the receiver receives the
message, it removes the stuffed 0s after each sequence of five 1s. The un-stuffed message is then sent
to the upper layers.

Error Detection Techniques


There are three main techniques for detecting errors in frames: Parity Check, Checksum and Cyclic
Redundancy Check (CRC).
Parity Check
 The parity check is done by adding an extra bit, called parity bit to the data to make a number
of 1s either even in case of even parity or odd in case of odd parity.
 While creating a frame, the sender counts the number of 1s in it and adds the parity bit in the
following way
 In case of even parity: If a number of 1s is even then parity bit value is 0. If the number of
1s is odd then parity bit value is 1.
 In case of odd parity: If a number of 1s is odd then parity bit value is 0. If a number of 1s is
even then parity bit value is 1.
 On receiving a frame, the receiver counts the number of 1s in it. In case of even parity
check, if the count of 1s is even, the frame is accepted, otherwise, it is rejected. A similar
rule is adopted for odd parity check.
 The parity check is suitable for single bit error detection only.

Checksum
In this error detection scheme, the following procedure is applied
 Data is divided into fixed sized frames or segments.
 The sender adds the segments using 1’s complement arithmetic to get the sum. It then
complements the sum to get the checksum and sends it along with the data frames.
 The receiver adds the incoming segments along with the checksum using 1’s complement
arithmetic to get the sum and then complements it.

 If the result is zero, the received frames are accepted; otherwise, they are discarded.

Cyclic Redundancy Check (CRC)


Cyclic Redundancy Check (CRC) involves binary division of the data bits being sent by a
predetermined divisor agreed upon by the communicating system. The divisor is generated using
polynomials.
 Here, the sender performs binary division of the data segment by the divisor. It then appends
the remainder called CRC bits to the end of the data segment. This makes the resulting data
unit exactly divisible by the divisor.
 The receiver divides the incoming data unit by the divisor. If there is no remainder, the data
unit is assumed to be correct and is accepted. Otherwise, it is understood that the data is
corrupted and is therefore rejected.

Error Correction Techniques


Error correction techniques find out the exact number of bits that have been corrupted and as well as
their locations. There are two principle ways
 Backward Error Correction (Retransmission) − If the receiver detects an error in the
incoming frame, it requests the sender to retransmit the frame. It is a relatively simple
technique. But it can be efficiently used only where retransmitting is not expensive as in fiber
optics and the time for retransmission is low relative to the requirements of the application.
 Forward Error Correction − If the receiver detects some error in the incoming frame, it
executes error-correcting code that generates the actual frame. This saves bandwidth
required for retransmission. It is inevitable in real-time systems. However, if there are too
many errors, the frames need to be retransmitted.

The four main error correction codes are


 Hamming Codes
 Binary Convolution Code
 Reed – Solomon Code
 Low-Density Parity-Check Code

Flow Control
Flow control is a technique that allows two stations working at different speeds to communicate with
each other. It is a set of measures taken to regulate the amount of data that a sender sends so that a
fast sender does not overwhelm a slow receiver. In data link layer, flow control restricts the number of
frames the sender can send before it waits for an acknowledgment from the receiver.

Approaches of Flow Control


Flow control can be broadly classified into two categories −

 Feedback based Flow Control - In these protocols, the sender sends frames after it has
received acknowledgments from the user. This is used in the data link layer.
 Rate based Flow Control - These protocols have built in mechanisms to restrict the rate of
transmission of data without requiring acknowledgment from the receiver. This is used in the
network layer and the transport layer.
Flow Control Techniques in Data Link Layer
Data link layer uses feedback based flow control mechanisms. There are two main techniques

Stop and Wait ARQ


This protocol involves the following transitions:
 A timeout counter is maintained by the sender, which is started when a frame is sent.
 If the sender receives acknowledgment of the sent frame within time, the sender is
confirmed about successful delivery of the frame. It then transmits the next frame
in queue.
 If the sender does not receive the acknowledgment within time, the sender assumes
that either the frame or its acknowledgment is lost in transit. It then retransmits the
frame.
 If the sender receives a negative acknowledgment, the sender retransmits the frame.

Go-Back-N ARQ
The working principle of this protocol is:
 The sender has buffers called sending window.
 The sender sends multiple frames based upon the sending-window size, without
receiving the acknowledgment of the previous ones.
 The receiver receives frames one by one. It keeps track of incoming frame’s
sequence number and sends the corresponding acknowledgment frames.
 After the sender has sent all the frames in window, it checks up to what sequence
number it has received positive acknowledgment.
 If the sender has received positive acknowledgment for all the frames, it sends
next set of frames.
 If sender receives NACK or has not receive any ACK for a particular frame, it
retransmits all the frames after which it does not receive any positive ACK.

Selective Repeat ARQ


 Both the sender and the receiver have buffers called sending window and
receiving window respectively.
 The sender sends multiple frames based upon the sending-window size, without
receiving the acknowledgment of the previous ones.
 The receiver also receives multiple frames within the receiving window size.
 The receiver keeps track of incoming frame’s sequence numbers, buffers the
frames in memory.
 It sends ACK for all successfully received frames and sends NACK for only
frames which are missing or damaged.
 The sender in this case, sends only packet for which NACK is received.

Sliding Window
This protocol improves the efficiency of stop and wait protocol by allowing multiple
frames to be transmitted before receiving an acknowledgment.
The working principle of this protocol can be described as follows −
 Both the sender and the receiver has finite sized buffers called windows. The
sender and the receiver agrees upon the number of frames to be sent based upon
the buffer size.
 The sender sends multiple frames in a sequence, without waiting for
acknowledgment. When its sending window is filled, it waits for acknowledgment.
On receiving acknowledgment, it advances the window and transmits the next
frames, according to the number of acknowledgments received.

You might also like