You are on page 1of 10

1

1
TCP III - Error Control
TCP Error Control
2
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
3
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
4
Background: Go-Back-N ARQ
P
a
c
k
e
t

0
Go-Back-N sends cumulative acknowledgments
A
B
P
a
c
k
e
t

1
A
C
K

1
P
a
c
k
e
t

3
P
a
c
k
e
t

4
P
a
c
k
e
t

2
P
a
c
k
e
t

3
Packets 2,3,4,5
are
retransmitted
A
C
K

2
P
a
c
k
e
t

2
loss
P
a
c
k
e
t

5
P
a
c
k
e
t

4
A
C
K

1
A
C
K

1
A
C
K

1
Timeout for Packet 2
A
C
K

3
A
C
K

4
A
C
K

5
P
a
c
k
e
t

5
A
C
K

6
3
5
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
6
Receiving duplicate ACKs
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.
This can fix losses of single
segments
1K SeqNo=0
AckNo=1024
AckNo=1024
1K SeqNo=1024
SeqNo=2048
1K
AckNo=1024
SeqNo=3072
1K
SeqNo=4096
1K
1. duplicate
2. duplicate
AckNo=1024
SeqNo=1024
1K
SeqNo=5120
1K
3. duplicate
4
7
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
8
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
5
9
Setting the value of RTO:
The RTO value is set based on round-trip time (RTT)
measurements that each TCP performs
Segment 1
Segment 4
ACK for Segment 1
Segment 2
Segment 3
ACK for Segment 2 + 3
Segment 5
ACK for Segment 4
ACK for Segment 5
R
T
T

#
1
R
T
T

#
2
R
T
T

#
3
Each TCP connection measures
the time difference between the
transmission of a segment and
the receipt of the corresponding
ACK
There is only one measurement
ongoing at any time (i.e.,
measurements do not overlap)
Figure on the right shows three
RTT measurements
10
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:
srtt
n+1
= RTT + (1- ) srtt
n
rttvar
n+1
= ( | RTT - srtt
n
| ) + (1- ) rttvar
n
RTO
n+1
= srtt
n+1
+ 4 rttvar
n+1
The gains are set to =1/4 and =1/8
6
11
Setting the RTO value (contd)
Initial value for RTO:
Sender should set the initial value of RTO to
RTO
0
= 3 seconds
RTO calculation after first RTT measurements arrived
srtt
1
= RTT
rttvar
1
= RTT / 2
RTO
1
= srtt
1
+ 4 rttvar
n+1
When a timeout occurs, the RTO value is doubled
RTO
n+1
= max ( 2 RTO
n
, 64) seconds
This is called an exponential backoff
12
Karns Algorithm
segm
ent
A
C
K
retransmission
of segment
Timeout !
R
T
T


?
R
T
T


?
Karns Algorithm:
Dont 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
If an ACK for a retransmitted segment is
received, the sender cannot tell if the
ACK belongs to the original or the
retransmission.
RTT measurements is ambiguous in
this case
7
13
RTO Calculation: Example
RTT #1 RTT #3
S
e
g
m
e
n
t

1
A
C
K

f
o
r

S
e
g
m
e
n
t

1
S
Y
N
S
Y
N

+

A
C
K
S
e
g
m
e
n
t

2
S
e
g
m
e
n
t

3
A
C
K

f
o
r

S
e
g
m
e
n
t

2
A
C
K

f
o
r
S
e
g
m
e
n
t

3
RTT #2
S
e
g
m
e
n
t

4






.
S
e
g
m
e
n
t

5













.
S
e
g
m
e
n
t

6








.
A
C
K

f
o
r
S
e
g
m
e
n
t

4
A
C
K
12 034578 69
1
0
1
1
1
2
1
3
1
4
1
5
1
7
1
8
1
6
1
9
2
0
2
1
2
3
2
4
2
2
14
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
8
15
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
Segment 4
ACK for Segment 1
Segment 2
Segment 3
ACK for Segment 2 + 3
Segment 5
ACK for Segment 4
ACK for Segment 5
R
T
T

#
1
R
T
T

#
2
R
T
T

#
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
16
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:
srtt
n+1
= RTT + (1- ) srtt
n
rttvar
n+1
= ( | RTT - srtt
n+1
| ) + (1- ) rttvar
n
RTO
n+1
= srtt
n+1
+ 4 rttvar
n+1
The gains are set to =1/4 and =1/8
srtt
0
= 0 sec, rttvar
0
= 3 sec, Also: RTO
1
= srtt
1
+ 2 rttvar
1
9
17
Karns Algorithm
If an ACK for a retransmitted
segment is received, the sender
cannot tell if the ACK belongs to
the original or the
retransmission.
segm
ent
A
C
K
retransmission
of segment
Timeout !
R
T
T


?
R
T
T


?
Karns Algorithm:
Dont update srtt on any segments that have been retransmitted.
Each time when TCP retransmits, it sets:
RTO
n+1
= max ( 2 RTO
n
, 64) (exponential backoff)
18
Measuring TCP Retransmission Timers
Transfer file from Argon to neonn
Unplug Ethernet of Argon cable in the middle of file transfer
10
19
Interpreting the Measurements
The interval between
retransmission attempts in
seconds is:
1.03, 3, 6, 12, 24, 48, 64,
64, 64, 64, 64, 64, 64.
Time between retrans-
missions is doubled each
time (Exponential Backoff
Algorithm)
Timer is not increased
beyond 64 seconds
TCP gives up after 13th
attempt and 9 minutes.
0
100
200
300
400
500
600
S
e
c
o
n
d
s
0 2 4 6 8 10 12
Transmission Attempts

You might also like