Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Lecture

Data Communication & Networks 08


Error Detection & Flow Control

Muhammad Yousaf
Errors on the network:
We know real life is very uncertain
Data sent might be lost in network
Or receiver receive data with errors
Noise may be higher enough to invert bit-values
How receiver will decide that data received
correctly or erroneously
Need to develop some mechanism that enables the
receiver to discriminate between correct data and
erroneous data

myousaf@ymail.com 2
Error Detection:
Idea is to add some extra information with user
data
Receiver uses these information to infer about the
correctness of data
There are many schemes that implement error
detection
Parity Checking
Cyclic Redundancy Check (CRC)
Checksum

myousaf@ymail.com 3
Parity Check:
Used with character-wise transmission
Append an extra bit with the character bits
01000010P
Count the number of ones & set the P-bit
accordingly
Even Parity:
Number of ones including P-bit should be even
010000100
010000111
Similarly in Odd Parity number of ones are odd

myousaf@ymail.com 4
Problem in Parity Check:
Odd number of error-bits can be detected easily
Send data with even parity: 0 1 0 0 0 0 1 0 0
Error occurred during transmission: 0 1 0 0 0 1 1 0 0
Receiver checked the parity: 0 1 0 0 0 1 1 0 0
Number of ones are not even: ERROR DETECTED
Even number of error-bits can’t be detected
Send data with even parity: 0 1 0 0 0 0 1 0 0
Error occurred during transmission: 0 1 0 0 1 1 1 0 0
Receiver checked the parity: 0 1 0 0 1 1 1 0 0
Number of ones are even: ERROR NOT DETECTED

myousaf@ymail.com 5
Cyclic Redundancy Check: (CRC)
Used with block-wise transmission
Transmitter & receiver agree on a common divisor
Transmitter divides the data with this divisor
Calculates the remainder
Appends this remainder with the data as CRC value
Transmit (data + CRC value)
Receiver divides this (data + CRC) value with the common
divisor
If remainder is zero then data received error free
If remainder is non-zero then data received erroneously

myousaf@ymail.com 6
CRC – Calculation: (sender side)
Let user data is: 10111 1100100111010000
10111
110010011101 11100
Common divisor is: 10111
10110
10111
10111
Start with 0000 11110
1100100111010000 10111
10011
Dividing using XOR
10111
Remainder is 1011 10000
Append it with data & 10111
transmit 11100
10111
1100100111011011 1011

myousaf@ymail.com 7
CRC – Verification: (receiver side)
10111 1100100111011011
Receiver received the
10111
data + CRC value 11100
10111
Performed same
10110
calculation 10111
If remainder is zero 11110
10111
Data received error free 10011
Else if Non-Zero 10111
10010
There is some error in 10111
received data 10111
10111
0000

myousaf@ymail.com 8
Frame transmission scenarios:

myousaf@ymail.com 9
Flow Control

myousaf@ymail.com 10
Why Flow Control ?
In this world, every one is not of same capability
Sender might be having more resources than
receiver in terms of:
Processing power
Memory space
Bandwidth
Sender can send so much data packets that
receiver might not be able to handle
Packets more than the receiver’s buffer space will
be dropped

myousaf@ymail.com 11
Means of Flow Control:
Need a mechanism in which:
Receiver can limit the sender from overwhelming him
There are two popular schemes:
Stop & Wait Flow Control
Sliding Window Flow Control

myousaf@ymail.com 12
Stop and Wait:
Source transmits frame
Destination receives frame and replies with
Acknowledgement
Source waits for ACK before sending next frame
Destination can stop flow by not send ACK
Very simple scheme

myousaf@ymail.com 13
Stop and Wait: cont…
Frames are alternatively numbered as frame-0 & frame-1
Similarly receiver uses two ACK messages:
ACK-0 = receiver has received frame-1 and is now asking for frame-0
ACK-1 = receiver is asking for frame-1
If sender doesn’t receive any ACK then:
Either receiver didn’t received the frame
Or ACK has been lost in the way
Sender waits for the period of Timeout
After the expiry of Timeout sender retransmits the previous frame
Often Timeout = 2 * RTT
RTT = Round Trip Time

myousaf@ymail.com 14
Stop and Wait:

myousaf@ymail.com 15
Stop and Wait: (Link Utilization)

myousaf@ymail.com 16
Stop & Wait: (pros & cons)
Advantages:
Very simple scheme
Implementation is easy

Disadvantages:
Poor link utilization
Higher delays
Poor throughput

myousaf@ymail.com 17
Sliding Windows:
We want to improve link utilization
Allow multiple frames to be in transit at the same
time
Each frame is labeled with a sequence number
Receiver can send Accumulative ACK
This ACK includes number of next frame expected
ACK-6 acknowledges the reception of previous 5 frames
& is now asking for frame-6

myousaf@ymail.com 18
Sliding Windows: cont…
Both sender & receiver maintain two windows
Common window sizes are:
3-bits = HDLC (High-level Data Link Control Protocol)
7-bits = HDLC enhancement for satellite communication
16-bits = TCP (Transmission Control Protocol)
Sender maintains a list of sequence numbers that
he can send
Receiver maintains a list of sequence numbers that
he can receive
Sender sends the number of frames usually less
than the maximum window size

myousaf@ymail.com 19
Example Sliding Window:

myousaf@ymail.com 20
Automatic Repeat Request: (ARQ)
If some frames are lost in transit or received with
error then what to do?
Definitely perform retransmission
In sliding window for retransmissions there are two
possibilities:
Go back N
Selective repeat

myousaf@ymail.com 21
Go Back N:
If frame N is lost or received with error;
Receiver side:
Receiver discards that frame and all subsequent frames
until error frame received correctly
Receiver doesn’t buffer the out of order frames
Sends ACK-N to indicate that receiver is asking for
frame-N
Sender side:
Goes back to sequence number N and sends all
subsequent frames

myousaf@ymail.com 22
Go Back N: cont…

myousaf@ymail.com 23
Selective Repeat:
Minimizes retransmission
Only lost/damaged frames are retransmitted
If frame N is lost or received with error:
Receiver side:
Receiver discards that frame but buffers the subsequent
frames
Receiver must maintain a buffer to store out of order
frames
Sender side:
Only the frame that has been asked by the receiver is
retransmitted
myousaf@ymail.com 24
Selective Repeat:

myousaf@ymail.com 25
HDLC:
High-level Data Link Control Protocol
Layer 2 protocol
Defines the services provided by data link layer
Appends layer-2 header and trailer with the data
Once heavily used protocol
Today’s data link protocols are based on HDLC

myousaf@ymail.com 26
Frame Structure of HDLC:

myousaf@ymail.com 27
Control Field: (information frame)

myousaf@ymail.com 28
Questions ???

myousaf@ymail.com 29

You might also like