Cnd unit 4
Cnd unit 4
What is an Error
The data can be corrupted during transmission (from source to receiver).
It may be affected by external noise or some other physical imperfections.
In this case, the input data is not same as the received output data. This mismatched data is called
“Error”.
Types Of Errors
In a data sequence, if 1 is changed to zero or 0 is changed to 1, it is called “Bit error”.
There are generally 3 types of errors occur in data transmission from transmitter to receiver. They are
• Single bit errors
• Multiple bit errors
• Burst errors
Single Bit Data Errors
The change in one bit in the whole data sequence , is called “Single bit
error”.
Occurrence of single bit error is very rare in serial communication
system.
This type of error occurs only in parallel communication system, as
data is transferred bit wise in single line, there is chance that single line to be
noisy.
Marks: 12 Page 1
UNIT 4 Data Link Layer
Burst Errors
The change of set of bits in data sequence is called “Burst error”. The burst error is calculated in from
the first bit change to last bit change.
1. Error Detection :
Error detection, as name suggests, simply means detection or identification of errors. These errors may
cause due to noise or any other impairments during transmission from transmitter to the receiver, in
communication system. It is class of technique for detecting garbled i.e. unclear and distorted data or
message.
2. Error Correction :
Error correction, as name suggests, simply means correction or solving or fixing of errors. It simply means
reconstruction and rehabilitation of original data that is error-free. But error correction method is very costly
and is very hard.
3.
Error Detecting Codes
In digital communication system errors are transferred from one communication system to another, along with
the data. If these errors are not detected and corrected, data will be lost . For effective communication, data
should be transferred with high accuracy .This can be achieved by first detecting the errors and then correcting
them.Error detection is the process of detecting the errors that are present in the data transmitted from
transmitter to receiver, in a communication system. We use some redundancy codes to detect these errors, by
adding to the data while it is transmitted from source (transmitter). These codes are called “Error detecting
codes”.
Types of Error detection
1. Hamming Code
2. Cyclic Redundancy Check (CRC)
3. Linear block code
4. Check Sum
Marks: 12 Page 2
UNIT 4 Data Link Layer
Hamming code
Even Parity
If the data has even number of 1’s, the parity bit is 0. Ex: data is 10000001 -> parity bit 0
Odd number of 1’s, the parity bit is 1. Ex: data is 10010001 -> parity bit 1
Odd Parity
If the data has odd number of 1’s, the parity bit is 0. Ex: data is 10011101 -> parity bit 0
Even number of 1’s, the parity bit is 1. Ex: data is 10010101 -> parity bit 1
Generate hamming code for message 1011 using even parity
Consider r=1
2^1>=4+1+1
2>=6
Consider r=2
2^2>=4+2+1
Consider r=3
2^3>=4+3+1
8>=8
Marks: 12 Page 3
UNIT 4 Data Link Layer
Marks: 12 Page 4
UNIT 4 Data Link Layer
Correction process-
Let’s consider 6th bit is sent incorrectly i.e 1 1 1 0 1 0 1 is sent then how to correct that error
Let’s consider all bits sent correctly i.e 1 0 1 0 1 0 1 How to detect incorrect bit & correct it
Marks: 12 Page 5
UNIT 4 Data Link Layer
Assume that g(x) is CRC-4, which equals X4 + X + 1, and the source data M is 10110011. In this case, the
divisor P is 10011.
The transmit end shifts M leftward by four bits, and divides the resulting number by P.
Marks: 12 Page 6
UNIT 4 Data Link Layer
Marks: 12 Page 7
UNIT 4 Data Link Layer
Step1: Separate the identity matrix and coefficient matrixGenerator matrix is given by:
[𝐺] = [𝐼𝑘 | 𝑃]
As the size of message block k =3, there are 8 possible message sequences
Ik P
= =
As the size of message block k =3, there are 8 possible message sequences
0 1 1
∴ [𝐶] = [𝑐0 𝑐2] = [𝑚0
= 0 ⊕ 𝑚1 ⊕ 𝑚2
= 𝑚1 ⊕ 𝑚2
Marks: 12 Page 8
0 0
UNIT 4 Data Link Layer
Mod-2 addition and mod-2 multiplication on binary symbols 0 and 1. Multiplication defined same as for
ordinary numbers. But for addition 1 + 1 = 0. This can be interpreted as 1 – 1 = 0 i.e., in binary computations,
subtraction coincides with addition.
Mod-2 addition table
0⊕0=0 A B A ⊕ B = 𝐴̅ 𝐵 + 𝐴 𝐵̅
0⊕1=1 0 0 0
1⊕0=1 0 1 1
1⊕1=0 1 0 1
1 1 0
Mod-2 subtraction table Multiplication in modulo-2 algebra
Complete codeword for message block (000)
m0 m1 m2 c0 c1 c2
0 0 0 0 0 0
1 1 0
𝑐0 = 𝑚1 ⊕ 𝑚2
𝑐1 = 𝑚0 ⊕ 𝑚2
𝑐2 = 𝑚0 ⊕ 𝑚1
m0 m1 m2 c0 c1 c2
0 0 1 1 1 0
Marks: 12 Page 9
UNIT 4 Data Link Layer
𝑐0 = 𝑚1 ⊕ 𝑚2
𝑐1 = 𝑚0 ⊕ 𝑚2
𝑐2 = 𝑚0 ⊕ 𝑚1
0 1 1
[𝐶] = [𝑐0 𝑐1 𝑐2] = [𝑚0 𝑚1 𝑚2 ] [1 0 1]
1 1 0
m0 m1 m2 c0 c1 c2
0 1 0 1 0 1
𝑐0 = 𝑚1 ⊕ 𝑚2
𝑐1 = 𝑚0 ⊕ 𝑚2
𝑐2 = 𝑚0 ⊕ 𝑚1
0 1 1
[𝐶] = [𝑐0 𝑐1 𝑐2] = [𝑚0 𝑚1 𝑚2] [1 0 1]
1 1 0
Marks: 12 Page 10
UNIT 4 Data Link Layer
m0 m1 m2 c0 c1 c2
1 0 0 0 1 1
𝑐1 = 𝑚0 ⊕ 𝑚2
𝑐2 = 𝑚0 ⊕ 𝑚1
0 1 1
[𝐶] = [𝑐0 𝑐1 𝑐2] = [𝑚0 𝑚1 𝑚2] [1 0 1]
1 1 0
m0 m1 m2 c0 c1 c2
1 1 0 1 1 0
𝑐0 = 𝑚1 ⊕ 𝑚2
𝑐1 = 𝑚0 ⊕ 𝑚2
𝑐2 = 𝑚0 ⊕ 𝑚1
0 1 1
[𝐶] = [𝑐0 𝑐1 𝑐2] = [𝑚0 𝑚1 𝑚2] [1 0 1]
1 1 0
m0 m1 m2 c0 c1 c2
1 1 1 0 0 0
Code vectors for (6,3) linear block code
S.No. Message vectors Parity bits Code vectors
1 000 000 000000
2 001 110 001110
3 010 101 010101
4 011 011 011011
5 100 011 100011
6 101 101 101101
7 110 110 110110
8 111 000 111000
Checksum:
Marks: 12 Page 12
UNIT 4 Data Link Layer
Flow control:
Flow control is the management of data flow between computers or devices or between nodes in a
network so that the data can be handled at an efficient pace.
Too much data arriving before a device can handle it causes data overflow, meaning the data is either
lost or must be retransmitted.
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).
Marks: 12 Page 13
UNIT 4 Data Link Layer
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.
Error Control Techniques
There are three main techniques for error control −
The above figure shows the working of the stop and wait protocol.
If there is a sender and receiver, then sender sends the packet and that packet is known as a data packet
The sender will not send the second packet without receiving the acknowledgment of the first packet.
The receiver sends the acknowledgment for the data packet that it has received.
Once the acknowledgment is received, the sender sends the next packet. This process continues until all
the packet are not sent.
Marks: 12 Page 14
UNIT 4 Data Link Layer
The main advantage of this protocol is its simplicity but it has some disadvantages also. For example, if
there are 1000 data packets to be sent, then all the 1000 packets cannot be sent at a time as in Stop and
Wait protocol, one packet is sent at a time.
Disadvantages of Stop and Wait protocol
The following are the problems associated with a stop and wait protocol:
1. Problems occur due to lost data
Suppose the sender sends the data and the data is lost. The receiver is waiting for the data for a long time. Since
the data is not received by the receiver, so it does not send any acknowledgment. Since the sender does not
receive any acknowledgment so it will not send the next packet. This problem occurs due to the lost data.
In this case, two problems occur:
Sender waits for an infinite amount of time for an acknowledgment.
Receiver waits for an infinite amount of time for a data.
2. Problems occur due to lost acknowledgment
Suppose the sender sends the data and it has also been received by the receiver. On receiving the packet, the
receiver sends the acknowledgment. In this case, the acknowledgment is lost in a network, so there is no chance
for the sender to receive the acknowledgment. There is also no chance for the sender to send the next packet as
in stop and wait protocol, the next packet cannot be sent until the acknowledgment of the previous packet is
received.
In this case, one problem occurs:
Sender waits for an infinite amount of time for an acknowledgment.
3. Problem due to the delayed data or acknowledgment
Suppose the sender sends the data and it has also been received by the receiver. The receiver then sends the
acknowledgment but the acknowledgment is received after the timeout period on the sender's side. As the
acknowledgment is received late, so acknowledgment can be wrongly considered as the acknowledgment of
some other data packet.
Marks: 12 Page 15
UNIT 4 Data Link Layer
Go-Back-N ARQ
The working principle of this protocol is −
o The sender has buffers called sending window.
o The sender sends multiple frames based upon the sending-window size, without receiving the
acknowledgment of the previous ones.
o The receiver receives frames one by one. It keeps track of incoming frame’s sequence number and sends
the corresponding acknowledgment frames.
o After the sender has sent all the frames in window, it checks up to what sequence number it has received
positive acknowledgment.
o If the sender has received positive acknowledgment for all the frames, it sends next set of frames.
o If sender receives 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.
Marks: 12 Page 16
UNIT 4 Data Link Layer
Let's assume that the receiver has sent the acknowledgment for the 0 frame, and the receiver has successfully
received it.
The sender will then send the next frame, i.e., 4, and the window slides containing four frames (1,2,3,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).
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.
Marks: 12 Page 17
UNIT 4 Data Link Layer
Marks: 12 Page 18
UNIT 4 Data Link Layer
Step 2: Once the transfer of window size is completed, the sender receives the acknowledgment of the first
frame, i.e., packet no1. As the acknowledgment receives, the sender sends the next packet, i.e., packet no 5. In
this case, the window slides having four packets, i.e., 2,3,4,5 and excluded the packet 1 as the acknowledgment
of the packet 1 has been received successfully.
Step 3: Now, the sender receives the acknowledgment of packet 2. After receiving the acknowledgment for
packet 2, the sender sends the next packet, i.e., packet no 6. As mentioned in the question that every 6th is being
lost, so this 6th packet is lost, but the sender does not know that the 6th packet has been lost.
Step 4: The sender receives the acknowledgment for the packet no 3. After receiving the acknowledgment of
3rd packet, the sender sends the next packet, i.e., 7th packet. The window will slide having four packets, i.e., 4,
5, 6, 7.
Marks: 12 Page 19
UNIT 4 Data Link Layer
Step 5: When the packet 7 has been sent, then the sender receives the acknowledgment for the packet no 4.
When the sender has received the acknowledgment, then the sender sends the next packet, i.e., the 8th packet.
The window will slide having four packets, i.e., 5, 6, 7, 8.
Step 6: When the packet 8 is sent, then the sender receives the acknowledgment of packet 5. On receiving the
acknowledgment of packet 5, the sender sends the next packet, i.e., 9th packet. The window will slide having
four packets, i.e., 6, 7, 8, 9.
Marks: 12 Page 20
UNIT 4 Data Link Layer
Step 7: The current window is holding four packets, i.e., 6, 7, 8, 9, where the 6th packet is the first packet in the
window. As we know, the 6th packet has been lost, so the sender receives the negative acknowledgment NAK(6).
As we know that every 6th packet is being lost, so the counter will be restarted from 1. So, the counter values 1,
2, 3 are given to the 7th packet, 8th packet, 9th packet respectively.
Step 8: As it is Go-BACK, so it retransmits all the packets of the current window. It will resend 6, 7, 8, 9. The
counter values of 6, 7, 8, 9 are 4, 5, 6, 1, respectively. In this case, the 8th packet is lost as it has a 6-counter
value, so the counter variable will again be restarted from 1.
Step 9: After the retransmission, the sender receives the acknowledgment of packet 6. On receiving the
acknowledgment of packet 6, the sender sends the 10th packet. Now, the current window is holding four
packets, i.e., 7, 8, 9, 10.
Marks: 12 Page 21
UNIT 4 Data Link Layer
Step 10: When the 10th packet is sent, the sender receives the acknowledgment of packet 7. Now the current
window is holding three packets, 8, 9 and 10. The counter values of 8, 9, 10 are 6, 1, 2.
Step 11: As the 8th packet has 6 counter value which means that 8th packet has been lost, and the sender
receives NAK (8).
Step 12: Since the sender has received the negative acknowledgment for the 8th packet, it resends all the
packets of the current window, i.e., 8, 9, 10.
Marks: 12 Page 22
UNIT 4 Data Link Layer
Step 13: The counter values of 8, 9, 10 are 3, 4, 5, respectively, so their acknowledgments have been received
successfully.
We conclude from the above figure that total 17 transmissions are required.
Selective Repeat ARQ
Both the sender and the receiver have buffers called sending window and receiving window
respectively.
The sender sends multiple frames based upon the sending-window size, without receiving the
acknowledgment of the previous ones.
The receiver also receives multiple frames within the receiving window size.
The receiver keeps track of incoming frame’s sequence numbers, buffers the frames in memory.
It sends ACK for all successfully received frames and sends NACK for only frames which are missing
or damaged.
The sender in this case, sends only packet for which NACK is received.
Marks: 12 Page 23
UNIT 4 Data Link Layer
acknowledgment. There is no waiting for any time-out to send that frame. The design of the Selective
Repeat ARQ protocol is shown below.
The example of the Selective Repeat ARQ protocol is shown below in the figure.
Explanation
Step 1 − Frame 0 sends from sender to receiver and set timer.
Step 2 − Without waiting for acknowledgement from the receiver another frame, Frame1 is sent by sender by
setting the timer for it.
Step 3 − In the same way frame2 is also sent to the receiver by setting the timer without waiting for previous
acknowledgement.
Step 4 − Whenever sender receives the ACK0 from receiver, within the frame 0 timer then it is closed and sent
to the next frame, frame 3.
Step 5 − whenever the sender receives the ACK1 from the receiver, within the frame 1 timer then it is closed
and sent to the next frame, frame 4.
Marks: 12 Page 24
UNIT 4 Data Link Layer
Step 6 − If the sender doesn’t receive the ACK2 from the receiver within the time slot, it declares timeout for
frame 2 and resends the frame 2 again, because it thought the frame2 may be lost or damaged.
If a frame is corrupted or lost in it,all In this, only the frame is sent again, which is corrupted or
subsequent frames have to be sent again. lost.
If it has a high error rate,it wastes a lot of There is a loss of low bandwidth.
bandwidth.
It does not require sorting. In this, sorting is done to get the frames in the correct
order.
Marks: 12 Page 25
UNIT 4 Data Link Layer
PPP Frame
PPP is a byte - oriented protocol where each field of the frame is composed of one or more bytes. The fields of
a PPP frame are −
Flag − 1 byte that marks the beginning and the end of the frame. The bit pattern of the flag is 01111110.
Address − 1 byte which is set to 11111111 in case of broadcast.
Control − 1 byte set to a constant value of 11000000.
Protocol − 1 or 2 bytes that define the type of data contained in the payload field.
Payload − This carries the data from the network layer. The maximum length of the payload field is
1500 bytes. However, this may be negotiated between the endpoints of communication.
FCS − It is a 2 byte or 4 bytes frame check sequence for error detection. The standard code used is CRC
(cyclic redundancy code)
Byte Stuffing in PPP Frame − Byte stuffing is used is PPP payload field whenever the flag sequence appears
in the message, so that the receiver does not consider it as the end of the frame. The escape byte, 01111101, is
stuffed before every byte that contains the same byte as the flag byte or the escape byte. The receiver on
receiving the message removes the escape byte before passing it onto the network layer.
Authenticate: It is an optional phase which means that the communication can also moves to the
authenticate phase. The phase moves from the establish to the authenticate phase only when both the
communicating nodes agree to make the communication authenticated.
Network: Once the authentication is successful, the network is established or phase is network. In this
phase, the negotiation of network layer protocols take place.
Open: After the establishment of the network phase, it moves to the open phase. Here open phase
means that the exchange of data takes place. Or we can say that it reaches to the open phase after the
configuration of the network layer.
Terminate: When all the work is done then the connection gets terminated, and it moves to the
terminate phase.
Techniques of Flow Control in Data Link Layer : There are basically two types of techniques being
developed to control the flow of data
Marks: 12 Page 27
UNIT 4 Data Link Layer
1. Stop-and-Wait Flow Control : This method is the easiest and simplest form of flow control. In this
method, basically message or data is broken down into various multiple frames, and then receiver indicates its
readiness to receive frame of data. When acknowledgement is received, then only sender will send or transfer
the next frame. This process is continued until sender transmits EOT (End of Transmission) frame. In this
method, only one of frames can be in transmission at a time. It leads to inefficiency i.e. less productivity if
propagation delay is very much longer than the transmission delay and Ultimately In this method sender sent
single frame and receiver take one frame at a time and sent acknowledgement(which is next frame number
only) for new frame.
Advantages –
This method is very easiest and simple and each of the frames is checked and acknowledged well.
This method is also very accurate.
Disadvantages –
This method is fairly slow.
In this, only one packet or frame can be sent at a time.
It is very inefficient and makes the transmission process very slow.
2. Sliding Window Flow Control : This method is required where reliable in-order delivery of packets
or frames is very much needed like in data link layer. It is point to point protocol that assumes that none of the
other entity tries to communicate until current data or frame transfer gets completed. In this method, sender
transmits or sends various frames or packets before receiving any acknowledgement. In this method, both the
sender and receiver agree upon total number of data frames after which acknowledgement is needed to be
transmitted. Data Link Layer requires and uses this method that simply allows sender to have more than one
unacknowledged packet “in-flight” at a time. This increases and improves network throughput. and
Ultimately In this method sender sent multiple frame but receiver take one by one and after completing one
frame acknowledge(which is next frame number only) for new frame.
Advantages –
It performs much better than stop-and-wait flow control.
This method increases efficiency.
Multiples frames can be sent one after another.
Disadvantages –
The main issue is complexity at the sender and receiver due to the transferring of multiple frames.
The receiver might receive data frames or packets out the sequence.
Marks: 12 Page 28