Академический Документы
Профессиональный Документы
Культура Документы
Chapter 3: TCP
Dr Ahmad Al-Zubi
Dr Ahmad Al-Zubi1
TCP: Overview
Point-to-point:
one sender, one receiver
Dr Ahmad Al-Zubi2
TCP: Overview
socket
door
a p p lic a tio n
w r ite s d a ta
a p p lic a t io n
re a d s d a ta
TCP
s e n d b u ffe r
TC P
r e c e iv e b u f f e r
socket
door
segm ent
Dr Ahmad Al-Zubi3
TCP: Overview
Full duplex data:
bi-directional data flow in same connection
MSS: maximum segment size
Connection-oriented:
handshaking (exchange of control msgs)
inits sender, receiver state before data
exchange
Dr Ahmad Al-Zubi4
source port #
dest port #
sequence number
acknowledgement number
head not
U AP R S F
len used
checksum
counting
by bytes
of data
(not segments!)
# bytes
rcvr willing
to accept
application
data
(variable length)
Dr Ahmad Al-Zubi5
Dr Ahmad Al-Zubi6
Host A
User
types
C
Seq=4
2, AC
79
Seq=
host ACKs
receipt
of echoed
C
Seq=4
K=79,
d
ata =
C
, data
3
4
=
, AC K
3, ACK
= C
host ACKs
receipt of
C, echoes
back C
=80
Dr Ahmad Al-Zubi7
Sequence Numbers
CRC or Checksum
ACKs
NAKs,
SACKs
Bitmaps
Retransmissions
Packets
FEC information
Dr Ahmad Al-Zubi8
Dr Ahmad Al-Zubi9
wait
wait
for
for
event
event
Dr Ahmad Al-Zubi
10
TCP:
reliable
data
transfer (II)
Simplified
TCP
sender
King Saud University -
Dr Ahmad Al-Zubi
11
Dr Ahmad Al-Zubi
12
2, 8 b
ytes d
ata
=100
K
C
A
loss
Seq=9
2, 8
bytes
data
Seq=
100,
8 byte
s data
20 by
t es d
at a
0
10
=
K
20
AC CK=1
A
Seq=9
2, 8 b
ytes d
ata
0
=12
K
AC
=100
ACK
time
Host B
Seq=9
2,
Seq=100 timeout
Seq=92 timeout
Seq=9
timeout
Host A
Host B
time
premature timeout,
cumulative ACKs
Dr Ahmad Al-Zubi
13
receiver: explicitly
informs sender of
free buffer space
RcvWindow field
in TCP segment
sender: keeps the
amount of
transmitted,
unACKed data less
than most recently
received
RcvWindow
receiver buffering
Dr Ahmad Al-Zubi
14
Dr Ahmad Al-Zubi
15
Chebyshevs Theorem:
MaxRTT = Avg RTT + k*Deviation
Error probability is less than 1/(k**2)
Result true for ANY distribution of
samples
King Saud University -
Dr Ahmad Al-Zubi
16
Dr Ahmad Al-Zubi
17
Dr Ahmad Al-Zubi
18
Dr Ahmad Al-Zubi
19
Dr Ahmad Al-Zubi
20
Dr Ahmad Al-Zubi
21
client
server
FIN
ACK
close
timed wait
FIN
ACK
closed
Dr Ahmad Al-Zubi
22
Connection
closed.
Dr Ahmad Al-Zubi
23
Dr Ahmad Al-Zubi
24
Dr Ahmad Al-Zubi
25
Dr Ahmad Al-Zubi
26
A
B
statistical multiplexing
1.5 Mbs
queue of packets
waiting for output
link
45 Mbs
Dr Ahmad Al-Zubi
27
The
Congestion Problem
outstrips
available capacity
Problem: demand
1
Demand
Capacity
Dr Ahmad Al-Zubi
28
Dr Ahmad Al-Zubi
29
No buffer
Too late
SS
SS
SS
SS
SS
SS
SS
SS
Dr Ahmad Al-Zubi
30
C
D
Dr Ahmad Al-Zubi
31
Dr Ahmad Al-Zubi
32
Causes/costs of congestion:
scenario 1
two senders, two
receivers
one router,
infinite buffers
no
retransmission
large delays
when congested
maximum
achievable
throughput
Dr Ahmad Al-Zubi
33
Causes/costs of congestion:
scenario 2
one router, finite buffers
sender retransmission of lost packet
Dr Ahmad Al-Zubi
34
Causes/costs of congestion:
scenario 2 (continued)
Costs of congestion:
More work (retrans) for given goodput
Unneeded retransmissions: link carries
multiple copies of pkt due to spurious
timeouts
King Saud University -
Dr Ahmad Al-Zubi
35
Causes/costs of congestion:
scenario 3
Dr Ahmad Al-Zubi
36
Approaches towards
congestion control - 1
Two broad approaches towards
congestion control:
Dr Ahmad Al-Zubi
37
Approaches towards
congestion control - 2
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
King Saud University -
Dr Ahmad Al-Zubi
38
Dr Ahmad Al-Zubi
39
w * MSS
RTT
Bytes/sec
Dr Ahmad Al-Zubi
40
Policy:
Increase Congwin until loss (congestion)
Loss => decrease Congwin, then begin
probing (increasing) again
King Saud University -
Dr Ahmad Al-Zubi
41
Additive Increase/Multiplicative
Decrease (AIMD) Policy
For stability:
rate-of-decrease > rate-of-increase
Decrease performed enough times as long as congestion exists
AIMD policy satisfies this condition, provided packet loss is
congestion indicator
window
time
King Saud University -
Dr Ahmad Al-Zubi
42
Fairness
Fairness goal: if N TCP sessions
share same bottleneck link, each
should get 1/N of link capacity
TCP connection 1
TCP
connection 2
bottleneck
router
capacity R
Dr Ahmad Al-Zubi
43
Fairness Analysis
Dr Ahmad Al-Zubi
44
Dr Ahmad Al-Zubi
45
Important variables:
Congwin
threshold: defines threshold between two
slow start phase, congestion avoidance
phase
Dr Ahmad Al-Zubi
46
TCP Slowstart - 1
Slowstart algorithm
initialize: Congwin = 1
for (each segment ACKed)
Congwin++
until (loss event OR
CongWin > threshold)
Dr Ahmad Al-Zubi
47
TCP Slowstart - 2
RTT
asdf
Host A
Host B
one segm
en
two segm
ents
four segm
ents
time
Dr Ahmad Al-Zubi
48
TCP Dynamics
1st RTT
2nd RTT
3rd RTT
4th RTT
10 Mbps
Router
Dr Ahmad Al-Zubi
49
Dr Ahmad Al-Zubi
51
Congestion
Window
(cwnd)
Timeout
Receiver Window
Idle
Interval
ssthresh
1
Time (units of RTTs)
Dr Ahmad Al-Zubi
52
Dr Ahmad Al-Zubi
53
Dr Ahmad Al-Zubi
54
Dr Ahmad Al-Zubi
55
Dr Ahmad Al-Zubi
56
K = O/WS
Dr Ahmad Al-Zubi
57
P
Latency 2 RTT P RTT (2 1)
R
R
R
Dr Ahmad Al-Zubi
58
Dr Ahmad Al-Zubi
59
Example:
re q u e s t
o b je c t
O/S = 15 segments
f ir s t w in d o w
= 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
Server stalls P=2 times.
c o m p le t e
t r a n s m is s io n
o b je c t
d e liv e r e d
t im e a t
c lie n t
t im e a t
s e rv e r
Dr Ahmad Al-Zubi
60
k 1
S
time to transmit the kth window
R
S
k 1 S
R RTT 2 R
Dr Ahmad Al-Zubi
61
Dr Ahmad Al-Zubi
62
Sample Results
R
Minimum Latency:
O/R + 2 RTT
O/R
28 Kbps
28.6 sec
28.8 sec
28.9 sec
100 Kbps
8 sec
8.2 sec
8.4 sec
1 Mbps
800
msec
1 sec
1.5 sec
10 Mbps
80 msec
0.28 sec
0.98 sec
Dr Ahmad Al-Zubi
63
Summary: Chapter 3
Dr Ahmad Al-Zubi
64