Data Link Layer
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.
Error Detection
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.
Types Of Errors
o Single-Bit Error
o Burst Error
Single-Bit Error:
The only one bit of a given data unit is changed from 1 to 0 or from 0 to 1.
In the above figure, the message which is sent is corrupted as single-bit, i.e.,
0 bit is changed to 1.
Single-Bit Error does not appear more likely in Serial Data Transmission.
For example, Sender sends the data at 10 Mbps, this means that the bit lasts
only for 1 ?s and for a single-bit error to occurred, a noise must be more than
1 ?s.
The Burst Error is determined from the first corrupted bit to the last
corrupted bit.
The duration of noise in Burst Error is more than the duration of noise in
Single-Bit.
The number of affected bits depends on the duration of the noise and data
rate.
o 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.
o This technique cannot be used to detect the 4-bit errors or more in some
cases.
Checksum
A Checksum is an error detection technique based on the concept of
redundancy.
Checksum Generator
Suppose L is the total sum of the data segments, then the checksum would
be ?L
1. The Sender follows the given steps:
2. The block unit is divided into k sections, and each of n bits.
3. All the k sections are added together by using one's complement to get the sum.
4. The sum is complemented and it becomes the checksum field.
5. The original data and checksum field are sent across the network.
Checksum Checker
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.
CRC Generator
o 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.
o Now, the string becomes 11100000, and the resultant string is divided by the
divisor 1001.
o The remainder generated from the binary division is known as CRC
remainder. The generated value of the CRC remainder is 111.
o 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
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.
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.
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,.....2 k-1.
o At the receiving end, the parity bits are recalculated. The decimal value of
the parity bits determines the position of an error.
1. The position of r1 = 1
2. The position of r2 = 2
3. The position of r4 = 4
We observe from the above figure that the bit positions that includes 1 in the
first position are 1, 3, 5, 7. Now, we perform the even-parity check at these
bit positions. The total number of 1 at these bit positions corresponding to r1
is even, therefore, the value of the r1 bit is 0.
Determining r2 bit
The r2 bit is calculated by performing a parity check on the bit positions
whose binary representation includes 1 in the second position.
We observe from the above figure that the bit positions that includes 1 in the
second position are 2, 3, 6, 7. Now, we perform the even-parity check at
these bit positions. The total number of 1 at these bit positions
corresponding to r2 is odd, therefore, the value of the r2 bit is 1.
Determining r4 bit
The r4 bit is calculated by performing a parity check on the bit positions
whose binary representation includes 1 in the third position.
We observe from the above figure that the bit positions that includes 1 in the
third position are 4, 5, 6, 7. Now, we perform the even-parity check at these
bit positions. The total number of 1 at these bit positions corresponding to r4
is even, therefore, the value of the r4 bit is 0.
R1 bit
The bit positions of the r1 bit are 1,3,5,7
R2 bit
The bit positions of r2 bit are 2,3,6,7.
We observe from the above figure that the binary representation of r2 is
1001. Now, we perform the even-parity check, the total number of 1s
appearing in the r2 bit is an even number. Therefore, the value of r2 is 0.
R4 bit
The bit positions of r4 bit are 4,5,6,7.
o The binary representation of redundant bits, i.e., r4r2r1 is 100, and its
corresponding decimal value is 4. Therefore, the error occurs in a 4 th bit
position. The bit value must be changed from 1 to 0 to correct the error.
Data Link Controls
Data Link Control is the service provided by the Data Link Layer to provide
reliable data transfer over the physical medium. For example, In the half-
duplex transmission mode, one device can only transmit the data at a time.
If both the devices at the end of the links transmit the data simultaneously,
they will collide and leads to the loss of the information. The Data link layer
provides the coordination among the devices so that no collision occurs.
o Line discipline
o Flow Control
o Error Control
Line Discipline
o Line Discipline is a functionality of the Data link layer that provides the
coordination among the link systems. It determines which device can send,
and when it can send the data.
o ENQ/ACK
o Poll/select
END/ACK
END/ACK stands for Enquiry/Acknowledgement is used when there is no
wrong receiver available on the link and having a dedicated path between
the two devices so that the device capable of receiving the transmission is
the intended one.
END/ACK coordinates which device will start the transmission and whether
the recipient is ready or not.
Working of END/ACK
The transmitter transmits the frame called an Enquiry (ENQ) asking whether
the receiver is available to receive the data or not.
o If the response to the ENQ is positive, the sender will transmit its data, and
once all of its data has been transmitted, the device finishes its transmission
with an EOT (END-of-Transmission) frame.
o If the response to the ENQ is negative, then the sender disconnects and
restarts the transmission at another time.
o If the response is neither negative nor positive, the sender assumes that the
ENQ frame was lost during the transmission and makes three attempts to
establish a link before giving up.
Poll/Select
The Poll/Select method of line discipline works with those topologies where
one device is designated as a primary station, and other devices are
secondary stations.
Working of Poll/Select
o In this, the primary device and multiple secondary devices consist of a single
transmission line, and all the exchanges are made through the primary
device even though the destination is a secondary device.
o The primary device has control over the communication link, and the
secondary device follows the instructions of the primary device.
o The primary device determines which device is allowed to use the
communication channel. Therefore, we can say that it is an initiator of the
session.
o If the primary device wants to receive the data from the secondary device, it
asks the secondary device that they anything to send, this process is known
as polling.
o If the primary device wants to send some data to the secondary device, then
it tells the target secondary to get ready to receive the data, this process is
known as selecting.
Select
o The select mode is used when the primary device has something to send.
o When the primary device wants to send some data, then it alerts the
secondary device for the upcoming transmission by transmitting a Select
(SEL) frame, one field of the frame includes the address of the intended
secondary device.
o When the secondary device receives the SEL frame, it sends an
acknowledgement that indicates the secondary ready status.
o If the secondary device is ready to accept the data, then the primary device
sends two or more data frames to the intended secondary device. Once the
data has been transmitted, the secondary sends an acknowledgement
specifies that the data has been received.
Poll
o The Poll mode is used when the primary device wants to receive some data
from the secondary device.
o When a primary device wants to receive the data, then it asks each device
whether it has anything to send.
o Firstly, the primary asks (poll) the first secondary device, if it responds with
the NACK (Negative Acknowledgement) means that it has nothing to send.
Now, it approaches the second secondary device, it responds with the ACK
means that it has the data to send. The secondary device can send more
than one frame one after another or sometimes it may be required to send
ACK before sending each one, depending on the type of the protocol being
used.
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.
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 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
Disadvantage of Stop-and-wait
Sliding Window
Sender Window
o 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 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).
Channelization Protocols
In this tutorial, we will be covering the Channelization protocols of Multiple
access in detail.
With the help of this technique, the available bandwidth is divided into
frequency bands. Each station is allocated a band in order to send its data.
Or in other words, we can say that each band is reserved for a specific
station and it belongs to the station all the time.
Advantages of FDMA
Given below are some of the benefits of using the FDMA technique:
Disadvantages of FDMA
By using FDMA, the maximum flow rate per channel is fixed and small.
2. Time-Division Multiple Access
With the help of this technique, the stations share the bandwidth of the
channel in time.
A time slot is allocated to each station during which it can send the
data.
When using the TDMA technique then each station needs to know the
beginning of its slot and the location of its slot.
If the stations are spread over a large area, then there occur
propagation delays; in order to compensate this guard, times are used.
The data link layer in each station mainly tells its physical layer to use
the allocated time slot.
CDMA technique differs from the FDMA because only one channel
occupies the entire bandwidth of the link.
The CDMA technique differs from the TDMA because all the stations
can send data simultaneously as there is no timesharing.
In the CDMA technique, there is only one channel that carries all the
transmission simultaneously.
CDMA is mainly based upon the coding theory; where each station is
assigned a code, Code is a sequence of numbers called chips.
The data from the different stations can be transmitted simultaneously but
using different code languages.
Advantages of CDMA
Given below are some of the advantages of using the CDMA technique:
The capacity of the system is higher than the TDMA and FDMA.
Error Control
Error Control is a technique of error detection and retransmission.
This technique works on the principle that the sender will not transmit the
next frame until it receives the acknowledgement of the last transmitted
frame.
o The sending device keeps a copy of the last transmitted frame until the
acknowledgement is received. Keeping the copy allows the sender to
retransmit the data if the frame is not received correctly.
o Both the data frames and the ACK frames are numbered alternately 0 and 1
so that they can be identified individually. Suppose data 1 frame
acknowledges the data 0 frame means that the data 0 frame has been
arrived correctly and expects to receive data 1 frame.
o If an error occurs in the last transmitted frame, then the receiver sends the
NAK frame which is not numbered. On receiving the NAK frame, sender
retransmits the data.
o It works with the timer. If the acknowledgement is not received within the
allotted time, then the sender assumes that the frame is lost during the
transmission, so it will retransmit the frame.
o In this case, the sender keeps the copies of all the transmitted frames until
they have been acknowledged. Suppose the frames from 0 through 4 have
been transmitted, and the last acknowledgement was for frame 2, the sender
has to keep the copies of frames 3 and 4 until they receive correctly.
o The receiver can send either NAK or ACK depending on the conditions. The
NAK frame tells the sender that the data have been received damaged. Since
the sliding window is a continuous trans mission mechanism, both ACK and
NAK must be numbered for the identification of a frame. The ACK frame
consists of a number that represents the next frame which the receiver
expects to receive. The NAK frame consists of a number that represents the
damaged frame.
o The sliding window ARQ is equipped with the timer to handle the lost
acknowledgements. Suppose then n-1 frames have been sent before
receiving any acknowledgement. The sender waits for the acknowledgement,
so it starts the timer and waits before sending any more. If the allotted time
runs out, the sender retransmits one or all the frames depending upon the
protocol used.
o Damaged Frame: When the frame is damaged, then the receiver sends a
NAK frame.
In the above figure, three frames have been transmitted before an error
discovered in the third frame. In this case, ACK 2 has been returned telling
that the frames 0,1 have been received successfully without any error. The
receiver discovers the error in data 2 frame, so it returns the NAK 2 frame.
The frame 3 is also discarded as it is transmitted after the damaged frame.
Therefore, the sender retransmits the frames 2,3.
o Lost Data Frame: In Sliding window protocols, data frames are sent
sequentially. If any of the frames is lost, then the next frame arrive at the
receiver is out of sequence. The receiver checks the sequence number of
each of the frame, discovers the frame that has been skipped, and returns
the NAK for the missing frame. The sending device retransmits the frame
indicated by NAK as well as the frames transmitted after the lost frame.
o Lost Acknowledgement: The sender can send as many frames as the
windows allow before waiting for any acknowledgement. Once the limit of the
window is reached, the sender has no more frames to send; it must wait for
the acknowledgement. If the acknowledgement is lost, then the sender could
wait forever. To avoid such situation, the sender is equipped with the timer
that starts counting whenever the window capacity is reached. If the
acknowledgement has not been received within the time limit, then the
sender retransmits the frame since the last ACK.
Selective-Reject ARQ
Data link layer protocols are divided into two categories based on whether the
transmission channel is noiseless or noisy.
The data link layer protocol is diagrammatically represented below −
Noiseless Channels
There are two noiseless channels which are as follows −
Simplex channel
Stop & wait channel
Let us consider an ideal channel where no frames are lost, duplicated, or corrupted. We
introduce two protocols for this type of channel. These two protocols are as follows −
Protocol that does not use flow control.
Protocol that uses the flow control.
Now let us consider the Protocols that do not use flow control −
Simplest Protocol
Step 1 − Simplest protocol that does not have flow or error control.
Step 2 − It is a unidirectional protocol where data frames are traveling in one direction
that is from the sender to receiver.
Step 3 − Let us assume that the receiver can handle any frame it receives with a
processing time that is small enough to be negligible, the data link layer of the receiver
immediately removes the header from the frame and hands the data packet to its
network layer, which can also accept the packet immediately.
Stop-and-Wait Protocol
Step 1 − If the data frames that arrive at the receiver side are faster than they can be
processed, the frames must be stored until their use.
Step 2 − Generally, the receiver does not have enough storage space, especially if it is
receiving data from many sources. This may result in either discarding of frames or
denial of service.
Step 3 − To prevent the receiver from becoming overwhelmed with frames, the sender
must slow down. There must be ACK from the receiver to the sender.
Step 4 − In this protocol the sender sends one frame, stops until it receives
confirmation from the receiver, and then sends the next frame.
Step 5 − We still have unidirectional communication for data frames, but auxiliary ACK
frames travel from the other direction. We add flow control to the previous protocol.
Noisy Channels
There are three types of requests for the noisy channels, which are as follows −
Go-Back-N ARQ
To improve the transmission efficiency, we need more than one frame to be
outstanding to keep the channel busy while the sender is waiting for acknowledgement.
There are two protocols developed for achieving this goal and they are as follows −
Example
For m = 2, the range of sequence numbers is: 0 to 3, i.e.
0,1,2,3, 0,1,2,3,…
The Go-Back-N ARQ is shown below in diagram format −
Example
Given below is an example problem on noiseless and noisy channel
Problem − Consider a binary signal sent over 4 KHZ wide channel, find out the
maximum data rate for noiseless and a noisy channel whose signal to noise ratio is
20dB.
Solution
Maximum Data Rate for noiseless = 2 * Bandwidth * log2(2)
=> 2 * 4khz * log2(2)
= 2*4000
= 8000 bps
Maximum Data Rate for noisy = Channel Capacity * log2(1 + SNR)
= 4000 * log2(1 + 20)
= 4000 * 4.39 = 17569.269 bps
High-level Data Link Control (HDLC)
Computer EngineeringComputer NetworkMCA
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.
Following are the types of multiple access protocol that is subdivided into the
different process as:
A. Random Access Protocol
In this protocol, all the station has the equal priority to send the data over a
channel. In random access protocol, one or more stations cannot depend on
another station nor any station control another station. Depending on the
channel's state (idle or busy), each station transmits the data frame.
However, if more than one station sends the data over a channel, there may
be a collision or data conflict. Due to the collision, the data frame packets
may be lost or changed. And hence, it does not receive by the receiver end.
o Aloha
o CSMA
o CSMA/CD
o CSMA/CA
It is designed for wireless LAN (Local Area Network) but can also be used in a
shared medium to transmit data. Using this method, any station can transmit
data across a network simultaneously when a data frameset is available for
transmission.
Aloha Rules
Pure Aloha
Slotted Aloha
1-Persistent: In the 1-Persistent mode of CSMA that defines each node, first
sense the shared channel and if the channel is idle, it immediately sends the
data. Else it must wait and keep track of the status of the channel to be idle
and broadcast the frame unconditionally as soon as the channel is idle.
CSMA/ CD
It is a carrier sense multiple access/ collision detection network
protocol to transmit data frames. The CSMA/CD protocol works with a
medium access control layer. Therefore, it first senses the shared channel
before broadcasting the frames, and if the channel is idle, it transmits a
frame to check whether the transmission was successful. If the frame is
successfully received, the station sends another frame. If any collision is
detected in the CSMA/CD, the station sends a jam/ stop signal to the shared
channel to terminate data transmission. After that, it waits for a random time
before sending a frame to a channel.
CSMA/ CA
Following are the methods used in the CSMA/ CA to avoid the collision:
Interframe space: In this method, the station waits for the channel to
become idle, and if it gets the channel is idle, it does not immediately send
the data. Instead of this, it waits for some time, and this time period is called
the Interframe space or IFS. However, the IFS time is often used to define
the priority of the station.
C. Channelization Protocols
It is a channelization protocol that allows the total usable bandwidth in a
shared channel to be shared across multiple stations based on their time,
distance and codes. It can access all the stations at the same time to send
the data frames to the channel.
Following are the various methods to access the channel based on their
time, distance and codes:
FDMA
CDMA
IEEE 802.11 standard, popularly known as WiFi, lays down the architecture and
specifications of wireless LANs (WLANs). WiFi or WLAN uses high frequency radio
waves instead of cables for connecting the devices in LAN. Users connected by
WLANs can move around within the area of network coverage.
The 802.11 MAC sublayer provides an abstraction of the physical layer to the logical
link control sublayer and upper layers of the OSI network. It is responsible for
encapsulating frames and describing frame formats.
When a frame is ready, the transmitting station checks whether the channel is idle or
busy.
If the channel is busy, the station waits until the channel becomes idle.
If the channel is idle, the station waits for an Inter-frame gap (IFG) amount of time and
then sends the frame.
After sending the frame, it sets a timer.
The station then waits for acknowledgement from the receiver. If it receives the
acknowledgement before expiry of timer, it marks a successful transmission.
Otherwise, it waits for a back-off time period and restarts the algorithm.
Co-ordination Functions in 802.11 MAC Sublayer
IEEE 802.11 MAC Sublayer uses two co-ordination functions for collision avoidance
before transmission −