Escolar Documentos
Profissional Documentos
Cultura Documentos
Our goals:
understand principles learn about transport
behind transport layer protocols in the
layer services: Internet:
multiplexing/ UDP: connectionless
demultiplexing transport
reliable data transfer TCP: connection-oriented
transport
flow control
TCP congestion control
congestion control
lo
data link
icg
physical
end systems
al
network
en
data link
d-
send side: breaks app physical network
en
data link
messages into segments,
d
physical
tr
an
passes to network layer network
sp
data link
or
physical
rcv side: reassembles
t
segments into messages, application
transport
passes to app layer network
data link
more than one transport physical
lo
data link
g
flow control
ic
physical
al
network
en
connection setup data link
d-
physical network
en
data link
unreliable, unordered
d
physical
tr
an
delivery: UDP network
sp
data link
or
physical
no-frills extension of
t
“best-effort” IP application
transport
network
services not available: data link
physical
delay guarantees
bandwidth guarantees
application P3 P1
P1 application P2 P4 application
host 2 host 3
host 1
Transport Layer 3-5
How demultiplexing works
host receives IP datagrams
each datagram has source 32 bits
IP address, destination IP
address source port # dest port #
P1 P4 P5 P6 P2 P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
P1 P4 P4
P5 P6 P2 P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
Sender: Receiver:
treat segment contents compute checksum of
as sequence of 16-bit received segment
integers check if computed checksum
checksum: addition (1’s equals checksum field value:
complement sum) of NO - error detected
segment contents with YES - no error detected.
wraparound of carry out
bit
sender puts checksum
value into UDP checksum
field
send receive
side side
sender receiver
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt)
U L/R .008
= = = 0.00027
sender 30.008
RTT + L / R
U L/R .008
= = = 0.00027
sender 30.008
RTT + L / R
Increase utilization
by a factor of 3!
U 3*L/R .024
= = = 0.0008
sender 30.008
RTT + L / R
receiver sees no
difference in two
scenarios!
incorrectly passes
duplicate data as new
in (a)
Q: what relationship
between seq # size
and window size?
Transport Layer 3-45
Sequence Number vs. Window Size
Suppose we use k bits to represent SN
Question: What’s the minimum number of bits k
necessary for a window size of N?
Go-Back-N
Q: For a given expectedSN, what’s the largest possible value for
snd_base?
A: If all the last N ACKs sent by the receiver are received,
snd_base = expectedSN
snd_base=expectedSN expectedSN+N-1
sender
sender’s window
receiver
expectedSN
Transport Layer 3-46
Sequence Number vs. Window Size
Suppose we use k bits to represent SN
Question: What’s the minimum number of bits k
necessary for a window size of N?
Go-Back-N
Q: For a given expectedSN, what’s the smallest possible value for
snd_base?
A: If all the last N ACKs sent by the receiver are not received,
snd_base = expectedSN-N
snd_base=expectedSN-N expectedSN-1
sender
sender’s window
receiver
expectedSN
Transport Layer 3-47
Sequence Number vs. Window Size
Go-Back-N
All SNs in the interval [expectedSN-N,expectedSN+N-1] (an interval
of size 2N) can be received by the receiver. Since the receiver
accepts on the packet with SN=expectedSN, there should be no other
packet within this interval with SN=expectedSN. Therefore,
2k ≥ N+1
snd_base=expectedSN-N expectedSN+N-1
sender
receiver
expectedSN
sender
sender’s window
receiver’s window
receiver
rcv_base rcv_base+N-1
Transport Layer 3-49
Sequence Number vs. Window Size
Suppose we use k bits to represent SN
Question: What’s the minimum number of bits k
necessary for a window size of N?
Selective Repeat
Q: For a given rcv_base, what’s the smallest possible value for
snd_base?
A: If all the last N ACKs sent by the receiver are not received,
snd_base = rcv_base-N (same as Go-Back-N)
snd_base=rcv_base-N rcv_base-1
sender
sender’s window
receiver’s window
receiver
rcv_base rcv_base+N-1
Transport Layer 3-50
Sequence Number vs. Window Size
Selective Repeat
All SNs in the interval [rcv_base-N,rcv_base+N-1] (an interval of size
2N) can be received by the receiver. Since the receiver should be able
to distinguish between all packets in this interval and take
corresponding action, there should be no two packets within this
interval having the same SN. Therefore,
2k ≥ 2N
snd_base=rcv_base-N rcv_base+N-1
sender
receiver’s window
receiver
rcv_base rcv_base+N-1
Transport Layer 3-51
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581
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)
DevRTT = (1-β)*DevRTT +
β*|SampleRTT-EstimatedRTT|
(typically, β = 0.25)
Seq=9 Seq=9
2 , 8 byt 2 , 8 byt
es da es da
ta
Seq=92 timeout
ta Seq=
1 00, 2
0 byt
es da
timeout
ta
=100
A CK 0
10
X C K=
= 120
loss A AC K
Seq=9 Seq=9
2
2 , 8 byt
es da Sendbase , 8 byt
es da
ta
ta = 100
Seq=92 timeout
SendBase
= 120 = 12
0
=100 A CK
A C K
SendBase
= 100 SendBase
= 120 premature timeout
time time
lost ACK scenario
Transport Layer 3-62
TCP retransmission scenarios (more)
Host A Host B
Seq=9
2 , 8 byt
es da
ta
=100
timeout
Seq=1 A C K
0 0, 20
bytes
data
X
loss
SendBase C K =120
A
= 120
time
Cumulative ACK scenario
of sequence seq # x5
ACK x1
segment was ACK x1
ACK x1
received
triple
duplicate ACKs due duplicate
to packet ACKs resen
d seq X
reordering!
2
if window is small
don’t get duplicate timeout
ACKs!
time
Transport Layer 3-66
Fast retransmit algorithm:
speed-matching
service: matching the
send rate to the
receiving app’s drain
rate
app process may be
slow at reading from
buffer
Transport Layer 3-68
TCP Flow control: how it works
Rcvr advertises spare
room by including value
of RcvWin in segments
Sender limits unACKed
data to RcvWin
(Suppose TCP receiver guarantees receive
discards out-of-order buffer doesn’t overflow
segments)
spare room in buffer
= RcvWin
= RcvBuffer-[LastByteRcvd -
LastByteRead]
2K
RcvWin =2048
Sender AckNo=2048
sends 2K
of data 2K SeqNo=2
048
Sender blocked
4K
N o=4 09 6 Rc vWin=0
Ack
3K
o=4 09 6 Rc vWin=1024
AckN
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!
receivers
one router,
Host B unlimited shared
output link buffers
infinite buffers
no retransmission
large delays
when congested
maximum
achievable
throughput
Transport Layer 3-72
Causes/costs of congestion: scenario 2
λout R/3
λout
λout
R/4
a. b. c.
“costs” of congestion:
more work (retrans) for given “goodput”
unneeded retransmissions: link carries multiple copies of pkt
Transport Layer 3-74
Causes/costs of congestion: scenario 3
four senders
Q: what happens as λ
multihop paths in
and λ increase ?
timeout/retransmit in
Host A λout
λin : original data
λ'in : original data, plus
retransmitted data
Host B
H
o
s
t
B
TCP’s
X “sawtooth”
behavior
time
cwnd
rate = bytes/sec
RTT
RTT
cwnd is dynamic, function of
perceived network congestion ACK(s)
RTT
initial rate = 20 kbps
available bandwidth may be >>
two segm
en ts
MSS/RTT
desirable to quickly ramp up to
respectable rate four segm
ents
increase rate exponentially until
first loss event or when threshold
reached
double cwnd every RTT
done by incrementing cwnd by 1
time
for every ACK received
Avoidance
cwnd = 2
cwnd = 3
cwnd = 4
ssthresh = 8
cwnd = 6
cwnd = 7
cwnd = 8
14
12
Cwnd (in segments)
10 ssthresh
8
6
4 cwnd = 9
2
0
0
6
t=
t=
t=
t=
Roundtrip times
cwnd = 10
Transport Layer 3-86
Slow Start / Congestion Avoidance
A typical plot of CongWin for a TCP connection
(MSS = 1500 bytes) with TCP Tahoe:
CA
ssthresh
SS
TCP Reno
ssthresh
ssthresh
TCP Tahoe
Transmission round
SenderWin=min(RcvWin,CongWin)
1.22 ⋅ MSS
RTT L
L = 2·10-10 Wow
new versions of TCP for high-speed
TCP connection 1
bottleneck
TCP
router
connection 2
capacity R
Connection 1 throughput R
timed wait
A CK
FIN, replies with ACK.
Closes connection, sends
FIN.
closed
timed wait
A CK
closed
closed
TCP server
lifecycle
TCP client
lifecycle