Datalink
Datalink
I. Introduction
The data link layer transforms the physical layer, a raw transmission facility, to a link
responsible fornode-to-node (hop-to-hop) communication. Specific responsibilities of the
data link layer include framing, addressing, flow control, error control, and media access
control.
The network layer wants to be able to send packets to its neighbors without worrying about the
details of getting it there in one piece.
2. Framing
Group the physical layer bit stream into units called frames. Frames are nothing more than "packets"
or "messages". By convention, we use the term "frames" when discussing DLL.
3. Error Control
Sender checksums the frame and transmits checksum together with data. Receiver re-computes the
checksum and compares it with the received value.
4. Flow Control
Types of Errors
Error Detection
Errors in the received frames are detected by means of
(i)Parity Check and
(ii)Cyclic Redundancy Check (CRC).
In both cases, few extra bits are sent along with actual data to confirm that bits received at other end are
same as they were sent. If the counter-check at receiver’ end fails, the bits are considered corrupted.
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 erroneous, then it is very hard for the receiver to detect the error.
(ii) Cyclic Redundancy Check (CRC)
CRC is a different approach to detect if the received frame contains valid data. This technique
involves binary division of the data bits being sent. The divisor is generated using polynomials. The
sender performs a division operation on the bits being sent and calculates the remainder. Before
sending the actual bits, the sender adds the remainder at the end of the actual bits. Actual data bits
plus the remainder is called a codeword. The sender transmits data bits as code words.
At the other end, the receiver performs division operation on code words using the same CRC divisor.
If the remainder contains all zeros the data bits are accepted, otherwise it is considered as there some
data corruption occurred in transit.
Error Correction
Stop – and – wait Automatic Repeat Request (Stop – and – Wait ARQ) is a variation of the above protocol
with added error control mechanisms, appropriate for noisy channels. The sender keeps a copy of the sent
frame. It then waits for a finite time to receive a positive acknowledgement from receiver. If the timer
expires or a negative acknowledgement is received, the frame is retransmitted. If a positive
acknowledgement is received then the next frame is sent.
Go – Back – N ARQ
Go – Back – N ARQ provides for sending multiple frames before receiving the acknowledgementfor
the first frame. It uses the concept of sliding window, and so is also called sliding window protocol.
The frames are sequentially numbered and a finite number of frames are sent. If the acknowledgement
of a frame is not received within the time period, all frames starting from that frame are retransmitted.
Sliding window protocols are data link layer protocols for reliable and sequential delivery of data
frames. The sliding window is also used in Transmission Control Protocol.
In this protocol, multiple frames can be sent by a sender at a time before receiving an
acknowledgment from the receiver. The term sliding window refers to the imaginary boxes to hold
frames. Sliding window method is also known as windowing.
Working Principle
In these protocols, the sender has a buffer called the sending window and the receiver has buffer
called the receiving window.
The size of the sending window determines the sequence number of the outbound frames. If the
sequence number of the frames is an n-bit field, then the range of sequence numbers that can be
assigned is 0 to 2𝑛−1. Consequently, the size of the sending window is 2𝑛−1. Thus in order to
accommodate a sending window size of 2𝑛−1, a n-bit sequence number is chosen.
The size of the receiving window is the maximum number of frames that the receiver can accept at a
time. It determines the maximum number of frames that the sender can send before receiving
acknowledgment.
Example
Suppose that we have sender window and receiver window each of size 4. So the sequence
numbering of both the windows will be 0,1,2,3,0,1,2 and so on. The following diagram shows the
positions of the windows after sending the frames and receiving acknowledgments.
Types of Sliding Window Protocols
The Sliding Window ARQ (Automatic Repeat reQuest) protocols are of two categories –
• Go – Back – N ARQ
Go – Back – N ARQ provides for sending multiple frames before receiving the
acknowledgment for the first frame. It uses the concept of sliding window, and
so is also called sliding window protocol. The frames are sequentially
numbered and a finite number of frames are sent. If the acknowledgmentof a
frame is not received within the time period, all frames starting from that frame
are retransmitted.
This protocol also provides for sending multiple frames before receiving the
acknowledgment forthe first frame. However, here only the erroneous or lost
frames are retransmitted, while the good frames are received and buffered.