chapter3b
chapter3b
2581
data 06
07
create TCP segment with sequence number nextseqnum
start timer for segment nextseqnum
08 pass segment to IP
transfer 09
10
nextseqnum = nextseqnum + length(data)
event: timer timeout for segment with sequence number y
11 retransmit segment with sequence number y
12 compue new timeout interval for segment y
Simplified 13 restart timer for sequence number y
14 event: ACK received, with ACK field value of y
TCP 15 if (y > sendbase) { /* cumulative ACK of all data up to y */
sender 16 cancel all timers for segments with sequence numbers < y
17 sendbase = y
18 }
19 else { /* a duplicate ACK for already ACKed segment */
20 increment number of duplicate ACKs received for y
21 if (number of duplicate ACKS received for y == 3) {
22 /* TCP fast retransmit */
23 resend segment with sequence number y
24 restart timer for segment y
25 }
26 } /* end of loop forever */
3: Transport Layer 3b-5
TCP ACK generation [RFC 1122, RFC
2581]
Seq=9 Seq=9
2, 8 b 2, 8 b
y t es d y t es d
at a
Seq=92 timeout
at a Seq=
100,
20 b y
t es d
Seq=100 timeout
timeout
ata
100
A CK=
0
10
X CK
A AC
=
K =120
loss
Seq=9 Seq=9
2, 8 b 2, 8 b
y t es d y t es d
at a at a
=1 20
K
=10 0 AC
ACK
time time
lost ACK scenario premature timeout,
cumulative ACKs
receiver buffering
3: Transport Layer 3b-8
TCP Round Trip Time and
Timeout
Q: how to set TCP Q: how to estimate RTT?
timeout value? SampleRTT: measured time
longer than RTT from segment transmission
until ACK receipt
note: RTT will vary
ignore retransmissions,
too short: premature
cumulatively ACKed
timeout
segments
unnecessary
SampleRTT will vary, want
retransmissions
estimated RTT “smoother”
too long: slow
use several recent
reaction to segment
measurements, not just
loss
current SampleRTT
timed wait
ACK
replies with ACK. Closes
connection, sends FIN.
closed
closed
TCP server
lifecycle
TCP client
lifecycle
Congestion:
informally: “too many sources sending too
much data too fast for network to handle”
different from flow control!
manifestations:
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem!
large delays
when congested
maximum
achievable
throughput
“costs” of congestion:
more work (retrans) for given “goodput”
unneeded retransmissions: link carries multiple copies of
pkt 3: Transport Layer 3b-18
Causes/costs of congestion: scenario
3
four senders
Q: what happens as
multihop paths in
and
timeout/retransmit in
increase ?
Congwin
RTT
initialize: Congwin = 1
for (each segment ACKed) two segm
en ts
Congwin++
until (loss event OR
four segm
CongWin > threshold) ents
Connection 1 throughput R
O S S
Latency 2 RTT P RTT ( 2 P 1)
R R R
P min{Q, K 1}
K = 4 windows R TT
second w indow
= 2S /R
Q=2
third w indow
= 4S /R
P = min{K-1,Q} = 2
com plete
object transm ission
delivered
tim e at
tim e at server
client
S
2k 1 time to transmit the kth window request
R object
first w indow
= S /R
S k 1 S
R TT
second w indow
P
O
latency 2 RTT stallTime p
fourth w indow
= 8S /R
R p 1
P
O S S
2 RTT [ RTT 2k 1 ]
R k 1 R R object
com plete
transm ission
delivered
O S S
2 RTT P[ RTT ] ( 2 P 1) tim e at
tim e at
server
R R R client