Chapter 3
Chapter 3
Transport Layer
lo
processes running on
gi
ca
different hosts
enl
transport protocols run in
d-
en
end systems
d
tr
send side: breaks app
a ns
po
messages into segments,
tr
passes to network layer applicatio
rcv side: reassembles n
transport
segments into messages, network
data link
passes to app layer physical
lo
data link
network
gi
physical
data link
ca
flow control physical
l en
connection setup
d-
en
unreliable, unordered network
d
data link
tr
a
physicalnetwork
delivery: UDP
ns
data link
po
physical
r
no-frills extension of
t
network
data link
applicatio
“best-effort” IP physical network
data link
n
transport
services not available: physical network
data link
physical
delay guarantees
bandwidth guarantees
P3 P1
P1 P2 P4 application
application application
host 2 host 3
host 1
Transport Layer 3-8
How demultiplexing works
host receives IP datagrams
each datagram has source IP
address, destination IP address 32 bits
each datagram carries 1
source port # dest port #
transport-layer segment
each segment has source,
destination port number other header fields
host uses IP addresses & port
numbers to direct segment to
appropriate socket
application
data
(message)
P2 P1
P1
P3
P1 P4 P5 P6 P2 P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
P1 P4 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:
NO - error detected
complement sum) of
segment contents YES - no error detected.
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
Transport Layer 3-19
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-
services oriented transport:
3.2 Multiplexing and TCP
demultiplexing segment structure
3.3 Connectionless
reliable data transfer
flow control
transport: UDP
connection
3.4 Principles of
management
reliable data transfer 3.6 Principles of
congestion control
3.7 TCP congestion
control
Transport Layer 3-20
Principles of Reliable data
transfer
important in app., transport, link layers
top-10 list of important networking topics!
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)
extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt)
L 8000bits
d trans 9 8 microseconds
R 10 bps
U sender : utilization – fraction of time sender busy sending
L/ R .008
U = = = 0.00027
sender 30.008
RTT +L / R microsec
1KB pkt every 30 msec -> 33kB/sec thruput over 1 Gbps link onds
network protocol limits use of physical resources!
L/ R .008
U = = = 0.00027
sender 30.008
RTT +L / R microsec
onds
Increase utilization
by a factor of 3!
3*L/ R .024
U = = = 0.0008
sender 30.008
RTT +L / R microsecon
ds
Transport Layer 3-44
Pipelining Protocols
Go-back-N: overview Selective Repeat:
sender: up to N overview
unACKed pkts in sender: up to N
pipeline unACKed packets in
receiver: only sends pipeline
cumulative ACKs receiver: ACKs individual
doesn’t ACK pkt if pkts
there’s a gap sender: maintains timer
sender: has timer for for each unACKed pkt
oldest unACKed pkt if timer expires:
if timer expires: retransmit only unACKed
retransmit all packet
unACKed packets
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-54
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-
services oriented transport:
3.2 Multiplexing and TCP
demultiplexing segment structure
3.3 Connectionless
reliable data transfer
flow control
transport: UDP
connection
3.4 Principles of
management
reliable data transfer 3.6 Principles of
congestion control
3.7 TCP congestion
control
Transport Layer 3-55
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)
loop (forever) {
TCP
switch(event)
sender
event: data received from application above
create TCP segment with sequence number NextSeqNum
(simplified
if (timer currently not running) )
start timer
pass segment to IP
Comment:
NextSeqNum = NextSeqNum + length(data)
• SendBase-1: last
event: timer timeout cumulatively
retransmit not-yet-acknowledged segment with ACKed byte
smallest sequence number Example:
start timer • SendBase-1 = 71;
y= 73, so the rcvr
event: ACK received, with ACK field value of y wants 73+ ;
if (y > SendBase) {
y > SendBase, so
SendBase = y
if (there are currently not-yet-acknowledged segments)
that new data is
start timer ACKed
}
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
timeout
ata
=100
ACK 0
10
X CK
A AC
=
K =120
loss
Seq=9 Seq=9
2, 8 b 2, 8 b
y t es d Sendbase y t es d
at a
at a
Seq=92 timeout
= 100
SendBase
= 120 =1 20
K
CK =100 AC
A
SendBase
= 100 SendBase
= 120 premature timeout
time time
lost ACK scenario
Transport Layer 3-67
TCP retransmission scenarios
(more)
Host A Host B
Seq=9
2, 8 b
y t es d
at a
=100
timeout
Seq=1 A CK
00 , 2 0
b y t es
dat a
X
loss
SendBase CK =120
A
= 120
time
Cumulative ACK scenario
seq # x1
seq # x2
seq # x3
ACK x1
seq # x4 X
seq # x5
ACK x1
ACK x1
ACK x1
triple
duplicate
ACKs re s e n
d s eq
X2
timeout
time
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!
infinite buffers
no
retransmission
large delays
when congested
maximum
achievable
throughput
R/3
out
out
out
R/4
a. b. c.
“costs” of congestion:
more work (retrans) for given “goodput”
unneeded retransmissions: link carries multiple copies of pkt
Host B
H
o
s
t
B
decentralized: each TCP sender sets its own rate, based on implicit feedback:
ACK: segment received (a good thing!), network not congested, so increase sending
rate
lost segment: assume loss due to congested network, so decrease sending rate
X
TCP’s
X “sawtooth”
behavior
time
cwnd
rate = bytes/sec
RTT
cwnd is dynamic, function of perceived
RTT
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
increase rate exponentially ents
until first loss event or when
threshold reached
double cwnd every RTT
done by incrementing cwnd
time
by 1 for every ACK received
duplicate ACK
dupACKcount++ new ACK
cwnd = cwnd+MSS
dupACKcount = 0
transmit new segment(s),as allowed
cwnd = 1 MSS
ssthresh = 64 KB cwnd > ssthresh
dupACKcount = 0
slow congestion
start timeout avoidance
ssthresh = cwnd/2
cwnd = 1 MSS
dupACKcount = 0
timeout
retransmit missing segment
ssthresh = cwnd/2
cwnd = 1 MSS
dupACKcount = 0
retransmit missing segment
duplicate ACK
dupACKcount++ new ACK
new ACK
.
cwnd = cwnd + MSS (MSS/cwnd)
dupACKcount = 0
cwnd = cwnd+MSS transmit new segment(s),as allowed
dupACKcount = 0
transmit new segment(s),as allowed
cwnd = 1 MSS
ssthresh = 64 KB cwnd > ssthresh
dupACKcount = 0
slow congestion
start timeout avoidance
ssthresh = cwnd/2
cwnd = 1 MSS duplicate ACK
dupACKcount = 0
timeout dupACKcount++
retransmit missing segment
ssthresh = cwnd/2
cwnd = 1 MSS
dupACKcount = 0
retransmit missing segment
timeout
ssthresh = cwnd/2
cwnd = 1 New ACK
dupACKcount = 0
retransmit missing segment cwnd = ssthresh dupACKcount == 3
dupACKcount == 3 dupACKcount = 0
ssthresh= cwnd/2 ssthresh= cwnd/2
cwnd = ssthresh + 3 cwnd = ssthresh + 3
retransmit missing segment retransmit missing segment
fast
recovery
duplicate ACK
cwnd = cwnd + MSS
transmit new segment(s), as allowed
TCP Reno
cwnd window size (in
ssthresh
ssthresh
segments)
TCP Tahoe
Transmission round
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