0% found this document useful (0 votes)
42 views33 pages

2 Unit-2

Data Link layer

Uploaded by

it.mohan
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)
42 views33 pages

2 Unit-2

Data Link layer

Uploaded by

it.mohan
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/ 33

Unit -2: The Data Link Layer

Design Issues, Services Provided to the Network Layer, Framing, Error Control, Flow
Control, Error Detection and Correction, Error Correcting Codes, Error Detecting Codes, A
Simplex Stop and Wait Protocol for an Error free channel, A Simplex Stop and Wait Protocol
for a Noisy Channel, Sliding Window Protocols (A One Bit Sliding Window Protocol-A
Protocol Using Go-Back-NA Protocol Using Selective Repeat), Data Link Layer in HDLC:
Configuration and transmission modes, frames, control fields.

Data Link Layer

o In the OSI model, the data link layer is a 4 th layer from the top and 2nd
layer from the bottom.
o The communication channel that connects the adjacent nodes is known as
links, and in order to move the datagram from source to the destination,
the datagram must be moved across an individual link.
o The main responsibility of the Data Link Layer is to transfer the datagram
across an individual link.
o The Data link layer protocol defines the format of the packet exchanged
across the nodes as well as the actions such as Error detection,
retransmission, flow control, and random access.
o The Data Link Layer protocols are Ethernet, token ring, FDDI and PPP.
o An important characteristic of a Data Link Layer is that datagram can be
handled by different link layer protocols on different links in a path. For
example, the datagram is handled by Ethernet on the first link, PPP on the
second link.

Following services are provided by the Data Link Layer:

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 1


o Framing & Link access: Data Link Layer protocols encapsulate each
network frame within a Link layer frame before the transmission across
the link. A frame consists of a data field in which network layer datagram
is inserted and a number of data fields. It specifies the structure of the
frame as well as a channel access protocol by which frame is to be
transmitted over the link.
o 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.
o 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.
o 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 node can perform an error check.
o Error correction: Error correction is similar to the Error detection, except
that receiving node not only detect the errors but also determine where the
errors have occurred in the frame.
o 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.
The Data-link layer is the second layer from the bottom in the OSI (Open
System Interconnection) network architecture model. It is responsible for the node-
to-node delivery of data. Its major role is to ensure error-free transmission of
information. DLL is also responsible to encode, decode and organize the outgoing
and incoming data. This is considered the most complex layer of the OSI model as
it hides all the underlying complexities of the hardware from the other above
layers.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 2


Sub-layers of Data Link Layer:
The data link layer is further divided into two sub-layers, which are as follows:
Logical Link Control (LLC):
This sublayer of the data link layer deals with multiplexing, the flow of data
among applications and other services, and LLC is responsible for providing
error messages and acknowledgments as well.
Media Access Control (MAC):
MAC sublayer manages the device‟s interaction, responsible for addressing
frames, and also controls physical media access.

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.
Design Issues of Data Link Layer
The data link layer is supposed to carry out many specified functions. It is
responsible for effective data communication between two directly connected
transmitting and receiving stations.
The data link layer has to carry out several specific functions and the following
are the main design issues of data link layer:
 Data transfer
 Frame synchronization
 Flow control
 Error control
 Addressing
 Link management.
Provide Services to the Network Layer
The data link layer provides a well-defined service interface to the network layer.
The principle of services is to transfer data from the network layer on the source
machine to the network layer on the destination machine.
The transfer is done through DDL(Dynamic-link layer). The data link layer takes
services from the physical layer and provides well-defined services to the
network layer.
Datalink layer provides three types of services as follows:
 Unacknowledged connectionless service
 Acknowledged connection service
 Acknowledged connection-oriented service.
Frame Synchronization
Frame synchronization is one form the design issues of data link layer. The
source machine sends data in a block called frame to the destination machine.
The starting and ending of each frame must be recognized by the destination
machine.
For frame recognization, every frame comprises three parts, such as frame
header, payload field (contains data packet from the network layer) and trailer.
Flow Control
The source machine should not send a data frame at a fast data rate as compared
to the destination machine receiving data rate. When the sender sends the data at
a high speed, the slow receiver cannot able to handle it and the frame can lose in
such cases.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 3


There are two types of techniques that are used for flow control as follows.
 Rate based flow control
 Feedback based flow control.
Error Control
The errors made in bits during transmission from source to destination machines
must be detected and corrected. The data link layer ensures error-free data
transmission. For this, two types of error control techniques are used in the data
link layer are as follows.
 Error detection techniques
 Error correction techniques
Addressing
Addressing is also one of the design issues of data link layer. On a multipoint
line, the identity of the individual machines must be specified while transmitting
the data frames. Each frame comprises a header in which the source and
destination addresses are placed.
Link Management
The initiation, maintenance and termination of the link between the source and
destination is required for the effective exchange of data. The data link layer of
the OSI Model handles proper link management of connected devices.
What are the Data Link Layer services provided to the Network Layer?
In the OSI (Open System Interconnections) Model, each layer uses the services
of the layer below it and provides services to the layer above it. The primary function
of the data link layer is to provide a well-defined service interface to the network
layer above it.

Virtual Communication versus Actual Communication


The main service provided is to transfer data packets from thenetwork layer on the
sending machine to the network layer on the receiving machine. Data link layer of the
sending machine transmits accepts data from the network layer and sends them to the data link
layer of the destination machine which hands them to the network layer there.
In actual communication, the data link layer transmits bits via the physical
layers and physical medium. However virtually, this can be visualized as the two
data link layers communicating with each other using a data link protocol.
The processes are depicted in the following diagram −

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 4


Types of Services
The data link layer offers three types of services.
 Unacknowledged connectionless service − Here, the data link layer of
the sending machine sends independent frames to the data link layer of the
receiving machine. The receiving machine does not acknowledge
receiving the frame. No logical connection is set up between the host
machines. Error and data loss is not handled in this service. This is
applicable in Ethernet services and voice communications.
 Acknowledged connectionless service − Here, no logical connection is set
up between the host machines, but each frame sent by the source machine is
acknowledged by the destination machine on receiving. If the source does not
receive the acknowledgment within a stipulated time, then it resends the
frame. This is used in Wifi (IEEE 802.11) services.
 Acknowledged connection-oriented service − This is the best service
that the data link layer can offer to the network layer. A logical connection
is set up between the two machines and the data is transmitted along this
logical path. The frames are numbered, that keeps track of loss
offrames and also ensures that frames are received in correct order. The
service has three distinct phases −
o Set up of connection – A logical path is set up between the source
and the destination machines. Buffers and counters are initialised to
keep track of frames.
o Sending frames – The frames are transmitted.
o Release connection – The connection is released, buffers and other
resources are released.
It is appropriate for satellite communications and long-distance telephone
circuits.
Framing in Computer Network
Framing is a point-to-point connection between two devices that consists of a
wire in which data is transmitted as a stream of bits.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 5


Let‟s understand this from the given diagram.
We have given two devices with an adaptor attached to each one. This adaptor
will be sending the data into signals which will flow through the cable and will
be received by the physical layer of other devices.
Framing in a computer network uses frames to send/receive the data. The
data link layer packs bits into frames such that each frame is distinguishable
from another.The data link layer prepares a packet for transport across local
media by encapsulating it with a header and a trailer to create a frame.
The frame is defined as the data in telecommunications that moves between
various network points.
Usually, a frame moves bit-by-bit serially and consists of a trailer field and
header field that frames the information. These frames are understandable only
by the data link layer.
The frame consists of the following parts:
1. Frame Header: It consists of the frame's source and destination
address.
2. Payload Field: It contains the message to be delivered.
3. Flag: It points to the starting and the ending of the frame.
4. Trailer: It contains the error detection and correction bits.

The physical layer doesn‟t know anything about the frames. It takes individual
bits and converts them into equivalent signals before sending them. Now, the
receiving device's physical layer has to convert these bits into frames, but
certain problems need to be discussed before that.
Challenges in Framing
1. For example, the sending device sends 100 bits of data, out of which 50
bits belong to frame one. The receiving device receives all the bits. How
will the receiver know that up to 50 bits belong to the frame?
Solution: Some protocols are defined between the devices before beginning
with the communication and data exchange. Let both the devices agree
that the frame's start and end will be 11011 (added with the header and
trailer). The frame received by the receiving device will look like this
1101101101101011011.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 6


2. If you notice carefully, there is another problem the frame that is received
contain a part that resembles the start and the end of the frame
1101101101101011011. Hence, the receiver will consider only these bits
1101101011011,i.e., before the resembling part will not be considered a
part of the frame. This is known as a Framing Error. To understand the
solutions of this problem, we first have to learn the types of framing.
Types of Framing in Computer Network
Framing is further divided into two types:
Fixed-size Framing
In this type of framing, the size of the frame is fixed, and hence the frame length
acts as a delimiter of the frame.
This framing doesn‟t require the additional boundary bits to identify the frame's
start and end - for example: If a device is sending 200 bits of data and the 50
bits of frame size is fixed, then after receiving the 50 bits of data, the receiver
will automatically know that the next 50 bits are of frame two and so on.
Drawback: It goes through internal fragmentation when the data size is less than
the frame size. Padding is a solution to avoid such a situation.
Variable size Framing
In this type of framing, the size of each frame to be transmitted may vary; hence
additional mechanisms are kept to mark the end of one frame and the start of the
next frame.
For example, It is possible that out of 200 bits of data, 100 bits constitute frame
1, 25 bits constitute frame two, and the rest bits constitute frame 3.
The following are the two ways that are used to define the frame delimiters, i.e.,
the start and the end of the frame in variable size framing:
Framing Approaches in Computer Network
There are mainly three types of framing approaches:
1. Bit-Oriented Framing
2. Byte-Oriented Framing
3. Clock Based Framing

Bit-Oriented Approach
It views the frames as a collection of bits. The data is transmitted as a sequence
of bits that can be interpreted as text andmultimedia data in the upper layer.

Clock Based Framing


This framing is mainly used for Optical Networks such as SONET. In this
approach, a series of repetitive pulses maintain a constant bit rate and keep the
digital bits aligned in the data stream.

Advantages of Framing in Data Link Layer


 Frames are used continuously in the process of time- division
multiplexing.
 It facilitates a form to the sender for transmitting a group of valid bits to a
receiver.
 Frames also contain headers that include information such as error-
checking codes.
 A Frame relay, token ring, ethernet, and other types of data link layer
methods have their frame structures.
 Frames allow the data to be divided into multiple recoverable
parts that can be inspected further for corruption.
Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 7
 It provides a flow control mechanism that manages the frame flow such
that the data congestion does not occur on slow receivers due to fast
senders.
 It provides reliable data transfer services between the layers of the peer
network.
Error control in Data Link Layer
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).
Phases in Error Control
The error control mechanism in data link layer involves the following phases −
 Detection of Error − Transmission error, if any, is detected by either the
sender or the receiver.
 Acknowledgment − acknowledgment may be positive or negative.
o Positive ACK − On receiving a correct frame, the receiver
sends a positive acknowledge.
o Negative ACK − On receiving a damaged frame or a duplicate
frame, the receiver sends a negativeacknowledgment back to
the sender.
 Retransmission − The sender maintains a clock and sets a timeout
period. If an acknowledgment of a data-frame previously transmitted does
not arrive before the timeout, or a negative acknowledgment is received,
the sender retransmits the frame.
Error Control Techniques
There are three main techniques for error control −

 Stop and Wait ARQ


This protocol involves the following transitions −
o A timeout counter is maintained by the sender, which is started
when a frame is sent.
o 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.
o 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.
o If the sender receives a negative acknowledgment, the sender
retransmits the frame.
Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 8
 Go-Back-N ARQ
The working principle of this protocol is −
o The sender has buffers called sending window.
o The sender sends multiple frames based upon the sending-
window size, without receiving the acknowledgment of the
previous ones.
o The receiver receives frames one by one. It keeps track of incoming
frame‟s sequence number and sends the corresponding
acknowledgment frames.
o 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.
o 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
o Both the sender and the receiver have buffers called sending
window and receiving window respectively.
o The sender sends multiple frames based upon the sending-
window size, without receiving the acknowledgment of the
previous ones.
o The receiver also receives multiple frames within the receiving
window size.
o The receiver keeps track of incoming frame‟s sequence numbers,
buffers the frames in memory.
o It sends ACK for all successfully received frames and sends
NACK for only frames which are missing or damaged.
o The sender in this case, sends only packet for which NACK is
received.
Flow Control
o It is a set of procedures that tells the sender how much data it can transmit
before the data overwhelms the receiver.
o The receiving device has limited speed and limited memory to store the
data. Therefore, the receiving device must be able to inform the sending
device to stop the transmission temporarily before the limits are
reached.
o It requires a buffer, a block of memory for storing the information
until they are processed.
Two methods have been developed to control the flow of data:
o Stop-and-wait
o Sliding window
Stop-and-wait
o In the Stop-and-wait method, the sender waits for an
acknowledgement after every frame it sends.
o When acknowledgement is received, then only next frame is

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 9


sent. The process of alternately sending and waiting of a frame continues
until the sender transmits the EOT (End of transmission) frame.
Advantage of Stop-and-wait
The Stop-and-wait method is simple as each frame is checked and
acknowledged before the next frame is sent.
Disadvantage of Stop-and-wait
Stop-and-wait technique is inefficient to use as each frame must travel across all the
way to the receiver, and an acknowledgement travels all the way before the next
frame is sent. Each frame sent and received uses the entire time needed to
traverse the link.
Sliding Window
o The Sliding Window is a method of flow control in which a sender can
transmit the several frames before getting an acknowledgement.
o In Sliding Window Control, multiple frames can be sent one after the
another due to which capacity of the communication channel can be
utilized efficiently.
o A single ACK acknowledge multiple frames.
o Sliding Window refers to imaginary boxes at both the sender and receiver
end.
o The window can hold the frames at either end, and it provides the
upper limit on the number of frames that can be transmitted before the
acknowledgement.
o Frames can be acknowledged even when the window is not completely
filled.
o The window has a specific size in which they are numbered as modulo-n
means that they are numbered from 0 to n-1. For example, if n = 8, the
frames are numbered from 0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1........
o The size of the window is represented as n-1. Therefore, maximum n-1
frames can be sent before acknowledgement.
o When the receiver sends the ACK, it includes the number of the next
frame that it wants to receive. For example, to acknowledge the string of
frames ending with frame number 4, the receiver will send the ACK
containing the number 5. When the sender sees the ACK with the number
5, it got to know that the frames from 0 through 4 have been received.
Sender Window
o At the beginning of a transmission, the sender window contains n-1
frames, and when they are sent out, the left boundary moves inward
shrinking the size of the window. For example, if the size of the
window is w if three frames

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 10


are sent out, then the number of frames left out in the sender window is
w-3.
o Once the ACK has arrived, then the sender window expands to the
number which will be equal to the number of frames acknowledged by
ACK.
o For example, the size of the window is 7, and if frames 0 through 4 have
been sent out and no acknowledgement has arrived, then the sender
window contains only two frames, i.e., 5 and 6. Now, if ACK has arrived
with a number 4 which means that 0 through 3 frames have arrived
undamaged and the sender window is expanded to include the next four
frames. Therefore, the sender window contains six frames (5,6,7,0,1,2).

Receiver Window
o At the beginning of transmission, the receiver window does not contain n

frames, but it contains n-1 spaces for frames.


o When the new frame arrives, the size of the window shrinks.
o The receiver window does not represent the number of frames received, but
it represents the number of frames that can be received before an ACK is
sent. For example, the size of the window is w, if three frames are received
then the number of spaces available in the window is (w-3).
o Once the acknowledgement is sent, the receiver window expands by
the number equal to the number of frames acknowledged.
o Suppose the size of the window is 7 means that the receiver window
contains seven spaces for seven frames. If the one frame is received, then
the receiver window shrinks and moving the boundary from 0 to 1. In this
way, window shrinks one by one, so window now contains the six spaces.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 11


If frames from 0 through 4 have sent, then the window contains two spaces
before an acknowledgement is sent.

Flow control in Data Link Layer


. 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 −

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 12


Flow Control in Data Link Layer
Approaches to Flow Control : Flow Control is classified into two categories:
 Feedback – based Flow Control : In this control technique, sender
simply transmits data or information or frame to receiver, then receiver
transmits data back to sender and also allows sender to transmit more
amount of data or tell sender about how receiver is processing or doing.
This simply means that sender transmits data or frames after it has
received acknowledgements from user.
 Rate – based Flow Control : In this control technique, usually when
sender sends or transfer data at faster speed to receiver and receiver is
not being able to receive data at the speed, then mechanism known as
built-in mechanism in protocol will just limit or restricts overall rate at
which data or information is being transferred or transmitted by sender
without any feedback or acknowledgement from receiver.
Techniques of Flow Control in Data Link Layer : There are basically two types
of techniques being developed to control the flow of data

1. Stop-and-Wait Flow Control : This method is the easiest and simplest form of
flow control. In this method, basically message or data is broken down into
various multiple frames, and then receiver indicates its readiness to receive frame of
data. When acknowledgement is received, then only sender will send or transfer the
next frame. This process is continued until sender transmits EOT (End of
Transmission) frame. In this method, only one of frames can be in transmission at
a time. It leads to inefficiency i.e. less productivity if propagation delay is very
much longer than the transmission delay and Ultimately In this method sender
sent single frame and receiver take one frame at a time and sent
acknowledgement(which is next frame number only) for new frame.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 13


Advantages –
 This method is very easiest and simple and each of the frames is
checked and acknowledged well.
 This method is also very accurate.
Disadvantages –
 This method is fairly slow.
 In this, only one packet or frame can be sent at a time.
 It is very inefficient and makes the transmission process very slow.
2. Sliding Window Flow Control : This method is required where reliable in-
order delivery of packets or frames is very much needed like in data link layer. It is
point to point protocol that assumes that none of the other entity tries to
communicate until current data or frame transfer gets completed. In this method,
sender transmits or sends various frames or packets before receiving any
acknowledgement. In this method, both the sender and receiver agree upon total
number of data frames after which acknowledgement is needed to be transmitted.
Data Link Layer requires and uses this method that simply allows sender to have
more than one unacknowledged packet “in-flight” at a time. This increases and
improves network throughput. and Ultimately In this method sender sent multiple
frame but receiver take one by one and after completing one frame
acknowledge(which is next frame number only) for new frame.
Advantages –
 It performs much better than stop-and-wait flow control.
 This method increases efficiency.
 Multiples frames can be sent one after another.
Disadvantages –
 The main issue is complexity at the sender and receiver due to the
transferring of multiple frames.
 The receiver might receive data frames or packets out the sequence.
Error Detection & Correction
There are many reasons such as noise, cross-talk etc., which may help data to
get corrupted during transmission. The upper layers work on some generalized
view of network architecture and are not aware of actual hardware data
processing.Hence, the upper layers expect error-free transmission between the
systems. Most of the applications would not function expectedly if they receive
erroneous data. Applications such as voice and video may not be that affected
and with some errors they may still function well.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 14


Data-link layer uses some error control mechanism to ensure that frames (data
bit streams) are transmitted with certain level of accuracy. But to understand
how errors is controlled, it is essential to know what types of errors may
occur.
Types of Errors
There may be three types of errors:
 Single bit error

In a frame, there is only one bit, anywhere though, which is corrupt.


 Multiple bits error

Frame is received with more than one bits in corrupted state.


 Burst error

Frame contains more than1 consecutive bits corrupted. Error control


mechanism may involve two possible ways:
 Error detection
 Error correction
Error Detection
Errors in the received frames are detected by means of Parity Check and Cyclic
Redundancy Check (CRC). In both cases, few extra bits are sent along with
actual data to confirm that bits received at other end are same as they were sent.
If the counter- check at receiver‟ end fails, the bits are considered corrupted.
Parity Check
One extra bit is sent along with the original bits to make number of 1s either
even in case of even parity, or odd in case of odd parity.
The sender while creating a frame counts the number of 1s in it. For example, if
even parity is used and number of 1s is even then one bit with value 0 is added.
This way number of 1s remains even.If the number of 1s is odd, to make it even
a bit with value 1 is added.

The receiver simply counts the number of 1s in a frame. If the count of 1s is


even and even parity is used, the frame is

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 15


considered to be not-corrupted and is accepted. If the count of 1s is odd and odd
parity is used, the frame is still not corrupted.
If a single bit flips in transit, the receiver can detect it by counting the number
of 1s. But when more than one bits are erro neous, then it is very hard for the
receiver to detect the error.
Cyclic Redundancy Check (CRC)
CRC is a different approach to detect if the received frame contains valid data.
This technique involves binary division of the data bits being sent. The divisor is
generated using polynomials. The sender performs a division operation on the
bits being sent and calculates the remainder. Before sending the actual bits, the
sender adds the remainder at the end of the actual bits. Actual data bits plus the
remainder is called a codeword. The sender transmits data bits as codewords.

At the other end, the receiver performs division operation on codewords using the
same CRC divisor. If the remainder contains all zeros the data bits are accepted,
otherwise it is considered as there some data corruption occurred in transit.
Error Correction
In the digital world, error correction can be done in two ways:
 Backward Error Correction When the receiver detects an error in the
data received, it requests back the sender to retransmit the data unit.
 Forward Error Correction When the receiver detects some error in the
data received, it executes error-correcting code, which helps it to auto-
recover and to correct some kinds of errors.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 16


The first one, Backward Error Correction, is simple and can only be efficiently
used where retransmitting is not expensive. For example, fiber optics. But in
case of wireless transmission retransmitting may cost too much. In the latter
case, Forward Error Correction is used.
To correct the error in data frame, the receiver must know exactly which bit in
the frame is corrupted. To locate the bit in error, redundant bits are used as
parity bits for error detection.For example, we take ASCII words (7 bits data),
then there could be 8 kind of information we need: first seven bits to tell us
which bit is error and one more bit to tell that there is no error.
Error Detection in Computer Networks Error
A condition when the receiver‟s information does not match with the sender‟s
information. During transmission, digital signals suffer from noise that can
introduce errors in the binary bits travelling from sender to receiver. That means
a 0 bit may change to 1 or a 1 bit may change to 0.

Error Detecting Codes (Implemented either at Data link layer or Transport


Layer of OSI Model)
Whenever a message is transmitted, it may get scrambled by noise or data may
get corrupted. To avoid this, we use error- detecting codes which are additional
data added to a given digital message to help us detect if any error has occurred
during transmission of the message.

Basic approach used for error detection is the use of redundancy bits, where
additional bits are added to facilitate detection of errors.
Some popular techniques for error detection are:
1. Simple Parity check
2. Two-dimensional Parity check
3. Checksum
4. Cyclic redundancy check

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 17


1. Simple Parity check
Blocks of data from the source are subjected to a check bit or parity bit
generator form, where a parity of :
 1 is added to the block if it contains odd number of 1‟s, and
 0 is added if it contains even number of 1‟s
This scheme makes the total number of 1‟s even, that is why it is called even
parity checking.

2. Two-dimensional Parity check


Parity check bits are calculated for each row, which is equivalent to a simple
parity check bit. Parity check bits are also calculated for all columns, then both
are sent along with the data. At the receiving end these are compared with the
parity bits calculated on the received data.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 18


3. Checksum
 In checksum error detection scheme, the data is divided into k segments
each of m bits.
 In the sender‟s end the segments are added using 1‟s complement
arithmetic to get the sum. The sum is complemented to get the
checksum.
 The checksum segment is sent along with the data segments.
 At the receiver‟s end, all received segments are added using 1‟s
complement arithmetic to get the sum. The sum is complemented.
 If the result is zero, the received data is accepted; otherwise discarded.

4. Cyclic redundancy check (CRC)


 Unlike checksum scheme, which is based on addition, CRC is based on
binary division.
 In CRC, a sequence of redundant bits, called cyclic redundancy check bits,
are appended to the end of data unit so that the resulting data unit
becomes exactly divisible by a second, predetermined binary number.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 19


 At the destination, the incoming data unit is divided by the same number.
If at this step there is no remainder, the data unit is assumed to be correct
and is therefore accepted.
 A remainder indicates that the data unit has been damaged in transit and
therefore must be rejected.

Example :

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 20


Error Correction
Error Correction codes are used to detect and correct the errors when data is
transmitted from the sender to the receiver.
Error Correction can be handled in two ways:
o Backward error correction: Once the error is discovered, the receiver
requests the sender to retransmit the entire data unit.
o Forward error correction: In this case, the receiver uses the error-
correcting code which automatically corrects the errors.
A single additional bit can detect the error, but cannot correct it. For correcting
the errors, one has to know the exact position of the error. For example, If we
want to calculate a single-bit error, the error correction code will determine
which one of seven bits is in error. To achieve this, we have to add some
additional redundant bits.
Suppose r is the number of redundant bits and d is the total number of the data
bits. The number of redundant bits r can be calculated by using the formula:
2r>=d+r+1
The value of r is calculated by using the above formula. For example, if the
value of d is 4, then the possible smallest value that satisfies the above relation
would be 3.
To determine the position of the bit which is in error, a technique developed by
R.W Hamming is Hamming code which can be applied to any length of the data
unit and uses the relationship between data units and redundant units.

Hamming Code
Parity bits: The bit which is appended to the original data of binary bits so that
the total number of 1s is even or odd.
Even parity: To check for even parity, if the total number of 1s is even, then the
value of the parity bit is 0. If the total number of 1s occurrences is odd, then the
value of the parity bit is 1.
Odd Parity: To check for odd parity, if the total number of 1s is even, then the
value of parity bit is 1. If the total number of 1s is odd, then the value of parity
bit is 0.
Algorithm of Hamming code:
o An information of 'd' bits are added to the redundant bits 'r' to form d+r.
o The location of each of the (d+r) digits is assigned a decimal value.
o The 'r' bits are placed in the positions 1,2,......................2k-1.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 21


o At the receiving end, the parity bits are recalculated. The decimal
value of the parity bits determines the position of an error.

Noiseless Channel Protocol Introduction :


A protocol is a set of rules used by two devices to communicate. These sets of
rules are usually decided by headers (fixed headers determined by the protocol).
These headers specify the content of the message and the way this message is
processed. To detect the error, the header must be the address of the destination,
the address of the source, the checksum of the message.
Categorization of protocol :
The exploration of protocols is split into those that can be applied for
noiseless(error-free) channels and those that can be used for noisy(error-causing)
channels. The first category of protocols cannot be used in actual life, but they
serve as a basis for protocols for noise channels.

Noiseless Channel :
An idealistic channel in which no frames are lost, corrupted or duplicated. The
protocol does not implement error control in this category. There are two
protocols for the noiseless channel as follows.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 22


Simplest Protocol –
We consider here that the receiver can maintain any frame received with
insignificant processing time. The receiver‟s data link layer immediately
removes the header from the frame and assigns the data packet to its network
layer, which can also accept the packet immediately. That is to say, the
receiver can never be overwhelmed with forthcoming frames.
 Design :
The data link layer at the sender site gets data from its network layer,
makes a frame out of the data, and sends it. The data link layer(receiver
site) receives a frame from its physical layer, extracts data from the frame,
and convey the data to its network layer. The data link layers of the sender
and receiver provide communication/transmission services for their
network layers. The data link layers utilization the services provided by
their physical layers for the physical transmission of bits.
Design of Simplest Protocol with no error control or flow
 Sender-site and Receivers algorithms : Sender-
site algorithm –

}
 Flow Diagram :
This Flow Diagram shows an example of communication using the
simplest protocol. It is very straightforward. The sender sends a series of
frames without further consideration about the receiver. Let‟s take an
example, three frames will send from the sender, and three frames
received by receivers. Bear in mind the data frames are shown by tilted
boxes; the height of the box defines the transmission time difference
between the first bit and the last bit in the frame.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 23


A Simplex Stop-and-Wait Protocol for a Noisy Channel Simplex Stop – and
– Wait protocol for noisy channel is data link layer protocol for data
communications with error control and flow control mechanisms. It is popularly
known as Stop – and – Wait Automatic Repeat Request (Stop – and –Wait
ARQ) protocol. It adds error control facilities to Stop – and – Wait protocol.
This protocol takes into account the facts that the receiver has a finite processing
speed and that frames may get corrupted while transmission. If data frames arrive
at the receiver‟s end at a rate which is greater than its rate of processing, frames
can be dropped out. Also, frames may get corrupted or entirely lost whenthey are
transmitted via network channels. So, the receiver sends an acknowledgment for
each valid frame that it receives. The sender sends the next frame only when it has
received a positive acknowledgment from the receiver that it is available for further
data processing. Otherwise, it waits for a certain amount of time and then resends
the frame.
Design
 Sender Site − At the sender site, a field is added to the frame to hold a
sequence number. If data is available, the data link layer makes a frame with
the certain sequence number and sends it. The sender then waits for arrival of
acknowledgment for a certain amount of time. If it receives a positive
acknowledgment for the frame with that sequence number within the stipulated
time, it sends the frame with next sequence number. Otherwise, it resends
the same frame.
 Receiver Site − The receiver also keeps a sequence number of the frames
expected for arrival. When a frame arrives, the receiver processes it and
checks whether it is valid or not. If it is valid and its sequence number
matches the sequence number of the expected frame, it extracts the data and
delivers it to the network layer. It then sends an acknowledgement for that
frame back to the sender along with its sequence number.

What is Sliding Window Protocol?


Sliding windows are a method of sending multiple frames at once. It manages
data packets between the two devices, ensuring delivery of data frames reliably
and gradually. It‟s also found in TCP (Transmission Control Protocol).
Each frame is sent from the sequence number in this technique. The sequence
numbers find use in the receiving end to locate missing data. The sequence
number finds use in the sliding window technique in order to avoid duplicate
Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 24
data.
Working Principle of Sliding Window:
The sender‟s buffer is the sending window, and the receiver‟s buffer is the
receiving window in these protocols.Assignment of sequence numbers to frames
is between the range 0 to 2n-1 if the frames‟ sequence number is an n-bit field.
As a result, the sending window has a size of 2n-1. As a result, we choose an n-
bit sequence number to accommodate a sending window size of 2n-1.
Modulo-n is used to number the sequence numbers. If the sending window size
is set as 3, the sequence numbers will be 0, 1, 2, 0, 1, 2, 0, 1, 2 and so on.
The receiving window‟s size refers to the maximum number of frames the
receiver can accept at one time. It establishes the maximum number of frames
a sender can send before receiving an acknowledgement.
Sliding Window (Sender and Receiver side):
a. Sender Side:
The sequence number of the frame occupies a field in the frame. So, the
sequence number should be kept to a minimum.
The sequence number ranges from 0 to 2k-1 if the frame header allows k bits.
The sender maintains a list of sequence numbers that are only allowed to be sent
by the sender.
The sender window can only be 2k-1 in size.
For example, if the frame allows 4 bits, the window‟s size is 2 raised to the
power 4 -1 16-1=15.
The sender has a buffer with the same size as the window.
b. Receiver Side:
On the receiver side, the size of the window is always 1.
The receiver acknowledges a frame by sending an ACK frame to the sender,
along with the sequence number of the next expected frame.
The receiver declares explicitly that it is ready to receive N subsequent frames,
starting with the specified number.
We use this scheme in order to acknowledge multiple frames. The receiver‟s
window can hold 2,3,4 frames, but the ACK frame will be held until frame 4
arrives. It will send the
ACK along with sequence number 5 after the arrival, with which the
acknowledgment of 2,3,4 will be done one at a time.
The receiver requires a buffer size of one. Types of
Sliding Window Protocols:
1. Go-Back-N ARQ:
The Go-Back-N Automatic Repeat Request protocol is also known as the Go-
Back-N ARQ protocol. A sliding window method finds use in this data link
layer protocol. In the event of corruption or loss of frames, all subsequent
frames must be sent again.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 25


In this protocol, the sender window size is N. The size of the receiver window is
always one.
In the event of transmission of a corrupted frame, the receiver cancels it. The
receiver does not accept a corrupted frame. The sender sends the correct
frame again when the timer expires. Example of Go-Back-N ARQ:
a. First, the sender sends the first four frames in the window (here the

window size is 4).

b. Then, the receiver sends the acknowledgment for the 0th frame

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 26


The receiver then slides the window over and sends the next frame in the
queue.

d. Accordingly, the receiver sends the acknowledgement for the 1st frame, and
upon receiving that, the sender slides the window again and sends the next
frame. This process keeps on happening until all the frames are sent
successfully.
2. Selective Repeat ARQ:
Selective Repeat ARQ (Selective Repeat Automatic Repeat Request) is
another name for Selective Repeat ARQ. A sliding window method is used in
this data link layer protocol. If the frame has fewer errors, Go-Back-N ARQ
works well. However, if the frame contains a lot of errors, sending the frames
again will result in a lot of bandwidth loss. As a result, we employ the
Selective Repeat ARQ method. The size of the sender window is always equal
to the size of the receiver window in this protocol. The sliding window‟s size
is always greater than 1.
Example of Selective Repeat ARQ:

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 27


a. First, the sender sends the contents of the first window, which are frames 0
and 1 (because the window size is 2).
b. When the receiver receives the frames sent above, it sends an
acknowledgment for frame 2 (because frame 2 is the frame it expects to receive
next).
c. The sender then sends frames 2 and 3, however, frame 2 is lost on the way.
The receiver thus sends back a “NAK” signal or a
non-acknowledgment to let the sender know that frame 2 has been lost, and thus
the sender retransmits frame 2.
Difference between Go-Back-N ARQ vs Selective Repeat ARQ:
Go-Back-N ARQ Selective Repeat ARQ
All subsequent frames must be
sent again if a frame is Only the frame that has been
corrupted or lost. corrupted or lost is sent again.

It wastes a lot of bandwidth if


it has a high error rate. There is less bandwidth loss.

It‟s more difficult because it requires


It‟s less complicated. sorting and searching. It also
necessitates

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 28


more storage.
Sorting is done in this step to ensure
It does not necessitate any that the frames are in the correct
sorting. order.

It does not necessitate any It is where the search is


searching. carried out.

Because it is more complicated,


This is being used more it is used less frequently.
frequently.

Advantages of Sliding Window Protocols:


It is possible to send multiple packets without receiving an
acknowledgment.
2. Piggybacking with full-duplex lines is possible.
Disadvantages of Sliding Window Protocol:
1. This protocol does not impose any restrictions on sequence numbers.
2. In some cases, there may be a waste of bandwidth. Summary
In this article, we looked at the concept of Sliding Window protocols, and also
explored the two types of sliding window protocols: Go-Back-N ARQ and
Selective Repeat ARQ. We covered the detailed working of each of the two types
and also looked at the difference between the 2 protocols.

Difference Between Go-Back-N and Selective Repeat Protocol Both Go-Back-


N Protocol and Selective Repeat Protocol are the types of sliding window
protocols. The main difference between these two protocols is that after finding
the suspect or damage in sent frames go-back-n protocol re-transmits all the
frames whereas selective repeat protocol re-transmits only that frame which is
damaged. Now, we shall see the difference between them:
S.NO Go-Back-N Protocol Selective Repeat Protocol
1. In Go-Back-N Protocol, if the In selective Repeat protocol, only
sent frame are find suspected those frames are re- transmitted
then all the frames are re- which are found suspected.
transmitted
from the lost packet to the last
packet transmitted.

2. Sender window size of Go- Sender window size of selective


Back-N Protocol is N. Repeat protocol is
also N.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 29


3. Receiver window size of Go- Receiver window size of selective
Back-N Protocol is 1. Repeat protocol is
N.
4. Go-Back-N Protocol is less Selective Repeat protocol is
complex. more complex.
5. In Go-Back-N Protocol, In selective Repeat protocol, receiver
neither sender nor at side needs sorting to
receiver need sorting. sort the frames.
6. In Go-Back-N Protocol, type of In selective Repeat protocol, type
Acknowledgement is of Acknowledgement is
cumulative. individual.
7. In Go-Back-N Protocol, Out- of- In selective Repeat protocol, Out-
Order packets are NOT Accepted of-Order packets are Accepted.
(discarded) and
the entire window is re-
transmitted.
8. In Go-Back-N Protocol, if In selective Repeat protocol, if
Receives a corrupt packet, then Receives a corrupt packet, it
also, the entire window is re- immediately sends a negative
transmitted. acknowledgement and hence only
the selective
packet is retransmitted.

9. Efficiency of Go-Back-N Protocol is Efficiency of selective Repeat


N/(1+2*a) protocol is also
N/(1+2*a)

High-level Data Link Control (HDLC


High-level Data Link Control (HDLC) is a group of communication protocols of
the data link layer for transmitting data between network points or nodes. Since
it is a data link protocol, data is organized into frames. A frame is transmitted via
the network to the destination that verifies its successful arrival. It is a bit -
oriented protocol that is applicable for both point - to - point and multipoint
communications.
Transfer Modes
HDLC supports two types of transfer modes, normal response mode and
asynchronous balanced mode.
 Normal Response Mode (NRM) − Here, two types of stations are
there, a primary station that send commands and secondary station that
can respond to received commands. It is used for both point - to -
point and multipoint communications.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 30


 Asynchronous Balanced Mode (ABM) − Here, the configuration is
balanced, i.e. each station can both send commands and respond to
commands. It is used for only point - to - point communications.

HDLC Frame
HDLC is a bit - oriented protocol where each frame contains up to six fields.
The structure varies according to the type of frame. The fields of a HDLC
frame are −
 Flag − It is an 8-bit sequence that marks the beginning and the end of
the frame. The bit pattern of the flag is 01111110.
 Address − It contains the address of the receiver. If the frame is sent by
the primary station, it contains the address(es) of the secondary
station(s). If it is sent by the secondary station, it contains the address
of the primary station. The address field may be from 1 byte to
several bytes.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 31


 Control − It is 1 or 2 bytes containing flow and error control information.
 Payload − This carries the data from the network layer. Its length may
vary from one network to another.
 FCS − It is a 2 byte or 4 bytes frame check sequence for error
detection. The standard code used is CRC (cyclic redundancy code)

Types of HDLC Frames


There are three types of HDLC frames. The type of frame is determined by the
control field of the frame −
 I-frame − I-frames or Information frames carry user data from the
network layer. They also include flow and error control information that
is piggybacked on user data. The first bit of control field of I-frame is
0.
 S-frame − S-frames or Supervisory frames do not contain information
field. They are used for flow and error control when piggybacking is
not required. The first two bits of control field of S-frame is 10.
 U-frame − U-frames or Un-numbered frames are used for myriad
miscellaneous functions, like link management. It may contain an
information field, if required. The first two bits of control field of U-
frame is 11.

Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page 32


Dr A V N CHANDRA SEKHAR, PROFESSOR, IT, SITE Page
33

You might also like