Chapter Seven Error - &flow - Control - Mechanisms
Chapter Seven Error - &flow - Control - Mechanisms
Chapter Seven Error - &flow - Control - Mechanisms
• 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 …)