CPSC 360 Network Programming The Transport Layer Congestion control in TCP Michele Weigle Department of Computer Science Clemson University mweigle@cs.clemson.edu http://www.cs.clemson.edu/~mweigle/courses/cpsc360 1 Congestion Control Congestion control v. Flow control! In flow control the sender adjusts its transmission rate so as not to overwhelm the receiver» One source is sending too fast for a receiver to handle! In congestion control the sender(s) adjust their transmission rate so as not to overwhelm routers in the network» Many sources independently work to avoid sending too much too fast for the network to handle! Symptoms of congestion:» Lost packets (buffer overflow at routers)» Long delays (queuing in router buffers)
Congestion Control Fairness... k 1 k 1 k k k+1...! When a connection slows down, by how much should it slow down?! If n k connections share a congested link k with capacity k, each connection should receive r = k /n k bandwidth! But what if a connection can t consume /n bandwidth? 3 Congestion Control Fairness... k 1 k 1 k k k+1...! A connection can t consume more bandwidth on link k than it consumes on any previous link! If a connection traverses L links then its end-to-end bandwidth is r! MIN( 1 /n 1,, L /n L )! k /n! Fairness implies that if there exists a connection such that r! k /n, then the connection s unused share of the bandwidth on link k, k /n r, is evenly shared with all other connections that are capable of consuming more bandwidth
Congestion Control MAX-MIN Fairness! Consider a set of n connections that consume r 1! r!! r n bits per second of bandwidth! Fairness implies that» No connection receives more bandwidth than it requires» If a connection receives less bandwidth than it requires then it receives the same amount of bandwidth as all other unsatisfied connection Initially each connection gets /n of a link s capacity. If r 1 < /n then the unused /n r 1 is reallocated. such that flows through n receive /n + /n r 1 n 1 of the link s capacity. 5 Congestion Control MAX-MIN Fairness! Consider a set of n connections that consume r 1! r!! r n bits per second of bandwidth! Fairness implies that» No connection receives more bandwidth than it requires» If a connection receives less bandwidth than it requires then it receives the same amount of bandwidth as all other unsatisfied connection Initially each connection gets /n of a link s capacity. If r 1 < /n and r < /n + (/n r 1 )/(n 1) then the unused bandwidth is reallocated such that flows 3 through n receive /n r /n + 1 /n + (/n r + 1 )/(n 1) r n 1 n of the link s capacity. 6
The Causes and Effects of Congestion Scenario 1: Two equal-rate senders share a single link x CPU B 3 T 3 B B 1!out outer! Two sources send at an average rate of to two receivers across a shared link with capacity» Data is delivered to the application at the receiver at rate! out! Packets queue at the router» Assume the router has infinite storage capacity (Thus no packets are lost and there are no retransmissions) 7 The Causes and Effects of Congestion Scenario 1: Two equal-rate senders share a single link /! out Time / Throughput Delay /! The maximum achievable per connection throughput is constrained by 1 / the capacity of the shared link! Exponentially large delays are experienced when the router becomes congested» The queue grows without bound 8
The Causes and Effects of Congestion Scenario : Finite capacity router queue x! in CPU B 3 T 3 B B 1! in! in outer! out! Assume packets can now be lost» Sender retransmits upon detection of loss! Define offered load as the original transmissions plus retransmissions»! in = +! retransmit 9 The Causes and Effects of Congestion Scenario : Throughput analysis / /3 /! out /! in Ideal throughput ( =! in ) Perfect retransmissions (! out <! in ) (But an extreme loss rate!) Early retransmissions (! in = ) (Each segment transmitted twice) Early retransmissions plus loss Throughput! By definition! out =! etransmission scenarios:» Perfect etransmissions occur only when there is loss» Premature Delayed packets are retransmitted 10
The Causes and Effects of Congestion Scenario 3: Four equal-rate senders share multiple hops! Each source s traffic transits two routers! outers have finite storage! All links have the same capacity! Senders retransmit lost packets A! 3 in D 1 B C! What happens as and! in increase?! in = +! retransmit 11 The Causes and Effects of Congestion Scenario 3: Four equal-rate senders share multiple hops! Throughput increases linearly as the network remains underloaded! At the saturation point loss occurs! Once loss occurs the offered load increases! Loss rates increase D A 3 C If! in >> then A s traffic dominates link 1 1 B Eventually! out = 0! 1
The Causes and Effects of Congestion Scenario 3: Throughput analysis /! out /! in Throughput! Congestion collapse» All the links are fully utilized but no is delivered to applications! 13 The Causes and Effects of Congestion Summary! Uncontrolled, congestion can lead to dropped packets» This means that bandwidth used delivering packets to the point of congestion was wasted D A 3 1 B! In the limit it can lead to network collapse» The network is fully busy but no work gets done C 1
Approaches to Congestion Control End-to-end v. Hop-by-hop ATE r 1 ACK x ACK x ACK x X! End-to-end congestion control» End-systems receive no feedback from network» Congestion inferred by observing loss and/or delay! Hop-by-hop congestion control» outers provide feedback to end systems " Network determines an explicit rate that a sender should transmit at " Network signals congestion by setting a bit in a packet s header (SNA, DECbit, TCP/IP ECN, ATM) 15 End-to-End Congestion Control TCP Congestion Control Byte sequence 1 st Byte Sent and ACKed Sender!s Congestion Window Sent and not ACKed Eligible to be sent Ineligible Last Byte nextseqnum (= LastByteSent + 1) sendbase (= LastByteACKed + 1)! Transmission rate is limited by the congestion window size, congwin, or cwnd LastByteSent - LastByteACKed! MIN(congWin,cvWindow)! Maximum rate is w MSS byte segments sent every TT w x MSS throughput = TT bytes/sec 16
TCP Congestion Control Congestion window and transmission rate! If w " MSS/ < TT, then the maximum rate at which a TCP connection can transmit is w x MSS TT bytes/sec wmss bytes TT secs Host A ACK Host B! w is the minimum of the number of segments in the receiver s window or the congestion window ACK Time 17 TCP Congestion Control Congestion window control Byte sequence 1 st Byte Sender!s Congestion Window Last Byte! TCP connections probe for available bandwidth» Increase the congestion window until loss occurs» When loss is detected decrease window, then begin probing (increasing) again! The congestion window grows in two phases:» Slow start amp up transmission rate until loss occurs» Congestion avoidance Keep connection close to sustainable bandwidth! A window size threshold (bytes transmitted) distinguishes between slow start and congestion avoidance phases 18
TCP Congestion Control Slowstart congwin = 1 MSS for (each original ACK received) congwin++ until (loss event O congwin > threshold)! Exponential increase in window size each TT until:» Loss occurs» congwin = threshold (Not so slow!) TT Host A Host B one segment two segments four segments Time 19 TCP Congestion Control Congestion avoidance /* slowstart is over; congwin > threshold */ until (loss event) { whenever congwin segments ACKed: congwin++ } /* loss event timeout */ threshold = congwin/ congwin = 1 MSS perform slowstart Congestion window size (segments) 1 11 10 9 8 Threshold 7 6 5 Threshold Loss 3 event 1 0 0 1 3 5 6 7 8 9 10 111 131 Window transmissions 0
TCP Congestion Control Slow-start v. Congestion avoidance Initial Threshold is 1 MB " 700 segments! The threshold is an estimate of a safe level of throughput that is sustainable in the network» The threshold specifies a throughput that was sustainable in the recent past! Slow-start quickly increases throughput to this threshold! Congestion avoidance slows probes for additional available bandwidth beyond the threshold Congestion window size (segments) 0 18 16 1 1 10 8 6 Slow Start Congestion Avoidance 0 0 6 8 10 1 1 16 18 0 Window transmissions Assume TT > w x MSS TCP Congestion Control Slow-start v. Congestion avoidance Initial Threshold is 1 MB " 700 segments! Loss (at any time) reduces the safe throughput estimate to 1/ of the current throughput» This is the throughput that resulted in loss! Slow-start begins anew whenever there is loss! Throughput at initial threshold = 1 MB/TT» At 1 st threshold: 16MSS/TT» At nd threshold: 10MSS/TT Congestion window size (segments) 0 18 16 1 1 10 8 6 Slow Start Congestion Avoidance 0 0 6 8 10 1 1 16 18 0 Window transmissions Assume TT > w x MSS 3
TCP Congestion Control Major TCP variants! TCP Tahoe:» Loss signaled by timeout» threshold = congwin/» congwin = 1 MSS» Fast retransmit " receipt of 3 duplicate ACKs also signals a packet loss! TCP eno:» Fast recovery " skips slowstart and continues in congestion avoidance " congwin = congwin/ " additive increase, multiplicative decrease (AIMD) Congestion window size (segments) 0 18 16 1 1 10! Others: TCP Neweno, SACK, 8 6 Slow Start Congestion Avoidance 3 duplicate ACKs 0 0 6 8 10 1 1 16 18 0 Window transmissions Assume TT > w x MSS