Transport Layer
11-1
2016 session 1TELE3118: Network TechnologiesWeek 11: Transport LayerTCP
Some slides have been taken from:
rComputer Networking: A Top Down Approach Featuring the Internet,3rd edition. Jim Kurose, Keith Ross. Addison-Wesley, July 2004. Allmaterial copyright 1996-2004. J.F Kurose and K.W. Ross, All RightsReserved.
Transport Layer
11-2
TCP Connection Management: Setup
Recall: TCP sender, receiverestablish connectionbefore exchanging datasegments
rinitialize TCP variables:
mseq. #s
buffers, flow controlinfo (e.g. RcvWindow)
rclient: connection initiator
mconnect()
rserver: contacted by client
maccept()
Three way handshake:
Step 1: client host sends TCPSYN segment to server
mspecifies initial seq #
mno data
Step 2: server host receivesSYN, replies with SYNACKsegment
mserver allocates buffers
mspecifies server initialseq. #
Step 3: client receives SYNACK,replies with ACK segment,which may contain data
Transport Layer
11-3
TCP Connection Management: Teardown
Closing a connection:
Step 1: client end systemsends TCP FIN controlsegment to server
Step 2: server receives FIN,replies with ACK. Closesconnection, sends FIN.
Step 3: client receives FIN,replies with ACK.
mEnters timed wait -will respond with ACKto received FINs
Step 4: server, receives ACK.Connection closed.
client
FIN
server
ACK
ACK
FIN
close
close
closed
timed wait
Transport Layer
11-4
TCP Connection Management (cont)
transClient
transServer2
TCP client
lifecycle
TCP server
lifecycle
Transport Layer
11-5
TCP Flow Control
rreceive side of TCPconnection has areceive buffer:
rspeed-matchingservice: matching thesend rate to thereceiving apps drainrate
rcvwin
rapp process may beslow at reading frombuffer
sender wont overflow
receivers buffer by
transmitting too much,
 too fast
flow control
Transport Layer
11-6
TCP Flow control: how it works
(Suppose TCP receiverdiscards out-of-ordersegments)
spare room in buffer
= RcvWindow
= RcvBuffer-[LastByteRcvd -LastByteRead]
Rcvr advertises spareroom by including valueof RcvWindow insegments
Sender limits unACKeddata to RcvWindow
mguarantees receivebuffer doesnt overflow
rcvwin
Transport Layer
11-7
Congestion Control
Congestion:
rinformally: too many sources sending too muchdata too fast for network to handle
rdifferent from flow control!
rmanifestations:
mlost packets (buffer overflow at routers)
mlong delays (queueing in router buffers)
ra top-10 problem!
Transport Layer
11-8
Approaches towards congestion control
End-end congestioncontrol:
rno explicit feedback fromnetwork
rcongestion inferred fromend-system observed loss,delay
rapproach taken by TCP
Network-assistedcongestion control:
rrouters provide feedbackto end systems
msingle bit indicatingcongestion (SNA,DECbit, TCP/IP ECN,ATM)
mexplicit rate sendershould send at
Two broad approaches towards congestion control:
Transport Layer
11-9
TCP Congestion Control
rend-end control (no networkassistance)
rsender limits transmission:
  LastByteSent-LastByteAcked
                    CongWin
rRoughly,
CongWin is dynamic, functionof perceived networkcongestion
How does  senderperceive congestion?
rloss event = timeout or3 duplicate acks
TCP sender reducesrate (CongWin) afterloss event
three mechanisms:
mAIMD
mslow start
mconservative aftertimeout events
rate =
CongWin
RTT
Bytes/sec
Transport Layer
11-10
TCP AIMD
multiplicative decrease:cut CongWin in halfafter loss event
additive increase:increase  CongWin by1 MSS every RTT inthe absence of lossevents: probing
Long-lived TCP connection
Transport Layer
11-11
TCP Slow Start
When connection begins,CongWin = 1 MSS. E.g.:
MSS = 500 bytes
RTT = 200 msec
initial rate = 20 kbps
ravailable bandwidth may be >>MSS/RTT
mRamp-up takes too long
rWhen connection begins,increase rate exponentiallyuntil first loss event:
double CongWin every RTT
done by incrementing CongWinfor every ACK received
rSummary: initial rate slow butramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
Transport Layer
11-12
Refinement
rAfter 3 dup ACKs:
CongWin is cut in half
mwindow then growslinearly
rBut after timeout event:
CongWin instead set to1 MSS;
mwindow then growsexponentially
mto a threshold, thengrows linearly
 3 dup ACKs indicatesnetwork capable ofdelivering some segments
 timeout before 3 dupACKs is more alarming
Philosophy:
Transport Layer
11-13
Refinement (more)
Q: When should theexponential increaseswitch to linear?
A: When CongWin gets to1/2 of its value beforetimeout.
 
Implementation:
rVariable Threshold
rAt loss event, Threshold isset to 1/2 of CongWin justbefore loss event
Transport Layer
11-14
Summary: TCP Congestion Control
When CongWin is below Threshold, sender inslow-start phase, window grows exponentially.
When CongWin is above Threshold, sender is incongestion-avoidance phase, window grows linearly.
When a triple duplicate ACK occurs, Thresholdset to CongWin/2 and CongWin set toThreshold.
When timeout occurs, Threshold set toCongWin/2 and CongWin is set to 1 MSS.
Transport Layer
11-15
TCP sender congestion control
Event
State
TCP Sender Action
Commentary
ACK receiptfor previouslyunackeddata
Slow Start(SS)
CongWin = CongWin + MSS,
If (CongWin > Threshold)
      set state to CongestionAvoidance
Resulting in a doubling ofCongWin every RTT
ACK receiptfor previouslyunackeddata
Congestion
Avoidance(CA)
CongWin = CongWin+MSS *(MSS/CongWin)
 
Additive increase, resultingin increase of CongWin  by1 MSS every RTT
Loss eventdetected bytripleduplicateACK
SS or CA
Threshold = CongWin/2,
CongWin = Threshold,
Set state to CongestionAvoidance
Fast recovery,implementing multiplicativedecrease. CongWin will notdrop below 1 MSS.
Timeout
SS or CA
Threshold = CongWin/2,
CongWin = 1 MSS,
Set state to Slow Start
Enter slow start
DuplicateACK
SS or CA
Increment duplicate ACK countfor segment being acked
CongWin and Threshold notchanged
Transport Layer
11-16
TCP throughput
rWhats the average throughout of TCP as afunction of window size and RTT?
mIgnore slow start
rLet W be the window size when loss occurs.
rWhen window is W, throughput is W/RTT
rJust after loss, window drops to W/2,throughput to W/2RTT.
rAverage throughout: .75 W/RTT
Transport Layer
11-17
TCP Futures
rExample: 1500 byte segments, 100ms RTT, want 10Gbps throughput
rRequires window size W = 83,333 in-flightsegments
rThroughput in terms of loss rate:
 L = 2·11-10  Wow
rNew versions of TCP for high-speed needed!
Transport Layer
11-18
Fairness goal: if K TCP sessions share samebottleneck link of bandwidth R, each should haveaverage rate of R/K
TCP connection 1
bottleneck
router
capacity R
TCP
connection 2
TCP Fairness
Transport Layer
11-19
Why is TCP fair?
Two competing sessions:
rAdditive increase gives slope of 1, as throughout increases
rmultiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughput
Connection 2 throughput
congestion avoidance: additive increase
loss: decrease window by factor of 2
congestion avoidance: additive increase
loss: decrease window by factor of 2
Transport Layer
11-20
Fairness (more)
Fairness and UDP
rMultimedia apps oftendo not use TCP
mdo not want ratethrottled by congestioncontrol
rInstead use UDP:
mpump audio/video atconstant rate, toleratepacket loss
rResearch area: TCPfriendly
Fairness and parallel TCPconnections
rnothing prevents app fromopening parallel cnctionsbetween 2 hosts.
rWeb browsers do this
rExample: link of rate Rsupporting 9 cnctions;
mnew app asks for 1 TCP, getsrate R/10
mnew app asks for 11 TCPs,gets R/2 !