Professional Documents
Culture Documents
Transport Layer
A note on the use of these PowerPoint slides:
We’re making these slides freely available to all (faculty, students,
readers). They’re in PowerPoint form so you see the animations; and
can add, modify, and delete slides (including this one) and slide content
to suit your needs. They obviously represent a lot of work on our part.
In return for use, we only ask the following:
▪ If you use these slides (e.g., in a class) that you mention their
source (after all, we’d like people to use our book!)
▪ If you post any slides on a www site, that you note that they are
adapted from (or perhaps identical to) our slides, and note our
copyright of this material.
Computer Networking: A
For a revision history, see the slide note for this page.
Top-Down Approach
Thanks and enjoy! JFK/KWR 8th edition
Jim Kurose, Keith Ross
All material copyright 1996-2020
J.F Kurose and K.W. Ross, All Rights Reserved Pearson, 2020
Transport Layer: 3-1
Transport layer: overview
Our goal:
▪ understand principles ▪ learn about Internet transport
behind transport layer layer protocols:
services: • UDP: connectionless transport
• multiplexing, • TCP: connection-oriented reliable
demultiplexing transport
• reliable data transfer • TCP congestion control
• flow control
• congestion control
▪ Go back N (3.4.3)
▪ Selective Repeat (3.4.4)
▪ Connection-oriented transport: TCP (3.5)
• TCP connection (3.5.1)
• TCP Segment structure (3.5.2 )
• Rotund trip time estimation and timeout (3.5.3)
• Reliable data transfer (3.5.4)
• Flow control (3.5.5)
• TCP connection management (3.5.6)
▪ TCP congestion control (3.7)
Transport Layer: 3-3
Chapter 3: roadmap
▪ Multiplexing and demultiplexing
▪ Connectionless transport: UDP
▪ Principles of reliable data transfer
(Go-back-N and Selective Repeat)
▪ Connection-oriented transport: TCP
▪ TCP congestion control
transport
Hn Ht HTTP msg
transport
application
application application
transport transport
(UDP) (UDP)
link link
physical physical
physical physical
physical physical
data to/from
UDP segment application layer
format
Transmitted: 5 6 11
Received: 4 6 11
receiver-computed
checksum
= sender-computed
checksum (as received)
sum 1011101110111100
checksum 0100010001000011
Note: when adding numbers, a carryout from the most significant bit needs to be
added to the result
* Check out the online interactive exercises for more examples: h ttp://gaia.cs.umass.edu/kurose_ross/interactive/
Transport Layer: 3-27
Internet checksum: weak protection!
example: add two 16-bit integers
01
1110011001100110 10
1101010101010101
wraparound 11011101110111011 Even though
numbers have
sum 1011101110111100 changed (bit
flips), no change
checksum 0100010001000011 in checksum!
L/R L/R
Usender =
RTT + L / R
.008 RTT
=
30.008
= 0.00027
rcv_base
Not received
Transport Layer: 3-36
Go-Back-N in action
sender window (N=4) sende receiver
012345678 r
send pkt0
012345678 send pkt1
send pkt2 receive pkt0, send ack0
012345678
send pkt3 Xloss receive pkt1, send ack1
012345678
(wait)
receive pkt3, discard,
012345678 rcv ack0, send pkt4 (re)send ack1
012345678 rcv ack1, send pkt5 receive pkt4, discard,
(re)send ack1
ignore duplicate receive pkt5, discard,
ACK
(re)send ack1
pkt 2 timeout
012345678 send pkt2
012345678 send pkt3
012345678 send pkt4 rcv pkt2, deliver, send ack2
012345678 send pkt5 rcv pkt3, deliver, send ack3
rcv pkt4, deliver, send ack4
rcv pkt5, deliver, send ack5
a dilemma!
012301 pkt
2 0pkt
012301 012301
2 1
pkt 2
012301
012301
2 2 2
012301
example: 012301 pkt
3 X
2
▪ window size=3
0 with seq number 0
(a) no problem
012301 pkt
2 0
pkt
012301 012301
2 1
pkt 2
012301 X 012301
2 2 X 2
012301
X 2
timeout
retransmit pkt0
012301 pkt
2 0 will accept packet
with seq number 0
(b) oops!
Transport Layer: 3-42
Selective repeat:
sender receiver
window window
(after receipt) (after receipt)
a dilemma!
012301 pkt
2 0pkt
012301 012301
2 1
pkt 2
012301
012301
2 2 2
012301
example: 012301 pkt
3 X
2
options (variable
C, E: congestion notification length)
TCP options
application data sent by
RST, SYN, FIN: connection data application into
management (variable TCP socket
length)
User types‘C’
Seq=42, ACK=79, data = ‘C’
host ACKs receipt of‘C’,
echoes back ‘C’
Seq=79, ACK=43, data = ‘C’
host ACKs receipt
of echoed ‘C’
Seq=43, ACK=80
(milliseconds)
RTT
sampleRTT
EstimatedRTT
time (seconds)
Transport Layer: 3-50
TCP round trip time, timeout
▪timeout interval: EstimatedRTT plus “safety margin”
• large variation in EstimatedRTT: want a larger safety margin
TimeoutInterval = EstimatedRTT + 4*DevRTT
* Check out the online interactive exercises for more examples: h ttp://gaia.cs.umass.edu/kurose_ross/interactive/
Transport Layer: 3-51
TCP Sender (simplified)
event: data received from event: timeout
application ▪ retransmit segment that
▪create segment with seq # caused timeout
▪ restart timer
▪ seq # is byte-stream number
of first data byte in segment
event: ACK received
▪ start timer if not already
running ▪if ACK acknowledges
• think of timer as for oldest
previously unACKed segments
unACKed segment • update what is known to be
ACKed
• expiration interval:
TimeOutInterval • start timer if there are still
unACKed segments
Transport Layer: 3-52
TCP Receiver: ACK generation [RFC 5681]
Event at receiver TCP receiver action
arrival of in-order segment with delayed ACK. Wait up to 500ms
expected seq #. All data up to for next segment. If no next segment,
expected seq # already ACKed send ACK
SendBase=9
Seq=92, 8 bytes of 2 Seq=92, 8 bytes of
data data
Seq=100, 20 bytes of
timeo
timeo
ACK=100 data
ut
ut
X
ACK=100
ACK=120
SendBase=12
0
lost ACK scenario premature timeout
Seq=92, 8 bytes of
data
Seq=100, 20 bytes of
data
ACK=100
X
ACK=120
=100
timeout
ACK
CK =100
A
= 10 0
Receipt of three duplicate ACKs ACK
TCP
code
Network layer
delivering IP datagram
payload into TCP
IP
socket buffers code
from
sender
receiver protocol stack
TCP
code
Network layer
delivering IP datagram
payload into TCP
IP
socket buffers code
from
sender
receiver protocol stack
TCP
code
receive window
flow control: # bytes
receiver willing to accept IP
code
from
sender
receiver protocol stack
TCP
flow control code
application application
network network
ESTAB
data(x+1) accept
data(x+1)
ACK(x+1)
connection
x
completes
No problem!
choose x
req_conn(x)
ESTAB
retransmit acc_conn(x)
req_conn(x)
ESTAB
req_conn(x)
connection
client x server
terminates completes forgets x
ESTAB
acc_conn(x)
Problem: half open
connection! (no client)
Transport Layer: 3-67
2-way handshake scenarios
choose x
req_conn(x)
ESTAB
retransmit acc_conn(x)
req_conn(x)
ESTAB
data(x+1) accept
data(x+1)
retransmit
data(x+1)
connection
x server
client completes
terminates forgets x
req_conn(x)
ESTAB
data(x+1) accept
data(x+1)
Problem: dup data
accepted!
TCP 3-way handshake
Server state
serverSocket = socket(AF_INET,SOCK_STREAM)
Client state serverSocket.bind((‘’,serverPort))
serverSocket.listen(1)
clientSocket = socket(AF_INET, SOCK_STREAM) connectionSocket, addr = serverSocket.accept()
LISTEN
clientSocket.connect((serverName,serverPort)) LISTEN
choose init seq num,
x
SYNSENT send TCP SYN msg SYNbit=1,
Seq=x choose init seq num,
y
send TCP SYNACK SYN RCVD
SYNbit=1, Seq=y msg, acking SYN
ACKbit=1; ACKnum=x+1
received SYNACK(x)
ESTAB indicates server is live;
send ACK for SYNACK;
this segment may contain ACKbit=1, ACKnum=y+1
client-to-server data
received ACK(y)
indicates client is
live ESTAB
1. On belay?
2. Belay on.
3. Climbing.
AIMD sawtooth
behavior: probing
for bandwidth
Why AIMD?
▪ AIMD – a distributed, asynchronous algorithm – has been
shown to:
• optimize congested flow rates network wide!
• have desirable stability properties
RTT
segment
Implementation:
▪ variable ssthresh
▪ on loss event, ssthresh is set to
1/2 of cwnd just before loss event
* Check out the online interactive exercises for more examples: h ttp://gaia.cs.umass.edu/kurose_ross/interactive/
Transport Layer: 3-77
Summary: TCP congestion control
New
New ACK!
ACK! new ACK
duplicate ACK
dupACKcount++ 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 >
dupACKcount = 0
slow ssthresh
Λ congestion
start timeout avoidance
ssthresh = cwnd/2
cwnd = 1 MSS duplicate ACK
timeout dupACKcount = 0 dupACKcount++
ssthresh = cwnd/2 retransmit missing segment
cwnd = 1 MSS
dupACKcount = 0
retransmit missing segment
timeout
New
ACK!
ssthresh = cwnd/2
cwnd = 1 New ACK
dupACKcount = 0
cwnd = ssthresh dupACKcount == 3
dupACKcount == 3 retransmit missing segment 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
time
t0 t1 t2 t3 t4
Transport Layer: 3-80
TCP and the congested “bottleneck link”
▪TCP (classic, CUBIC) increase TCP’s sending rate until packet loss occurs
at some router’s output: the bottleneck link
sourc destination
e
application application
TCP TCP
network network
link link
physical physical
packet queue almost
never empty, sometimes
overflows packet (loss)
ECN=10 ECN=11
IP datagram
Transport Layer: 3-85
TCP fairness
Fairness goal: if K TCP sessions share same bottleneck link of
bandwidth R, each should have average rate of R/K
TCP connection 1
bottleneck
TCP connection 2 router
capacity R
Connection 1 throughput R
Transport Layer: 3-87
Fairness: must all network apps be “fair”?
Fairness and UDP Fairness, parallel TCP
▪multimedia apps often do not connections
use TCP ▪application can open multiple
• do not want rate throttled by parallel connections between two
congestion control hosts
▪instead use UDP: ▪ web browsers do this , e.g., link of
• send audio/video at constant rate, rate R with 9 existing connections:
tolerate packet loss • new app asks for 1 TCP, gets rate R/10
▪there is no “Internet police” • new app asks for 11 TCPs, gets R/2
policing use of congestion
control
SYN
SYN sent
rcvd
SYNACK(seq=y,ACKnum=x+1)
ESTAB
ACK(ACKnum=y+1) ACK(ACKnum=y+1)
Λ
LAST_ACK
FINbit=1,
TIMED_WAIT seq=y can no
longer
ACKbit=1; ACKnum=y+1 send data
timed wait
for 2*max CLOSED
segment
lifetime
CLOSED
W/2
TCP over “long, fat pipes”
▪example: 1500 byte segments, 100ms RTT, want 10 Gbps throughput
▪ requires W = 83,333 in-flight segments
▪ throughput in terms of segment loss probability, L [Mathis 1997]:
1.22 . MSS
TCP throughput =
RTT L
➜ to achieve 10 Gbps throughput, need a loss rate of L = 2·10-10 – a
very small loss rate!
▪versions of TCP for long, high-speed scenarios