ECSE-4670: Computer Communication Networks (CCN)
ECSE-4670: Computer Communication Networks (CCN)
Chapter 3: TCP
Shivkumar Kalyanaraman: [email protected]
Biplab Sikdar: [email protected]
ACKs:
– seq # of next byte expected from other side
– cumulative ACK
host ACKs
receipt Seq=4
of echoed 3, ACK
=80
‘C’
wait
wait
event: timer timeout for • no flow, congestion
segment with seq # y
for
for
retransmit segment
control
event
event
TCP:
08 pass segment to IP
09 nextseqnum = nextseqnum + length(data)
10 event: timer timeout for segment with sequence number y
11 retransmit segment with sequence number y
reliable
12 compute new timeout interval for segment y
13 restart timer for sequence number y
14 event: ACK received, with ACK field value of y
15 if (y > sendbase) { /* cumulative ACK of all data up to y */
16 cancel all timers for segments with sequence numbers < y
data 17
18
19
sendbase = y
}
else { /* a duplicate ACK for already ACKed segment */
20 increment number of duplicate ACKs received for y
transfer (II) 21
22
23
24
if (number of duplicate ACKS received for y == 3) {
/* TCP fast retransmit */
resend segment with sequence number y
restart timer for segment y
25 }
26 } /* end of loop forever */
Simplified
TCP
sender
Seq=9 Seq=9
2, 8 byte 2, 8 bytes
s data d ata
Seq=92 timeout
Seq=
100,
20 by
t es d
Seq=100 timeout
at a
timeout
CK=100
A 0
10
X K=
AC CK=1
20
loss A
Seq=9 Seq=9
2, 8 b 2, 8 b
y tes da y tes da
ta ta
0
=12
=100 AC
K
ACK
time time
lost ACK scenario premature timeout,
cumulative ACKs
Rensselaer Polytechnic Institute © Shivkumar Kalvanaraman & © Biplab Sikdar 13
TCP Flow Control
flow control receiver: explicitly
sender won’t overrun informs sender of
receiver’s buffers by free buffer space
transmitting too much,
– RcvWindow field
too fast
in TCP segment
RcvBuffer = size or TCP Receive Buffer sender: keeps the
RcvWindow = amount of spare room in Buffer
amount of
transmitted,
unACKed data less
than most recently
received
RcvWindow
receiver buffering
Rensselaer Polytechnic Institute © Shivkumar Kalvanaraman & © Biplab Sikdar 14
Timeout and RTT Estimation
• Timeout: for robust detection of
packet loss
• Problem: How long should timeout
be ?
– Too long => underutilization
– Too short => wasteful
retransmissions
– Solution: adaptive timeout: based on
estimate of max RTT
Rensselaer Polytechnic Institute © Shivkumar Kalvanaraman & © Biplab Sikdar 15
How to estimate max RTT?
• RTT = prop + queuing delay
– Queuing delay highly variable
– So, different samples of RTTs will give
different random values of queuing delay
• Chebyshev’s Theorem:
– MaxRTT = Avg RTT + k*Deviation
– Error probability is less than 1/(k**2)
– Result true for ANY distribution of
samples
Closing a connection:
client closes socket: clientSocket.close();
close
FIN
ACK
close
FIN
timed wait
ACK
closed
d
Rensselaer Polytechnic Institute © Shivkumar Kalvanaraman & © Biplab Sikdar 22
TCP Connection Management - 5
1.5 Mbs
B
queue of packets 45 Mbs
waiting for output
link
D E
Cost: self-descriptive header per-packet,
buffering and delays for applications.
Need to either reserve resources or
dynamically detect/adapt to overload for stability
Rensselaer Polytechnic Institute © Shivkumar Kalvanaraman & © Biplab Sikdar 27
The
Congestion Problem
i i
•Problem: demand
outstrips
available capacity
1
Demand Capacity
n
• If information about i , and is
known in a central location where
control of i or can be effected
with zero time delays,
– the congestion problem is solved!
Rensselaer Polytechnic Institute © Shivkumar Kalvanaraman & © Biplab Sikdar 28
The Congestion Problem
(Continued)
• Problems:
– Incomplete information (eg: loss
indications)
– Distributed solution required
– Congestion and control/measurement
locations different
– Time-varying, heterogeneous time-
delay
SS SS SS SS SS SS SS SS
File Transfer time = 5 mins File Transfer Time = 7 hours
Rensselaer Polytechnic Institute © Shivkumar Kalvanaraman & © Biplab Sikdar
The Congestion Problem
(Continued)
• c) Processors become cheap
(fast routers & switches)
A C
S
B D
Scenario: All links 1 Gb/s.
A & B send to C
=> “high-speed” congestion!!
(lose more packets faster!)
Rensselaer Polytechnic Institute © Shivkumar Kalvanaraman & © Biplab Sikdar
Principles of Congestion Control
Congestion:
• informally: “too many sources sending too
much data too fast for network to handle”
• different from flow control (receiver overload)!
• manifestations:
– lost packets (buffer overflow at routers)
– long delays (queuing in router buffers)
• a top-10 problem!
“Costs” of congestion:
• More work (retrans) for given “goodput”
• Unneeded retransmissions: link carries
multiple copies of pkt due to spurious
timeouts
Rensselaer Polytechnic Institute © Shivkumar Kalvanaraman & © Biplab Sikdar 35
Causes/costs of congestion:
scenario 3
Network-assisted congestion
control:
• routers provide feedback to end
systems
– single bit indicating congestion
(SNA, DECbit, TCP/IP ECN, ATM)
– explicit rate sender should send at
window
bottleneck
TCP
router
connection 2
capacity R
one segm
en t
RTT
two segm
en ts
four segm
ents
time
Receiver Window
Congestion Timeout
Window ssthresh Idle
(cwnd) Interval
1
Time (units of RTTs)
Notation, assumptions:
• Assume one link between client and
server of rate R
• Assume: fixed congestion window, W
segments
• S: MSS (bits)
• O: object size (bits)
• no retransmissions (no loss, no
corruption)
K = O/WS
R R R
P min{Q, K 1}
Example:
re q u e s t
o b je c t
f ir s t w in d o w
O/S = 15 segments
= S /R
RTT
s e c o n d w in d o w
= 2 S /R
K = 4 windows t h ir d w in d o w
= 4 S /R
Q=2
f o u r t h w in d o w
= 8 S /R
P = min{K-1,Q} = 2
c o m p le t e
o b je c t
Server stalls P=2 times. d e liv e r e d
t r a n s m is s io n
t im e a t
t im e a t s e rv e r
c lie n t
k 1 S
2 time to transmit the kth window
R
S k 1 S
R RTT 2 R stall time after the kth window
P
O
latency 2 RTT stallTime p
R p 1
P
O S k 1 S
2 RTT [ RTT 2 ]
R k 1 R R
O S S
2 RTT P[ RTT ] (2 1)
P
R R R