0% found this document useful (0 votes)
9 views

Unit 2 - DLL-final

The document discusses the data link layer, which is the second layer of the OSI model. It provides framing, error control, flow control, and addressing between two directly connected hosts. The data link layer hides the details of the underlying hardware and represents itself to the network layer as the communication medium. It is responsible for converting data streams to signals for transmission and assembling received signals into recognizable frame formats.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Unit 2 - DLL-final

The document discusses the data link layer, which is the second layer of the OSI model. It provides framing, error control, flow control, and addressing between two directly connected hosts. The data link layer hides the details of the underlying hardware and represents itself to the network layer as the communication medium. It is responsible for converting data streams to signals for transmission and assembling received signals into recognizable frame formats.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Data Link Layer

PAWA N K U M A R

A S S I S TA N T P R O F E S S O R

G J U S & T, H I S A R

1
Introduction to Data Link layer (DLL)
Design Issues
Framing and Error Handling
Framing Protocols
Error Detection and Correction
Contents Flow Control Protocols
 Stop-and-wait
 Sliding Window Protocol
 Go-back-N
 Selective Repeat

2
Data Link Layer: It is second layer of OSI Layered Model.

Data link layer hides the details of underlying hardware and


represents itself to upper layer as the medium to communicate.

It works between two hosts which are directly connected in some


Introduction sense. The connection could be point to point or broadcast.

Data link layer is responsible for converting data stream from upper
layer to signals bit by bit and to send that over the underlying
hardware.

At the receiving end, Data link layer picks up data from hardware
which are in the form of electrical signals, assembles them in a
recognizable frame format, and hands over to upper layer.

3
Introduction
 It is one of the most complicated layers and has complex
functionalities and liabilities.
 Systems on broadcast network are said to be on same
link.
 The work of data link layer tends to get more complex
when it is dealing with multiple hosts on single collision
domain.
Data link layer has two sub-layers:
Logical Link Control: It deals with protocols, flow-control,
and error control
Media Access Control: It deals with actual control of media.
 Data Link Layer protocols are Ethernet, token ring, FDDI
and PPP. 4
DLL exists between the physical layer and the network layer.

It converts the raw transmission facility provided by the


physical layer to a reliable and error-free link.
Functions and
Design Issues Some of the function may not work properly of there are
some design issue in layer. Main functions and the design
of DLL issues of this layer are
• Providing services to the network layer
• Framing
• Error Control
• Flow Control
• Addressing
• Synchronization
• Multi-access

5
Functions and Design
Issues of DLL
 Providing services to the network layer: In the OSI
Model, each layer uses the services of the layer
below it and provides services to the layer above it.
 DLL uses the services offered by the physical layer.
 DLL act as a service interface to the network layer
 Primary service of DLL is transferring data from
network layer on sending machine to the network
layer on destination machine.
 Types of services provided can be of three types −
 Unacknowledged connectionless service
 Acknowledged connectionless service
 Acknowledged connection - oriented service
6
Functions
and Design
Issues of
DLL

7
Functions and Design
Issues of DLL
Framing: Data-link layer takes packets from
Network Layer and encapsulates them into Frames.
Then, it sends each frame bit-by-bit on the
hardware.
At receiver’ end, data link layer picks up signals
from hardware and assembles them into frames.
A frame has three parts, mainly −
 Frame Header
 Payload field that contains the data packet from network
layer
 Trailer
8
Addressing: Data-link layer provides layer-2 hardware
addressing mechanism. Hardware address is assumed to
be unique on the link. It is encoded into hardware at the
time of manufacturing.
Synchronization: When data frames are sent on the link,
both machines must be synchronized in order to transfer
to take place.
Functions and  Error Control: Sometimes signals may have
encountered problem in transition and the bits are
Design Issues flipped. These errors are detected and attempted to
of DLL recover actual data bits. It ensures error free link for
data transmission.
 The issues it deal with respect to error control are −
 Dealing with transmission errors
 Sending acknowledgement frames in reliable connections
 Retransmitting lost frames
 Identifying duplicate frames and deleting them
 Controlling access to shared channels in case of broadcasting
9
 It also provides error reporting mechanism to the sender.
 Flow Control: Stations on same link may have different
speed or capacity.
 DLL ensures flow control that enables both machine to
exchange data on same speed.
Functions and  The two common approaches for flow control are −
 Feedback based flow control
Design Issues  Rate based flow control
of DLL  Multi-Access: When host on the shared link tries to
transfer the data, it has a high probability of collision.
 Data link layer provides mechanism such as CSMA/CD
to equip capability of accessing a shared media among
multiple Systems.

10
DLL Framing
Data-link layer takes the packets from the Network Layer and
encapsulates them into frames.
If the frame size becomes too large, then the packet may be
divided into small sized frames.
Smaller sized frames makes flow control and error control more
efficient.
A frame has the following parts −
 Header − It contains the source and the destination addresses
of the frame.
 Payload field − It contains the message to be delivered.
 Trailer − It contains the error detection and error correction
bits.
 Flag − It marks the beginning and end of the frame.

11
 Framing can be of two types, fixed sized framing
and variable sized framing.
 Fixed-sized Framing: Here the size of the frame is
fixed and so the frame length acts as delimiter of
the frame.
 Consequently, it does not require additional
boundary bits to identify the start and end of the
DLL Framing frame.
 Example − ATM cells.
 Variable – Sized Framing: Here, the size of each
frame to be transmitted may be different.
So additional mechanisms are kept to mark the end
of one frame and the beginning of the next frame.
 It is used in local area networks. 12
§Two ways to define frame delimiters in variable sized
framing are −
§Length Field: Here, a length field is used that
determines the size of the frame.
§It is used in Ethernet (IEEE 802.3).
§End Delimiter: In this way, a pattern is used as a
delimiter to determine the size of frame.
DLL Framing
§It is used in Token Rings.
§If the pattern occurs in the message, then two
approaches are used to avoid the situation −
§ 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.
13
 When data is transmitted from one device to another
device, the system does not guarantee whether the data
received by the device is identical to the data
transmitted by another device. An Error is a situation
when the message received at the receiver end is not
identical to the message transmitted.
 DLL uses error control techniques to ensure that
Error Detection frames, i.e. bit streams of data, are transmitted from the
source to the destination with a certain extent of
and Correction accuracy.
 Errors can be of three types, namely single bit errors,
multiple bit errors, and burst errors.
 Single bit
 Multiple bits error
 Burst error
14
Error Detection and
Correction
§ Single bit: Only one bit of a given data
unit is changed from 1 to 0 or from 0 to 1.
§ Multiple bits error: In the received frame,
more than one bits are corrupted.
 Burst error: The two or more consecutive
bits are changed from 0 to 1 or from 1 to 0
is known as Burst Error.
The Burst Error is determined from the
first corrupted bit to the last corrupted bit.

15
In DLL, 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.
§Some of the error Detecting Techniques are as
follows:
Error Detection § Single parity check
and Correction § Two-dimensional parity check
§ Checksum
§ Cyclic redundancy check
Error Correction − Error correction involves
ascertaining the exact number of bits that has been
corrupted and the location of the corrupted bits.

16
Error Detection
Techniques – Parity Check
Single parity check: It is the simple mechanism and inexpensive to detect
the errors.
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.
At the receiving end, the parity bit is calculated from the received data
bits and compared with the received parity bit.
This technique generates the total number of 1s even, so it is known as
even-parity checking.
Even parity example

17
Error Detection Techniques –
Parity Check
Single bit parity Drawback:
It can only detect single-bit errors which are very rare.
If two bits are interchanged, then it cannot detect the errors.
Two-Dimensional Parity Check:
Performance can be improved by using Two-Dimensional Parity
Check which organizes the data in the form of a table.
Parity check bits are computed for each row, which is equivalent to
the single-parity check.
In Two-Dimensional Parity check, a block of bits is divided into rows,
and the redundant row of bits is added to the whole block.
At the receiving end, the parity bits are compared with the parity
bits computed from the received data.
18
Error Detection Techniques – Parity
Check
Two-Dimensional Parity Check Drawbacks:
If two bits in one data unit are corrupted and two bits exactly the same position
in another data unit are also corrupted, then 2D Parity checker will not be able to
detect the error.
This technique cannot be used to detect the 4-bit errors or more in some cases.

19
Error Detection Techniques - Checksum
 A Checksum is an error detection technique based on the concept of
redundancy.
 It follows the below steps for error detection:
 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.

20
Cyclic Redundancy Check (CRC)
CRC is a redundancy error detection technique used to determine the error.
Following are the steps used in CRC for error detection:
 In CRC technique, a string of n 0s is appended to the data unit, and this n number is
less than the number of bits in a predetermined number, known as division which is
n+1 bits.
 Secondly, the newly extended data is divided by a divisor using a process is known as
binary division. The remainder generated from this division is known as CRC
remainder.
 Thirdly, the CRC remainder replaces the appended 0s at the end of the original data.
This newly generated unit is sent to the receiver.

21
Cyclic Redundancy Check (CRC)
 The receiver receives the data followed by
the CRC remainder. The receiver will treat
this whole unit as a single unit, and it is
divided by the same divisor that was used
to find the CRC remainder.
 If the resultant of this division is zero
which means that it has no error, and the
data is accepted.
 If the resultant of this division is not zero
which means that the data consists of an
error. Therefore, the data is discarded.

22
Cyclic Redundancy Check (CRC)
Example: Suppose the original data is 11100 and divisor is
1001.
CRC Generator
A CRC generator uses a modulo-2 division. Firstly, three
zeroes are appended at the end of the data as the length of the
divisor is 4 and we know that the length of the string 0s to be
appended is always one less than the length of the divisor.
Now, the string becomes 11100000, and the resultant string is
divided by the divisor 1001.
The remainder generated from the binary division is known as
CRC remainder. The generated value of the CRC remainder is
111.
23
Cyclic Redundancy Check (CRC)
CRC remainder replaces the appended string of 0s at the
end of the data unit, and the final string would be
11100111 which is sent across the network.
CRC Checker
The functionality of the CRC checker is similar to the
CRC generator.
When the string 11100111 is received at the receiving end,
then CRC checker performs the modulo-2 division.
A string is divided by the same divisor, i.e., 1001.
In this case, CRC checker generates the remainder of zero.
Therefore, the data is accepted.

24
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.
25
Error Correction Techniques
 Four main error correction codes are
 Hamming Codes: It is a block code that is capable of detecting up to two
simultaneous bit errors and correcting single-bit errors.
 Binary Convolution Code: Here, an encoder processes an input sequence of bits of
arbitrary length and generates a sequence of output bits.
 Reed – Solomon Code: They are block codes that are capable of correcting burst
errors in the received data block.
 Low-Density Parity-Check Code: It is a block code specified by a parity-check
matrix containing a low density of 1s. They are suitable for large block sizes in very
noisy channels.

26
Flow Control in DLL
 Flow control is a technique that allows two stations working at different speeds to
communicate with each other.
 Flow control coordinates that amount of data that can be transferred before receiving
an acknowledgement.
 Flow control is one of the most important duty of DLL.
 It makes the sender wait for some sort of an acknowledgement (ACK) before sending
more data in continuous.
 Flow Control Approaches are as:
 Feedback Based flow control
 Rate Based Flow Control

27
Flow Control in DLL
 Feedback Based flow control- sender sends frames after it has received
acknowledgments from the user. This is used in the data link layer.
 Rate Based Flow Control- It 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.
 Data Link Layer uses feedback based flow control mechanism which mainly
uses the techniques as follows:
 Stop-and-wait
 Sliding Window

28
Flow Control in DLL
 Stop-and-wait: Sender sends a frame and
waits for acknowledgment.
 Once the receiver receives the frame, it
sends an acknowledgment frame back to
the sender.
 On receiving the acknowledgment
frame, the sender understands that the
receiver is ready to accept the next
frame. So it sender the next frame in
queue.

29
Flow Control in DLL
Sliding Window: These protocols 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.

30
Error control in DLL
 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).

31
Error control in DLL
 Phases in Error Control: Error control mechanism in data link layer involves the
following phases −
 Detection of Error − Sender and receiver, either both or any, must ascertain that there
is some error in the transit.
 Acknowledgment − Acknowledgment may be positive or negative.
 Positive ACK − On receiving a correct frame, the receiver sends a positive acknowledge.
 Negative ACK − On receiving a damaged frame or a duplicate frame, the receiver sends
a negative acknowledgment 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.

32
Error control in DLL
Error Control Techniques
There are three types of techniques available which Data-link layer may deploy
to control the errors by Automatic Repeat Requests (ARQ):
 Stop-and-wait ARQ
 Go-Back-N ARQ
 Selective Repeat ARQ

33
Error control in DLL
Stop-and-wait ARQ: It 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.

34
Error control in DLL
Go-Back-N ARQ: Stop and wait ARQ mechanism
does not utilize the resources at their best. When the
acknowledgement is not received, the sender sits
idle and does nothing.
In Go-Back-N ARQ method, both sender and
receiver maintain a window.
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.

35
Error control in DLL
 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.

36
Error control in DLL
Selective Repeat ARQ: In Go-back-N ARQ, it is
assumed that the receiver does not have any buffer
space for its window size and has to process each
frame as it comes.
This enforces the sender to retransmit all the
frames which are not acknowledged.
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.
37
Error control in DLL
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.

38
References
1. Forouzan, B. A., & Mosharraf, F. (2012). Computer networks: a top-down
approach, McGraw-Hill.
2. https://www.tutorialspoint.com/
3. https://www.slideshare.net/
4. https://www.gatevidyalay.com/
5. https://www.computernetworkingnotes.com/

39
Thank You!

40

You might also like