Unit 5 Data Link Layer
Unit 5 Data Link Layer
5.1 Introduction to Data Link Layer and its issues: When host on the shared link tries to transfer the data, it has a high
Introduction to Data Link Layer probability of collision. Data-link layer provides mechanism such as
Data Link Layer is second layer of OSI Layered Model. This layer is one of CSMA/CD to equip capability of accessing a shared media among multiple
the most complicated layers and has complex functionalities and liabilities. Data Systems.
link layer hides the details of underlying hardware and represents itself to upper Issues in Data link layer:
layer as the medium to communicate. The data link layer in the OSI (Open System Interconnections) Model, is in between
Data link layer works between two hosts which are directly connected in the physical layer and the network layer. This layer converts the raw transmission
some sense. This direct connection could be point to point or broadcast. Systems on facility provided by the physical layer to a reliable and error-free link.
broadcast network are said to be on same link. The work of data link layer tends to The main functions and the design issues of this layer are
get more complex when it is dealing with multiple hosts on single collision domain. Providing services to the network layer
Data link layer is responsible for converting data stream to signals bit by bit Framing
and to send that over the underlying hardware. At the receiving end, Data link layer Error Control
picks up data from hardware which are in the form of electrical signals, assembles Flow Control
them in a recognizable frame format, and hands over to upper layer. Services to the Network Layer
Data link layer has two sub-layers: In the OSI Model, each layer uses the services of the layer below it and provides
Logical Link Control: It deals with protocols, flow-control, and error services to the layer above it. The data link layer uses the services offered by the
control physical layer. The primary function of this layer is to provide a well-defined service
Media Access Control: It deals with actual control of media interface to network layer above it.
Functionality of Data-link Layer
Data link layer does many tasks on behalf of upper layer. These are:
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.
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 types of services provided can be of three types −
the time of manufacturing. Unacknowledged connectionless service
Synchronization Acknowledged connectionless service
When data frames are sent on the link, both machines must be synchronized Acknowledged connection - oriented service
in order to transfer to take place. Framing
Error Controll The data link layer encapsulates each data packet from the network layer into frames
Sometimes signals may have encountered problem in transition and the bits that are then transmitted.
are flipped. These errors are detected and attempted to recover actual data A frame has three parts, namely −
bits. It also provides error reporting mechanism to the sender. Frame Header
Flow Control Payload field that contains the data packet from network layer
Stations on same link may have different speed or capacity. Data-link layer Trailer
ensures flow control that enables both machine to exchange data on same
speed.
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:
Error Control
The data link layer ensures error free link for data transmission. The issues it caters
Stop and Wait
to with respect to error control are − This protocol involves the following transitions −
Dealing with transmission errors
The sender sends a frame and waits for acknowledgment.
Sending acknowledgement frames in reliable connections
Once the receiver receives the frame, it sends an acknowledgment frame
Retransmitting lost frames
back to the sender.
Identifying duplicate frames and deleting them
On receiving the acknowledgment frame, the sender understands that the
Controlling access to shared channels in case of broadcasting
receiver is ready to accept the next frame. So, its sender the next frame in
Flow Control queue.
The data link layer regulates flow control so that a fast sender does not drown a slow
Sliding Window
receiver. When the sender sends frames at very high speeds, a slow receiver may not
This protocol improves the efficiency of stop and wait protocol by allowing multiple
be able to handle it. There will be frame losses even if the transmission is error-free. frames to be transmitted before receiving an acknowledgment.
The two common approaches for flow control are − The working principle of this protocol can be described as follows –
Feedback based flow control
Both the sender and the receiver have finite sized buffers called windows.
Rate based flow control
The sender and the receiver agree upon the number of frames to be sent
5.2 Flow control at data link layer:
based upon the buffer size.
Flow control is a technique that allows two stations working at different speeds to
The sender sends multiple frames in a sequence, without waiting for
communicate with each other. It is a set of measures taken to regulate the amount of
acknowledgment. When its sending window is filled, it waits for
data that a sender sends so that a fast sender does not overwhelm a slow receiver. In
acknowledgment. On receiving acknowledgment, it advances the window
data link layer, flow control restricts the number of frames the sender can send
and transmits the next frames, according to the number of acknowledgments
before it waits for an acknowledgment from the receiver.
received.
Approaches of Flow Control
Flow control can be broadly classified into two categories − 5.3 Error control issues at 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
Feedback based Flow Control - In these protocols, the sender sends frames Request (ARQ).
after it has received acknowledgments from the user. This is used in the data Phases in Error Control
link layer. The error control mechanism in data link layer involves the following phases:
Detection of Error − Transmission error, if any, is detected by either the o If the sender has received positive acknowledgment for all the frames,
sender or the receiver. it sends next set of frames.
Acknowledgment − acknowledgment may be positive or negative. o If sender receives NACK or has not receive any ACK for a particular
o Positive ACK − On receiving a correct frame, the receiver sends a frame, it retransmits all the frames after which it does not receive any
positive acknowledge. positive ACK.
o Negative ACK − On receiving a damaged frame or a duplicate frame, Selective Repeat ARQ
the receiver sends a negative acknowledgment back to the sender. o Both the sender and the receiver have buffers called sending window
Retransmission − The sender maintains a clock and sets a timeout period. If and receiving window respectively.
an acknowledgment of a data-frame previously transmitted does not arrive o The sender sends multiple frames based upon the sending-window
before the timeout, or a negative acknowledgment is received, the sender size, without receiving the acknowledgment of the previous ones.
retransmits the frame. o The receiver also receives multiple frames within the receiving
Error Control Techniques window size.
There are three main techniques for error control: 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.
5.4 Data Link Layer Protocols:
Stop and Wait ARQ High Level Data Link Protocol (HDLC) − High-level Data Link Control
This protocol involves the following transitions: (HDLC) is a group of communication protocols of the data link layer for
o A timeout counter is maintained by the sender, which is started when transmitting data between network points or nodes. Since it is a data link
a frame is sent. protocol, data is organized into frames. A frame is transmitted via the
o If the sender receives acknowledgment of the sent frame within time, network to the destination that verifies its successful arrival. It is a bit -
the sender is confirmed about successful delivery of the frame. It then oriented protocol that is applicable for both point - to - point and multipoint
transmits the next frame in queue. communications.
o If the sender does not receive the acknowledgment within time, the Transfer Modes
sender assumes that either the frame or its acknowledgment is lost in HDLC supports two types of transfer modes, normal response mode and
transit. It then retransmits the frame. asynchronous balanced mode.
o If the sender receives a negative acknowledgment, the sender Normal Response Mode (NRM) − Here, two types of stations are there, a
retransmits the frame. primary station that send commands and secondary station that can respond
Go-Back-N ARQ to received commands. It is used for both point - to - point and multipoint
The working principle of this protocol is: communications.
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.
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-
Asynchronous Balanced Mode (ABM) − Here, the configuration is frame is 10.
balanced, i.e. each station can both send commands and respond to U-frame − U-frames or Un-numbered frames are used for myriad
commands. It is used for only point - to - point communications. 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.
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.
Point - to - Point Protocol (PPP) − Point - to - Point Protocol (PPP) is a
Address − It contains the address of the receiver. If the frame is sent
communication protocol of the data link layer that is used to transmit
by the primary station, it contains the address(es) of the secondary
multiprotocol data between two directly connected (point-to-point)
station(s). If it is sent by the secondary station, it contains the address
computers. It is a byte - oriented protocol that is widely used in broadband
of the primary station. The address field may be from 1 byte to
communications having heavy loads and high speeds. Since it is a data link
several bytes.
layer protocol, data is transmitted in frames. It is also known as RFC 1661.
Control − It is 1- or 2-bytes containing flow and error control
Services Provided by PPP
information.
The main services provided by Point - to - Point Protocol are −
Payload − This carries the data from the network layer. Its length
Defining the frame format of the data to be transmitted.
may vary from one network to another.
Defining the procedure of establishing link between two points and
FCS − It is a 2 byte or 4 bytes frame check sequence for error exchange of data.
detection. The standard code used is CRC (cyclic redundancy code) Stating the method of encapsulation of network layer data in the
frame.
Stating authentication rules of the communicating devices.
Providing address for network communication.
Providing connections over multiple links.
Supporting a variety of network layer protocols by providing a range Address − 1 byte which is set to 11111111 in case of broadcast.
OS services. Control − 1 byte set to a constant value of 11000000.
Components of PPP Protocol − 1 or 2 bytes that define the type of data contained in the
Point - to - Point Protocol is a layered protocol having three components − payload field.
Encapsulation Component − It encapsulates the datagram so that it Payload − This carries the data from the network layer. The
can be transmitted over the specified physical layer. maximum length of the payload field is 1500 bytes. However, this
Link Control Protocol (LCP) − It is responsible for establishing, may be negotiated between the endpoints of communication.
configuring, testing, maintaining and terminating links for FCS − It is a 2 byte or 4 bytes frame check sequence for error
transmission. It also imparts negotiation for set up of options and use detection. The standard code used is CRC (cyclic redundancy code)
of features by the two endpoints of the links.
Authentication Protocols (AP) − These protocols authenticate
endpoints for use of services. The two authentication protocols of
PPP are:
o Password Authentication Protocol (PAP)
o Challenge Handshake Authentication Protocol (CHAP)
Network Control Protocols (NCPs) − These protocols are used for Byte Stuffing in PPP Frame − Byte stuffing is used is PPP payload field
negotiating the parameters and facilities for the network layer. For whenever the flag sequence appears in the message, so that the receiver does
every higher-layer protocol supported by PPP, one NCP is there. not consider it as the end of the frame. The escape byte, 01111101, is stuffed
Some of the NCPs of PPP are: before every byte that contains the same byte as the flag byte or the escape
o Internet Protocol Control Protocol (IPCP) byte. The receiver on receiving the message removes the escape byte before
o OSI Network Layer Control Protocol (OSINLCP) passing it onto the network layer.
o Internetwork Packet Exchange Control Protocol (IPXCP)
o DEC net Phase IV Control Protocol (DNCP)
o NetBIOS Frames Control Protocol (NBFCP)
o IPv6 Control Protocol (IPV6CP)
PPP Frame
PPP is a byte - oriented protocol where each field of the frame is composed
of one or more bytes. The fields of a PPP frame are −
Flag − 1 byte that marks the beginning and the end of the frame. The
bit pattern of the flag is 01111110.