Unit-Iii Data Link Layer
Unit-Iii Data Link Layer
Unit-Iii Data Link Layer
Link Layer: Types of errors –Error detection- VRC, LRC, CRC techniques - Data Forward
and backward error correction - Hamming code. Flow control: stop and wait- sliding window
protocol, Error control: Stop and wait ARQ- Go-Back-N ARQ- Selective Repeat ARQ
Protocols- Asynchronous and Synchronous Protocol - HDLC frames.
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.
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.
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.
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 detect the errors but also determine where the errors have
occurred in the frame.
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.
Synchronization
When data frames are sent on the link, both machines must be synchronized in
order to transfer to take place.
Three Types of addresses
Some link-layer protocols define three types of addresses: unicast, multicast, and broadcast.
Unicast Address
Each host or each interface of a router is assigned a unicast address. Unicasting
means one-to-one communication. A frame with a unicast address destination is
destined only for one entity in the link.
Multicast Address
Some link-layer protocols define multicast addresses. Multicasting means one-to-
many communication. However, the jurisdiction is local (inside the link).
Broadcast Address
Some link-layer protocols define a broadcast address. Broadcasting means one-to-all
communication. A frame with a destination broadcast address is sent to all entities in
the link.
TYPES OF ERRORS
Error
A condition when the receiver’s information does not match 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.
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.
EXAMPLE:
Suppose the original data is 11100 and divisor is 1001.
CRC Generator
A CRC generator uses a modulo-2 division. Firstly, three zeroes are appended at the
end of the data as the length of the divisor is 4 and we know that the length of the
string 0s to be appended is always one less than the length of the divisor.
Now, the string becomes 11100000, and the resultant string is divided by the divisor
1001.
The remainder generated from the binary division is known as CRC remainder. The
generated value of the CRC remainder is 111.
CRC remainder replaces the appended string of 0s at the end of the data unit, and
the final string would be 11100111 which is sent across the network.
CRC Checker
The functionality of the CRC checker is similar to the CRC generator.
When the string 11100111 is received at the receiving end, then CRC checker
performs the modulo-2 division.
A string is divided by the same divisor, i.e., 1001.
In this case, CRC checker generates the remainder of zero. Therefore, the data is
accepted.
One extra bit is sent along with the original bits to make number of 1s either even in
case of even parity, or odd in case of odd parity.
The sender while creating a frame counts the number of 1s in it.
For example, if even parity is used and number of 1s is even then one bit with value
0 is added.
This way number of 1s remains even.If the number of 1s is odd, to make it even a bit
with value 1 is added.
The receiver simply counts the number of 1s in a frame. If the count of 1s is even
and even parity is used, the frame is considered to be not-corrupted and is
accepted.
If the count of 1s is odd and odd parity is used, the frame is still not corrupted.
If a single bit flips in transit, the receiver can detect it by counting the number of 1s.
But when more than one bits are erro neous, then it is very hard for the receiver to
detect the error.
Drawbacks Of Single Parity Checking
It can only detect single-bit errors which are very rare.
If two bits are interchanged, then it cannot detect the errors.
Two-Dimensional Parity Check
Performance can be improved by using Two-Dimensional Parity Check which
organizes the data in the form of a table.
Parity check bits are computed for each row, which is equivalent to the single-parity
check.
In Two-Dimensional Parity check, a block of bits is divided into rows, and the
redundant row of bits is added to the whole block.
At the receiving end, the parity bits are compared with the parity bits computed
from the received data.
In this error detection method, a block of bits are organized in a table (of rows and
columns).
For example, instead of sending block of 32 bits, first it is organized into four rows
and eight columns.
Then parity bits for each column is calculated and new row of eight parity bits is
formed.
These eight parity bits are appended to original data before transmission.
FLOW CONTROL
Whenever an entity produces items and another entity consumes them, there
should be a balance between production and consumption rates.
If the items are produced faster than they can be consumed, the consumer can be
overwhelmed and may need to discard some items.
If the items are produced more slowly than they can be consumed, the consumer
must wait, and the system becomes less efficient.
Sender States The sender is initially in the ready state, but it can move between the ready
and blocking state.
Ready State.
When the sender is in this state, it is only waiting for a packet from the network layer.
If a packet comes from the network layer, the sender creates a frame, saves a copy of the
frame, starts the only timer and sends the frame.
The sender then moves to the blocking state.
Blocking State.
When the sender is in this state, three events can occur:
a. If a time-out occurs, the sender resends the saved copy of the frame and restarts the
timer.
b. If a corrupted ACK arrives, it is discarded.
c. If an error-free ACK arrives, the sender stops the timer and discards the saved copy of
the frame. It then moves to the ready state.
When an acknowledgment arrives, the sender moves LAR to the right, thereby
allowing the sender to transmit another frame.
Also, the sender associates a timer with each frame it transmits, and it retransmits
the frame should the timer expire before an ACK is received.
Notice that the sender has to be willing to buffer up to SWS frames since it must be
prepared to retransmit them until they are acknowledged.
The receiver maintains the following three variables:
The receive window size, denoted RWS, gives the upper bound on the number of
out-of-order frames that the receiver is willing to accept;
LAF denotes the sequence number of the largest acceptable frame; and LFR denotes
the sequence number of the last frame received.
The receiver also maintains the following invariant:
ERROR CONTROL
Error control in data link layer is the process of detecting and correcting data
frames that have been corrupted or lost during transmission.
Requirements for error control mechanism:
Error detection - The sender and receiver, either both or any, must ascertain that
there is some error in the transit.
Positive ACK - When the receiver receives a correct frame, it should acknowledge it.
Negative ACK - When the receiver receives a damaged frame or a duplicate frame,
it sends a NACK back to the sender and the sender must retransmit the correct
frame.
Retransmission: The sender maintains a clock and sets a timeout period. If an
acknowledgement of a data-frame previously transmitted does not arrive before the
timeout the sender retransmits the frame, thinking that the frame or it’s
acknowledgement is lost in transit.
Error Control Techniques:
Types of Sliding Window Protocols:
i) Stop-and-wait ARQ
The sending-window size enables the sender to send multiple frames without
receiving the acknowledgement of the previous ones.
The receiving-window enables the receiver to receive multiple frames and
acknowledge them.
The receiver keeps track of incoming frame’s sequence number.
When the sender sends all the frames in window, it checks up to what sequence
number it has received positive acknowledgement.
If all frames are positively acknowledged, the sender sends next set of frames.
If sender finds that it has received NACK or has not receive any ACK for a particular
frame, it retransmits all the frames after which it does not receive any positive ACK.
SYNCHRONOUS TRANSMISSION
In synchronous transmission, the bit stream is combined into longer “frames,” which
the name itself is indicating that synchronous transmission needs synchronization
between transmitter and receiver in order to allow communication between the
two.
Basically, despite having internal clock pulses, the transmitter and receiver share a
common clock pulse so as to have synchronization in communication.
This means data will be transmitted between the transmitter and receiver only after
a constant time interval.
It allows the transmission of data in the form of frames or blocks. Thus a huge data
amount can be transmitted between transmitter and receiver once the clock pulse is
sent.
HDLC FRAMES
High-level Data Link Control (HDLC) is a bit-oriented protocol for communication
over point-to-point and multipoint links.
It implements the Stop-and-Wait protocol.
Since it is a data link protocol, data is organized into frames.
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.
Asynchronous Balanced Mode (ABM) − Here, the configuration is balanced, i.e.
each station can both send commands and respond to commands. It is used for only
point - to - point communications.
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.
Address − It contains the address of the receiver. If the frame is sent by the primary
station, it contains the address(es) of the secondary station(s). If it is sent by the
secondary station, it contains the address of the primary station. The address field
may be from 1 byte to several bytes.
Control − It is 1 or 2 bytes containing flow and error control information.
Payload − This carries the data from the network layer. Its length may vary from one
network to another.
FCS − It is a 2 byte or 4 bytes frame check sequence for error detection. The standard
code used is CRC (cyclic redundancy code)
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-frame is 10.
U-frame − U-frames or Un-numbered frames are used for myriad 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.
ERROR CORRECTION
In the digital world, error correction can be done in two ways:
Backward Error Correction When the receiver detects an error in the data received,
it requests back the sender to retransmit the data unit.
Forward Error Correction When the receiver detects some error in the data
received, it executes error-correcting code, which helps it to auto-recover and to
correct some kinds of errors.
The first one, Backward Error Correction, is simple and can only be efficiently used
where retransmitting is not expensive.
For example, fiber optics. But in case of wireless transmission retransmitting may
cost too much.
In the latter case, Forward Error Correction is used. To correct the error in data
frame, the receiver must know exactly which bit in the frame is corrupted.
To locate the bit in error, redundant bits are used as parity bits for error detection.
For example, we take ASCII words (7 bits data), then there could be 8 kind of
information we need: first seven bits to tell us which bit is error and one more bit to
tell that there is no error.
For m data bits, r redundant bits are used. r bits can provide 2r combinations of
information.
In m+r bit codeword, there is possibility that the r bits themselves may get
corrupted. So the number of r bits used must inform about m+r bit locations plus
no-error information, i.e. m+r+1.
HAMMING CODE
Hamming code is a set of error-correction codes that can be used to detect and correct the
errors that can occur when the data is moved or stored from the sender to the receiver. It is
technique developed by R.W. Hamming for error correction.
Example:
Data = 10011010
No of parity bits to be added to data: >= m + r + 1 ……. (i)
where,
r = number of parity bits,
m = number of message bits
The parity bits are added at power of 2’s position. For example, position will be 1st ( ), 2nd
( ), 4th ( ), 8th ( ) …and so on.
Now, total bits that will be sent to the receiver will be the message bits + parity bits. So, final
bits will be 1 001 1010.
To find the parity bits, we start from position. we take ‘i’ bits and leave the next ‘i’ bits.
Then, again consider the next ‘i’ bits and continue the process till the last bit.
Finding parity bits at the Sender’s Side:
Final Data
Finding the parity bits on Receiver’s Side:
Now, assume the received code word is
Data Received by Receiver
The receiver will also find the parities using the same method.
Now, total bits that will be sent to the receiver will be the message bits + parity bits.
Error correction