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

Chapter3(NEP)

The Data Link Layer, the second layer of the OSI model, ensures reliable data transmission by framing data, adding addresses, and implementing error detection and correction mechanisms. It consists of two sub-layers: Logical Link Control (LLC) for data flow control and Media Access Control (MAC) for managing device interactions. Protocols like Stop-and-Wait, Go-Back-N, and Selective Repeat are used for reliable communication, with techniques for error detection such as parity checks and cyclic redundancy checks.

Uploaded by

Shreya Kamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Chapter3(NEP)

The Data Link Layer, the second layer of the OSI model, ensures reliable data transmission by framing data, adding addresses, and implementing error detection and correction mechanisms. It consists of two sub-layers: Logical Link Control (LLC) for data flow control and Media Access Control (MAC) for managing device interactions. Protocols like Stop-and-Wait, Go-Back-N, and Selective Repeat are used for reliable communication, with techniques for error detection such as parity checks and cyclic redundancy checks.

Uploaded by

Shreya Kamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Unit-3 The Data Link Layer

DATALINK LAYER
The data link layer, or layer 2, is the second layer of the seven-layer OSI model reference model. This layer
describes the techniques to access a shared communication channel and to ensure reliable transmission of
data frame in computer communication environment
• The data link layer takes the data bits and “frames,” and creates packets of the data to
guarantee reliable transmission.
• This layer adds source and destination addresses to the data stream as well as information to
detect and control transmission errors.

Sub-layers of the Data Link Layer


The data link layer is further divided into two sub-layers, which are as follows:

• Logical Link Control (LLC)


LLC controls data flow among various applications and services, as well as provide
acknowledgement and error notification mechanisms.

• Media Access Control (MAC)


MAC sublayer manages the device’s interaction, responsible for addressing frames, and also
controls physical media access.

Functions / Design issues of Datalink layer


1. Services provided to the network layer:
It provides a well-defined and reliable service interface to the layer 3 or Network layer,
which is also contingent upon the efficiency and error rate of the underlying physical layer. The
data link layer accomplishes these activities in the following manner:
(a) Unacknowledged connectionless service.
(b) Acknowledged connectionless service.
(c) Acknowledged connection-oriented service.
2. Framing: Frames are the streams of bits received from the network layer into manageable data
units. This division of stream of bits is done by Data Link Layer.
3. Physical Addressing:The Data Link layer adds a header to the frame in order to define physical
address of the sender or receiver of the frame, if the frames are to be distributed to different
systems on the network.
4. 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. This
prevents traffic jam at the receiver side.

GFGC Tiptur Page 1


Unit-3 The Data Link Layer

5. Error Control:Error control is achieved by adding a trailer at the end of the frame. Duplication of
frames is also prevented by using this mechanism. Data Link Layers adds mechanism to prevent
duplication of frames.
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.
Error correction: Error correction is similar to the Error detection, except that receiving node not
only detects the errors but also determine where the errors have occurred in the frame.
6. Access Control:Protocols of this layer determine which of the devices has control over the link
at any given time, when two or more devices are connected to the same link.
7. 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.
8. 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.

A. Framing
How does Framing Work?
Framing works by breaking data into smaller, manageable units called frames. Each frame
consists of a header (containing control information) and a payload (the actual data). The sender
adds the header and sends the frame over the network. The receiver then extracts the header,
processes the data, and checks for errors to ensure proper delivery. This process allows for efficient
and reliable data transmission between devices.
Framing is essential for efficient data transfer because it allows for error detection and
recovery. By dividing the data into smaller frames, if any frame is lost or corrupted during
transmission, only that specific frame needs to be retransmitted rather than the entire data packet.
Additionally, the header information helps in error checking and ensuring that the data is delivered
accurately to the intended recipient. This process ensures reliable communication between devices
in a network.
Parts of a Frame

GFGC Tiptur Page 2


Unit-3 The Data Link Layer

• Frame Header A frame header contains the destination address, the source address and
control field. The conntrol field determines how to control the communications
process. There are three control fields namely, kind, seq, and ack serving the following
purposes:
o Kind: This field states whether the frame is a data frame or it is used for control
functions like error and flow control or link management etc.
o seq: This contains the sequence number of the frame for rearrangement of out – of –
sequence frames and sending acknowledgements by the receiver.
o ack: This contains the acknowledgement number of some frame, particularly when
piggybacking is used.
• 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.
• Frame Check Sequence (FCS) - is generally used for identification of errors i.e., error
detection.

ELEMENTARY DATA LINK PROTOCOLS


Data link protocols can be broadly divided into two categories, depending on whether the
transmission channel is noiseless or noisy.

GFGC Tiptur Page 3


Unit-3 The Data Link Layer

• Simplest Protocol

It is very simple. The sender sends a sequence of frames without even thinking about the
receiver. Data are transmitted in one direction only. Both sender & receiver always ready. Processing
time can be ignored. Infinite buffer space is available. And best of all, the communication channel
between the data link layers never damages or loses frames. This thoroughly unrealistic protocol,
which we will nickname ‘‘Utopia,’’ .The utopia protocol is unrealistic because it does not handle
either flow control or error correction

• Stop-and-wait Protocol

It is still very simple. The sender sends one frame and waits for feedback from the receiver.
When the ACK arrives, the sender sends the next frame. It is Stop-and-Wait Protocol because the
sender sends one frame, stops until it receives confirmation from the receiver (okay to go ahead),
and then sends the next frame. We still have unidirectional communication for data frames, but
auxiliary ACK frames (simple tokens of acknowledgment) travel from the other direction. We add
flow control to our previous protocol.

NOISY CHANNELS
Although the Stop-and-Wait Protocol gives us an idea of how to add flow control to its
predecessor, noiseless channels are nonexistent. We can ignore the error (as we sometimes do), or

GFGC Tiptur Page 4


Unit-3 The Data Link Layer

we need to add error control to our protocols. We discuss three protocols in this section that use
error control.

Sliding Window Protocols


The sliding window is a technique for sending multiple frames at a time. It controls the data
packets between the two devices where reliable and gradual delivery of data frames is needed.
In this technique, each frame has sent from the sequence number. The sequence numbers
are used to find the missing data in the receiver end. The purpose of the sliding window technique is
to avoid duplicate data, so it uses the sequence number.

Types of Sliding Window Protocol


Sliding window protocol has three types:

1. Go-Back-N ARQ (Automatic Repeat Request)


2. Selective Repeat ARQ (Automatic Repeat Request)
3. Selective Repeat Automatic Repeat Request

1. Stop-and-Wait Automatic Repeat Request


To detect and correct corrupted frames, we need to add redundancy bits to our data frame.
When the frame arrives at the receiver site, it is checked and if it is corrupted, it is silently discarded.
The detection of errors in this protocol is manifested by the silence of the receiver.

Lost frames are more difficult to handle than corrupted ones. In our previous protocols, there
was no way to identify a frame. The received frame could be the correct one, or a duplicate, or a
frame out of order. The solution is to number the frames. When the receiver receives a data frame
that is out of order, this means that frames were either lost or duplicated

The lost frames need to be resent in this protocol. If the receiver does not respond when there
is an error, how can the sender know which frame to resend? To remedy this problem, the sender
keeps a copy of the sent frame. At the same time, it starts a timer. If the timer expires and there is
no ACK for the sent frame, the frame is resent, the copy is held, and the timer is restarted. Since the
protocol uses the stop-and-wait mechanism, there is only one specific frame that needs an ACK

Error correction in Stop-and-Wait ARQ is done by keeping a copy of the sent frame and
retransmitting of the frame when the timer expires

In Stop-and-Wait ARQ, we use sequence numbers to number the frames. The sequence numbers
are based on modulo-2 arithmetic.

In Stop-and-Wait ARQ, the acknowledgment number always announces in modulo-2 arithmetic


the sequence number of the next frame expected.

GFGC Tiptur Page 5


Unit-3 The Data Link Layer

2. Go-Back-N Automatic Repeat Request


In Go-Back-N ARQ, N is the sender's window size. Suppose we say that Go-Back-3, which
means that the three frames can be sent at a time before expecting the acknowledgment from the
receiver.
It uses the principle of protocol pipelining in which the multiple frames can be sent before
receiving the acknowledgment of the first frame. If we have five frames and the concept is Go-
Back-3, which means that the three frames can be sent, i.e., frame no 1; frame no 2, frame no 3
can be sent before expecting the acknowledgment of frame no 1.
In Go-Back-N ARQ, the frames are numbered sequentially as Go-Back-N ARQ sends the
multiple frames at a time that requires the numbering approach to distinguish the frame from
another frame, and these numbers are known as the sequential numbers.

Working of Go-Back-N ARQ


Suppose there are a sender and a receiver, and let's assume that there are 11 frames to be
sent. These frames are represented as 0,1,2,3,4,5,6,7,8,9,10, and these are the sequence numbers
of the frames. Mainly, the sequence number is decided by the sender's window size. But, for the

GFGC Tiptur Page 6


Unit-3 The Data Link Layer

better understanding, we took the running sequence numbers, i.e., 0,1,2,3,4,5,6,7,8,9,10. Let's
consider the window size as 4, which mean that the four frames can be sent at a time before
expecting the acknowledgment of the first frame.

Step 1: Firstly, the sender will send the first four frames to the receiver, i.e., 0,1,2,3, and now the sender
is expected to receive the acknowledgment of the 0th frame.

Step 2:Let's assume that the receiver has sent the acknowledgment for the 0 frame, and the receiver
has successfully received it.

Step 3:The sender will then send the next frame, i.e., 4, and the window slides containing four frames
(1,2,3,4).

GFGC Tiptur Page 7


Unit-3 The Data Link Layer

Step 4:The receiver will then send the acknowledgment for the frame no 1. After receiving the
acknowledgment, the sender will send the next frame, i.e., frame no 5, and the window will slide
having four frames (2,3,4,5).

Step 5:Now, let's assume that the receiver is not acknowledging the frame no 2, either the frame is
lost, or the acknowledgment is lost. Instead of sending the frame no 6, the sender Go-Back to 2,
which is the first frame of the current window, retransmits all the frames in the current window, i.e.,
2,3,4,5.

GFGC Tiptur Page 8


Unit-3 The Data Link Layer

3. Selective Repeat Automatic Repeat Request


The go-back-n protocol works well if errors are less, but if the line is poor it wastes a lot of
bandwidth on retransmitted frames. An alternative strategy, the selective repeat protocol, is to allow
the receiver to accept and buffer the frames following a damaged or lost one.

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.

B. Error Detection
Error
A condition when the receiver’s information does not matches with the sender’s information.
During transmission, digital signals suffer from noise that can introduce errors in the binary bits
travelling from sender to receiver. That means a 0 bit may change to 1 or a 1 bit may change to
0.

GFGC Tiptur Page 9


Unit-3 The Data Link Layer

Error Detecting Codes (Implemented either at Data link layer or Transport Layer of OSI Model)
Whenever a message is transmitted, it may get scrambled by noise or data may get corrupted.
To avoid this, we use error-detecting codes which are additional data added to a given digital
message to help us detect if any error has occurred during transmission of the message.
Basic approach used for error detection is the use of redundancy bits, where additional bits
are added to facilitate detection of errors. Some popular techniques for error detection are:
a. Simple Parity check
b. Two-dimensional Parity check
c. Checksum
d. Cyclic redundancy check
a. Simple Parity check
Blocks of data from the source are subjected to a check bit or parity bit generator form, where
a parity of : 1 is added to the block if it contains odd number of 1’s, and0 is added if it contains even
number of 1’s.

This scheme makes the total number of 1’s even, that is why it is called even parity checking.

b. Checksum

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

GFGC Tiptur Page 10


Unit-3 The Data Link Layer

c. Cyclic redundancy check (CRC)


• Unlike checksum scheme, which is based on addition, CRC is based on binary division.
• In CRC, a sequence of redundant bits, called cyclic redundancy check bits, are appended to
the end of data unit so that the resulting data unit becomes exactly divisible by a second,
predetermined binary number.
• At the destination, the incoming data unit is divided by the same number. If at this step there
is no remainder, the data unit is assumed to be correct and is therefore accepted.
• A remainder indicates that the data unit has been damaged in transit and therefore must be
rejected.

GFGC Tiptur Page 11


Unit-3 The Data Link Layer

C. 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:
Backward error correction:Once the error is discovered, the receiver requests the sender to
retransmit the entire data unit.
Forward error correction:In this case, the receiver uses the error-correctingcode which
automatically corrects the errors.A single additional bit can detect the error, but cannot correct it.

For correcting the errors, one has to know the exact position of the error. For example, If we
want to calculate a single-bit error, the error correction code will determine which one of seven bits
is in error. To achieve this, we have to add some additional redundant bits.
Suppose r is the number of redundant bits and d is the total number of the data bits. The
number of redundant bits r can be calculated by using the formula:
2r>=d+r+1
The value of r is calculated by using the above formula. For example, if the value of d is 4,
then the possible smallest value that satisfies the above relation would be 3.
To determine the position of the bit this is in error, a technique developed byR.W Hamming
is Hamming code which can be applied to any length of the data unit and uses the relationship
between data units and redundant units.

Hamming Code
Parity bits: The bit which is appended to the original data of binary bits so that the total number of
1s is even or odd.

Even parity:To check for even parity, if the total number of 1s is even, then thevalue 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 thevalue of parity bit is 1.
If the total number of 1s is odd, then the value of parity bit is 0.

Working of Hamming Code


To solve the data bit issue with the hamming code method, some steps need to be followed:

• Step 1 - The position of the data bits and the number of redundant bits in the original data.
The number of redundant bits is deduced from the expression [2^r >= d+r+1].
• Step 2 - Fill in the data bits and redundant bit, and find the parity bit value using the
expression [2^p, where, p - {0,1,2, …… n}].
• Step 3 - Fill the parity bit obtained in the original data and transmit the data to the receiver
side.
GFGC Tiptur Page 12
Unit-3 The Data Link Layer

• Step 4 - Check the received data using the parity bit and detect any error in the data, and in
case damage is present, use the parity bit value to correct the error.

Example for Hamming Code


The data bit to be transmitted is 1011010, to be solved using the hamming code method.

1. Determining the Number of Redundant Bits and Position in the Data,


The data bits = 7

The redundant bit,


• 2^r >= d+r+1
• 2^4 >= 7+4+1
• 16 >= 12, [So, the value of r = 4.]

Position of the redundant bit, applying the 2^p expression:


• 2^0 - P1
• 2^1 - P2
• 2^2 - P4
• 2^3 - P8

Applying the data bits in Fig. 1.

2. Finding the Parity Bits, for ”Even parity bits,”


a) P1 parity bit is deduced by checking all the bits with 1’s in the least significant location.
P1: 1, 3, 5, 7, 9, 11
• P1 - P1, 0, 1, 1, 1, 1
• P1 - 0
b) P2 parity bit is deduced by checking all the bits with 1’s in the second significant location.
P2: 2, 3, 6, 7, 10, 11
• P2 - P2, 0, 0, 1, 0, 1
• P2 - 0

GFGC Tiptur Page 13


Unit-3 The Data Link Layer

c) P4 parity bit is deduced by checking all the bits with 1’s in the third significant location.
P4: 4, 5, 6, 7
• P4 - P4, 1, 0, 1
• P4 - 0
d) P8 parity bit is deduced by checking all the bits with 1’s in the fourth significant location.
P8: 8, 9, 10, 11
• P8 – P8, 1, 0, 1
• P8 - 0

So, the original data to be transmitted to the receiver side is:

3. Error Detecting and Correction of the Data Received,


Assume that during transmission, the data bit at position 7 is changed from 1 to 0. Then
by applying the parity bit technique, we can identify the error:

Parity values obtained in the above deduction vary from the originally deduced parity values,
proving that an error occurred during data transmission.

To identify the position of the error bit, use the new parity values as,
• [0111]
• [0+2^2+2^1+2^0]

GFGC Tiptur Page 14


Unit-3 The Data Link Layer

• 7, i.e., same as the assumed error position.


To correct the error, simply reverse the error bit to its complement, i.e., for this case, change 0 to 1,
to obtain the original data bit.

D. Access Control
Access control mechanisms in the data link layer primarily address the issue of multiple
devices attempting to use a shared communication medium simultaneously. This is essential in
shared communication environments to avoid collisions and ensure efficient data transmission. Two
main access control methods in the data link layer are:

1. CSMA/CD (Carrier Sense Multiple Access with Collision Detection):


• Carrier Sense (CS): Before transmitting data, a device listens to the medium to check if it's
idle (no other transmission is ongoing). If the medium is busy, the device waits for a suitable
time to transmit.
• Multiple Access (MA): Multiple devices have access to the same communication medium.
• Collision Detection (CD): While transmitting, devices continue to listen to the medium. If a
collision is detected (i.e., two or more devices transmitting at the same time), they stop
transmitting, wait for a random backoff time, and then retry.
CSMA/CD is commonly used in Ethernet networks, especially in older implementations like
traditional Ethernet (10BASE5 and 10BASE2). However, with the prevalence of full-duplex
communication and switched Ethernet, CSMA/CD is not typically used in modern Ethernet networks.
2. CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance):
• Carrier Sense (CS): Similar to CSMA/CD, devices listen to the medium to determine if it's idle
before transmitting.
• Multiple Access (MA): Multiple devices contend for access to the medium.
• Collision Avoidance (CA): Instead of detecting collisions and then responding, CSMA/CA
attempts to avoid collisions by having devices follow specific rules for contention and
transmission. Devices may use techniques like waiting for random periods or using virtual
carrier sensing to determine if the medium is busy.
CSMA/CA is often used in wireless networks, such as Wi-Fi, where the physical characteristics of
the medium make collision detection challenging or impractical.

GFGC Tiptur Page 15

You might also like