Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 31

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:

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.

Next T 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

Errors can be classified into two categories:

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.

Single-Bit Error mainly occurs in Parallel Data Transmission. For example, if eight wires are used to
send the eight bits of a byte, if one of the wire is noisy, then single-bit is corrupted per byte.

Burst Error:

The two or more 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.

The duration of noise in Burst Error is more than the duration of noise in Single-Bit.

Burst Errors are most likely to occurr in Serial Data Transmission.

The number of affected bits depends on the duration of the noise and data rate.

Error Detecting Techniques:


The most popular Error Detecting Techniques are:

o Single parity check


o Two-dimensional parity check
o Checksum
o Cyclic redundancy check

Single Parity Check


o Single Parity checking is the simple mechanism and inexpensive to detect the errors.
o In this technique, a redundant bit is also known as a parity bit which is appended at the end of
the data unit so that the number of 1s becomes even. Therefore, the total number of
transmitted bits would be 9 bits.
o If the number of 1s bits is odd, then parity bit 1 is appended and if the number of 1s bits is
even, then parity bit 0 is appended at the end of the data unit.
o At the receiving end, the parity bit is calculated from the received data bits and compared
with the received parity bit.
o This technique generates the total number of 1s even, so it is known as even-parity checking.

Drawbacks Of Single Parity Checking

o It can only detect single-bit errors which are very rare.


o If two bits are interchanged, then it cannot detect the errors.
Two-Dimensional Parity Check
o Performance can be improved by using Two-Dimensional Parity Check which organizes the
data in the form of a table.
o Parity check bits are computed for each row, which is equivalent to the single-parity check.
o 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.
o At the receiving end, the parity bits are compared with the parity bits computed from the
received data.

Drawbacks Of 2D Parity Check

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.

It is divided into two parts:

Checksum Generator

A Checksum is generated at the sending side. Checksum generator subdivides the data into equal
segments of n bits each, and all these segments are added together by using one's complement
arithmetic. The sum is complemented and appended to the original data, known as checksum field.
The extended data is transmitted across the network.

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

A Checksum is verified at the receiving side. The receiver subdivides the incoming data into equal
segments of n bits each, and all these segments are added together, and then this sum is
complemented. If the complement of the sum is zero, then the data is accepted otherwise data is
rejected.

1. The Receiver 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 algorithm to get the sum.
4. The sum is complemented.
5. If the result of the sum is zero, then the data is accepted otherwise the data is discarded.

Example
Suppose that the sender wants to send 4 frames each of 8 bits, where the frames are 11001100,
10101010, 11110000 and 11000011.
The sender adds the bits using 1s complement arithmetic. While adding two numbers using 1s
complement arithmetic, if there is a carry over, it is added to the sum.
After adding all the 4 frames, the sender complements the sum to get the checksum, 11010011, and
sends it along with the data frames.
The receiver performs 1s complement arithmetic sum of all the frames including the checksum. The
result is complemented and found to be 0. Hence, the receiver assumes that no error has occurred.

Cyclic Redundancy Check (CRC)

CRC is a redundancy error technique used to determine the error.

Following are the steps used in CRC for error detection:

o 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.
o 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.
o Thirdly, the CRC remainder replaces the appended 0s at the end of the original data. This
newly generated unit is sent to the receiver.
o 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.
Let's understand this concept through an example:

Suppose the original data is 11100 and divisor is 1001.

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

o The functionality of the CRC checker is similar to the CRC generator.


o When the string 11100111 is received at the receiving end, then CRC checker performs the
modulo-2 division.
o A string is divided by the same divisor, i.e., 1001.
o In this case, CRC checker generates the remainder of zero. Therefore, the data is accepted.
Example-

Consider the CRC generator is x7 + x6 + x4 + x3 + x + 1.

Thus, for the given CRC generator, the corresponding binary pattern is 11011011.

Properties Of CRC Generator-


The algebraic polynomial chosen as a CRC generator should have at least the following properties-

Rule-01:

 It should not be divisible by x.


 This condition guarantees that all the burst errors of length equal to the length of polynomial are
detected.

Rule-02:

 It should be divisible by x+1.


 This condition guarantees that all the burst errors affecting an odd number of bits are detected.

Important Notes-

If the CRC generator is chosen according to the above rules, then-

 CRC can detect all single-bit errors


 CRC can detect all double-bit errors provided the divisor contains at least three logic 1’s.
 CRC can detect any odd number of errors provided the divisor is a factor of x+1.
 CRC can detect all burst error of length less than the degree of the polynomial.
 CRC can detect most of the larger burst errors with a high probability.

Steps Involved-

Error detection using CRC technique involves the following steps-

Step-01: Calculation Of CRC At Sender Side-

At sender side,

 A string of n 0’s is appended to the data unit to be transmitted.


 Here, n is one less than the number of bits in CRC generator.
 Binary division is performed of the resultant string with the CRC generator.
 After division, the remainder so obtained is called as CRC.
 It may be noted that CRC also consists of n bits.

Step-02: Appending CRC To Data Unit-

At sender side,

 The CRC is obtained after the binary division.


 The string of n 0’s appended to the data unit earlier is replaced by the CRC remainder.
Step-03: Transmission To Receiver-

 The newly formed code word (Original data + CRC) is transmitted to the receiver.

Step-04: Checking at Receiver Side-

At receiver side,

 The transmitted code word is received.


 The received code word is divided with the same CRC generator.
 On division, the remainder so obtained is checked.

The following two cases are possible-

Case-01: Remainder = 0

If the remainder is zero,

 Receiver assumes that no error occurred in the data during the transmission.
 Receiver accepts the data.

Case-02: Remainder ≠ 0

If the remainder is non-zero,

 Receiver assumes that some error occurred in the data during the transmission.
 Receiver rejects the data and asks the sender for retransmission.

Also Read- Parity Check

PRACTICE PROBLEMS BASED ON CYCLIC REDUNDANCY CHECK


(CRC)-

Problem-01:

A bit stream 1101011011 is transmitted using the standard CRC method. The generator polynomial is
x4+x+1. What is the actual bit string transmitted?

Solution-

 The generator polynomial G(x) = x4 + x + 1 is encoded as 10011.


 Clearly, the generator polynomial consists of 5 bits.
 So, a string of 4 zeroes is appended to the bit stream to be transmitted.
 The resulting bit stream is 11010110110000.

Now, the binary division is performed as-


From here, CRC = 1110.
Now,

 The code word to be transmitted is obtained by replacing the last 4 zeroes of 11010110110000 with the
CRC.
 Thus, the code word transmitted to the receiver = 11010110111110.

Problem-02:

A bit stream 10011101 is transmitted using the standard CRC method. The generator polynomial is x 3+1.
1. What is the actual bit string transmitted?
2. Suppose the third bit from the left is inverted during transmission. How will receiver detect this error?

Solution-
Part-01:

 The generator polynomial G(x) = x3 + 1 is encoded as 1001.


 Clearly, the generator polynomial consists of 4 bits.
 So, a string of 3 zeroes is appended to the bit stream to be transmitted.
 The resulting bit stream is 10011101000.
Now, the binary division is performed as-
From here, CRC = 100.
Now,

 The code word to be transmitted is obtained by replacing the last 3 zeroes of 10011101000 with the
CRC.
 Thus, the code word transmitted to the receiver = 10011101100.

Part-02:

According to the question,

 Third bit from the left gets inverted during transmission.


 So, the bit stream received by the receiver = 10111101100.

Now,

 Receiver receives the bit stream = 10111101100.


 Receiver performs the binary division with the same generator polynomial as-
From here,

 The remainder obtained on division is a non-zero value.


 This indicates to the receiver that an error occurred in the data during the transmission.
 Therefore, receiver rejects the data and asks the sender for retransmission.

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

Simplest Protocol is a protocol that neither has flow control nor has error control( as we
have already told you that it lies under the category of Noiseless channels).

 The simplest protocol is basically a unidirectional protocol in which data frames


only travel in one direction; from the sender to the receiver.

 In this, the receiver can immediately handle the frame it receives whose processing
time is small enough to be considered as negligible.

 Basically, the data link layer of the receiver immediately removes the header from the
frame and then hand over the data packet to the network layer that also accepts the
data packet immediately.
 We can also say that in the case of this protocol the receiver never gets overwhelmed
with the incoming frames from the sender.

Design of the Simplest Protocol

The flow control is not needed by the Simplest Protocol. The data link layer at the sender side
mainly gets the data from the network layer and then makes the frame out of data and sends
it. On the Receiver site, the data link layer receives the frame from the physical layer and
then extracts the data from the frame, and then delivers the data to its network layer.

The Datalink layers of both sender and receiver mainly provide transmission services for
their Network layers. The data link layer also uses the services provided by the physical layer
such as signaling, multiplexing, etc for the physical transmission of the bits.

The procedure used by the data link layer

Let us now take a look at the procedure used by the data link layer at both sides(sender as
well as the receiver).

 There is no frame send by the data link layer of the sender site until its network layer
has a data packet to send.

 Similarly, the receiver site cannot deliver a data packet to its network layer until a
frame arrives.
 In case if the implementation of the protocol is done as a procedure then there is a
need to introduce the idea of events in the protocol.

 The procedure at the sender site runs constantly; there is no action until there is a
request from the network layer.

 Also, the procedure at the receiver site runs constantly; there is no action until there is
a notification from the physical layer.

 Both the procedure runs continuously because either of them doesn't know when the
corresponding events will occur.

 Flow Diagram for Simplest Protocol

 Using the simplest protocol the sender A sends a sequence of frames without even
thinking about receiver B.

Stop-and-Wait Protocol
As the name suggests, when we use this protocol during transmission, then the sender
sends one frame, and then stops until it receives the confirmation from the receiver, after
receiving the confirmation sender sends the next frame.

 There is unidirectional communication for the data frames, but the acknowledgment
or ACK frames travel from the other direction. Thus the flow control is added here.

 Thus the stop-and-wait is one of the flow control protocol which makes the use of
flow control service provided by the data link layer.

 For every sent frame, the acknowledgment is needed and it takes the same amount of
time for propagation in order to get back to the sender.
 In order to end up the transmission, the sender transmits an end of transmission that
means(EOT frame).

Design of the Stop-and-Wait protocol

Data link layer at the sender side waits for its network layer in order to send the data
packet. After that data link checks that it can send the frame or not. In case of receiving a
positive notification from the physical layer; the data link layer makes the frame out of
the data provided by the network layer and then sends it to the physical layer. After
sending the data it will then wait for the acknowledgment before sending the next frame.

The data link layer on the receiver side waits for the frame to arrive. When the frame
arrives then the receiver processes the frame and then delivers it to the network layer.
After that, it will send the acknowledgment or we can say that ACK frame back to the
sender.
Advantages

One of the main advantages of the stop-and-wait protocol is the accuracy provided. As
the transmission of the next frame is only done after receiving the acknowledgment of the
previous frame. Thus there is no chance for data loss.

Disadvantages

Given below are some of the drawbacks of using the stop-and-wait Protocol:

 Using this protocol only one frame can be transmitted at a time.

 Suppose in a case, the frame is sent by the sender but it gets lost during the
transmission and then the receiver can neither get it nor can send an acknowledgment
back to the sender. Upon not receiving the acknowledgment the sender will not send
the next frame. Thus there will occur two situations and these are: The receiver has to
wait for an infinite amount of time for the data and the sender has to wait for an
infinite amount of time in order to send the next frame.

 In the case of the transmission over a long distance, this is not suitable because the
propagation delay becomes much longer than the transmission delay.

 In case the sender sends the data and this data has also been received by the receiver.
After receiving the data the receiver then sends the acknowledgment but due to some
reasons, this acknowledgment is received by the sender after the timeout period. Now
as this acknowledgment is received too late; thus it can be wrongly considered as the
acknowledgment of another data packet.

 The time spent waiting for the acknowledgment for each frame also adds up in the
total transmission time.

Go-Back-N Automatic Repeat request


Go-Back-N ARQ is mainly a specific instance of Automatic Repeat Request (ARQ)
protocol where the sending process continues to send a number of frames as specified by
the window size even without receiving an acknowledgement(ACK) packet from the
receiver.

The sender keeps a copy of each frame until the arrival of acknowledgement.

This protocol is a practical approach to the sliding window.

 In Go-Back-N ARQ, the size of the sender is N and the size of the receiver window is
always 1.

 This protocol makes the use of cumulative acknowledgements means here the
receiver maintains an acknowledgement timer; whenever the receiver receives a new
frame from the sender then it starts a new acknowledgement timer. When the timer
expires then the receiver sends the cumulative acknowledgement for all the frames
that are unacknowledged by the receiver at that moment.

 It is important to note that the new acknowledgement timer only starts after the
receiving of a new frame, it does not start after the expiry of the old
acknowledgement timer.

 If the receiver receives a corrupted frame, then it silently discards that corrupted
frame and the correct frame is retransmitted by the sender after the timeout timer
expires. Thus receiver silently discards the corrupted frame. By discarding silently we
mean that: “Simply rejecting the frame and not taking any action for the frame".

 In case after the expiry of the acknowledgement timer, suppose there is only one
frame that is left to be acknowledged. In that case, the receiver sends the independent
acknowledgement for that frame.

 In case if the receiver receives the out of order frame then it simply discards all the
frames.

 In case if the sender does not receive any acknowledgement then the entire window of
the frame will be retransmitted in that case.

 Using the Go-Back-N ARQ protocol leads to the retransmission of the lost frames
after the expiry of the timeout timer.
The Need of Go-Back-N ARQ

This protocol is used to send more than one frame at a time. With the help of Go-Back-N
ARQ, there is a reduction in the waiting time of the sender.

With the help of the Go-Back-N ARQ protocol the efficiency in the transmission
increases.

Send (sliding) window for Go-Back-N ARQ

Basically, the range which is in the concern of the sender is known as the send sliding
window for the Go-Back-N ARQ. It is an imaginary box that covers the sequence
numbers of the data frame which can be in transit.

The size of this imaginary box is 2m-1 having three variables Sf( which indicates send
window, the first outstanding frame), Sn(indicates the send window, the next frame to be
sent), SSize.(indicates the send window, size).

 The sender can transmit N frames before receiving the ACK frame.

 The size of the send sliding window is N.

 The copy of sent data is maintained in the sent buffer of the sender until all the sent
packets are acknowledged.

 If the timeout timer runs out then the sender will resend all the packets.

 Once the data get acknowledged by the receiver then that particular data will be
removed from the buffer.

Whenever a valid acknowledgement arrives then the send window can slide one or more
slots.
Sender Window Size

As we have already told you the Sender window size is N.The value of N must be greater
than 1.

In case if the value of N is equal to 1 then this protocol becomes a stop-and-wait protocol.

Receive (sliding) window for Go-Back-N ARQ

The range that is in the concern of the receiver is called the receiver sliding window.

 The receive window is mainly an abstract concept of defining an imaginary box


whose size is 1and has a single variable Rn.

 The window slides when a correct frame arrives, the sliding occurs one slot at a time.

 The receiver always looks for a specific frame to arrive in the specific order.

 Any frame that arrives out of order at the receiver side will be discarded and thus need
to be resent by the sender.

 If a frame arrives at the receiver safely and in a particular order then the receiver send
ACK back to the sender.

 The silence of the receiver causes the timer of the unacknowledged frame to expire.
Design of Go-Back-N ARQ

With the help of Go-Back-N ARQ, multiple frames can be transit in the forward direction
and multiple acknowledgements can transit in the reverse direction. The idea of this
protocol is similar to the Stop-and-wait ARQ but there is a difference and it is the window
of Go-Back-N ARQ allows us to have multiple frames in the transition as there are many
slots in the send window.
Window size for Go-Back-N ARQ
In the Go-Back-N ARQ, the size of the send window must be always less than 2m and the
size of the receiver window is always 1.

Flow Diagram
Advantages

Given below are some of the benefits of using the Go-Back-N ARQ protocol:

 The efficiency of this protocol is more.

 The waiting time is pretty much low in this protocol.


 With the help of this protocol, the timer can be set for many frames.

 Also, the sender can send many frames at a time.

 Only one ACK frame can acknowledge more than one frame.

Disadvantages

Given below are some drawbacks:

 Timeout timer runs at the receiver side only.

 The transmitter needs to store the last N packets.

 The retransmission of many error-free packets follows an erroneous packet.

 Selective Repeat ARQ


 Selective Repeat ARQ is also known as the Selective Repeat Automatic Repeat
Request. It is a data link layer protocol that uses a sliding window method. The Go-
back-N ARQ protocol works well if it has fewer errors. But if there is a lot of error in
the frame, lots of bandwidth loss in sending the frames again. So, we use the Selective
Repeat ARQ protocol. In this protocol, the size of the sender window is always equal
to the size of the receiver window. The size of the sliding window is always greater
than 1.

 If the receiver receives a corrupt frame, it does not directly discard it. It sends a
negative acknowledgment to the sender. The sender sends that frame again as soon as
on the receiving negative acknowledgment. There is no waiting for any time-out to
send that frame. The design of the Selective Repeat ARQ protocol is shown below.

 The example of the Selective Repeat ARQ protocol is shown below in the figure.

 Difference between the Go-Back-N ARQ and Selective


Repeat ARQ?

Go-Back-N ARQ Selective Repeat ARQ

If a frame is corrupted or lost in it,all In this, only the frame is sent again, which is corrupted
subsequent frames have to be sent again. or lost.

If it has a high error rate,it wastes a lot of There is a loss of low bandwidth.
bandwidth.

It is less complex. It is more complex because it has to do sorting and


searching as well. And it also requires more storage.

It does not require sorting. In this, sorting is done to get the frames in the correct
order.

It does not require searching. The search operation is performed in it.

It is used more. It is used less because it is more complex.


Common Data Link Protocols

 Synchronous Data Link Protocol (SDLC) − SDLC was developed by IBM in the
1970s as part of Systems Network Architecture. It was used to connect remote devices
to mainframe computers. It ascertained that data units arrive correctly and with right
flow from one network point to the next.

 High Level Data Link Protocol (HDLC) − HDLC is based upon SDLC and
provides both unreliable service and reliable service. It is a bit – oriented protocol that
is applicable for both point – to – point and multipoint communications.

 Serial Line Interface Protocol (SLIP) − This is a simple protocol for transmitting
data units between an Internet service provider (ISP) and home user over a dial-up
link. It does not provide error detection / correction facilities.

 Point - to - Point Protocol (PPP) − This is used to transmit multiprotocol data


between two directly connected (point-to-point) computers. It is a byte – oriented
protocol that is widely used in broadband communications having heavy loads and
high speeds.

 Link Control Protocol (LCP) − It one of PPP protocols that is responsible for
establishing, configuring, testing, maintaining and terminating links for transmission.
It also imparts negotiation for set up of options and use of features by the two
endpoints of the links.

 Network Control Protocol (NCP) − These protocols are used for negotiating the
parameters and facilities for the network layer. For every higher-layer protocol
supported by PPP, one NCP is there.

You might also like