Date post: | 21-Apr-2017 |
Category: |
Engineering |
Upload: | amin-omi |
View: | 275 times |
Download: | 0 times |
Transport Layer 3-1
Chapter 3Transport Layer
Computer Networking A Top Down Approach 6th edition
Jim Kurose Keith Ross
Transport Layer 3-2
Transport services and protocols
provide logical communication between app processes running on different hosts
transport protocols run in end systems send side breaks app
messages into segments passes to network layer
rcv side reassembles segments into messages passes to app layer
more than one transport protocol available to apps Internet TCP and UDP
application
transportnetworkdata linkphysical
logical end-end transportapplicatio
ntransportnetworkdata linkphysical
Transport Layer 3-3
Transport vs network layer network layer logical communication between hosts transport layer logical communication between processes
relies on enhances network layer services
12 kids in Annrsquos house sending letters to 12 kids in Billrsquos house
hosts = houses processes = kids app messages = letters in envelopes transport protocol = Ann and Bill who demux to in-house siblings network-layer protocol = postal service
household analogy
Transport Layer 3-4
Internet transport-layer protocols
reliable in-order delivery (TCP) congestion control flow control connection setup
unreliable unordered delivery UDP no-frills extension of
ldquobest-effortrdquo IP services not
available delay guarantees bandwidth guarantees
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysicalnetwork
data linkphysical network
data linkphysical
logical end-end transport
Transport Layer 3-5
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocol
ldquobest effortrdquo service UDP segments may be lost delivered out-of-order
to app connectionless
no handshaking between UDP sender receiver
each UDP segment handled independently of others
UDP use streaming
multimedia apps (loss tolerant rate sensitive)
DNS SNMP
reliable transfer over UDP add reliability at
application layer application-specific
error recovery
Transport Layer 3-6
TCP Overview RFCs 79311221323 2018 2581
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
flow controlled sender will not
overwhelm receiver
point-to-point one sender one
receiver reliable in-order
byte steam no ldquomessage
boundariesrdquo pipelined
TCP congestion and flow control set window size
Transport Layer 3-7
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
receive window
Urg data pointerchecksum
FSRPAUheadlen
notused
options (variable length)
URG urgent data (generally not used)
ACK ACK valid
PSH push data now(generally not used)
RST SYN FINconnection estab(setup teardown
commands)
bytes rcvr willingto accept
countingby bytes of data(not segments)
Internetchecksum
(as in UDP)
Transport Layer 3-8
TCP seq numbers ACKssequence numbers
byte stream ldquonumberrdquo of first byte in segmentrsquos data
acknowledgementsseq of next byte expected from other side
cumulative ACKQ how receiver handles out-of-order segmentsA TCP spec doesnrsquot say - up to implementor
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
incoming segment to sender
A
sent ACKed
sent not-yet ACKed(ldquoin-flightrdquo)
usablebut not yet sent
not usable
window size N
sender sequence number space
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
outgoing segment from sender
Transport Layer 3-9
TCP seq numbers ACKs
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoesback lsquoCrsquo
simple telnet scenario
Host BHost A
Seq=42 ACK=79 data = lsquoCrsquo
Seq=79 ACK=43 data = lsquoCrsquo
Seq=43 ACK=80
Transport Layer 3-10
congestion informally ldquotoo many sources sending
too much data too fast for network to handlerdquo
different from flow control manifestations
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem
Principles of congestion control
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-2
Transport services and protocols
provide logical communication between app processes running on different hosts
transport protocols run in end systems send side breaks app
messages into segments passes to network layer
rcv side reassembles segments into messages passes to app layer
more than one transport protocol available to apps Internet TCP and UDP
application
transportnetworkdata linkphysical
logical end-end transportapplicatio
ntransportnetworkdata linkphysical
Transport Layer 3-3
Transport vs network layer network layer logical communication between hosts transport layer logical communication between processes
relies on enhances network layer services
12 kids in Annrsquos house sending letters to 12 kids in Billrsquos house
hosts = houses processes = kids app messages = letters in envelopes transport protocol = Ann and Bill who demux to in-house siblings network-layer protocol = postal service
household analogy
Transport Layer 3-4
Internet transport-layer protocols
reliable in-order delivery (TCP) congestion control flow control connection setup
unreliable unordered delivery UDP no-frills extension of
ldquobest-effortrdquo IP services not
available delay guarantees bandwidth guarantees
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysicalnetwork
data linkphysical network
data linkphysical
logical end-end transport
Transport Layer 3-5
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocol
ldquobest effortrdquo service UDP segments may be lost delivered out-of-order
to app connectionless
no handshaking between UDP sender receiver
each UDP segment handled independently of others
UDP use streaming
multimedia apps (loss tolerant rate sensitive)
DNS SNMP
reliable transfer over UDP add reliability at
application layer application-specific
error recovery
Transport Layer 3-6
TCP Overview RFCs 79311221323 2018 2581
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
flow controlled sender will not
overwhelm receiver
point-to-point one sender one
receiver reliable in-order
byte steam no ldquomessage
boundariesrdquo pipelined
TCP congestion and flow control set window size
Transport Layer 3-7
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
receive window
Urg data pointerchecksum
FSRPAUheadlen
notused
options (variable length)
URG urgent data (generally not used)
ACK ACK valid
PSH push data now(generally not used)
RST SYN FINconnection estab(setup teardown
commands)
bytes rcvr willingto accept
countingby bytes of data(not segments)
Internetchecksum
(as in UDP)
Transport Layer 3-8
TCP seq numbers ACKssequence numbers
byte stream ldquonumberrdquo of first byte in segmentrsquos data
acknowledgementsseq of next byte expected from other side
cumulative ACKQ how receiver handles out-of-order segmentsA TCP spec doesnrsquot say - up to implementor
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
incoming segment to sender
A
sent ACKed
sent not-yet ACKed(ldquoin-flightrdquo)
usablebut not yet sent
not usable
window size N
sender sequence number space
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
outgoing segment from sender
Transport Layer 3-9
TCP seq numbers ACKs
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoesback lsquoCrsquo
simple telnet scenario
Host BHost A
Seq=42 ACK=79 data = lsquoCrsquo
Seq=79 ACK=43 data = lsquoCrsquo
Seq=43 ACK=80
Transport Layer 3-10
congestion informally ldquotoo many sources sending
too much data too fast for network to handlerdquo
different from flow control manifestations
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem
Principles of congestion control
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-3
Transport vs network layer network layer logical communication between hosts transport layer logical communication between processes
relies on enhances network layer services
12 kids in Annrsquos house sending letters to 12 kids in Billrsquos house
hosts = houses processes = kids app messages = letters in envelopes transport protocol = Ann and Bill who demux to in-house siblings network-layer protocol = postal service
household analogy
Transport Layer 3-4
Internet transport-layer protocols
reliable in-order delivery (TCP) congestion control flow control connection setup
unreliable unordered delivery UDP no-frills extension of
ldquobest-effortrdquo IP services not
available delay guarantees bandwidth guarantees
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysicalnetwork
data linkphysical network
data linkphysical
logical end-end transport
Transport Layer 3-5
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocol
ldquobest effortrdquo service UDP segments may be lost delivered out-of-order
to app connectionless
no handshaking between UDP sender receiver
each UDP segment handled independently of others
UDP use streaming
multimedia apps (loss tolerant rate sensitive)
DNS SNMP
reliable transfer over UDP add reliability at
application layer application-specific
error recovery
Transport Layer 3-6
TCP Overview RFCs 79311221323 2018 2581
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
flow controlled sender will not
overwhelm receiver
point-to-point one sender one
receiver reliable in-order
byte steam no ldquomessage
boundariesrdquo pipelined
TCP congestion and flow control set window size
Transport Layer 3-7
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
receive window
Urg data pointerchecksum
FSRPAUheadlen
notused
options (variable length)
URG urgent data (generally not used)
ACK ACK valid
PSH push data now(generally not used)
RST SYN FINconnection estab(setup teardown
commands)
bytes rcvr willingto accept
countingby bytes of data(not segments)
Internetchecksum
(as in UDP)
Transport Layer 3-8
TCP seq numbers ACKssequence numbers
byte stream ldquonumberrdquo of first byte in segmentrsquos data
acknowledgementsseq of next byte expected from other side
cumulative ACKQ how receiver handles out-of-order segmentsA TCP spec doesnrsquot say - up to implementor
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
incoming segment to sender
A
sent ACKed
sent not-yet ACKed(ldquoin-flightrdquo)
usablebut not yet sent
not usable
window size N
sender sequence number space
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
outgoing segment from sender
Transport Layer 3-9
TCP seq numbers ACKs
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoesback lsquoCrsquo
simple telnet scenario
Host BHost A
Seq=42 ACK=79 data = lsquoCrsquo
Seq=79 ACK=43 data = lsquoCrsquo
Seq=43 ACK=80
Transport Layer 3-10
congestion informally ldquotoo many sources sending
too much data too fast for network to handlerdquo
different from flow control manifestations
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem
Principles of congestion control
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-4
Internet transport-layer protocols
reliable in-order delivery (TCP) congestion control flow control connection setup
unreliable unordered delivery UDP no-frills extension of
ldquobest-effortrdquo IP services not
available delay guarantees bandwidth guarantees
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysicalnetwork
data linkphysical network
data linkphysical
logical end-end transport
Transport Layer 3-5
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocol
ldquobest effortrdquo service UDP segments may be lost delivered out-of-order
to app connectionless
no handshaking between UDP sender receiver
each UDP segment handled independently of others
UDP use streaming
multimedia apps (loss tolerant rate sensitive)
DNS SNMP
reliable transfer over UDP add reliability at
application layer application-specific
error recovery
Transport Layer 3-6
TCP Overview RFCs 79311221323 2018 2581
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
flow controlled sender will not
overwhelm receiver
point-to-point one sender one
receiver reliable in-order
byte steam no ldquomessage
boundariesrdquo pipelined
TCP congestion and flow control set window size
Transport Layer 3-7
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
receive window
Urg data pointerchecksum
FSRPAUheadlen
notused
options (variable length)
URG urgent data (generally not used)
ACK ACK valid
PSH push data now(generally not used)
RST SYN FINconnection estab(setup teardown
commands)
bytes rcvr willingto accept
countingby bytes of data(not segments)
Internetchecksum
(as in UDP)
Transport Layer 3-8
TCP seq numbers ACKssequence numbers
byte stream ldquonumberrdquo of first byte in segmentrsquos data
acknowledgementsseq of next byte expected from other side
cumulative ACKQ how receiver handles out-of-order segmentsA TCP spec doesnrsquot say - up to implementor
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
incoming segment to sender
A
sent ACKed
sent not-yet ACKed(ldquoin-flightrdquo)
usablebut not yet sent
not usable
window size N
sender sequence number space
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
outgoing segment from sender
Transport Layer 3-9
TCP seq numbers ACKs
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoesback lsquoCrsquo
simple telnet scenario
Host BHost A
Seq=42 ACK=79 data = lsquoCrsquo
Seq=79 ACK=43 data = lsquoCrsquo
Seq=43 ACK=80
Transport Layer 3-10
congestion informally ldquotoo many sources sending
too much data too fast for network to handlerdquo
different from flow control manifestations
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem
Principles of congestion control
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-5
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocol
ldquobest effortrdquo service UDP segments may be lost delivered out-of-order
to app connectionless
no handshaking between UDP sender receiver
each UDP segment handled independently of others
UDP use streaming
multimedia apps (loss tolerant rate sensitive)
DNS SNMP
reliable transfer over UDP add reliability at
application layer application-specific
error recovery
Transport Layer 3-6
TCP Overview RFCs 79311221323 2018 2581
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
flow controlled sender will not
overwhelm receiver
point-to-point one sender one
receiver reliable in-order
byte steam no ldquomessage
boundariesrdquo pipelined
TCP congestion and flow control set window size
Transport Layer 3-7
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
receive window
Urg data pointerchecksum
FSRPAUheadlen
notused
options (variable length)
URG urgent data (generally not used)
ACK ACK valid
PSH push data now(generally not used)
RST SYN FINconnection estab(setup teardown
commands)
bytes rcvr willingto accept
countingby bytes of data(not segments)
Internetchecksum
(as in UDP)
Transport Layer 3-8
TCP seq numbers ACKssequence numbers
byte stream ldquonumberrdquo of first byte in segmentrsquos data
acknowledgementsseq of next byte expected from other side
cumulative ACKQ how receiver handles out-of-order segmentsA TCP spec doesnrsquot say - up to implementor
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
incoming segment to sender
A
sent ACKed
sent not-yet ACKed(ldquoin-flightrdquo)
usablebut not yet sent
not usable
window size N
sender sequence number space
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
outgoing segment from sender
Transport Layer 3-9
TCP seq numbers ACKs
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoesback lsquoCrsquo
simple telnet scenario
Host BHost A
Seq=42 ACK=79 data = lsquoCrsquo
Seq=79 ACK=43 data = lsquoCrsquo
Seq=43 ACK=80
Transport Layer 3-10
congestion informally ldquotoo many sources sending
too much data too fast for network to handlerdquo
different from flow control manifestations
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem
Principles of congestion control
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-6
TCP Overview RFCs 79311221323 2018 2581
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
flow controlled sender will not
overwhelm receiver
point-to-point one sender one
receiver reliable in-order
byte steam no ldquomessage
boundariesrdquo pipelined
TCP congestion and flow control set window size
Transport Layer 3-7
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
receive window
Urg data pointerchecksum
FSRPAUheadlen
notused
options (variable length)
URG urgent data (generally not used)
ACK ACK valid
PSH push data now(generally not used)
RST SYN FINconnection estab(setup teardown
commands)
bytes rcvr willingto accept
countingby bytes of data(not segments)
Internetchecksum
(as in UDP)
Transport Layer 3-8
TCP seq numbers ACKssequence numbers
byte stream ldquonumberrdquo of first byte in segmentrsquos data
acknowledgementsseq of next byte expected from other side
cumulative ACKQ how receiver handles out-of-order segmentsA TCP spec doesnrsquot say - up to implementor
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
incoming segment to sender
A
sent ACKed
sent not-yet ACKed(ldquoin-flightrdquo)
usablebut not yet sent
not usable
window size N
sender sequence number space
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
outgoing segment from sender
Transport Layer 3-9
TCP seq numbers ACKs
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoesback lsquoCrsquo
simple telnet scenario
Host BHost A
Seq=42 ACK=79 data = lsquoCrsquo
Seq=79 ACK=43 data = lsquoCrsquo
Seq=43 ACK=80
Transport Layer 3-10
congestion informally ldquotoo many sources sending
too much data too fast for network to handlerdquo
different from flow control manifestations
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem
Principles of congestion control
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-7
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
receive window
Urg data pointerchecksum
FSRPAUheadlen
notused
options (variable length)
URG urgent data (generally not used)
ACK ACK valid
PSH push data now(generally not used)
RST SYN FINconnection estab(setup teardown
commands)
bytes rcvr willingto accept
countingby bytes of data(not segments)
Internetchecksum
(as in UDP)
Transport Layer 3-8
TCP seq numbers ACKssequence numbers
byte stream ldquonumberrdquo of first byte in segmentrsquos data
acknowledgementsseq of next byte expected from other side
cumulative ACKQ how receiver handles out-of-order segmentsA TCP spec doesnrsquot say - up to implementor
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
incoming segment to sender
A
sent ACKed
sent not-yet ACKed(ldquoin-flightrdquo)
usablebut not yet sent
not usable
window size N
sender sequence number space
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
outgoing segment from sender
Transport Layer 3-9
TCP seq numbers ACKs
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoesback lsquoCrsquo
simple telnet scenario
Host BHost A
Seq=42 ACK=79 data = lsquoCrsquo
Seq=79 ACK=43 data = lsquoCrsquo
Seq=43 ACK=80
Transport Layer 3-10
congestion informally ldquotoo many sources sending
too much data too fast for network to handlerdquo
different from flow control manifestations
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem
Principles of congestion control
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-8
TCP seq numbers ACKssequence numbers
byte stream ldquonumberrdquo of first byte in segmentrsquos data
acknowledgementsseq of next byte expected from other side
cumulative ACKQ how receiver handles out-of-order segmentsA TCP spec doesnrsquot say - up to implementor
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
incoming segment to sender
A
sent ACKed
sent not-yet ACKed(ldquoin-flightrdquo)
usablebut not yet sent
not usable
window size N
sender sequence number space
source port dest port
sequence numberacknowledgement number
checksum
rwndurg pointer
outgoing segment from sender
Transport Layer 3-9
TCP seq numbers ACKs
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoesback lsquoCrsquo
simple telnet scenario
Host BHost A
Seq=42 ACK=79 data = lsquoCrsquo
Seq=79 ACK=43 data = lsquoCrsquo
Seq=43 ACK=80
Transport Layer 3-10
congestion informally ldquotoo many sources sending
too much data too fast for network to handlerdquo
different from flow control manifestations
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem
Principles of congestion control
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-9
TCP seq numbers ACKs
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoesback lsquoCrsquo
simple telnet scenario
Host BHost A
Seq=42 ACK=79 data = lsquoCrsquo
Seq=79 ACK=43 data = lsquoCrsquo
Seq=43 ACK=80
Transport Layer 3-10
congestion informally ldquotoo many sources sending
too much data too fast for network to handlerdquo
different from flow control manifestations
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem
Principles of congestion control
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-10
congestion informally ldquotoo many sources sending
too much data too fast for network to handlerdquo
different from flow control manifestations
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
a top-10 problem
Principles of congestion control
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-11
Causescosts of congestion scenario 1
two senders two receivers
one router infinite buffers
output link capacity R no retransmission
maximum per-connection throughput R2
unlimited shared output link buffers
Host A
original data in
Host B
throughputout
R2
R2
out
in R2de
lay
in large delays as arrival
rate in approaches capacity
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-12
one router finite buffers sender retransmission of timed-out packet
application-layer input = application-layer outputin = out
transport-layer input includes retransmissions in in
finite shared output link buffers
Host A
in original data
Host B
outin original data plus retransmitted data
lsquo
Causescosts of congestion scenario 2
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-13
idealization perfect knowledge
sender sends only when router buffers available
finite shared output link buffers
in original dataoutin original data plus
retransmitted data
copy
free buffer space
R2
R2
out
in
Causescosts of congestion scenario 2
Host B
A
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-14
in original dataoutin original data plus
retransmitted data
copy
no buffer space
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
Causescosts of congestion scenario 2
A
Host B
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-15
in original dataoutin original data plus
retransmitted data
free buffer space
Causescosts of congestion scenario 2
Idealization known loss packets can be lost dropped at router due to full buffers
sender only resends if packet known to be lost
R2
R2in
out
when sending at R2 some packets are retransmissions but asymptotic goodput is still R2 (why)
A
Host B
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-16
A
in outincopy
free buffer space
timeout
R2
R2in
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
Host B
Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Causescosts of congestion scenario 2
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-17
R2
out
when sending at R2 some packets are retransmissions including duplicated that are delivered
ldquocostsrdquo of congestion more work (retrans) for given ldquogoodputrdquo unneeded retransmissions link carries multiple
copies of pkt decreasing goodput
R2in
Causescosts of congestion scenario 2 Realistic duplicates packets can be lost
dropped at router due to full buffers
sender times out prematurely sending two copies both of which are delivered
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-18
four senders multihop paths timeoutretransmit
Q what happens as in and in
rsquo increase
finite shared output link buffers
Host A out
Causescosts of congestion scenario 3
Host B
Host CHost D
in original data
in original data plus retransmitted data
A as red inrsquo increases all
arriving blue pkts at upper queue are dropped blue throughput 0
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-19
another ldquocostrdquo of congestion when packet dropped any ldquoupstream
transmission capacity used for that packet was wasted
Causescosts of congestion scenario 3
C2
C2
out
inrsquo
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-20
Approaches towards congestion controltwo broad approaches towards congestion
controlend-end
congestion control
no explicit feedback from network
congestion inferred from end-system observed loss delay
approach taken by TCP
network-assisted congestion control
routers provide feedback to end systemssingle bit indicating congestion (SNA DECbit TCPIP ECN ATM)
explicit rate for sender to send at
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-21
TCP congestion control additive increase multiplicative decrease
approach sender increases transmission rate (window size) probing for usable bandwidth until loss occurs additive increase increase cwnd by 1
MSS every RTT until loss detected multiplicative decrease cut cwnd in half
after loss
cwnd
TCP
sen
der
cong
estio
n w
indo
w s
ize
AIMD saw toothbehavior probing
for bandwidth
additively increase window size helliphellip until loss occurs (then cut window in half)
time
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-22
TCP Congestion Control details
sender limits transmission
cwnd is dynamic function of perceived network congestion
TCP sending rate roughly send
cwnd bytes wait RTT for ACKS then send more bytes
last byteACKed sent not-
yet ACKed(ldquoin-flightrdquo)
last byte sent
cwnd
LastByteSent-LastByteAcked
lt cwnd
sender sequence number space
rate ~~cwndRTT bytessec
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-23
TCP Slow Start when connection
begins increase rate exponentially until first loss event initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received
summary initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-24
TCP detecting reacting to loss
loss indicated by timeout cwnd set to 1 MSS window then grows exponentially (as in slow start) to threshold
then grows linearly loss indicated by 3 duplicate ACKs TCP RENO
dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-25
Q when should the exponential increase switch to linear
A when cwnd gets to 12 of its value before timeout
Implementation variable ssthresh on loss event ssthresh
is set to 12 of cwnd just before loss event
TCP switching from slow start to CA
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-26
TCP throughput avg TCP thruput as function of window
size RTT ignore slow start assume always data to send
W window size (measured in bytes) where loss occurs avg window size ( in-flight bytes) is frac34 W avg thruput is 34W per RTT
W
W2
avg TCP thruput = 34W
RTTbytessec
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-27
TCP Futures TCP over ldquolong fat pipesrdquo example 1500 byte segments 100ms
RTT want 10 Gbps throughput requires W = 83333 in-flight segments throughput in terms of segment loss
probability L [Mathis 1997]
to achieve 10 Gbps throughput need a loss rate of L = 210-10 ndash a very small loss rate
new versions of TCP for high-speed
TCP throughput = 122 MSSRTT L
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-28
fairness goal if K TCP sessions share same bottleneck link of bandwidth R each should have average rate of RK
TCP connection 1
bottleneckrouter
capacity R
TCP Fairness
TCP connection 2
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-29
Why is TCP fairtwo competing sessions additive increase gives slope of 1 as throughout
increases multiplicative decrease decreases throughput
proportionally R
R
equal bandwidth share
Connection 1 throughput
Con
nec t
ion
2 t h
roug
hput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-30
Fairness (more)Fairness and UDP multimedia apps
often do not use TCP do not want rate
throttled by congestion control
instead use UDP send audiovideo
at constant rate tolerate packet loss
Fairness parallel TCP connections
application can open multiple parallel connections between two hosts
web browsers do this eg link of rate R with 9
existing connections new app asks for 1 TCP gets
rate R10 new app asks for 11 TCPs gets
R2
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-31
UDP segment header
source port dest port 32 bits
applicationdata (payload)
UDP segment format
length checksum
length in bytes of UDP segment
including header
no connection establishment (which can add delay)
simple no connection state at sender receiver
small header size no congestion control
UDP can blast away as fast as desired
why is there a UDP
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-32
UDP checksum
sender treat segment contents
including header fields as sequence of 16-bit integers
checksum addition (onersquos complement sum) of segment contents
sender puts checksum value into UDP checksum field
receiver compute checksum of
received segment check if computed
checksum equals checksum field value NO - error detected YES - no error detected
But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-33
Internet checksum exampleexample add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sumchecksum
Note when adding numbers a carryout from the most significant bit needs to be added to the result
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-34
Pipelined protocols overviewGo-back-N sender can have up
to N unacked packets in pipeline
receiver only sends cumulative ack doesnrsquot ack packet if
therersquos a gap sender has timer
for oldest unacked packet when timer expires
retransmit all unacked packets
Selective Repeat sender can have up to
N unackrsquoed packets in pipeline
rcvr sends individual ack for each packet
sender maintains timer for each unacked packet when timer expires
retransmit only that unacked packet
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-35
Go-Back-N sender k-bit seq in pkt header ldquowindowrdquo of up to N consecutive unackrsquoed pkts
allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquo may receive duplicate ACKs (see receiver)
timer for oldest in-flight pkt timeout(n) retransmit packet n and all higher seq
pkts in window
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-36
GBN in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 discard (re)send ack1rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2send pkt3send pkt4send pkt5
Xloss
receive pkt4 discard (re)send ack1receive pkt5 discard (re)send ack1
rcv pkt2 deliver send ack2rcv pkt3 deliver send ack3rcv pkt4 deliver send ack4rcv pkt5 deliver send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-37
Selective repeat receiver individually acknowledges all
correctly received pkts buffers pkts as needed for eventual in-
order delivery to upper layer sender only resends pkts for which
ACK not received sender timer for each unACKed pkt
sender window N consecutive seq rsquos limits seq s of sent unACKed pkts
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-38
Selective repeat sender receiver windows
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-39
Selective repeatdata from above if next available seq
in window send pkttimeout(n) resend pkt n restart
timerACK(n) in
[sendbasesendbase+N] mark pkt n as received if n smallest unACKed
pkt advance window base to next unACKed seq
senderpkt n in [rcvbase
rcvbase+N-1] send ACK(n) out-of-order buffer in-order deliver (also
deliver buffered in-order pkts) advance window to next not-yet-received pkt
pkt n in [rcvbase-Nrcvbase-1]
ACK(n)otherwise ignore
receiver
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives
Transport Layer 3-40
Selective repeat in actionsend pkt0send pkt1send pkt2send pkt3
(wait)
sender receiver
receive pkt0 send ack0receive pkt1 send ack1 receive pkt3 buffer send ack3rcv ack0 send pkt4
rcv ack1 send pkt5
pkt 2 timeoutsend pkt2
Xloss
receive pkt4 buffer send ack4receive pkt5 buffer send ack5
rcv pkt2 deliver pkt2pkt3 pkt4 pkt5 send ack2
record ack3 arrived
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
record ack4 arrivedrecord ack5 arrived
Q what happens when ack2 arrives