Академический Документы
Профессиональный Документы
Культура Документы
1
TCP seq. #’s and ACKs
Seq. #’s
Host A Host B
❍ sequence number of
first byte in User Seq=4
2, AC
types K=79,
segment’s data ‘C’
d ata =
‘C’
ACKs host ACKs
receipt of
❍ seq # of next byte ta = ‘C’ ‘C’, echoes
3, da
expected from other q=79, A
CK=4 back ‘C’
S e
side
❍ cumulative ACK host ACKs
Q: how receiver handles receipt Seq=4
of echoed 3, ACK
out-of-order segments? ‘C’
=80
2
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)*EstimatedRTT + α*SampleRTT
350
300
250
RTT (milliseconds)
200
150
100
1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106
time (seconnds)
3
TCP Round Trip Time and Timeout
Setting the timeout
❒ EstimatedRTT plus “safety margin”
❍ large variation in EstimatedRTT -> larger safety margin
❒ first estimate how much SampleRTT deviates from
EstimatedRTT:
DevRTT = (1-β)*DevRTT +
β*|SampleRTT-EstimatedRTT|
(typically, β = 0.25)
4
Sliding Window Protocol
At the sender, a will be referred to as
SendBase, and s as NextSeqNum
P1
0 1 2 a–1 a s–1 s
Sender
acknowledged unacknowledged
next expected r + RW – 1
Sink: received
P2
0 1 2 r
Receiver
delivered receive window
5
NextSeqNum = InitialSeqNum
SendBase = InitialSeqNum
Seq=9 Seq=9
2, 8 b 2, 8 b
yte s data ytes d
Seq= ata
Seq=92 timeout
100,
20 by
tes d
ata
timeout
=1 00
ACK 0
10
X K=
AC ACK=
120
loss
Seq=9 Sendbase Seq=9
2, 8 b 2, 8 b
yte s data = 100 yte s data
reset timer
Seq=92 timeout
SendBase
= 120 20
K=1
=100 Stop timer AC
ACK
SendBase
= 100 SendBase
= 120 premature timeout
time time
lost ACK scenario
3b: Transport Layer 12
2/4/05 (SSL)
6
TCP retransmission scenarios (more)
Host A Host B
Seq=9
2, 8 b
yte s data
=100
timeout
Seq=1 ACK
0 0, 20
bytes
data
X
loss
SendBase =120
ACK
= 120
Stop timer
time
Cumulative ACK scenario
7
Fast Retransmit
❒ Time-out period often ❒ If sender receives 3
relatively long: ACKs for the same
❍ long delay before data, it assumes that
resending lost packet segment after ACKed
❒ Detect lost segments data was lost:
via duplicate ACKs. ❍ fast retransmit: resend
❍ Sender often sends segment before timer
many segments back-to- expires
back
❍ If segment is lost,
there will likely be many
duplicate ACKs.
8
TCP Flow Control
flow control receiver: explicitly
sender won’t overrun informs sender of
receiver’s buffers by (dynamically changing)
transmitting too much, amount of free buffer
too fast space
❍ RcvWindow field in
TCP segment
9
TCP Connection Management (cont.)
timed wait
ACK
Then closes connection,
sends FIN.
closed
ACK
Note: protocol spec allows
simultaneous FINs closed
closed
10
TCP Connection Management (cont)
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!
11
Causes/costs of congestion
12
TCP Congestion Control
❒ end-to-end control (no network How does sender
assistance) determine CongWin?
❒ sender limits transmission: ❒ loss event = timeout or
LastByteSent-LastByteAcked 3 duplicate acks
≤ CongWin ❒ TCP sender reduces
❒ Roughly, CongWin after loss
CongWin event
send rate ≤ bytes/sec
RTT three mechanisms:
slow start
where CongWin is in bytes ❍
❍ AIMD
❍ reduce to 1 segment
after timeout event
(Note: Consider RcvWindow size to be very large
such that send window size is equal to CongWin)
3b: Transport Layer 25
2/4/05 (SSL)
13
TCP Slow Start (more)
❒ When connection Host A Host B
begins, increase rate
exponentially until one segm
ent
first loss event or
RTT
“threshold” two segm
ents
❍ double CongWin every
RTT
❍ done by incrementing
four segm
CongWin by 1 MSS for ents
every ACK received
❒ Summary: initial rate
is slow but ramps up
exponentially fast time
Refinement (more)
Q: If no loss, when
should the exponential
increase switch to 14
TCP
linear?
congestion window size
12 Reno
A: When CongWin gets 10
(segments)
to current value of 8
threshold 6
4 threshold
2 TCP
Tahoe
Implementation: 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
❒ Variable threshold
Transmission round
❒ At loss event, threshold is set
to 1/2 of CongWin just Series1 Series2
before loss event
(Note: For simplicity, CongWin is in
❒ For initial slow start,
number of segments in the above graph.)
threshold is set to a very
large value (e.g., 65 Kbytes)
3b: Transport Layer 28
2/4/05 (SSL)
14
Rationale for Reno’s Fast Recovery
❒ After 3 dup ACKs:
24 Kbytes
16 Kbytes
8 Kbytes
time
Long-lived TCP connection
3b: Transport Layer 30
2/4/05 (SSL)
15
TCP sender congestion control
Event State TCP Sender Action Comments
ACK receipt Slow Start CongWin = CongWin + MSS, Resulting in a doubling of
for previously (SS) If (CongWin > Threshold) CongWin every RTT
unacked set state to “Congestion
data Avoidance”
ACK receipt Congestion CongWin = CongWin+ Additive increase, resulting
for previously Avoidance MSS * (MSS/CongWin) in increase of CongWin by
unacked (CA) 1 MSS every RTT
data
Loss event SS or CA Threshold = CongWin/2, Fast recovery,
detected by CongWin = Threshold, implementing multiplicative
triple Set state to “Congestion decrease. CongWin will not
duplicate Avoidance” drop below 1 MSS.
ACK
Timeout SS or CA Threshold = CongWin/2, Enter slow start
CongWin = 1 MSS,
Set state to “Slow Start”
Duplicate SS or CA Increment duplicate ACK count CongWin and Threshold not
ACK for segment being acked changed
16
TCP Fairness
Fairness goal: if K TCP sessions share same
bottleneck link of bandwidth R, each should have
average rate of R/K (AIMD only provides convergence
to same window size, not necessarily same throughput rate)
TCP connection 1
bottleneck
TCP
router
connection 2
capacity R
17
Fairness (more)
Fairness and UDP Fairness and parallel TCP
❒ Multimedia apps often
connections
do not use TCP ❒ nothing prevents app from
❍ do not want rate opening parallel connections
throttled by congestion between 2 hosts.
control ❒ Web browsers do this
❒ Instead use UDP: ❒ Example: link of rate R
❍ pump audio/video at supporting 9 connections
constant rate, tolerate
packet loss ❍ new app asks for 1 TCP, gets
rate R/10
❒ Research area: TCP ❍ new app asks for 11 TCPs, gets
friendly congestion more than R/2 !
control
18