UNIT I Error Correction Method - Extra

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 9

CS2363 Computer Networks - Anna University Academic Year 2011-2012

Error Correction method


Error Correction can be handled in two ways.
One is when an error is discovered; the receiver can ask the sender to retransmit the entire data unit.
This is known as retransmission.
In the other, receiver can use an error-correcting code, which automatically corrects certain errors. One of
the techniques is Hamming code.
For correcting an error one has to know the exact position of error, i.e. exactly which bit is in error? To
this, we have to add some additional redundant bits. To calculate the numbers of redundant bits (r)
required to correct m data bits, we must find out the relationship between the two. With m bits of data
and r bit of redundancy added to them, the length of the resulting code is m+r.
To find the number of redundancy bit for a m data bits, the following formulae is used:
2r >= m+r+1
For example, if the value of m is 7, the r value can satisfy this equation is 4:
24 >= 7+4+1
The following table shows some possible m values and the corresponding r values.

Also, it is important to know the locations of the r bits in the m bits data. The r bits are placed in position
1,2,4,8, (power of 2). Suppose if m =7, then r must be 4 bits and total number of bits becomes
11(m+r), in which the r bits are placed in the locations 1, 2, 4, and 8 as shown below

KCG College of Technology, Karapakkam, Chennai

CS2363 Computer Networks - Anna University Academic Year 2011-2012


In a 7 bit data unit, the combinations of locations used to calculate r values are as follows:
The algorithm is as follows Hamming Codes r value calculated from the given data set:
1.
2.
3.
4.
5.

Number the bits starting from 1: bit 1, 2, 3, 4, 5, etc.


Write the bit numbers in binary. 1, 10, 11, 100, 101, etc.
All bit positions that are powers of two (have only one 1 bit in the binary form of their
position) are parity bits.
All other bit positions, with two or more 1 bits in the binary form of their position, are
data bits.
Each data bit is included in a unique set of 2 or more parity bits, as determined by the
binary form of its bit position.
1. Parity bit 1 covers all bit positions which have the least significant bit set: bit 1
(the parity bit itself), 3, 5, 7, 9, etc.
2. Parity bit 2 covers all bit positions which have the second least significant bit
set: bit 2 (the parity bit itself), 3, 6, 7, 10, 11, etc.
3. Parity bit 4 covers all bit positions which have the third least significant bit set:
bits 47, 1215, 2023, etc.
4. Parity bit 8 covers all bit positions which have the fourth least significant bit
set: bits 815, 2431, 4047, etc.
5. In general each parity bit covers all bits where the binary AND of the parity
position and the bit position is non-zero.

0001 0011 0101 0111 1001 1011 least significant bit must be 1 from the given data set:
r1:
1,3,5,7,9,11 locations
0010 0011 0110 0111 1010 1011 second least significant bit must be 1 from the given data set:
r2:
2, 3,6,7,10,11 locations
0100 0101 0110
r4:
1000 1001 1010
r8:

0111 Third least significant bit must be 1 from the given data set:
4,5,6,7 locations
1011 Fourth least significant bit must be 1 from the given data set:
8, 9, 10, 11 locations

Calculating r values
1. We place r bits in its appropriate location in the m+r length data unit.
2. We calculate the even parities for the various bit combinations
For example,

KCG College of Technology, Karapakkam, Chennai

CS2363 Computer Networks - Anna University Academic Year 2011-2012

KCG College of Technology, Karapakkam, Chennai

CS2363 Computer Networks - Anna University Academic Year 2011-2012

KCG College of Technology, Karapakkam, Chennai

CS2363 Computer Networks - Anna University Academic Year 2011-2012


Link Level Protocol : Reliable Transmission
Even when error-correcting codes are used some errors will be too severe to be corrected. As a result,
some corrupt frames must be discarded. A link-level protocol that wants to deliver frames reliably must
somehow recover from these discarded (lost) frames.
This is usually accomplished using a combination of two fundamental mechanisms
1. acknowledgments
2. timeouts

An acknowledgment (ACK for short) is a small control frame that a protocol sends back to its
peer saying that it has received an earlier frame. By control frame we mean a header without any
data.

If the sender does not receive an acknowledgment after a reasonable amount of time, then it
retransmits the original frame. This action of waiting a reasonable amount of time is called a
timeout.
Piggybacking: To improve the use of network bandwidth, an acknowledgment method known as
piggybacking is often used. In piggybacking, instead of sending a separate acknowledgment frame, the
receiver waits until it has data frame to send to the sender and embeds the acknowledgment in that data
frame.
Thus the link bandwidth can be utilized better also it increases the speed of data transmission.
Propagation delay is defined as the delay between transmission and receipt of packets between hosts.
Propagation delay can be used to estimate timeout period
The general strategy of using acknowledgments and timeouts to implement reliable delivery is sometimes
called automatic repeat request (ARQ).
There are four different ARQ algorithms:
Stop-and-Wait ARQ
Sliding Window ARQ
Go back N ARQ
Selective Repeat ARQ

Stop and Wait ARQ

Sender doesnt send next frame until hes sure receiver has last packet
The data frame/Ack. Frame sequence enables reliability. They are sequenced alternatively 0 and
1
Sequence numbers help avoid problem of duplicate frames
If the sender does not receive an acknowledgment after a reasonable amount of time, then it
retransmits the original frame
The sender also starts retransmission when the timeout occurs.

KCG College of Technology, Karapakkam, Chennai

CS2363 Computer Networks - Anna University Academic Year 2011-2012

a) Normal operation b) The Original frame is lost c) The ACK is lost d) Timeout occurs
Disadvantage

The link capacity can not be utilized effectively since only one data frame or ACK frame can e
sent at a time

Sliding Window Algorithm


The sliding window algorithm works as follows:
1.

The sender assigns a sequence number, denoted SeqNum, to each frame.

2.

The sender maintains three variables:


a. SWS denotes the send window size, gives the upper bound on the number of
outstanding (unacknowledged) frames that the sender can transmit;

KCG College of Technology, Karapakkam, Chennai

CS2363 Computer Networks - Anna University Academic Year 2011-2012


b.
c.
3.

LAR denotes the sequence number of the last acknowledgment received; and
LFS denotes the sequence number of the last frame sent.

The sender maintains the following invariant:


LFS LAR SWS
This situation is illustrated in below figure

When an acknowledgment arrives, the sender moves LAR to the right, thereby allowing
the sender to transmit another frame.

The sender associates a timer with each frame it transmits, and it retransmits the frame
should the timer expire before an ACK is received.

4.

The receiver maintains the following three variables:


a. RWS denotes the receive window size, gives the upper bound on the number of out-oforder frames that the receiver is willing to accept;
b. LAF denotes the sequence number of the largest acceptable frame;
c. LFR denotes the sequence number of the last frame received.

5.

The receiver also maintains the following invariant:


LAF LFR RWS

6.

if LFR<SeqNum<-LFA, then the corresponding SeqNum frame is accepted

7.

if SeqNum<=LFR or SeqNum > LFA, then the correspong SeqNum frame is discarded
This situation is illustrated in below figure

KCG College of Technology, Karapakkam, Chennai

CS2363 Computer Networks - Anna University Academic Year 2011-2012

Operation:
The sender window denotes the frames that have been transmitted but remain unacknowledged.
This window can vary in size, from empty to the entire range.
The receiver window size is fixed. A receiver window size of 1 means that frames must be received in
transmission order. Larger window sizes allow the receiver to receive as many frames out of order.
When a frame with sequence number SeqNum arrives, the receiver takes the following action.
a.

If SeqNum LFR or SeqNum > LAF,


then the frame is outside the receivers window and it is discarded.

b.

If LFR < SeqNum LAF,


then the frame is within the receivers window and it is accepted.

c.

It then sets LFR = SeqNumToAck and adjusts LAF = LFR + RWS.

The following figure illustrates the operation of sliding window.

The receiver can set RWS to whatever it wants.


Two common settings are:
1.
2.

RWS = 1, implies that the receiver will not buffer any frames that arrive out of order
RWS = SWS implies that the receiver can buffer any of the frames the sender transmits.

It is no sense to set RWS > SWS since its impossible for more than SWS frames to arrive out of order.
Advantages

KCG College of Technology, Karapakkam, Chennai

CS2363 Computer Networks - Anna University Academic Year 2011-2012

Reliable transmission: The algorithm can be used to reliably deliver messages across an
unreliable network
Frame Order: The sliding window algorithm can serve is to preserve the order in which frames
are transmitted. Since each frame has a sequence number.
Flow control: The receiver not only acknowledges frames it has received, but also informs the
sender of how many frames it has room to receive
The link capacity can be utilized effectively since multiple frames can be transmitted at a time

Selective Repeat ARQ:


Upon encountering a faulty frame, the receiver requests the retransmission of that specific frame.
Since additional frames may have followed the faulty frame, the receiver needs to be able to temporarily
store these frames until it has received a corrected version of the faulty frame, so that frame order is
maintained.
Go Back N ARQ:
A simpler method, Go-Back-N, involves the transmitter requesting the retransmission of the
faulty frame as well as all succeeding frames (i.e., all frames transmitted after the faulty frame).
Advantages
o

The advantage of Selective Reject over Go-Back-N is that it leads to better throughput, because
only the erroneous frames are retransmitted.

Go-Back-N has the advantage of being simpler to implement and requiring less memory.

KCG College of Technology, Karapakkam, Chennai

You might also like