EEC-484/584Computer NetworksEEC-484/584Computer Networks
Lecture 14Lecture 14
Wenbing ZhaoWenbing Zhao
(Part of the slides are based on Drs. Kurose &Rossslides for their Computer Networking book)(Part of the slides are based on Drs. Kurose &Rossslides for their Computer Networking book)
22
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
OutlineOutline
Reminder:
Wiki project#2 due: 4/16 Wednesday
Quiz 4: 4/21 Monday
TCP
Reliable data transfer (ack generation)
Flow control
Congestion control
33
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP ACK GenerationTCP ACK Generation
Event at Receiver
Arrival of in-order segment with
expected seq #. All data up to
expected seq # already ACKed
Arrival of in-order segment with
expected seq #. One other
segment has ACK pending
Arrival of out-of-order segment
higher-than-expect seq. # .
Gap detected
Arrival of segment that
partially or completely fills gap
TCP Receiver action
Delayed ACK. Wait up to 500ms
for next segment. If no next segment,
send 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 that
segment starts at lower end of gap
44
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP Flow ControlTCP Flow Control
Receive side of TCPconnection has areceive buffer:
Speed-matchingservice: matchingthe send rate to thereceiving app’s drainrate
rcvwin
App process may beslow at reading frombuffer
Flow control:
sender won’t overflow
receiver’s buffer by
transmitting too much,
 too fast
55
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP Flow ControlTCP Flow Control
(Suppose TCP receiver discardsout-of-order segments)
Spare room in buffer
= RcvWindow
= RcvBuffer-[LastByteRcvd- LastByteRead]
Rcvr advertisesspare room byincluding value ofRcvWindow insegments
Sender limitsunACKed data toRcvWindow
guarantees receivebuffer doesn’toverflow
rcvwin
66
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
Principles of Congestion ControlPrinciples of Congestion Control
Congestion:
Informally: “too many sources sending too muchdata too fast for network to handle”
Different from flow control!
Manifestations:
lost packets (buffer overflow at routers)
long delays (queueing in router buffers)
77
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
Approaches towards Congestion ControlApproaches towards Congestion Control
End-end congestioncontrol:
no explicit feedback fromnetwork
congestion inferred fromend-system observedloss, delay
approach taken by TCP
Network-assistedcongestion control:
routers provide feedbackto end systems
single bit indicatingcongestion (SNA,DECbit, TCP/IP ECN,ATM)
explicit rate sendershould send at
Two broad approaches towards congestion control
88
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP Congestion Control:Additive Increase, Multiplicative DecreaseTCP Congestion Control:Additive Increase, Multiplicative Decrease
Approach: increase transmission rate (window size),probing for usable bandwidth, until loss occurs
Additive increase: increase  cwnd every RTT untilloss detected
Multiplicative decrease: cut cwnd after loss
Saw tooth
behavior: probing
for bandwidth
Presentation1
99
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP Congestion ControlTCP Congestion Control
Sender limits transmission:
  LastByteSent-LastByteAcked
                    cwnd
Roughly,
cwnd is dynamic, function ofperceived networkcongestion
How does  senderperceivecongestion?
loss event = timeoutor 3 duplicate acks
TCP sender reducesrate (cwnd) afterloss event
rate =
cwnd
RTT
Bytes/sec
1010
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP Slow StartTCP Slow Start
When connection begins,cwnd = 1 MSS
Example: MSS = 500 bytes& RTT = 200 msec
Initial rate = 25 kBps
Available bandwidth maybe >> MSS/RTT
Desirable to quickly rampup to respectable rate
When connectionbegins, increase rateexponentially fast untilfirst loss event
1111
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP Slow StartTCP Slow Start
When connectionbegins, increase rateexponentially until firstloss event:
Double cwnd every RTT
Done by incrementingcwnd for every ACKreceived
Summary: initial rate isslow but ramps upexponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
1212
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
Congestion AvoidanceCongestion Avoidance
Q: When should theexponential increaseswitch to linear?
A: When cwnd gets to1/2 of its valuebefore timeout
 
Implementation:
Variable Threshold
At loss event, Thresholdis set to 1/2 of cwnd justbefore loss event
How to increase cwnd linearly:cwnd (new) = cwnd + mss*mss/cwnd
1313
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
Congestion ControlCongestion Control
After 3 duplicated ACKs:
cwnd is cut in half
window then grows linearly
But after timeout event:
cwnd instead set to 1 MSS
window then growsexponentially
to a threshold, then growslinearly
 3 dup ACKs indicatesnetwork capable ofdelivering some segments
 timeout indicates a“more alarming”congestion scenario
Philosophy:
1414
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
Summary: TCP Congestion ControlSummary: TCP Congestion Control
When cwnd is below Threshold, sender in slow-start phase, window grows exponentially
When cwnd is above Threshold, sender is incongestion-avoidance phase, window grows linearly
When a triple duplicate ACK occurs, Threshold setto cwnd/2 and cwnd set to Threshold
When timeout occurs, Threshold set to cwnd/2and cwnd is set to 1 MSS
1515
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP Sender Congestion ControlTCP Sender Congestion Control
State
Event
TCP Sender Action
Commentary
Slow Start(SS)
ACK receiptfor previouslyunackeddata
CongWin = CongWin + MSS,
If (CongWin > Threshold)
      set state to CongestionAvoidance
Resulting in a doublingof CongWin every RTT
Congestion
Avoidance(CA)
ACK receiptfor previouslyunackeddata
CongWin = CongWin+       MSS * (MSS/CongWin)
 
Additive increase,resulting in increase ofCongWin  by 1 MSSevery RTT
1616
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP Sender Congestion ControlTCP Sender Congestion Control
State
Event
TCP Sender Action
Commentary
SS or CA
Losseventdetectedby tripleduplicateACK
Threshold = CongWin/2,
CongWin = Threshold,
Set state to CongestionAvoidance
Fast recovery,implementingmultiplicativedecrease. CongWinwill not drop below 1MSS.
SS or CA
Timeout
Threshold = CongWin/2,
CongWin = 1 MSS,
Set state to Slow Start
Enter slow start
SS or CA
DuplicateACK
Increment duplicate ACKcount for segment beingacked
CongWin andThreshold notchanged
1717
Spring Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP Congestion ControlTCP Congestion Control
Segment lost
Repeated acks
Slow start