Chapter Seven Error - &flow - Control - Mechanisms

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 50

Chapter Seven

Error and Flow Control


Mechanisms
Introduction
• For reliable and efficient data communication a great
deal of coordination is necessary between at least two
machines.
• Some of these are necessary because of the following
constraints:
– Both sender and receiver have limited speed
– Both sender and receiver have limited memory
• It is necessary to satisfy the following requirements:
– A fast sender should not overwhelm a slow receiver, which
must perform a certain amount of processing before passing
the data on to the higher-level software.
– If error occur during transmission, it is necessary to devise
mechanism to correct it
Introduction (cont …)
• The most important functions of Data Link layer to
satisfy the above requirements are
 flow control and
 error control
• Collectively, these functions are known as data link
control.
Introduction (cont …)
• Flow Control is a technique so that transmitter and
receiver with different speed characteristics can
communicate with each other.
• Flow control ensures that a transmitting station, such
as a server with higher processing capability, does
not overwhelm a receiving station, such as a desktop
system, with lesser processing capability.
• This is where there is an orderly flow of transmitted
data between the source and the destination.
Introduction (cont …)
• Error Control involves both error detection and error
correction.
• It is necessary because errors are inevitable in data
communication, in spite of the use of better equipment and
reliable transmission media based on the current technology.
• Error control is performed based on retransmission of the
corrupted data.
• When an error is detected, the receiver can have the
specified frame retransmitted by the sender.
• This process is commonly known as Automatic Repeat
Request (ARQ).
Flow Control
• Flow Control is a set of procedures that tells the sender
how much data it can transmit before it must wait for an
acknowledgment from the receiver.
• The flow of data should not be allowed to overwhelm the
receiver.
• Receiver should also be able to inform the transmitter
before its limits are reached (this limit may be amount of
memory used to store the incoming data or the processing
power at the receiver end) and the sender must send fewer
frames.
• Hence, Flow control refers to the set of procedures used to
restrict the amount of data the transmitter can send before
waiting for acknowledgment.
Flow Control (cont…)
 There are two methods developed for flow control namely
1. Stop-and-wait and
2. Sliding-window
 Stop-and-wait is also known as Request/reply sometimes.
 requires each data packet to be acknowledged by the
remote host before the next packet is sent.
 Sliding window algorithms (used by TCP)
 permit multiple data packets to be in simultaneous
transit, making more efficient use of network bandwidth.
Stop-and-wait (cont …)

• The blue arrows show the sequence of data frames being sent
across the link from the sender (top) to the receiver (bottom).
• The green arrow shows acknowledgements from receiver
to the original sender.
Stop and wait (cont …)
• The protocol relies on two-way transmission (full
duplex or half duplex) to allow the receiver at the
remote node to return frames acknowledging the
successful transmission.
• . A small processing delay may be introduced between
reception of the last byte of a Data PDU and generation
of the corresponding ACK.
• Major drawback of Stop-and-Wait Flow Control
– only one frame can be in transmission at a time,
– this leads to inefficiency if propagation delay is much
longer than the transmission delay.
Link Utilization in Stop-and-Wait
• Let us assume the following:
 Transmission time: The time it takes for a station to
transmit a frame (normalized to a value of 1).
 Propagation delay: The time it takes for a bit to travel from
sender to receiver (expressed as a).
• Let us observe the following scenarios
 a < 1 :The frame is sufficiently long such that the first bits of the
frame arrive at the destination before the source has completed
transmission of the frame.
 a > 1: Sender completes transmission of the entire frame before
the leading bits of the frame arrive at the receiver.
• The link utilization ,
U = 1/(1+2a),
where a = Propagation time / transmission time
Link Utilization in Stop-and-Wait
• The link utilization ,
U = 1/(1+2a),
where a = Propagation time / transmission time
• It is evident from the above equation that the link utilization
is strongly dependent on the ratio of the propagation time to
the transmission time (a).
• When the propagation time is small, as in case of LAN
environment, the link utilization is good.
• But, in case of long propagation delays, as in case of
satellite communication, the utilization can be very poor.
• Therefore, to improve the link utilization, we can use the
following (sliding-window) protocol instead of using stop-
and-wait protocol.
Sliding Window
• With the use of multiple frames for a single message, the stop-
and-wait protocol does not perform well because only one
frame at a time can be in transit.
• In stop-and-wait flow control, if a > 1, serious inefficiencies
result.
• Efficiency can be greatly improved
– by allowing multiple frames to be in transit at the same time.
– by making use of the full-duplex line.
• To keep track of the frames, sender station sends sequentially
numbered frames. Since the sequence number to be used
occupies a field in the frame, it should be of limited size.
• If the header of the frame allows k bits, the sequence numbers
range from 0 to 2k – 1.
Sliding Window (cont …)
• Sender maintains a list of sequence numbers that it is allowed to
send (sender window).
• The size of the sender’s window is at most N=2k – 1.
• The sender is provided with a buffer equal to the window size.
• Receiver also maintains a window of size N = 2k – 1.
• The receiver acknowledges a frame by sending an ACK frame
that includes the sequence number of the next frame expected.
• This also explicitly announces that it is prepared to receive the
next N frames, beginning with the number specified.
• This scheme can be used to acknowledge multiple frames. It
could receive frames 2, 3, 4 but withhold ACK until frame 4 has
arrived.
• By returning an ACK with sequence number 5, it acknowledges
frames 2, 3, 4 in one go.
Sliding Window (cont …)
• Sliding window algorithm is a method of flow control
for network data transfers.
• TCP, the Internet's stream transfer protocol, uses a
sliding window algorithm.
• A sliding window algorithm places a buffer between the
application program and the network data flow.
• For TCP, the buffer is typically in the operating system
kernel.
• Data received from the network is stored in the buffer,
from where the application can read at its own pace.
• As the application reads data, buffer space is freed up to
accept more input from the network.
• The window is the amount of data that can be "read
ahead" - the size of the buffer
• Window announcements are used to inform the remote
host of the current window size.
Sliding Window (cont …)
• Sender sliding Window: At any instant, the sender is permitted
to send frames with sequence numbers in a certain range (the
sending window).
Sliding Window (cont …)
 Hence, Sliding Window Flow Control
 Allows transmission of multiple frames
 Assigns each frame a k-bit sequence number
 Range of sequence number is [0…2k-1], i.e., frames are
counted modulo 2k.
 The link utilization in case of Sliding Window Protocol
 U = 1, for N > 2a + 1
 U = N/(1+2a), for N < 2a + 1 ,
where N = the window size, and
a = Propagation time / transmission time
Error detection and Correction
• What is Error?
• Error is a condition when the output information does not
match with the input information.
• During transmission, digital signals suffer from noise that
can introduce errors in the binary bits travelling from one
system to other.
• That means a 0 bit may change to 1 or a 1 bit may change to
0.
Error Detection
Definition of Error
• Networks must be able to transform data from
once device to another with complete accuracy.
• While the transmission data can be corrupted, for
reliable communication errors must be detected
and corrected.
• Types of Errors
 Single-bit errors
 Burst errors
Error Detection (cont …)
• Single bit error

• Burst error
Error detection and Correction
• Error-Detecting codes
• Whenever a message is transmitted, it may get scrambled by
noise or data may get corrupted.
• To avoid this, we use error-detecting codes which are additional
data added to a given digital message to help us detect if an error
occurred during transmission of the message.
• A simple example of error-detecting code is parity check.
• Error-Correcting codes
• Along with error-detecting code, we can also pass some data to
figure out the original message from the corrupt message that we
received. This type of code is called an error-correcting code.
• Error-correcting codes also deploy the same strategy as error-
detecting codes but additionally, such codes also detect the exact
location of the corrupt bit.
Error handling mechanism
• In error detection, we can detect whether there is an error in
the received packet.
• If error found, the receiver will ask for retransmission
• Some techniques
– Redundancy (Data + Data)
– Parity bit (even or odd)
– Cyclic redundancy check
– Checksum
Redundancy
• To detect or correct errors, redundant bits of data must be
added
Parity Checks
• Parity bits are used as the simplest form of error
detecting code.
• If that count is odd, the parity bit value is set to 1, making the
total count of occurrences of 1s in the whole set (including
the parity bit) an even number.
• If the count of 1s in a given set of bits is already even,
the parity bit's value is 0.
Parity Checking of Error Detection
• It is the simplest technique for detecting and correcting errors.
The MSB of an 8-bits word is used as the parity bit and the
remaining 7 bits are used as data or message bits.
• The parity of 8-bits transmitted word can be either even parity or
odd parity.
Parity Checks
• Even parity -- Even parity means the number of 1's in the given word
including the parity bit should be even (2,4,6,....).
• Odd parity -- Odd parity means the number of 1's in the given word
including the parity bit should be odd (1,3,5,....).
Use of Parity Bit
• The parity bit can be set to 0 and 1 depending on the type of the parity
required.
– For even parity, this bit is set to 1 or 0 such that the no. of "1 bits"
in the entire word is even. Shown in fig. (a).
– For odd parity, this bit is set to 1 or 0 such that the no. of "1 bits"
in the entire word is odd. Shown in fig. (b).
Parity Checks
• How Does Error Detection Take Place?
• Parity checking at the receiver can detect the presence of an error if
the parity of the receiver signal is different from the expected parity.
• That means, if it is known that the parity of the transmitted signal is
always going to be "even" and if the received signal has an odd parity,
then the receiver can conclude that the received signal is not correct.
• If an error is detected, then the receiver will ignore the received byte
and request for retransmission of the same byte to the transmitter.
Cyclic Redundancy Checksum (CRC)
• CRC error detection method treats packet of data to
be transmitted as a large polynomial
• Transmitter
– Using polynomial arithmetic, divides polynomial by a
given generating polynomial

• Quotient is discarded
– Remainder is “attached” to the end of message
Cyclic Redundancy Checksum (CRC)
• Message (with the remainder) is transmitted to the
receiver
• Receiver divides the message and remainder by
same generating polynomial
– If a remainder not equal to zero results → error during
transmission
– If a remainder of zero results → no error during
transmission
CRC Encoder/Decoder
CRC - Example
Error Correction
• Two methods
– Retransmission after detecting error
– Forward error correction (FEC)
Forward error correction (FEC)
• Common error correction technique for wireless communication and
satellite communication
• Use hamming distance to detect the error
• Hamming distance measures the bitwise the difference between to
equal length bit-stream
• FEC requires Error Correcting Codes (ECC), i.e a dictionary of code
words at the receiver end.
Forward error correction (FEC)
Forward error correction (FEC)
Checksum Method
• Checksum = check + sum
• Sender side = checksum creation
• Receiver side = checksum validation
Checksum operation at the Sender side
1. Break the original message in to ‘k’ number of
blocks with ‘n’ bits in each block
2. Sum all the ‘k’ data blocks
3. Add the carry to the sum, if any
4. Do 1’s complement to the sum = checksum
Checksum Method (cont …)
Checksum Method (cont …)
• Checksum operation at the receiver side
1. Collect all the data blocks including the checksum
2. Sum all the data blocks and checksum
3. If the result is all 1’s, ACCEPT, else, REJECT!
Checksum Example
• Consider the data unit to be transmitted :
10011001111000100010010010000100
• Step 1: divide the data unit in to 4 blocks
10011001 11100010 00100100 10000100
• Step 2 : sum all the data blocks and the carry if any. Then do the 1’s
complement the result which is the CHECKSUM
Error Control Techniques
• When an error is detected in a message, the receiver sends a request to
the transmitter to retransmit the ill-fated message or packet.
• The most popular retransmission scheme is known as Automatic-
Repeat-Request (ARQ).
• Such schemes, where receiver asks transmitter to re-transmit if it
detects an error, are known as reverse error correction techniques.
• There exist three popular ARQ techniques, as shown in the Fig below.
Stop-and-Wait ARQ
• In Stop-and-Wait ARQ, which is simplest among all protocols, the
sender (say station A) transmits a frame and then waits till it receives
positive acknowledgement (ACK) or negative acknowledgement
(NACK) from the receiver (say station B).
• Station B sends an ACK if the frame is received correctly, otherwise it
sends NACK.
• Station A sends a new frame after receiving ACK; otherwise it
retransmits the old frame, if it receives a NACK.
Stop-and-Wait ARQ (cont …)
• To tackle the problem of a lost or damaged frame, the sender is
equipped with a timer. In case of a lost ACK, the sender transmits the
old frame after the timer expires.
Stop-and-Wait ARQ (cont …)
• To tackle the problem of damaged frames, say a frame that has been
corrupted during the transmission due to noise, there is a concept of
NACK frames, i.e. Negative Acknowledge frames.
• Receiver transmits a NACK frame to the sender if it founds the
received frame to be corrupted.
• When a NACK is received by a transmitter before the time-out, the
old frame is sent again as shown in Fig below.
Stop-and-Wait ARQ (cont …)
• The main advantage of stop-and-wait ARQ is its simplicity.
• It also requires minimum buffer size.
• However, it makes highly inefficient use of communication links,
particularly when ‘a’ is large.
Go-back-N ARQ
• The most popular ARQ protocol is the go-back-N ARQ.
 the sender sends the frames continuously without waiting for
acknowledgement (continuous ARQ)
 As the receiver receives the frames, it keeps on sending ACKs or a
NACK, in case a frame is incorrectly received.
 When the sender receives a NACK, it retransmits the frame in
error plus all the succeeding frames, hence, the name of the
protocol is go-back-N ARQ.
 If a frame is lost,
 the receiver sends NACK after receiving the next frame. In
case there is long delay before sending the NACK, the
sender will resend the lost frame after its timer times out.
 If the ACK frame sent by the receiver is lost,
 the sender resends the frames after its timer times out.
Go-back-N ARQ (cont …)

Frames in error in go-Back-N ARQ


Go-back-N ARQ (cont …)

Lost Frames in Go-Back-N ARQ Lost ACK in Go-Back-N ARQ


Selective-Repeat ARQ
• The selective-repetitive ARQ scheme retransmits only those for which
NACKs are received or for which timer has expired.
• This is the most efficient among the ARQ schemes, but the sender
must be more complex so that it can send out-of-order frames.
• The receiver also must have storage space to store the post-NACK
frames and processing power to reinsert frames in proper sequence.
Example 1
• Problem 1 : A 20 Kbps satellite link has a propagation delay of 400 ms. The
transmitter employs the “go back n ARQ” scheme with n set to 10. Assuming that
each frame is 100 bytes long, what is the maximum data rate possible?
Solution:
• Given- Bandwidth = 20 Kbps, Propagation delay (Tp) = 400 ms, Frame size = 100
bytes, Go back N is used where N = 10
• Transmission delay (Tt) = Frame size / Bandwidth= 100 bytes / 20 Kbps = 40 msec
• a = Tp / Tt = 400 msec / 40 msec = 10
• Efficiency (η) or Utilization(U) = N / (1+2a) = 10 / (1 + 2 x 10)= 10 / 21= 0.476=
47.6 %
• Maximum data rate possible or Throughput = Efficiency x Bandwidth = 0.476 x
20 Kbps = = 9.52 Kbps ≅ 10 Kbps
Example 2
• Problem 1 : A 1 Mbps satellite link connects two ground stations. The altitude of the
satellite is 36504 km and speed of the signal is 3 x 108 m/sec. What should be the packet
size for a channel utilization of 25% for a satellite link using go back 127 sliding
window protocol?
Solution
• Given- Bandwidth = 1 Mbps, Distance = 2 x 36504 km = 73008 km, Propagation speed
= 3 x 108 m/sec, Efficiency = 25% = ¼, Go back N is used where N = 127
• Let the packet size be L bits.
•  Transmission delay (Tt)= Packet size / Bandwidth= L bits / 1 Mbps= L μsec
• Propagation delay (Tp) = Distance / Speed = (73008 x 103 m) / (3 x 108 m/sec) = 24336 x
10-5 sec = 243360 μsec
• a = Tp / Tt = 243360 μsec / L μsec = 243360 / L
• Efficiency (η) = N / (1+2a)
• Substituting the values, we get-
• 1/4 = 127 / (1 + 2 x 243360 / L)
• 1/4 = 127 x L / (L + 486720)
• L + 486720 = 508 x L
• 507 x L = 486720
• L = 960 , therefore, packet size = 960 bits or 120 bytes.
Example 3
• Problem 3 :A channel has a bit rate of 4 Kbps and one way propagation delay of 20
msec. The channel uses stop and wait protocol. The transmission time of the
acknowledgement frame is negligible. To get a channel efficiency of at least 50%,
the minimum frame size should be-
Solution
• Given- Bandwidth = 4 Kbps, Propagation delay (Tp) = 20 msec, Efficiency >= 50%
•  Let the required frame size = L bits.
• Transmission delay (Tt)= Packet size / Bandwidth= L bits / 4 Kbps
•  a = Tp / Tt= 20 msec / ( L bits / 4 Kbps) a = (20 msec x 4 Kbps) / L bits
•  For efficiency to be at least 50%, we must have-
• 1 / 1+2a >= ½ , a <= 1/2
•  Substituting the value of ‘a’, we get-
• (20 msec x 4 Kbps) / L bits <= 1/2
• L bits >= (20 msec x 4 Kbps) x 2
• L bits >= (20 x 10-3 sec x 4 x 103 bits per sec) x 2
• L bits >= 20 x 4 bits x 2
• L >= 160 , From here, frame size must be at least 160 bits.
Example 4
• In SR protocol, suppose frames through 0 to 4 have been transmitted. Now, imagine
that 0 times out, 5 (a new frame) is transmitted, 1 times out, 2 times out and 6
(another new frame) is transmitted. At this point, what will be the outstanding
packets in sender’s window?
• Solution,
• In SR Protocol, only the required frame is retransmitted and not the entire window.
• Step 1: Frames through 0 to 4 have been transmitted- 4 , 3 , 2 , 1 , 0
• Step 2: 0 times out. So, sender retransmits it-0 , 4 , 3 , 2 , 1
• Step 3: 5 (a new frame) is transmitted- 5 , 0 , 4 , 3 , 2 , 1
• Step 4: 1 times out. So, sender retransmits it- 1 , 5 , 0 , 4 , 3 , 2
• Step 5: 2 times out. So, sender retransmits it- 2 , 1 , 5 , 0 , 4 , 3
• Step 6: 6 (another new frame) is transmitted- 6 , 2 , 1 , 5 , 0 , 4 , 3

You might also like