error control tanenbaum 3.1.3 other references 6/3/2015design and analysis of computer networks...
Post on 19-Dec-2015
215 views
TRANSCRIPT
Error Control
Tanenbaum 3.1.3
Other references
04/18/23 Design and Analysis of Computer Networks Error Control 2
Error Control
• What? Technique(s) used to enable reliable delivery of data to a destination.
• Why? Signal may get corrupted and packets may be disappear
• How?
04/18/23 Design and Analysis of Computer Networks Error Control 3
Review of OSI Reference ModelApplication Application
Presentation Presentation
Interface Interface
Session Session
Interface Interface
Transport Transport
Interface Interface
Protocol
Protocol
Protocol
Protocol
Interface Interface
Interface Interface
Network Network
Link Link
Interface Interface
Phys. Phys
InterfaceInterfaceLink Link
InterfaceInterface
Phys. Phys
NetworkNetwork
User/Client User/Server
04/18/23 Design and Analysis of Computer Networks Error Control 4
Types of Errors• Bit corruption: one or multiple bits in a frame are corrupted (0 flipped
to 1, or 1 flipped to 0) during transmission. Results in packet corruption. Bit error rate (BER) very low on terrestrial links. Derive relationship between BER and packet error rate PER (assuming a packet with n bits).
• Packet error: loss (due to congestion), duplication, or reordering
It is also the probability that no bit in a frame is corrupted (1-BER)N
What is the probability that a packet is not corrupted? 1-PER
Then 1-PER = (1-BER)N PER = 1-(1-BER)N
~~ N.BER if BER very small
04/18/23 Design and Analysis of Computer Networks Error Control 5
Error Control (Where?)
• Link Layer (point-to-point)– Point-to-point protocol (PPP) (Detection only)
– High-level Data Link Control (HDLC) (AQM protocol)
• Transport Layer (end-to-end)– User Datagram Protocol (UDP) (Detection only)
– Transmission Control Protocol (TCP) (AQM)
04/18/23 Design and Analysis of Computer Networks Error Control 6
Main Strategies
• Error Detection and retransmission: data is encoded such that errors can be detected. When an error occurs, sender must retransmit the packet
• Error Correction: data is encoded such that errors are detected and corrected with no retransmission.
04/18/23 Design and Analysis of Computer Networks Error Control 7
Error Detection
• Consider a word w to be sent• To detect corrupted bits on w at receiver, we need to
add some check bits, forming a codeword cw• Example: let the word w=‘01100001’ to be sent, we could
add a check bit equal to 0 if the total number of bit in the word is even. Check bit is 1 otherwise.
• Such check bit is called a parity bit, codeword would be cw=‘011000011’
04/18/23 Design and Analysis of Computer Networks Error Control 8
Error Detection (General)
• Consider an alphabet of words {wi}
w0 000a0 corrupted
w1 001
a2 corrupted
w4 100
a1 corrupted
w2 010
a2a1a0
w0 000w1 001w2 010w3 011w4 100w5 101w6 110w7 111
Words
04/18/23 Design and Analysis of Computer Networks Error Control 9
Error Detection (General)
• Consider an alphabet of words {wi}
a2a1a0
w0 000w1 001w2 010w3 011w4 100w5 101w6 110w7 111
Codeword
c1c0
0001111010110100
Checkbits
Hamming Distance (wi,wj) is thethe number of bits by which wi and wj
differ.
Smallest Hamming distance for thisencoding scheme is 2
(c1=a2+a1 and c0=a1+a0)
04/18/23 Design and Analysis of Computer Networks Error Control 10
Requirements for Detection or Correction
• To detect d corrupted bits, the encoding scheme needs to have a minimal hamming distance of d+1
• To correct d corrupted bits, the encoding scheme needs to have a minimal hamming distance of 2.d+1
04/18/23 Design and Analysis of Computer Networks Error Control 11
Constraints on Generating Check bits
• We need to generate the smallest number of check bits and obtain the highest hamming distance between codewords.
• How to generate check bits under such constraints?
04/18/23 Design and Analysis of Computer Networks Error Control 12
Examples
• Cyclic Redundancy Check (CRC)
• BCH (Bose-Chaudhury-Hocquenghem) codes
• Reed-Solomon code
• Turbo codes
• Convolutional codes
04/18/23 Design and Analysis of Computer Networks Error Control 13
Error Correction or Error Detection?
• Consider a frame of n bits to be sent– To be able to detect up to k corrupted bits, we
need to add m bits.
– To be able to detect and correct up to k corrupted bits, we need m’ bits.
m’ > m
04/18/23 Design and Analysis of Computer Networks Error Control 14
Error Correction or Error Detection? (Cont’d)
• Consider a channel on which packet error rate is p such that there are never more than k corrupted bits per frame sent.
• If we use error detection only, each frame has size n+m
• If we use error correction, each frame has size n+m’ m’ > m
04/18/23 Design and Analysis of Computer Networks Error Control 15
Error Correction or Error Detection? (Cont’d)
• If we use error correction, a packet is always successfully received. So, the cost of sending each packet and is equal to the time it takes to send (n+m’) bits. Denote this time as T(n+m’).
• If we use error detection, the packet must be resent whenever the packet gets corrupted. Suppose that the penalty to resend a packet is equal to A. The penalty A includes the time to realize that the packet is lost. How much time does it take to send successfully a packet when using error detection?
04/18/23 Design and Analysis of Computer Networks Error Control 16
Error Correction or Error Detection? (Cont’d)
• We are trying to answer the question: how much time does it take to send successfully a packet when using error detection?
• We can in fact derive the expected time it would take to send successfully a packet when using error detection.
The time is :1) T(n+m) if successful the first time with probability (1-p)2) 2.T(n+m)+A if successful the second time with probability p.(1-p)3) 3.T(n+m)+2.A) if successful the third time with probability p2.(1-p)4) …………………………….5) i.(T(n+m)+ (i-1).A) if successful the ith time with probability pi-1.(1-p)
• The expected time is (T(n+m)+ p.A)/(1-p)
04/18/23 Design and Analysis of Computer Networks Error Control 17
Error Correction or Error Detection? (Cont’d)
• Recall that expected time is (T(n+m)+ p.A)/(1-p) with error detection and the time is T(n+m’) with error correction.
• If p is small, the expected cost becomes T(n+m) + p.A. The answer relies on whether p.A compensates the extra bits due to m’
• If p is not small, error correction becomes more interesting
• Sometimes, we just cannot afford to retransmit (for example real audio), then error correction is necessary!
04/18/23 Design and Analysis of Computer Networks Error Control 18
Retransmission Protocols
• Stop and wait protocol (SWP)
• Alternating Bit Protocol (ABP)
• Selective repeat protocol (SRP)
• Go back n (GBN)
04/18/23 Design and Analysis of Computer Networks Error Control 19
Characteristics of Retransmission Protocols
• Correctness: A retransmission protocol is correct if it delivers exactly one correct copy of each packet
• Efficiency: it is the largest fraction of the channel capacity that the retransmission protocol “consumes”. Called also “link utilization”.
04/18/23 Design and Analysis of Computer Networks Error Control 20
Correctness of SWP
• Operation of SWP:– Whenever a receiver gets a correct packet, it sends
back an acknowledgment (without sequence #).– The sender resends a packet previously sent if it did
not get an acknowledgement from the receiver within a known bound To (Timeout value)
– Sender, alternately, numbers the packets with 0 or 1.
04/18/23 Design and Analysis of Computer Networks Error Control 21
Correctness: Finite State Machine
• List all possible states of the system
• List all events leading to transitions from state to state
• Check the sequences of transitions
04/18/23 Design and Analysis of Computer Networks Error Control 22
SWP Correctness
• We have a sender S and a receiver R• What are the possible states for such protocol?• A state can be summarized by a couple (x,y):
– X is the sequence number on the last packet sent
– Y is the sequence number that the receiver is waiting for (0 initially).
04/18/23 Design and Analysis of Computer Networks Error Control 23
SWP Correctness (2)
Start S sends 0S(0) (S sends a new packet 0)
0,0
0 lostS sends copy of 0
R gets 0R(0) (R receives a new packet 0) 0,1
Ack 0 lost
S gets ACK 0S send 1
1,1
Last sequence number sent
Sequence number expected by receiver
R(1)R gets 1
S(1)
1,0
1 lostS sends copy of 1Ack 1 lost
S gets ACK 1S send 0 S(0)
04/18/23 Design and Analysis of Computer Networks Error Control 24
SWP Efficiency
• Case 1: Analysis with loss error. No packet is lost
• Case 2: We assume a packet error rate PER
04/18/23 Design and Analysis of Computer Networks Error Control 25
Simplified Model
Sender Receiver
Bandwidth
Propagation delay
Speed of beltSpeed of loading
04/18/23 Design and Analysis of Computer Networks Error Control 26
Bandwidth vs Propagation Delay
• Bandwidth: the number of bits sent or received per unit time. This is a measure of the time it takes to put a given number on the wire.
• Propagation delay: time it takes the first bit to travel from the source to the destination. This parameter is related to and limited by the speed of light.
04/18/23 Design and Analysis of Computer Networks Error Control 27
Examples
• Consider a T1 line from Seattle to Miami:– Bandwidth=1.5 Mbits/s– Propagation delay is about 70ms
• Consider Ethernet in CSSE department:– Bandwidth=?– Propagation delay=?
04/18/23 Design and Analysis of Computer Networks Error Control 28
Analysis• What are the values we are interested in?
– 1) Throughput = Amount of data flowing from sender to receiver per unit time
– How to compute that?– Bw: bandwidth in bits/s (given), Tp=Propagation delay in s (given), – S= Size of frame in bits (given) Ct= Computing time negligible
– Tr = transmission time of a frame = S/Bw– Ta = transmission of an ack = Sa/Bw
timeSenderTr
Receiver TpCt
Ta
Tp
Time 0 T
Tr
TpCt
Ta
Tp
T
Tr
04/18/23 Design and Analysis of Computer Networks Error Control 29
Analysis (cont’d)• Between the time the sender starts sending a
segment and the time the ack is received, a time T elapses.
• This time T= Tp + Tr + Ct + 1/B + Tp• If we neglect the processing time Ct and 1/B, the
time T becomesT = Tp + Tr + Tp = 2.Tp + Tr
timeSenderTr
Receiver TpCt
Ta
Tp
Tr
TpCt
Ta
Tp
T
04/18/23 Design and Analysis of Computer Networks Error Control 30
Analysis (cont’d)• Conclusion: every cycle T, we send one segment.
Therefore we send one segment per T, then the throughput = 1/(2.Tp+Tr) (in frames per sec)
• Tr = Frame size / Bandwidth
timeSenderTr
Receiver TpCt
Ta
Tp
Tr
TpCt
Ta
Tp
T
04/18/23 Design and Analysis of Computer Networks Error Control 31
Is Stop-And-Wait Efficient? Example
• Frame size = S = 100 bits, Bw = 1.5 Mbits/s• Tr = Frame size / Bandwidth = S/Bw = 100 / 1.5 Mbits/s= 66.67 s• Throughput=1/T = 1/(2.Tp+Tr) =1/(2*50ms + 66.67 s) which is about 1
frame per 100ms = 10 pkts/second• Line rate (bandwidth in frames per seconds) = 1/Tr• Efficiency is by definition equal to (Throughput)/(Line rate) = (1/T) / (1/Tr) • In this case, the efficiecy 10 / [1/66 10-6]• Therefore …Efficiency = 660 10-6 = 0.00066 = 0.066 %
Sender Receiver
Bandwidth = 1.5 Mbps
Propagation delay =50ms
04/18/23 Design and Analysis of Computer Networks Error Control 32
Where Is the Problem?
• The throughput achieved uses 0.067% of the available bandwidth when there are no losses. Efficiency is here 0.067%
• What is the efficiency when there are losses?
04/18/23 Design and Analysis of Computer Networks Error Control 33
Keys Facts about SWP
• Propagation delay in critical
• Even, if bandwidth is infinite
• i.e., Tr = 0
Throughput (in packets/second) = 1
2.Tp + Tr
04/18/23 Design and Analysis of Computer Networks Error Control 34
Case 2: Efficiency in Presence of Errors
Sender
Receiver
T (if successful)
#n+1#n
• Let X = random variable representing the duration of a cycle (time between two different frames)
• We have to compute E(X): the expected value of X
#n
To (when unsuccessful)
04/18/23 Design and Analysis of Computer Networks Error Control 35
Case 2: Efficiency in Presence of Errors (2)
• We can say:– 1) When successful, X = T
– 2) When unsucessful, X = To + Y, where Y is a random variable representing the time it would take before we send the (n+1)th frame
• Based on above, we can say:– X = T with probability (1-PER) (PER= Packet Error Rate)
– X = To + Y with probability PER
• What is E(X), the expected value of X?
Sender
Receiver
#n
T (if successful)
#n+1 #n
To (when unsuccessful)
04/18/23 Design and Analysis of Computer Networks Error Control 36
Case 2: Efficiency in Presence of Errors (3)
• Recall that:– X = T with probability (1-PER) (PER= Packet Error Rate)
– X = To + Y with probability PER
• By definition of E(X):– E(X) = (1-PER).T + PER.(To + E(Y))
• But, what is E(Y)?
Sender
Receiver
#n
T (if successful)
#n+1 #n
To (when unsuccessful)
04/18/23 Design and Analysis of Computer Networks Error Control 37
Case 2: Efficiency in Presence of Errors (4)
• Recall that by definition of E(X):– E(X) = (1-PER).T + PER.(To + E(Y))
• But, what is E(Y)? Recall that Y is the time until we send the next frame. Then E(Y) is also the expected length of the cycle.
• Then, E(Y) = E(X)• Then, E(X) = (1-PER).T + PER.(To + E(X))• We just have to solve for E(X)
Sender
Receiver
#n
T (if successful)
#n+1 #n
To (when unsuccessful)
04/18/23 Design and Analysis of Computer Networks Error Control 38
Case 2: Efficiency in Presence of Errors (5)
• Recall, E(X) = (1-PER).T + PER.(To + E(X))
• Solving for E(X):
• E(X) = T + [To . PER/(1-PER)]
• In words, the average cycle is E(X).
• In other words, we send one frame per E(X)
Sender
Receiver
#n
T (if successful)
#n+1 #n
E(X) (on average)
04/18/23 Design and Analysis of Computer Networks Error Control 39
Case 2: Efficiency in Presence of Errors (6)
• Recall, we send one frame every E(X) = T + [To . PER/(1-PER)]
• Throughput is then equal to 1/E(X) . (in frames per second)• The efficiency is by definition Throughput/ Line Rate.• The efficiency is then (1/E(X)) / (1/Tr) • The efficiency is then Tr/E(X) = Tr/(T + [To . PER/(1-PER)])• If we replace T with its value (slide # 29), I.e., T= 2. Tp + Tr
• The efficiency is Tr/E(X) = Tr/(2.Tp + Tr + [To . PER/(1-PER)])
Sender
Receiver
#n
T (if successful)
#n+1 #n
E(X) (on average)
Tr
04/18/23 Design and Analysis of Computer Networks Error Control 40
Example: Efficiency in Presence of Errors (7)
• Frame size = S = 1500 bytes, Bw = 1.5 Mbits/s, Tp = 50ms
• What is Tr ?
• Let us discuss the value of the time out To
• Let PER = 10-2.
• What is the efficiency ?
• Recall that the efficiency is Tr/E(X) = Tr/(2.Tp + Tr + [To . PER/(1-PER)])
Sender
Receiver
#n
T (if successful)
#n+1 #n
E(X) (on average)
Tr
04/18/23 Design and Analysis of Computer Networks Error Control 41
Impact of PER on SWP
• Frame size = S = 1500 bytes, Bw = 1.5 Mbits/s, Tp = 50ms
• Tr = S/Bw = 8 ms
• Let To = 2.T = 2. (2.Tp+Tr) = 216 ms
• Recall that the efficiency is Tr/E(X) = Tr/(2.Tp + Tr + [To . PER/(1-PER)])
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0 0.2 0.4 0.6 0.8 1 1.2
Series1
04/18/23 Design and Analysis of Computer Networks Error Control 42
Impact of Frame Size on SWP
• Frame size = S = variable, Bw = 1.5 Mbits/s, Tp = 50ms, PER = 1% = 0.01
• Tr = S/Bw = 8 ms
• Let To = 2.T = 2. (2.Tp+Tr) = 216 ms
• Recall that the efficiency is Tr/E(X) = Tr/(2.Tp + Tr + [To . PER/(1-PER)])
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0 100000 200000 300000 400000 500000 600000
Packet Size (Bits)
Eff
icie
ncy
Series1
04/18/23 Design and Analysis of Computer Networks Error Control 43
True Picture Impact of Frame Size on SWP
• PER depends on packet size for a given BER, as PER = 1-(1-BER)S
• Frame size = S = variable, Bw = 1.5 Mbits/s, Tp = 50ms,BER = 5.10-6
• Tr = S/Bw = 8 ms• Let To = 2.T = 2. (2.Tp+Tr) = 216 ms• Recall that the efficiency is Tr/E(X) = Tr/(2.Tp + Tr + [To . PER/(1-PER)])
0
0.05
0.1
0.15
0.2
0.25
0 100000 200000 300000 400000 500000 600000
Packet Size (Bits)
Eff
icie
ncy
Series1
04/18/23 Design and Analysis of Computer Networks Error Control 44
Alternating Bit Protocol (ABP)
• We do not know the bound To (Timeout value).
• If the bound is not known, we may confuse acknowledgements (is ack for new packet, or for some OLD packet thought lost).
• What to do?
• Put sequence numbers on acks
04/18/23 Design and Analysis of Computer Networks Error Control 45
Alternating Bit Protocol (ABP)
• Correctness: ABP can be shown to be correct is acks are numbered (0,1).
• Efficiency: same efficiency as SWP
04/18/23 Design and Analysis of Computer Networks Error Control 46
Sliding Window Protocol
• Keep sending packets without waiting for acknowledgements.
• How many packets should be outstanding without ack?
• The number of oustanding frames is the window size W
timeSender
Receiver
0 1 2 3
S=0
ack=0
S=1 S=2 S=3 S=4 S=5 S=6
4 5 6 7
ack=1 ack=2 ack=3 ack=0 ack=0
04/18/23 Design and Analysis of Computer Networks Error Control 47
Window Principle (Maintained by the Sender)
Sequencenumber
Sent andacked
34 35 36 37 38 39 40 45 46 47 48 49 50…...
Sent, notacked
May be sentif data available
Cannot besent
Window Size = W = 7 (advertised by receiver or limited by network conditions)
04/18/23 Design and Analysis of Computer Networks Error Control 48
Go Back N
• If packet # i is not acked, the sender will resend all packets starting packet # i.
• We are using a window of W=4 frames
Sender
Receiver
0 1 2 3
To (Timeout)
1 2 30
Discarded
0
04/18/23 Design and Analysis of Computer Networks Error Control 49
Speeding Up Go Back N
• Use negative acknowledgments
Sender
Receiver
0 1 2 3
To (Timeout)
1 2 30 0
NAK
04/18/23 Design and Analysis of Computer Networks Error Control 50
Go Back N• Correctness: proof is made by induction starting
with ABP
• Efficiency:
• Without error E= min(1, W.Tr/T)
• Weakness: wasteful retransmissions
Sender
Receiver
0 1 2 3To (Timeout)
1 2 30 0
04/18/23 Design and Analysis of Computer Networks Error Control 51
Selective Repeat Protocol• Only packets not acknowledged are resent.
• Efficiency:
• Without error E= min(1, W.Tr/T)
• Efficiency with errors will be studied later
04/18/23 Design and Analysis of Computer Networks Error Control 52
Conclusion
• SWP is not efficient when propagation delay is high
• Sliding window protocols are needed on path with high propagation delat
• SRP is the best, but requires larger buffers than Go Back N.
• PER is critical to performance
• Frame size has an impact of performance