unit-2
unit-2
unit-2
2. Frame
Data-link layer takes the packets from the Network Layer and encapsulates them into frames.
If the frame size becomes too large, then the packet may be divided into small sized frames.
Smaller sized frames makes flow control and error control more efficient.
Then, it sends each frame bit-by-bit on the hardware. At receiver's end, data link layer picks up
signals from hardware and assembles them into frames.
Parts of a Frame
• Frame Header − It contains the source and the destination addresses of the frame.
• 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.
Types of Framing
Framing can be of two types, fixed sized framing and variable sized framing.
Fixed-sized Framing
Here the size of the frame is fixed and so the frame length acts as delimiter of the frame.
Consequently, it does not require additional boundary bits to identify the start and end of the
frame.
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.
In case of lost or corrupted frames, the receiver does not receive the correct data-frame and
sender is ignorant about the loss. Data link layer follows a technique to detect transit errors and
take necessary actions, which is retransmission of frames whenever error is detected or frame
is lost. The process is called Automatic Repeat Request (ARQ).
The error control mechanism in data link layer involves the following phases −
• Detection of Error − Transmission error, if any, is detected by either the sender or the
receiver.
• Acknowledgment − acknowledgment may be positive or negative.
o Positive ACK − On receiving a correct frame, the receiver sends a positive
acknowledge.
o Negative ACK − On receiving a damaged frame or a duplicate frame, the
receiver sends a negative acknowledgment back to the sender.
• Retransmission − The sender maintains a clock and sets a timeout period. If an
acknowledgment of a data-frame previously transmitted does not arrive before the
timeout, or a negative acknowledgment is received, the sender retransmits the frame.
Flow control
Flow control is a technique that allows two stations working at different speeds to communicate
with each other. It is a set of measures taken to regulate the amount of data that a sender sends
so that a fast sender does not overwhelm a slow receiver. In data link layer, flow control
restricts the number of frames the sender can send before it waits for an acknowledgment from
the receiver.
• Feedback based Flow Control In these protocols, the sender sends frames after it has
received acknowledgments from the user. This is used in the data link layer.
• Rate based Flow Control These protocols have built in mechanisms to restrict the rate
of transmission of data without requiring acknowledgment from the receiver. This is
used in the network layer and the transport layer.
Data link layer uses feedback-based flow control mechanisms. There are two main techniques
−
Stop and Wait
Sliding Window
This protocol improves the efficiency of stop and wait protocol by allowing multiple frames to
be transmitted before receiving an acknowledgment.
• Both the sender and the receiver has finite sized buffers called windows. The sender
and the receiver agrees upon the number of frames to be sent based upon the buffer
size.
• The sender sends multiple frames in a sequence, without waiting for acknowledgment.
When its sending window is filled, it waits for acknowledgment. On receiving
acknowledgment, it advances the window and transmits the next frames, according to
the number of acknowledgments received.
automatic Repeat ReQuest (ARQ) is a group of error – control protocols for transmission of
data over noisy or unreliable communication network. These protocols reside in the Data Link
Layer and in the Transport Layer of the OSI (Open Systems Interconnection) reference model.
They are named so because they provide for automatic retransmission of frames that are
corrupted or lost during transmission. ARQ is also called Positive Acknowledgement with
Retransmission (PAR).
ARQs are used to provide reliable transmissions over unreliable upper layer services. They are
often used in Global System for Mobile (GSM) communication.
Working Principle
In these protocols, the receiver sends an acknowledgement message back to the sender if it
receives a frame correctly. If the sender does not receive the acknowledgement of a transmitted
frame before a specified period of time, i.e. a timeout occurs, the sender understands that the
frame has been corrupted or lost during transit. So, the sender retransmits the frame. This
process is repeated until the correct frame is transmitted.
• Stop – and – Wait ARQ − Stop – and – wait ARQ provides unidirectional data
transmission with flow control and 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, 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 acknowledgement 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 acknowledgement of a frame is
not received within the time period, all frames starting from that frame are
retransmitted.
• Selective Repeat ARQ − This protocol also provides for sending multiple frames
before receiving the acknowledgement for the first frame. However, here only the
erroneous or lost frames are retransmitted, while the good frames are received and
buffered.
Errors
When bits are transmitted over the computer network, they are subject to get corrupted due to
interference and network problems. The corrupted bits leads to spurious data being received by
the destination and are called errors.
Types of Errors
Errors can be of three types, namely single bit errors, multiple bit errors, and burst errors.
• Single bit error − In the received frame, only one bit has been corrupted, i.e. either
changed from 0 to 1 or from 1 to 0.
• Multiple bits error − In the received frame, more than one bits are corrupted.
• Burst error − In the received frame, more than one consecutive bits are corrupted.
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.
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
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.
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:
ADVERTISEMENT
ADVERTISEMENT
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.
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 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.
The number of redundant bits is 3. The three bits are represented by r1, r2, r4. The position of
the redundant bits is calculated with corresponds to the raised power of 2. Therefore, their
corresponding positions are 1, 21, 22.
1. The position of r1 = 1
2. The position of r2 = 2
3. The position of r4 = 4
The r1 bit is calculated by performing a parity check on the bit positions whose binary
representation includes 1 in the first position.
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.
Suppose the 4th bit is changed from 0 to 1 at the receiving end, then parity bits are recalculated.
R1 bit
We observe from the above figure that the binary representation of r1 is 1100. Now, we perform
the even-parity check, the total number of 1s appearing in the r1 bit is an even number.
Therefore, the value of r1 is 0.
R2 bit
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
We observe from the above figure that the binary representation of r4 is 1011. Now, we perform
the even-parity check, the total number of 1s appearing in the r4 bit is an odd number.
Therefore, the value of r4 is 1.