EEC-484/584EEC-484/584Computer NetworksComputer Networks
Lecture 14Lecture 14
Wenbing ZhaoWenbing Zhao
[email protected](Part of the slides are based on Drs. Kurose & (Part of the slides are based on Drs. Kurose &
RossRoss’’s slides for their s slides for their Computer Networking Computer Networking book)book)
22
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing 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 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
TCP ACK GenerationTCP ACK Generation
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 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 thatsegment starts at lower end of gap
44
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
TCP Flow ControlTCP Flow Control• Receive side of TCP
connection has a receive buffer:
• Speed-matching service: matching the send rate to the receiving app’s drain rate
• App process may be slow at reading from buffer
Flow control:sender won’t overflow
receiver’s buffer bytransmitting too much,
too fast
55
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
TCP Flow ControlTCP Flow Control
(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 segments
• Sender limits unACKed data to RcvWindow– guarantees receive
buffer doesn’t overflow
66
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
Principles of Congestion ControlPrinciples of Congestion Control
Congestion:• Informally: “too many sources sending too much
data 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 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
Approaches towards Congestion ControlApproaches towards Congestion Control
End-end congestion control:
• no explicit feedback from network
• congestion inferred from end-system observed loss, delay
• approach taken by TCP
Network-assisted congestion control:
• routers provide feedback to end systems– single bit indicating
congestion (SNA, DECbit, TCP/IP ECN, ATM)
– explicit rate sender should send at
Two broad approaches towards congestion control
88
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
TCP Congestion Control: TCP Congestion Control: Additive Increase, Multiplicative DecreaseAdditive Increase, Multiplicative Decrease
• Approach: increase transmission rate (window size), probing for usable bandwidth, until loss occurs– Additive increase: increase cwnd every RTT until
loss detected– Multiplicative decrease: cut cwnd after loss
Saw toothbehavior: probing
for bandwidth
99
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
TCP Congestion ControlTCP Congestion Control
• Sender limits transmission: LastByteSent-LastByteAcked cwnd
• Roughly,
• cwnd is dynamic, function of perceived network congestion
How does sender perceive congestion?
• loss event = timeout or 3 duplicate acks
• TCP sender reduces rate (cwnd) after loss event
rate = cwnd
RTT Bytes/sec
1010
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing 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 may be >> MSS/RTT– Desirable to quickly ramp
up to respectable rate
• When connection begins, increase rate exponentially fast until first loss event
1111
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
TCP Slow StartTCP Slow Start• When connection
begins, increase rate exponentially until first loss event:– Double cwnd every RTT– Done by incrementing cwnd for every ACK received
• Summary: initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
two segments
four segments
1212
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
Congestion AvoidanceCongestion AvoidanceQ: When should the
exponential increase switch to linear?
A: When cwnd gets to 1/2 of its value before timeout
Implementation:• Variable Threshold • At loss event, Threshold is
set to 1/2 of cwnd just before loss event
How to increase cwnd linearly:cwnd (new) = cwnd + mss*mss/cwnd
1313
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing 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 grows
exponentially– to a threshold, then grows
linearly
3 dup ACKs indicates
network capable of delivering some segments timeout indicates a “more alarming” congestion scenario
Philosophy:
1414
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing 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 in congestion-avoidance phase, window grows linearly
• When a triple duplicate ACK occurs, Threshold set to cwnd/2 and cwnd set to Threshold
• When timeout occurs, Threshold set to cwnd/2 and cwnd is set to 1 MSS
1515
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
TCP Sender Congestion ControlTCP Sender Congestion Control
State Event TCP Sender Action Commentary
Slow Start (SS)
ACK receipt for previously unacked data
CongWin = CongWin + MSS,
If (CongWin > Threshold) set state to “Congestion Avoidance”
Resulting in a doubling of CongWin every RTT
CongestionAvoidance (CA)
ACK receipt for previously unacked data
CongWin = CongWin+ MSS * (MSS/CongWin)
Additive increase, resulting in increase of CongWin by 1 MSS every RTT
1616
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
TCP Sender Congestion ControlTCP Sender Congestion Control
State Event TCP Sender Action Commentary
SS or CA Loss event detected by triple duplicate ACK
Threshold = CongWin/2, CongWin = Threshold,Set state to “Congestion Avoidance”
Fast recovery, implementing multiplicative decrease. CongWin will not drop below 1 MSS.
SS or CA Timeout Threshold = CongWin/2, CongWin = 1 MSS,Set state to “Slow Start”
Enter slow start
SS or CA Duplicate ACK
Increment duplicate ACK count for segment being acked
CongWin and Threshold not changed
1717
Spring Semester 2008Spring Semester 2008 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
TCP Congestion ControlTCP Congestion Control
Segment lost Repeated acks
Slow start