PPT - cs.Virginia

TCP III - Error Control
TCP Error Control
1
ARQ Error Control
• Two types of errors:
– Lost packets
– Damaged packets
• Most Error Control techniques are based on:
1. Error Detection Scheme (Parity checks, CRC).
2. Retransmission Scheme.
• Error control schemes that involve error detection and
retransmission of lost or corrupted packets are referred to as
Automatic Repeat Request (ARQ) error control.
2
Background: ARQ Error Control
• The most common ARQ retransmission schemes:
– Stop-and-Wait ARQ
– Go-Back-N ARQ
– Selective Repeat ARQ
• The protocol for sending ACKs in all ARQ protocols are based
on the sliding window flow control scheme
• TCP uses a version of the Go-Back-N Protocol
3
Background: Go-Back-N ARQ
• Go-Back-N sends cumulative acknowledgments
Timeout for Packet 2
Packets 2,3,4,5
are
retransmitted
A
loss
B
4
Retransmissions in TCP
•
A TCP sender retransmits a segment when it assumes that
the segment has been lost:
1. No ACK has been received and a timeout occurs
2. Multiple ACKs have been received for the same segment
5
Receiving duplicate ACKs
1K SeqNo=0
• If three or more duplicate
ACKs are received in a row,
the TCP sender believes that
a segment has been lost.
• Then TCP performs a
retransmission of what seems
to be the missing segment,
without waiting for a timeout to
happen.
AckNo=1024
1K SeqNo=1
024
1K SeqNo=2
048
1. duplicate
1K SeqNo=3
072
2. duplicate
AckNo=1024
1K SeqNo=4
096
3. duplicate
• This can fix losses of single
segments
AckNo=1024
AckNo=1024
1K SeqNo=1
024
1K SeqNo=5
120
6
Retransmission Timer
•
•
TCP sender maintains one retransmission timer for each
connection
When the timer reaches the retransmission timeout (RTO)
value, the sender retransmits the first segment that has not
been acknowledged
•
The timer is started when
1. When a packet with payload is transmitted and timer is not running
2. When an ACK arrives that acknowledges new data,
3. When a segment is retransmitted
•
The timer is stopped when
– All segments are acknowledged
7
How to set the timer
• Retransmission Timer:
– The setting of the retransmission timer is crucial for good
performance of TCP
– Timeout value too small  results in unnecessary
retransmissions
– Timeout value too large  long waiting time before a
retransmission can be issued
– A problem is that the delays in the network are not fixed
– Therefore, the retransmission timers must be adaptive
8
Setting the value of RTO:
• The RTO value is set based on round-trip time (RTT)
measurements that each TCP performs
ent 1
Segment 2
Segment 3
ACK for S
egment 2
Segment
RTT #3
• Figure on the right shows three
RTT measurements
ACK for Segm
RTT #2
• There is only one measurement
ongoing at any time (i.e.,
measurements do not overlap)
Segment 1
RTT #1
• Each TCP connection measures
the time difference between the
transmission of a segment and
the receipt of the corresponding
ACK
ACK for S
egment 4
ACK for S
egment 5
+3
Segme
5
nt 4
9
Setting the RTO value
• RTO is calculated based on the RTT measurements
– Uses an exponential moving average to calculate
estimators for delay (srtt) and variance of delay (rttvar)
from
• The RTT measurements are smoothed by the following
estimators srtt and rttvar:
srttn+1 = a RTT + (1- a ) srttn
rttvarn+1 = b ( | RTT - srttn | ) + (1- b ) rttvarn
RTOn+1 = srttn+1 + 4 rttvarn+1
– The gains are set to a =1/4 and b =1/8
10
Setting the RTO value (cont’d)
• Initial value for RTO:
– Sender should set the initial value of RTO to
RTO0 = 3 seconds
• RTO calculation after first RTT measurements arrived
srtt1 = RTT
rttvar1 = RTT / 2
RTO1 = srtt1 + 4 rttvarn+1
• When a timeout occurs, the RTO value is doubled
RTOn+1 = max ( 2 RTOn, 64) seconds
This is called an exponential backoff
11
Karn’s Algorithm
Timeout !
RTT ?
 RTT measurements is ambiguous in
this case
segme
RTT ?
If an ACK for a retransmitted segment is
received, the sender cannot tell if the
ACK belongs to the original or the
retransmission.
nt
retransm
ission
of segm
ent
ACK
Karn’s Algorithm:
• Don’t update RTT on any segments that have been
retransmitted
• Restart RTT measurements only after an ACK is received
for a segment that is not retransmitted
12
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
ACK
Segm en
t1
Segm
ent 2
Segm
ent 3
S eg
fo r
ACK t 4
m en
RTT #2
Seg
2
4
me
nt 6
me
m en
.
nt 5
S eg
Seg
gm ent
3
t4
or Se
ACK f
t1
2
gm en
RTT #1
.
.
fo r
A C K ent 3
m
Seg
or Se
ACK f
1
SYN
CK
SYN + A
0
RTO Calculation: Example
RTT #3
13
TCP Retransmission Timer
• Retransmission Timer:
– The setting of the retransmission timer is crucial for
efficiency
– Timeout value too small  results in unnecessary
retransmissions
– Timeout value too large  long waiting time before a
retransmission can be issued
– A problem is that the delays in the network are not fixed
– Therefore, the retransmission timers must be adaptive
14
Round-Trip Time Measurements
• The retransmission mechanism of TCP is adaptive
• The retransmission timers are set based on round-trip time
(RTT) measurements that TCP performs
Segment 1
RTT #1
ent 1
Segment 2
Segment 3
RTT #2
ACK for S
egment 2
Segment
RTT #3
The RTT is based on time difference
between segment transmission and
ACK
But:
TCP does not ACK each
segment
Each connection has only one
timer
ACK for Segm
ACK for S
egment 4
ACK for S
egment 5
+3
Segme
5
nt 4
15
Round-Trip Time Measurements
• Retransmission timer is set to a Retransmission Timeout
(RTO) value.
• RTO is calculated based on the RTT measurements.
• The RTT measurements are smoothed by the following
estimators srtt and rttvar:
srttn+1 = a RTT + (1- a ) srttn
rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn
RTOn+1 = srttn+1 + 4 rttvarn+1
• The gains are set to a =1/4 and b =1/8
• srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1
16
Karn’s Algorithm
segme
Timeout !
RTT ?
RTT ?
• If an ACK for a retransmitted
segment is received, the sender
cannot tell if the ACK belongs to
the original or the
retransmission.
nt
retransm
ission
of segm
ent
ACK
Karn’s Algorithm:
Don’t update srtt on any segments that have been retransmitted.
Each time when TCP retransmits, it sets:
RTOn+1 = max ( 2 RTOn, 64)
(exponential backoff)
17
Measuring TCP Retransmission Timers
argon.tcpip-lab.edu
("Argon")
neon.tcpip-lab.edu
("Neon")
Transfer file
Web client
Web server
• Transfer file from Argon to neonn
• Unplug Ethernet of Argon cable in the middle of file transfer
18
Interpreting the Measurements
600
500
400
Seconds
• The interval between
retransmission attempts in
seconds is:
1.03, 3, 6, 12, 24, 48, 64,
64, 64, 64, 64, 64, 64.
• Time between retransmissions is doubled each
time (Exponential Backoff
Algorithm)
• Timer is not increased
beyond 64 seconds
• TCP gives up after 13th
attempt and 9 minutes.
300
200
100
0
0
2
4
6
8 10
Transmission Attempts
12
19