Chapter 3 Transport Layer - Western Illinois Universityfaculty.wiu.edu/Y-Kim2/TM322ch3.pdf · 2009....
Transcript of Chapter 3 Transport Layer - Western Illinois Universityfaculty.wiu.edu/Y-Kim2/TM322ch3.pdf · 2009....
3-1
Chapter 3Transport Layer
3-2
Transport services and protocolsprovide logical communicationbetween application processes running on different hoststransport protocols run in end systems
send side breaks application messages into segments passes to network layerReceiving side reassembles segments into messages passes to application layer
more than one transport protocol available to applications
Internet TCP and UDP
applicationtransportnetworkdata linkphysical
applicationtransportnetworkdata linkphysical
3-3
Transport vs network layer
network layer logical communication between hoststransport layer logical communication between processes
relies on enhances network layer services
Household analogy12 kids sending letters to
12 kidsprocesses = kidsapp messages = letters in envelopeshosts = housestransport protocol = Ann and Billnetwork-layer protocol = postal service
3-4
Internet transport-layer protocols
reliable in-order delivery (TCP)
congestion control flow controlconnection setup
unreliable unordered delivery UDP
no-frills extension of ldquobest-effortrdquo IP
services not available delay guaranteesbandwidth guarantees
applicationtransportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
applicationtransportnetworkdata linkphysical
3-5
Multiplexingdemultiplexing
application
transport
network
link
physical
P1 application
transport
network
link
physical
application
transport
network
link
physical
P2P3 P4P1
host 1 host 2 host 3
= process= socket
delivering received segmentsto correct socket
Demultiplexing at rcv hostgathering data from multiplesockets enveloping data with header (later used for demultiplexing)
Multiplexing at send host
3-6
How demultiplexing workshost receives IP datagrams
each datagram has source IP address destination IP addresseach datagram carries 1 transport-layer segmenteach segment has source destination port number
host uses IP addresses amp port numbers to direct segment to appropriate socket
source port dest port
32 bits
applicationdata
(message)
other header fields
TCPUDP segment format
3-7
Connectionless demultiplexing
Create sockets with port numbers
DatagramSocket mySocket1 = new DatagramSocket( )
DatagramSocket mySocket2 = new DatagramSocket( )
UDP socket identified by two-tuple
(dest IP address dest port number)
When host receives UDP segment
checks destination port number in segmentdirects UDP segment to socket with that port number
IP datagrams with different source IP addresses andor source port numbers directed to same socket
3-8
Connectionless demultiplexingDatagramSocket serverSocket = new DatagramSocket(6428)
ClientIPB
P2
clientIP A
P1P1P3
serverIP C
SP 6428DP 9157
SP 9157DP 6428
SP 6428DP 5775
SP 5775DP 6428
SP provides ldquoreturn addressrdquo
3-9
Connection-oriented demultiplexing
TCP socket identified by 4-tuple
source IP addresssource port numberdest IP addressdest port number
recv host uses all four values to direct segment to appropriate socket
Server host may support many simultaneous TCP sockets
each socket identified by its own 4-tuple
Web servers have different sockets for each connecting client
non-persistent HTTP will have different socket for each request
3-10
Connection-oriented demultiplexing
ClientIPB
P1
clientIP A
P1P2P4
serverIP C
SP 9157DP 80
SP 9157DP 80
P5 P6 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-2
Transport services and protocolsprovide logical communicationbetween application processes running on different hoststransport protocols run in end systems
send side breaks application messages into segments passes to network layerReceiving side reassembles segments into messages passes to application layer
more than one transport protocol available to applications
Internet TCP and UDP
applicationtransportnetworkdata linkphysical
applicationtransportnetworkdata linkphysical
3-3
Transport vs network layer
network layer logical communication between hoststransport layer logical communication between processes
relies on enhances network layer services
Household analogy12 kids sending letters to
12 kidsprocesses = kidsapp messages = letters in envelopeshosts = housestransport protocol = Ann and Billnetwork-layer protocol = postal service
3-4
Internet transport-layer protocols
reliable in-order delivery (TCP)
congestion control flow controlconnection setup
unreliable unordered delivery UDP
no-frills extension of ldquobest-effortrdquo IP
services not available delay guaranteesbandwidth guarantees
applicationtransportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
applicationtransportnetworkdata linkphysical
3-5
Multiplexingdemultiplexing
application
transport
network
link
physical
P1 application
transport
network
link
physical
application
transport
network
link
physical
P2P3 P4P1
host 1 host 2 host 3
= process= socket
delivering received segmentsto correct socket
Demultiplexing at rcv hostgathering data from multiplesockets enveloping data with header (later used for demultiplexing)
Multiplexing at send host
3-6
How demultiplexing workshost receives IP datagrams
each datagram has source IP address destination IP addresseach datagram carries 1 transport-layer segmenteach segment has source destination port number
host uses IP addresses amp port numbers to direct segment to appropriate socket
source port dest port
32 bits
applicationdata
(message)
other header fields
TCPUDP segment format
3-7
Connectionless demultiplexing
Create sockets with port numbers
DatagramSocket mySocket1 = new DatagramSocket( )
DatagramSocket mySocket2 = new DatagramSocket( )
UDP socket identified by two-tuple
(dest IP address dest port number)
When host receives UDP segment
checks destination port number in segmentdirects UDP segment to socket with that port number
IP datagrams with different source IP addresses andor source port numbers directed to same socket
3-8
Connectionless demultiplexingDatagramSocket serverSocket = new DatagramSocket(6428)
ClientIPB
P2
clientIP A
P1P1P3
serverIP C
SP 6428DP 9157
SP 9157DP 6428
SP 6428DP 5775
SP 5775DP 6428
SP provides ldquoreturn addressrdquo
3-9
Connection-oriented demultiplexing
TCP socket identified by 4-tuple
source IP addresssource port numberdest IP addressdest port number
recv host uses all four values to direct segment to appropriate socket
Server host may support many simultaneous TCP sockets
each socket identified by its own 4-tuple
Web servers have different sockets for each connecting client
non-persistent HTTP will have different socket for each request
3-10
Connection-oriented demultiplexing
ClientIPB
P1
clientIP A
P1P2P4
serverIP C
SP 9157DP 80
SP 9157DP 80
P5 P6 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-3
Transport vs network layer
network layer logical communication between hoststransport layer logical communication between processes
relies on enhances network layer services
Household analogy12 kids sending letters to
12 kidsprocesses = kidsapp messages = letters in envelopeshosts = housestransport protocol = Ann and Billnetwork-layer protocol = postal service
3-4
Internet transport-layer protocols
reliable in-order delivery (TCP)
congestion control flow controlconnection setup
unreliable unordered delivery UDP
no-frills extension of ldquobest-effortrdquo IP
services not available delay guaranteesbandwidth guarantees
applicationtransportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
applicationtransportnetworkdata linkphysical
3-5
Multiplexingdemultiplexing
application
transport
network
link
physical
P1 application
transport
network
link
physical
application
transport
network
link
physical
P2P3 P4P1
host 1 host 2 host 3
= process= socket
delivering received segmentsto correct socket
Demultiplexing at rcv hostgathering data from multiplesockets enveloping data with header (later used for demultiplexing)
Multiplexing at send host
3-6
How demultiplexing workshost receives IP datagrams
each datagram has source IP address destination IP addresseach datagram carries 1 transport-layer segmenteach segment has source destination port number
host uses IP addresses amp port numbers to direct segment to appropriate socket
source port dest port
32 bits
applicationdata
(message)
other header fields
TCPUDP segment format
3-7
Connectionless demultiplexing
Create sockets with port numbers
DatagramSocket mySocket1 = new DatagramSocket( )
DatagramSocket mySocket2 = new DatagramSocket( )
UDP socket identified by two-tuple
(dest IP address dest port number)
When host receives UDP segment
checks destination port number in segmentdirects UDP segment to socket with that port number
IP datagrams with different source IP addresses andor source port numbers directed to same socket
3-8
Connectionless demultiplexingDatagramSocket serverSocket = new DatagramSocket(6428)
ClientIPB
P2
clientIP A
P1P1P3
serverIP C
SP 6428DP 9157
SP 9157DP 6428
SP 6428DP 5775
SP 5775DP 6428
SP provides ldquoreturn addressrdquo
3-9
Connection-oriented demultiplexing
TCP socket identified by 4-tuple
source IP addresssource port numberdest IP addressdest port number
recv host uses all four values to direct segment to appropriate socket
Server host may support many simultaneous TCP sockets
each socket identified by its own 4-tuple
Web servers have different sockets for each connecting client
non-persistent HTTP will have different socket for each request
3-10
Connection-oriented demultiplexing
ClientIPB
P1
clientIP A
P1P2P4
serverIP C
SP 9157DP 80
SP 9157DP 80
P5 P6 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-4
Internet transport-layer protocols
reliable in-order delivery (TCP)
congestion control flow controlconnection setup
unreliable unordered delivery UDP
no-frills extension of ldquobest-effortrdquo IP
services not available delay guaranteesbandwidth guarantees
applicationtransportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
applicationtransportnetworkdata linkphysical
3-5
Multiplexingdemultiplexing
application
transport
network
link
physical
P1 application
transport
network
link
physical
application
transport
network
link
physical
P2P3 P4P1
host 1 host 2 host 3
= process= socket
delivering received segmentsto correct socket
Demultiplexing at rcv hostgathering data from multiplesockets enveloping data with header (later used for demultiplexing)
Multiplexing at send host
3-6
How demultiplexing workshost receives IP datagrams
each datagram has source IP address destination IP addresseach datagram carries 1 transport-layer segmenteach segment has source destination port number
host uses IP addresses amp port numbers to direct segment to appropriate socket
source port dest port
32 bits
applicationdata
(message)
other header fields
TCPUDP segment format
3-7
Connectionless demultiplexing
Create sockets with port numbers
DatagramSocket mySocket1 = new DatagramSocket( )
DatagramSocket mySocket2 = new DatagramSocket( )
UDP socket identified by two-tuple
(dest IP address dest port number)
When host receives UDP segment
checks destination port number in segmentdirects UDP segment to socket with that port number
IP datagrams with different source IP addresses andor source port numbers directed to same socket
3-8
Connectionless demultiplexingDatagramSocket serverSocket = new DatagramSocket(6428)
ClientIPB
P2
clientIP A
P1P1P3
serverIP C
SP 6428DP 9157
SP 9157DP 6428
SP 6428DP 5775
SP 5775DP 6428
SP provides ldquoreturn addressrdquo
3-9
Connection-oriented demultiplexing
TCP socket identified by 4-tuple
source IP addresssource port numberdest IP addressdest port number
recv host uses all four values to direct segment to appropriate socket
Server host may support many simultaneous TCP sockets
each socket identified by its own 4-tuple
Web servers have different sockets for each connecting client
non-persistent HTTP will have different socket for each request
3-10
Connection-oriented demultiplexing
ClientIPB
P1
clientIP A
P1P2P4
serverIP C
SP 9157DP 80
SP 9157DP 80
P5 P6 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-5
Multiplexingdemultiplexing
application
transport
network
link
physical
P1 application
transport
network
link
physical
application
transport
network
link
physical
P2P3 P4P1
host 1 host 2 host 3
= process= socket
delivering received segmentsto correct socket
Demultiplexing at rcv hostgathering data from multiplesockets enveloping data with header (later used for demultiplexing)
Multiplexing at send host
3-6
How demultiplexing workshost receives IP datagrams
each datagram has source IP address destination IP addresseach datagram carries 1 transport-layer segmenteach segment has source destination port number
host uses IP addresses amp port numbers to direct segment to appropriate socket
source port dest port
32 bits
applicationdata
(message)
other header fields
TCPUDP segment format
3-7
Connectionless demultiplexing
Create sockets with port numbers
DatagramSocket mySocket1 = new DatagramSocket( )
DatagramSocket mySocket2 = new DatagramSocket( )
UDP socket identified by two-tuple
(dest IP address dest port number)
When host receives UDP segment
checks destination port number in segmentdirects UDP segment to socket with that port number
IP datagrams with different source IP addresses andor source port numbers directed to same socket
3-8
Connectionless demultiplexingDatagramSocket serverSocket = new DatagramSocket(6428)
ClientIPB
P2
clientIP A
P1P1P3
serverIP C
SP 6428DP 9157
SP 9157DP 6428
SP 6428DP 5775
SP 5775DP 6428
SP provides ldquoreturn addressrdquo
3-9
Connection-oriented demultiplexing
TCP socket identified by 4-tuple
source IP addresssource port numberdest IP addressdest port number
recv host uses all four values to direct segment to appropriate socket
Server host may support many simultaneous TCP sockets
each socket identified by its own 4-tuple
Web servers have different sockets for each connecting client
non-persistent HTTP will have different socket for each request
3-10
Connection-oriented demultiplexing
ClientIPB
P1
clientIP A
P1P2P4
serverIP C
SP 9157DP 80
SP 9157DP 80
P5 P6 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-6
How demultiplexing workshost receives IP datagrams
each datagram has source IP address destination IP addresseach datagram carries 1 transport-layer segmenteach segment has source destination port number
host uses IP addresses amp port numbers to direct segment to appropriate socket
source port dest port
32 bits
applicationdata
(message)
other header fields
TCPUDP segment format
3-7
Connectionless demultiplexing
Create sockets with port numbers
DatagramSocket mySocket1 = new DatagramSocket( )
DatagramSocket mySocket2 = new DatagramSocket( )
UDP socket identified by two-tuple
(dest IP address dest port number)
When host receives UDP segment
checks destination port number in segmentdirects UDP segment to socket with that port number
IP datagrams with different source IP addresses andor source port numbers directed to same socket
3-8
Connectionless demultiplexingDatagramSocket serverSocket = new DatagramSocket(6428)
ClientIPB
P2
clientIP A
P1P1P3
serverIP C
SP 6428DP 9157
SP 9157DP 6428
SP 6428DP 5775
SP 5775DP 6428
SP provides ldquoreturn addressrdquo
3-9
Connection-oriented demultiplexing
TCP socket identified by 4-tuple
source IP addresssource port numberdest IP addressdest port number
recv host uses all four values to direct segment to appropriate socket
Server host may support many simultaneous TCP sockets
each socket identified by its own 4-tuple
Web servers have different sockets for each connecting client
non-persistent HTTP will have different socket for each request
3-10
Connection-oriented demultiplexing
ClientIPB
P1
clientIP A
P1P2P4
serverIP C
SP 9157DP 80
SP 9157DP 80
P5 P6 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-7
Connectionless demultiplexing
Create sockets with port numbers
DatagramSocket mySocket1 = new DatagramSocket( )
DatagramSocket mySocket2 = new DatagramSocket( )
UDP socket identified by two-tuple
(dest IP address dest port number)
When host receives UDP segment
checks destination port number in segmentdirects UDP segment to socket with that port number
IP datagrams with different source IP addresses andor source port numbers directed to same socket
3-8
Connectionless demultiplexingDatagramSocket serverSocket = new DatagramSocket(6428)
ClientIPB
P2
clientIP A
P1P1P3
serverIP C
SP 6428DP 9157
SP 9157DP 6428
SP 6428DP 5775
SP 5775DP 6428
SP provides ldquoreturn addressrdquo
3-9
Connection-oriented demultiplexing
TCP socket identified by 4-tuple
source IP addresssource port numberdest IP addressdest port number
recv host uses all four values to direct segment to appropriate socket
Server host may support many simultaneous TCP sockets
each socket identified by its own 4-tuple
Web servers have different sockets for each connecting client
non-persistent HTTP will have different socket for each request
3-10
Connection-oriented demultiplexing
ClientIPB
P1
clientIP A
P1P2P4
serverIP C
SP 9157DP 80
SP 9157DP 80
P5 P6 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-8
Connectionless demultiplexingDatagramSocket serverSocket = new DatagramSocket(6428)
ClientIPB
P2
clientIP A
P1P1P3
serverIP C
SP 6428DP 9157
SP 9157DP 6428
SP 6428DP 5775
SP 5775DP 6428
SP provides ldquoreturn addressrdquo
3-9
Connection-oriented demultiplexing
TCP socket identified by 4-tuple
source IP addresssource port numberdest IP addressdest port number
recv host uses all four values to direct segment to appropriate socket
Server host may support many simultaneous TCP sockets
each socket identified by its own 4-tuple
Web servers have different sockets for each connecting client
non-persistent HTTP will have different socket for each request
3-10
Connection-oriented demultiplexing
ClientIPB
P1
clientIP A
P1P2P4
serverIP C
SP 9157DP 80
SP 9157DP 80
P5 P6 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-9
Connection-oriented demultiplexing
TCP socket identified by 4-tuple
source IP addresssource port numberdest IP addressdest port number
recv host uses all four values to direct segment to appropriate socket
Server host may support many simultaneous TCP sockets
each socket identified by its own 4-tuple
Web servers have different sockets for each connecting client
non-persistent HTTP will have different socket for each request
3-10
Connection-oriented demultiplexing
ClientIPB
P1
clientIP A
P1P2P4
serverIP C
SP 9157DP 80
SP 9157DP 80
P5 P6 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-10
Connection-oriented demultiplexing
ClientIPB
P1
clientIP A
P1P2P4
serverIP C
SP 9157DP 80
SP 9157DP 80
P5 P6 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-11
Connection-oriented demultiplexing Threaded Web Server
ClientIPB
P1
clientIP A
P1P2
serverIP C
SP 9157DP 80
SP 9157DP 80
P4 P3
D-IPCS-IP AD-IPC
S-IP B
SP 5775DP 80
D-IPCS-IP B
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-12
UDP User Datagram Protocol [RFC 768]
ldquono frillsrdquo ldquobare bonesrdquo Internet transport protocolldquobest effortrdquo service UDP segments may be
lostdelivered out of order to app
connectionlessno handshaking between UDP sender receivereach UDP segment handled independently of others
Why is there a UDPno connection establishment (which can add delay)simple no connection state at sender receiversmall segment headerno congestion control UDP can blast away as fast as desired
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-13
UDP moreoften used for streaming multimedia apps
loss tolerantrate sensitive
other UDP usesDNSSNMP
reliable transfer over UDP add reliability at application layer
application-specific error recovery
source port dest port
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength in
bytes of UDPsegmentincluding
header
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-14
UDP checksum
Sendertreat segment contents as sequence of 16-bit integerschecksum addition (1rsquos complement sum) of segment contentssender puts checksum value into UDP checksum field
Receivercompute checksum of received segmentcheck if computed checksum equals checksum field value
NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip
Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted segment
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-15
Internet Checksum ExampleNote
When adding numbers a carryout from the most significant bit needs to be added to the result
Example 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
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-16
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-17
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-18
Principles of Reliable data transferimportant in app transport link layerstop-10 list of important networking topics
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-19
Reliable data transfer getting started
sendside
receiveside
rdt_send() called from above (eg by app) Passed data to
deliver to receiver upper layer
udt_send() called by rdtto transfer packet over
unreliable channel to receiver
rdt_rcv() called when packet arrives on rcv-side of channel
deliver_data() called by rdt to deliver data to upper
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-20
Reliable data transfer getting startedWersquoll
incrementally develop sender receiver sides of reliable data transfer protocol (rdt)consider only unidirectional data transfer
but control info will flow on both directionsuse finite state machines (FSM) to specify sender receiver
state1
state2
event causing state transitionactions taken on state transition
state when in this ldquostaterdquo next state
uniquely determined by next event
eventactions
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-21
Rdt10 reliable transfer over a reliable channel
underlying channel perfectly reliableno bit errorsno loss of packets
separate FSMs for sender receiversender sends data into underlying channelreceiver read data from underlying channel
Wait for call from above packet = make_pkt(data)
udt_send(packet)
rdt_send(data)extract (packetdata)deliver_data(data)
Wait for call from
below
rdt_rcv(packet)
sender receiver
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-22
Rdt20 channel with bit errors
underlying channel may flip bits in packetchecksum to detect bit errors
the question how to recover from errorsacknowledgements (ACKs) receiver explicitly tells sender that pkt received OKnegative acknowledgements (NAKs) receiver explicitly tells sender that pkt had errorssender retransmits pkt on receipt of NAK
new mechanisms in rdt20 (beyond rdt10)error detectionreceiver feedback control msgs (ACKNAK) rcvr-gtsender
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-23
rdt20 FSM specification
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
belowsender
receiverrdt_send(data)
Λ
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-24
rdt20 operation with no errors
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-25
rdt20 error scenario
Wait for call from above
snkpkt = make_pkt(data checksum)udt_send(sndpkt)
extract(rcvpktdata)deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampampisNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Wait for ACK or
NAK
Wait for call from
below
rdt_send(data)
Λ
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-26
rdt20 has a fatal flaw
What happens if ACKNAK corruptedsender doesnrsquot know what happened at receivercanrsquot just retransmit possible duplicate
Handling duplicates sender retransmits current pkt if ACKNAK garbledsender adds sequence number to each pktreceiver discards (doesnrsquot deliver up) duplicate pkt
Sender sends one packet then waits for receiver response
stop and wait
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-27
rdt21 sender handles garbled ACKNAKs
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt)
Wait forcall 1 from
above
Wait for ACK or NAK 1
ΛΛ
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-28
rdt21 receiver handles garbled ACKNAKs
Wait for 0 from below
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq0(rcvpkt)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq0(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp not corrupt(rcvpkt) ampamphas_seq1(rcvpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt)
sndpkt = make_pkt(ACK chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK chksum)udt_send(sndpkt)
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-29
rdt21 discussion
Senderseq added to pkttwo seq rsquos (01) will suffice Whymust check if received ACKNAK corrupted twice as many states
state must ldquorememberrdquo whether ldquocurrentrdquo pkt has 0 or 1 seq
Receivermust check if received packet is duplicate
state indicates whether 0 or 1 is expected pkt seq
note receiver can notknow if its last ACKNAK received OK at sender
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-30
rdt22 a NAK-free protocol
same functionality as rdt21 using ACKs onlyinstead of NAK receiver sends ACK for last pkt received OK
receiver must explicitly include seq of pkt being ACKed duplicate ACK at sender results in same action as NAK retransmit current pkt
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-31
rdt22 sender receiver fragments
Wait for call 0 from
above
sndpkt = make_pkt(0 data checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||
isACK(rcvpkt1) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
Wait for ACK
0sender FSM
fragment
Wait for 0 from below
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp has_seq1(rcvpkt)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(ACK1 chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) ampamp (corrupt(rcvpkt) ||
has_seq1(rcvpkt))
udt_send(sndpkt)receiver FSM
fragment
Λ
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-32
rdt30 channels with errors and loss
New assumptionunderlying channel can also lose packets (data or ACKs)
checksum seq ACKs retransmissions will be of help but not enough
Approach sender waits ldquoreasonablerdquo amount of time for ACK retransmits if no ACK received in this timeif pkt (or ACK) just delayed (not lost)
retransmission will be duplicate but use of seq rsquos already handles thisreceiver must specify seq of pkt being ACKed
requires countdown timer
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-33
rdt30 sendersndpkt = make_pkt(0 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for
ACK0
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt1) )
Wait for call 1 from
above
sndpkt = make_pkt(1 data checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt0)
rdt_rcv(rcvpkt) ampamp ( corrupt(rcvpkt) ||isACK(rcvpkt0) )
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt) ampamp isACK(rcvpkt1)
stop_timerstop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0from
above
Wait for
ACK1
Λrdt_rcv(rcvpkt)
ΛΛ
Λ
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-34
rdt30 in action
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-35
rdt30 in action
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-36
Performance of rdt30
rdt30 works but performance stinksex 1 Gbps link 15 ms prop delay 8000 bit packet
U sender utilization ndash fraction of time sender busy sending
U sender =
00830008
= 000027 L R RTT + L R
=
1KB pkt every 30 msec -gt 33kBsec thruput over 1 Gbps linknetwork protocol limits use of physical resources
dsmicrosecon8bps10bits8000
9 ===RLdtrans
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-37
rdt30 stop-and-wait operation
first packet bit transmitted t = 0
sender receiver
RTT
last packet bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
U sender =
008 30008
= 000027 L R RTT + L R
=
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-38
Pipelined protocolsPipelining sender allows multiple ldquoin-flightrdquo yet-to-
be-acknowledged pktsrange of sequence numbers must be increasedbuffering at sender andor receiver
Two generic forms of pipelined protocols go-Back-N selective repeat
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-39
Pipelining increased utilization
first packet bit transmitted t = 0
sender receiver
RTT
last bit transmitted t = L R
first packet bit arriveslast packet bit arrives send ACK
ACK arrives send next packet t = RTT + L R
last bit of 2nd packet arrives send ACKlast bit of 3rd packet arrives send ACK
U sender =
02430008
= 00008 3 L R RTT + L R
=
Increase utilizationby a factor of 3
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-40
Pipelining Protocols
Go-back-N big pictureSender can have up to N unacked packets in pipelineRcvr only sends cumulative acks
Doesnrsquot ack packet if therersquos a gap
Sender has timer for oldest unacked packet
If timer expires retransmit all unacked packets
Selective Repeat big picSender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-41
Selective repeat big picture
Sender can have up to N unacked packets in pipelineRcvr acks individual packetsSender maintains timer for each unacked packet
When timer expires retransmit only unack packet
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-42
Go-Back-NSender
k-bit seq in pkt headerldquowindowrdquo of up to N consecutive unackrsquoed pkts allowed
ACK(n) ACKs all pkts up to including seq n - ldquocumulative ACKrdquomay receive duplicate ACKs (see receiver)
timer for each in-flight pkttimeout(n) retransmit pkt n and all higher seq pkts in window
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-43
GBN sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])hellipudt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum lt base+N) sndpkt[nextseqnum] = make_pkt(nextseqnumdatachksum)udt_send(sndpkt[nextseqnum])if (base == nextseqnum)
start_timernextseqnum++
elserefuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum)
stop_timerelsestart_timer
rdt_rcv(rcvpkt) ampamp notcorrupt(rcvpkt)
base=1nextseqnum=1
rdt_rcv(rcvpkt) ampamp corrupt(rcvpkt)
Λ
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-44
GBN receiver extended FSM
ACK-only always send ACK for correctly-received pkt with highest in-order seq
may generate duplicate ACKsneed only remember expectedseqnum
out-of-order pkt discard (donrsquot buffer) -gt no receiver bufferingRe-ACK pkt with highest in-order seq
Wait
udt_send(sndpkt)default
rdt_rcv(rcvpkt)ampamp notcurrupt(rcvpkt)ampamp hasseqnum(rcvpktexpectedseqnum)
extract(rcvpktdata)deliver_data(data)sndpkt = make_pkt(expectedseqnumACKchksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=1sndpkt = make_pkt(expectedseqnumACKchksum)
Λ
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-45
GBN inaction
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-46
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 pktsender window
N consecutive seq rsquosagain limits seq s of sent unACKed pkts
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-47
Selective repeat sender receiver windows
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-48
Selective repeat
data from above if next available seq in window send pkt
timeout(n)resend pkt n restart timer
ACK(n) in [sendbasesendbase+N]
mark pkt n as receivedif n smallest unACKed pkt advance window base to next unACKed seq
senderpkt n in [rcvbase rcvbase+N-1]
send ACK(n)out-of-order bufferin-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
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-49
Selective repeat in action
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-50
Selective repeatdilemma
Example seq rsquos 0 1 2 3window size=3
receiver sees no difference in two scenariosincorrectly passes duplicate data as new in (a)
Q what relationship between seq size and window size
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-51
TCP Overview RFCs 793 1122 1323 2018 2581
full duplex databi-directional data flow in same connectionMSS maximum segment size
connection-orientedhandshaking (exchange of control msgs) initrsquos sender receiver state before data exchange
flow controlledsender will not overwhelm receiver
point-to-pointone sender one receiver
reliable in-order byte steam
no ldquomessage boundariesrdquopipelined
TCP congestion and flow control set window size
send amp receive buffers
socketdoor
TCPsend buffer
TCPreceive buffer
socketdoor
segment
applicationwrites data
applicationreads data
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-52
TCP segment structure
source port dest port
32 bits
applicationdata
(variable length)
sequence numberacknowledgement number
Receive windowUrg data pnterchecksum
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)
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-53
TCP seq rsquos and ACKsSeq rsquos
byte stream ldquonumberrdquo of first byte in segmentrsquos data
ACKsseq of next byte expected from other sidecumulative ACK
Q how receiver handles out-of-order segments
A TCP spec doesnrsquot say - up to implementor
Host A Host B
Usertypes
lsquoCrsquo
host ACKsreceipt
of echoedlsquoCrsquo
host ACKsreceipt oflsquoCrsquo echoes
back lsquoCrsquo
timesimple telnet scenario
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-54
TCP Round Trip Time and Timeout
Q how to set TCP timeout valuelonger than RTT
but RTT variestoo short premature timeout
unnecessary retransmissions
too long slow reaction to segment loss
Q how to estimate RTTSampleRTT measured time from segment transmission until ACK receipt
ignore retransmissionsSampleRTT will vary want estimated RTT ldquosmootherrdquo
average several recent measurements not just current SampleRTT
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-55
TCP Round Trip Time and Timeout
EstimatedRTT = (1- α)EstimatedRTT + αSampleRTT
Exponential weighted moving averageinfluence of past sample decreases exponentially fasttypical value α = 0125
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-56
Example RTT estimation
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-57
TCP Round Trip Time and Timeout
Setting the timeoutEstimtedRTT plus ldquosafety marginrdquo
large variation in EstimatedRTT -gt larger safety marginfirst estimate of how much SampleRTT deviates from EstimatedRTT
TimeoutInterval = EstimatedRTT + 4DevRTT
DevRTT = (1-β)DevRTT +β|SampleRTT-EstimatedRTT|
(typically β = 025)
Then set timeout interval
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-58
TCP reliable data transfer
TCP creates rdt service on top of IPrsquos unreliable servicePipelined segmentsCumulative acksTCP uses single retransmission timer
Retransmissions are triggered by
timeout eventsduplicate acks
Initially consider simplified TCP sender
ignore duplicate acksignore flow control congestion control
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-59
TCP sender eventsdata rcvd from app
Create segment with seq seq is byte-stream number of first data byte in segmentstart timer if not already running (think of timer as for oldest unacked segment)expiration interval TimeOutInterval
timeoutretransmit segment that caused timeoutrestart timer
Ack rcvdIf acknowledges previously unacked segments
update what is known to be ackedstart timer if there are outstanding segments
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-60
TCP sender(simplified)
NextSeqNum = InitialSeqNumSendBase = InitialSeqNum
loop (forever) switch(event)
event data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running)
start timerpass segment to IP NextSeqNum = NextSeqNum + length(data)
event timer timeoutretransmit not-yet-acknowledged segment with
smallest sequence numberstart timer
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
end of loop forever
Commentbull SendBase-1 last cumulatively ackrsquoed byteExamplebull SendBase-1 = 71y= 73 so the rcvrwants 73+ y gt SendBase sothat new data is acked
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-61
TCP retransmission scenariosHost A
timepremature timeout
Host B
Seq=
92 t
imeo
ut
Host A
loss
tim
eout
lost ACK scenario
Host B
X
time
Seq=
92 t
imeo
utSendBase
= 100
SendBase= 120
SendBase= 120
Sendbase= 100
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-62
TCP retransmission scenarios (more)Host A
loss
tim
eout
Cumulative ACK scenario
Host B
X
time
SendBase= 120
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-63
TCP ACK generation [RFC 1122 RFC 2581]
Event at Receiver
Arrival of in-order segment withexpected seq All data up toexpected seq already ACKed
Arrival of in-order segment withexpected seq One other segment has ACK pending
Arrival of out-of-order segmenthigher-than-expect seq Gap detected
Arrival of segment that partially or completely fills gap
TCP Receiver action
Delayed ACK Wait up to 500msfor next segment If no next segmentsend ACK
Immediately send single cumulative ACK ACKing both in-order segments
Immediately send duplicate ACK indicating seq of next expected byte
Immediate send ACK provided thatsegment starts at lower end of gap
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-64
Fast Retransmit
Time-out period often relatively long
long delay before resending lost packet
Detect lost segments via duplicate ACKs
Sender often sends many segments back-to-backIf segment is lost there will likely be many duplicate ACKs
If sender receives 3 ACKs for the same data it supposes that segment after ACKed data was lost
fast retransmit resend segment before timer expires
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-65
Host A
tim
eout
Host B
time
X
Figure 337 Resending a segment after triple duplicate ACK
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-66
event ACK received with ACK field value of y if (y gt SendBase)
SendBase = yif (there are currently not-yet-acknowledged segments)
start timer
else increment count of dup ACKs received for yif (count of dup ACKs received for y = 3)
resend segment with sequence number y
Fast retransmit algorithm
a duplicate ACK for already ACKed segment
fast retransmit
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-67
TCP Flow Control
receive side of TCP connection has a receive buffer
speed-matching service matching the send rate to the receiving apprsquos drain rateapp process may be
slow at reading from buffer
sender wonrsquot overflowreceiverrsquos buffer by
transmitting too muchtoo fast
flow control
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-68
TCP Flow control how it works
(Suppose TCP receiver discards out-of-order segments)spare room in buffer
= RcvWindow= RcvBuffer-[LastByteRcvd -
LastByteRead]
Rcvr advertises spare room by including value of RcvWindow in segmentsSender limits unACKed data to RcvWindow
guarantees receive buffer doesnrsquot overflow
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-69
TCP Connection ManagementRecall TCP sender receiver
establish ldquoconnectionrdquo before exchanging data segmentsinitialize TCP variables
seq sbuffers flow control info (eg RcvWindow)
client connection initiatorSocket clientSocket = new Socket(hostnameport
number)
server contacted by clientSocket connectionSocket = welcomeSocketaccept()
Three way handshakeStep 1 client host sends TCP
SYN segment to serverspecifies initial seq no data
Step 2 server host receives SYN replies with SYNACK segment
server allocates buffersspecifies server initial seq
Step 3 client receives SYNACK replies with ACK segment which may contain data
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-70
TCP Connection Management (cont)
Closing a connection
client closes socketclientSocketclose()
Step 1 client end system sends TCP FIN control segment to server
Step 2 server receives FIN replies with ACK Closes connection sends FIN
client server
close
close
closed
tim
ed w
ait
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-71
TCP Connection Management (cont)
Step 3 client receives FIN replies with ACK
Enters ldquotimed waitrdquo -will respond with ACK to received FINs
Step 4 server receives ACK Connection closed
Note with small modification can handle simultaneous FINs
client server
closing
closing
closed
tim
ed w
ait
closed
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-72
TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-73
Principles of Congestion Control
Congestioninformally ldquotoo many sources sending too much data too fast for network to handlerdquodifferent from flow controlmanifestations
lost packets (buffer overflow at routers)long delays (queueing in router buffers)
a top-10 problem
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-74
Causescosts of congestion scenario 1
two senders two receiversone router infinite buffers no retransmission
large delays when congestedmaximum achievable throughput
unlimited shared output link buffers
Host Aλin original data
Host B
λout
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-75
Causescosts of congestion scenario 2
one router finite buffers sender retransmission of lost packet
finite shared output link buffers
Host A λin original data
Host B
λout
λin original data plus retransmitted data
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-76
Causescosts of congestion scenario 2always (goodput)ldquoperfectrdquo retransmission only when loss
retransmission of delayed (not lost) packet makes larger (than perfect case) for same
λin
λout=
λin
λoutgtλ
inλout
ldquocostsrdquo of congestionmore work (retrans) for given ldquogoodputrdquounneeded retransmissions link carries multiple copies of pkt
R2
R2λin
λ out
b
R2
R2λin
λ out
a
R2
R2λin
λ out
c
R4
R3
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-77
Causescosts of congestion scenario 3four sendersmultihop pathstimeoutretransmit
λin
Q what happens as and increase λ
in
finite shared output link buffers
Host Aλin original data
Host B
λout
λin original data plus retransmitted data
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-78
Causescosts of congestion scenario 3
Another ldquocostrdquo of congestionwhen packet dropped any ldquoupstream transmission capacity used for that packet was wasted
Host A
Host B
λout
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-79
Approaches towards congestion control
End-end congestion controlno explicit feedback from networkcongestion inferred from end-system observed loss delayapproach taken by TCP
Network-assisted congestion controlrouters provide feedback to end systems
single bit indicating congestion (SNA DECbit TCPIP ECN ATM)explicit rate sender should send at
Two broad approaches towards congestion control
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-80
Case study ATM ABR congestion control
ABR available bit rateldquoelastic servicerdquo if senderrsquos path ldquounderloadedrdquo
sender should use available bandwidth
if senderrsquos path congested
sender throttled to minimum guaranteed rate
RM (resource management) cellssent by sender interspersed with data cellsbits in RM cell set by switches (ldquonetwork-assistedrdquo)
NI bit no increase in rate (mild congestion)CI bit congestion indication
RM cells returned to sender by receiver with bits intact
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-81
Case study ATM ABR congestion control
two-byte ER (explicit rate) field in RM cellcongested switch may lower ER value in cellsenderrsquo send rate thus maximum supportable rate on path
EFCI bit in data cells set to 1 in congested switchif data cell preceding RM cell has EFCI set sender sets CI bit in returned RM cell
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-82
TCP congestion control additive increase multiplicative decrease
8 Kbytes
16 Kbytes
24 Kbytes
time
congestionwindow
Approach increase transmission rate (window size) probing for usable bandwidth until loss occurs
additive increase increase CongWin by 1 MSS every RTT until loss detectedmultiplicative decrease cut CongWin in half after loss
timecong
estio
n w
indo
w s
ize
Saw toothbehavior probing
for bandwidth
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-83
TCP Congestion Control details
sender limits transmissionLastByteSent-LastByteAcked
le CongWin
Roughly
CongWin is dynamic function of perceived network congestion
How does sender perceive congestionloss event = timeout or3 duplicate acksTCP sender reduces rate (CongWin) after loss event
three mechanismsAIMDslow startconservative after timeout events
rate = CongWinRTT Bytessec
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-84
TCP Slow Start
When connection begins CongWin = 1 MSS
Example MSS = 500 bytes amp RTT = 200 msecinitial rate = 20 kbps
available bandwidth may be gtgt MSSRTT
desirable to quickly ramp up to respectable rate
When connection begins increase rate exponentially fast until first loss event
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-85
TCP Slow Start (more)
When connection begins increase rate exponentially until first loss event
double CongWin every RTTdone by incrementing CongWin for every ACK received
Summary initial rate is slow but ramps up exponentially fast
Host A
RTT
Host B
time
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-86
Refinement inferring lossAfter 3 dup ACKs
CongWin is cut in halfwindow then grows linearly
But after timeout eventCongWin instead set to 1 MSS window then grows exponentiallyto a threshold then grows linearly
3 dup ACKs indicates network capable of delivering some segments
timeout indicates a ldquomore alarmingrdquo congestion scenario
Philosophy
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-87
RefinementQ When should the
exponential increase switch to linear
A When CongWingets to 12 of its value before timeout
ImplementationVariable Threshold At loss event Threshold is set to 12 of CongWin just before loss event
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-88
Summary TCP Congestion Control
When CongWin is below Threshold sender in slow-start phase window grows exponentially
When CongWin is above Threshold sender is in congestion-avoidance phase window grows linearly
When a triple duplicate ACK occurs Thresholdset to CongWin2 and CongWin set to Threshold
When timeout occurs Threshold set to CongWin2 and CongWin is set to 1 MSS
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-89
TCP sender congestion controlState Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS If (CongWin gt Threshold)
set state to ldquoCongestion Avoidancerdquo
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+MSS (MSSCongWin)
Additive increase resulting in increase of CongWin by 1 MSS every RTT
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin2 CongWin = ThresholdSet state to ldquoCongestion Avoidancerdquo
Fast recovery implementing multiplicative decrease CongWin will not drop below 1 MSS
SS or CA Timeout Threshold = CongWin2 CongWin = 1 MSSSet state to ldquoSlow Startrdquo
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-90
TCP throughput
Whatrsquos the average throughout of TCP as a function of window size and RTT
Ignore slow startLet W be the window size when loss occursWhen window is W throughput is WRTTJust after loss window drops to W2 throughput to W2RTT Average throughout 75 WRTT
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-91
TCP Futures TCP over ldquolong fat pipesrdquo
Example 1500 byte segments 100ms RTT want 10 Gbps throughputRequires window size W = 83333 in-flight segmentsThroughput in terms of loss rate
L = 210-10 WowNew versions of TCP for high-speed
LRTTMSSsdot221
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-92
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 connection 2
TCP Fairness
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-93
Why is TCP fairTwo competing sessions
Additive increase gives slope of 1 as throughout increasesmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
congestion avoidance additive increaseloss decrease window by factor of 2
congestion avoidance additive increaseloss decrease window by factor of 2
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-
3-94
Fairness (more)Fairness and UDP
Multimedia apps often do not use TCP
do not want rate throttled by congestion control
Instead use UDPpump audiovideo at constant rate tolerate packet loss
Research area TCP friendly
Fairness and parallel TCP connectionsnothing prevents app from opening parallel connections between 2 hostsWeb browsers do this Example link of rate R supporting 9 connections
new app asks for 1 TCP gets rate R10new app asks for 11 TCPs gets R2
- Slide Number 1
- Transport services and protocols
- Transport vs network layer
- Internet transport-layer protocols
- Multiplexingdemultiplexing
- How demultiplexing works
- Connectionless demultiplexing
- Connectionless demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing
- Connection-oriented demultiplexing Threaded Web Server
- UDP User Datagram Protocol [RFC 768]
- UDP more
- UDP checksum
- Internet Checksum Example
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Principles of Reliable data transfer
- Reliable data transfer getting started
- Reliable data transfer getting started
- Rdt10 reliable transfer over a reliable channel
- Rdt20 channel with bit errors
- rdt20 FSM specification
- rdt20 operation with no errors
- rdt20 error scenario
- rdt20 has a fatal flaw
- rdt21 sender handles garbled ACKNAKs
- rdt21 receiver handles garbled ACKNAKs
- rdt21 discussion
- rdt22 a NAK-free protocol
- rdt22 sender receiver fragments
- rdt30 channels with errors and loss
- rdt30 sender
- rdt30 in action
- rdt30 in action
- Performance of rdt30
- rdt30 stop-and-wait operation
- Pipelined protocols
- Pipelining increased utilization
- Pipelining Protocols
- Selective repeat big picture
- Go-Back-N
- GBN sender extended FSM
- GBN receiver extended FSM
- GBN inaction
- Selective Repeat
- Selective repeat sender receiver windows
- Selective repeat
- Selective repeat in action
- Selective repeat dilemma
- TCP Overview RFCs 793 1122 1323 2018 2581
- TCP segment structure
- TCP seq rsquos and ACKs
- TCP Round Trip Time and Timeout
- TCP Round Trip Time and Timeout
- Example RTT estimation
- TCP Round Trip Time and Timeout
- TCP reliable data transfer
- TCP sender events
- TCP sender(simplified)
- TCP retransmission scenarios
- TCP retransmission scenarios (more)
- TCP ACK generation [RFC 1122 RFC 2581]
- Fast Retransmit
- Slide Number 65
- Fast retransmit algorithm
- TCP Flow Control
- TCP Flow control how it works
- TCP Connection Management
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- TCP Connection Management (cont)
- Principles of Congestion Control
- Causescosts of congestion scenario 1
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 2
- Causescosts of congestion scenario 3
- Causescosts of congestion scenario 3
- Approaches towards congestion control
- Case study ATM ABR congestion control
- Case study ATM ABR congestion control
- TCP congestion control additive increase multiplicative decrease
- TCP Congestion Control details
- TCP Slow Start
- TCP Slow Start (more)
- Refinement inferring loss
- Refinement
- Summary TCP Congestion Control
- TCP sender congestion control
- TCP throughput
- TCP Futures TCP over ldquolong fat pipesrdquo
- TCP Fairness
- Why is TCP fair
- Fairness (more)
-