Unit 2 Part 2
Unit 2 Part 2
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
situationwhen the message received at the receiver end is not identical to the message transmitted.
Types of Errors:
In the above figure, the message which is sent is corrupted as single-bit, i.e., 0 bit is changed to 1.
Multiple-Bit Error
More than one bit received in the frame is found to be corrupted. Refer to the below image for the
multiple-bit error
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.
Error Detecting Techniques:
The most popular Error Detecting Techniques are:
1. Single parity check
2. Two-dimensional parity check
3. Checksum
4. Cyclic redundancy check
Single Parity Check:
Simple-bit parity is a simple error detection method that involves adding an extra bit to a data
transmission. It works as:
1 is added to the block if it contains an odd number of 1’s, and
0 is added if it contains an even number of 1’s
This scheme makes the total number of 1’s even, that is why it is called even parity checking.
Disadvantage:
Only single-bit error is detected by this method, it fails in multi-bit error detection.
It can not detect an error in case of an error in two bits.
Two-Dimensional Parity Check:
Performance can be improved by using Two-Dimensional Parity Check which organizes the
datain the form of a table.
For every row and column, parity check bits are calculated by a simple method of parity
check. Parity for both rows and columns is transmitted with the data sent from sender to
receiver. At the receiver’s side, parity bits are compared with the calculated parity of the
data received.
Disadvantages:
If 2 bits are corrupted in 1 data unit and another data unit exactly at the same position is
corrupted then this method is not able to detect the error.
Sometimes this method is not used for **detecting 4-bit **errors or more than 4-bit errors.
Checksum:
Checksum is an error detection which detects the error by dividing the data into segments of equal
size and then use 1's complement to find the sum of the segments and then the sum is transmitted
with the data to the receiver and same process is done by the receiver and at the receiver side, all
zeros in the sum indicates the correctness of the data.
First of all data is divided into k segments in a checksum error detection scheme and each
segment has m bits.
For finding out the sum at the sender’s side, all segments are added through 1's complement
arithmetic. And for determining the checksum we complement the sum.
Along with data segments, the checksum segments are also transferred.
All the segments that are received on the receiver's side are added through 1S complement
arithmetic to determine the sum. Then complement the sum.
The received data is accepted only on the condition that the result is found to be 0. And if the
result is not 0 then it will be discarded.
Disadvantages: In checksum error is not detected, if one sub-unit of the data has one or
more corrupted bits and corresponding bits of the opposite value are also corrupted in
another sub-unit. Error is not detected in this situation because in this case the sum of
columns is not affected by corrupted bits.
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?
Problem-02:
A bit stream 10011101 is transmitted using the standard CRC method. The generator polynomial is
x3+1.
Error Correction:
When the data is sent from the sender side to the receiver's side it needs to be detected and corrected. So an
error correction method is used for this purpose. Following are the two ways through which error correction
can be handled:
2r>=d+r+1
The above formula is used to find out the value of r.
For example, suppose 4 will be the value of d, then 3 will be the only and smallest value that satisfies this
particular relation.
To determine the position of the bit which is in error, a technique developed by R.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 iseven or odd.
Even parity: To check for even parity, if the total number of 1s is even, then the value of the
parity bitis 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.
Algorithm of Hamming code:
o An information of 'd' bits are added to the redundant bits 'r' to form d+r.
o The location of each of the (d+r) digits is assigned a decimal value.
o The 'r' bits are placed in the positions 1,2,. ... 2k-1.
o At the receiving end, the parity bits are recalculated. The decimal value of the parity
bitsdetermines the position of an error.
Relationship b/w Error position & binary number:
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
bitpositions corresponding to r4 is even, therefore, the value of the r4 bit is 0.
Data transferred is given below:
ELEMENTARY DATA LINK PROTOCOLS
We divide the protocols into those that can be used for noiseless (error-free) channels and those that can
be used for noisy (error-creating) channels. The protocols in the first category cannot be used in real life,
but they serve as a basis for understanding the protocols of noisy channels.
For the noiseless channel, the following two protocols are used:
Simplest Protocol
Stop and Wait Protocol
The sliding window protocols are used for noisy channels. The sliding window protocol incomputer
networks is further divided into three parts, as follows:
Stop and Wait for ARQ
Go-back ARQ
Selective Repeat ARQ
NOISELESS CHANNELS:
Simplest Protocols:
Stop-and-Wait Protocol:
If data frames arrive at the receiver site faster than they can be processed, the frames must be stored until
their use. Normally, the receiver does not have enough storage space, especially if it is receiving data
from many sources. This may result in either the discarding of frames or denial of service. To prevent the
receiver from becoming overwhelmed with frames, we somehow need to tell the sender to slow down.
There must be feedback from the receiver to the sender.
The protocol we discuss now is called the 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.
Design
We can see the traffic on the forward channel (from sender to receiver) and the reverse channel. At any
time, there is either one data frame on the forward channel or one ACK frame on the reverse channel. We
therefore need a half-duplex link.
Example:
Below Figure shows an example of communication using this 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. Note that sending two frames in the protocol involves the sender in four events and the
receiver in two events.
Range: Consider the field is m bits long, the range of sequence numbers are from 0 to 2m-1,and then
the same number are repeated.
Acknowledgment Numbers
The acknowledgment numbers always announce the sequence number of the next frame
expected by the receiver.
Example:
1. If frame 0 has arrived safe and sound, the receiver sends an ACK frame with
acknowledgment 1 (meaning frame 1 is expected next).
2. If frame 1 has arrived safe and sound, the receiver sends an ACK frame with
acknowledgment 0 (meaning frame 0 is expected).
Design
The sending device keeps a copy of the last frame transmitted until it
receives anacknowledgment for that frame.
The design contains:
seqNo: Sequence Number
ackNo: Acknowledgement Number
Sn: Sender Control variable- that holds the sequence number for the next
frame to besent (0 or 1).
Rn: Receiver Control Variable- that holds the number of the next frame expected.
When a frame is sent, the value of Sn is incremented (modulo-2), which means if it
is 0, itbecomes 1 and vice versa.
When a frame is received, the value of Rn is incremented (modulo-2), which means
if it is0, it becomes 1 and vice versa.
Sn variable points to the slot that matches the sequence number of the frame that has been
sent, but not acknowledged.
Sequence numbers are modulo-2, the possible numbers are 0,1,0,1,0,1,……and so on.
Rn points to the slot that matches the sequence number of the expected frame.
Three events can happen at the sender site; one event can happen at the receiver site.
Example
Frame 0 is sent and acknowledged.
Frame 1 is lost and resent after the time-out.
The resent frame 1 is acknowledged and the timer stops.
Frame 0 is sent and acknowledged, but the acknowledgment is lost.
The sender has no idea if the frame or the acknowledgment is lost, so after the time-
out, itresends frame 0, which is acknowledged.
Go-Back-N Automatic Repeat Request:
Go-Back-N ARQ protocol is also known as Go-Back-N Automatic Repeat Request. It is a data link layer
protocol that uses a sliding window method. In this, if any frame is corrupted or lost, all subsequent
frames have to be sent again.
The size of the sender window is N in this protocol. For example, Go-Back-7, the size of the sender
window, will be 7. The receiver window size is always 1.
If the receiver receives a corrupted frame, it cancels it. The receiver does not accept a corrupted frame.
When the timer expires, the sender sends the correct frame again. The design of the Go-Back-N ARQ
protocol is shown below.
In this protocol
Sender can send several frames before receiving acknowledgments.
Sender keep a copy of these frames until the acknowledgments arrive.
The difference is that the send window allows us to have as many frames in
transition as there are slots in the send window.
1. Sequence Numbers
2. Sliding Window
3. Timers
4. Acknowledgement
5. Retransmission (Resending a Frame)
Sequence Numbers
It is a number given to each frame included in the header.
The header of the frame allows m bits for the sequence number, the sequence
numbersrange from 0 to 2m-1.
The sequence numbers are repeated after the number 2m-1 (i.e) the sequence
numbers aremodulo-2m
Example:
If m=4 , the sequence numbers are 0,1,2,3,4,5………14,15,0,1,2,3,4,5,6,…………………..
Sliding Window
Sliding Window is an abstract concept that defines the sender and receiver needs to
deal withonly part of the possible sequence numbers.
The range that is the concern of sender is called the send sliding window or Send
Window The range that is the concern of receiver is called receive sliding window or
receive window.
Send Window
The send window is an imaginary box covering the sequence numbers of the data
frameswhich can be in transit.
In each window position, some of these sequence numbers define the frames that
havebeen sent; others define those that can be sent.
The maximum size of the send window is
2m – 1.Example: Let us take m=4. Size of
window=15. Consider the below figure:
The window at any time divides the possible sequence numbers into four regions.
1. The first region (the left side of the window) defines the sequence numbers
belonging to frames that are already acknowledged. The sender don‟t need to keep
copies of the frames.
2. The second region defines the range of sequence numbers belonging to the frames
that are sent and have an unknown status. The sender needs to wait to find out if
these frames have been received or were lost. These frames are called outstanding
frames.
3. The third range defines the range of sequence numbers for frames that can be sent.
The corresponding data packets have not yet been received from the network layer.
4. The fourth region defines sequence numbers that cannot be used until the window slides.
The window uses three variables define its size and location at any time.
i. Sf defines the sequence number of the first (oldest) outstanding frame.
ii. Sn holds the sequence number that will be assigned to the next frame to be sent.
iii. Ssize defines the size of the window, which is fixed in our protocol.
The acknowledgments in this protocol are cumulative, meaning that more than one
frame canbe acknowledged by an ACK frame.
In the above figure frames 0, 1, and 2 are acknowledged, so the window has slid to
the rightthree slots.
Receive Window
The receive window makes sure that the correct data frames are received and
that thecorrect acknowledgments are sent.
The size of the receive window is always 1.
The receiver is always looking for the arrival of a specific frame.
Any frame arriving out of order is discarded and needs to be resent.
There is only one variable required, that is Rn
The sequence numbers to the left of the window belong to the frames already
receivedand acknowledged.
The sequence numbers to the right of this window define the frames that
cannot bereceived.
Any received frame with a sequence number in these two regions is discarded.
Only a frame with a sequence number matching the value of Rn is
accepted andacknowledged. (i.e. Sn=Rn)
Timers:
The timer for the first outstanding frame always expires first.We send all outstanding frameswhen this
timer expires
Acknowledgment
The receiver sends a positive acknowledgment if a frame has arrived safe and sound
and in order.
If a frame is damaged or frame is received out of order, the receiver is silent and
will discard all subsequent frames until it receives the one it is expecting.
The silence of the receiver causes the timer of the unacknowledged frame at the
sender site to expire. This causes the sender to go back and resend all frames,
beginning with the one with the expired timer.
The receiver does not have to acknowledge each frame received. It can send one
cumulative acknowledgment for several frames.
Retransmission (Resending a Frame)
When the timer expires, the sender resends all outstanding frames
Example:
Suppose the sender has already sent frame 6, but the timer for frame 3 expires.
This means that frame 3 has not been acknowledged.
The sender goes back and sends frames 3, 4,5, and 6 again.
Example
The below shows what happens when a frame is lost.
Frames 0, 1, 2, and 3 are sent.
Frame 0 is acknowledged but Frame 1 is lost.
The receiver receives frames 2 and 3, but they are discarded because they are
received outof order (frame 1 is expected)
Note that before the second timer expires, all outstanding frames have been sent and the
timeris stopped.
Disadvantage with Go-Back-N ARQ
Go-Back-N ARQ protocol is very inefficient for a noisy link.
Go-Back-N ARQ simplifies the process at the receiver site.
The receiver keeps track of only one variable, and there is no need to buffer out-
of-orderframes and they are simply discarded.
In a noisy link a frame has a higher probability of damage; so it leads to the
resending ofmultiple frames.
This resending uses more bandwidth and slows down the transmission. This is a
majordisadvantage
Solution: When there is just one frame is damaged, then only the damaged frame is resent, instead of
resending from Nth frame. This will be achieved by using Selective Repeat ARQ Protocol.
Selective Repeat Automatic Repeat Request:
It is more efficient for Noisy links but processing at the receiver is more complex.
Window size 2m-1 means the size of the sender and receiver window is at most one half of 2m(i.e 2m/2).
Windows
It uses two windows:
1. Send Window
2. Receive Window
The size of the send window and receive window is same as 2m-1.
Example: If m = 4, the sequence numbers ranges from 0 to 15, but the size of the
window isjust
The Selective Repeat Protocol allows as many frames as the size of the receive
window to arrive out of order and be kept until there is a set of in-order frames to be
delivered to the network layer.
Because the sizes of the send window and receive window are the same, all the
frames in the send frame can arrive out of order and be stored until they can be
delivered.
We need to mention that the receiver never delivers packets out of order to the
network layer.
Those slots inside the receive window that are colored define frames that have arrived outof
order and are waiting for their neighbors to arrive before delivery to the network layer
Example
Receiver Site
At the receiver site we need to distinguish between the acceptance of a frame
and its delivery to the network layer.
At the second arrival, frame 2 arrives and is stored and marked (colored slot),
but itcannot be delivered because frame 1 is missing.
At the next arrival, frame 3 arrives and is marked and stored, but still none of the
frames can be delivered.
Only at the last arrival, when finally a copy of frame 1 arrives and frames 1, 2,
and 3 bedelivered to the network layer.
There are two conditions for the delivery of frames to the network layer:
i. a set of consecutive frames must have arrived.
ii. the set starts from the beginning of the window.
After the first arrival, there was only one frame and it started from the beginning
of thewindow.
After the last arrival, there are three frames and the first one starts from the
beginning ofthe window.
PIGGYBACKING
The protocols Stop-and-wait ARQ, Go-Back-N ARQ, Selective Repeat ARQ are all unidirectional.
That means data frames flow in only one direction although control information such as ACK and
NAK frames can travel in the other direction.
In real life, data frames are normally flowing in both directions: from node A to node B and from
node B to node A. This means that the control information also needs to flow in both directions.
This technique called piggybacking.
Piggybacking is used to improve the efficiency of the bidirectional protocols. When a frame is
carrying data from A to B, it can also carry control information from B to A. Similarly when a
frame is carrying data from B to A, it can also carry control information frames from A to B.