CS3600 SYSTEMS AND NETWORKS NORTHEASTERN UNIVERSITY Lecture 24: Congestion Control Prof. Alan Mislove (amislove@ccs.neu.edu) Slides used with permissions from Edward W. Knightly, T. S. Eugene Ng, Ion Stoica, Hui Zhang
Abstract View A Sending Host Buffer in bottleneck Router B Receiving Host We ignore internal structure of network and model it as having a single bottleneck link Alan Mislove amislove at ccs.neu.edu Northeastern University2
Three Congestion Control Problems Adjusting to bottleneck bandwidth Adjusting to variations in bandwidth Sharing bandwidth between flows Alan Mislove amislove at ccs.neu.edu Northeastern University3
Single Flow, Fixed Bandwidth A 100 Mbps B Adjust rate to match bottleneck bandwidth without any a priori knowledge could be gigabit link, could be a modem Alan Mislove amislove at ccs.neu.edu Northeastern University4
Single Flow, Varying Bandwidth A BW(t) B Adjust rate to match instantaneous bandwidth Bottleneck can change because of a routing change Alan Mislove amislove at ccs.neu.edu Northeastern University5
Multiple Flows Two Issues: Adjust total sending rate to match bottleneck bandwidth Allocation of bandwidth between flows A1 A2 100 Mbps B1 B2 A3 B3 Alan Mislove amislove at ccs.neu.edu Northeastern University6
General Approaches Send without care many packet drops could cause congestion collapse Reservations pre-arrange bandwidth allocations requires negotiation before sending packets Pricing don t drop packets for the high-bidders requires payment model Alan Mislove amislove at ccs.neu.edu Northeastern University7
General Approaches (cont d) Dynamic Adjustment (TCP) Every sender probe network to test level of congestion speed up when no congestion slow down when congestion suboptimal, messy dynamics, simple to implement Distributed coordination problem! Alan Mislove amislove at ccs.neu.edu Northeastern University8
TCP Congestion Control TCP connection has window controls number of unacknowledged packets Sending rate: ~Window/RTT Vary window size to control sending rate Introduce a new parameter called congestion window (cwnd) at the sender Congestion control is mainly a sender-side operation Alan Mislove amislove at ccs.neu.edu Northeastern University9
Congestion Window (cwnd) Limits how much data can be in transit Implemented as # of bytes Described as # packets in this lecture MaxWindow = min(cwnd, AdvertisedWindow) EffectiveWindow = MaxWindow (LastByteSent LastByteAcked) MaxWindow LastByteAcked LastByteSent EffectiveWindow sequence number increases Alan Mislove amislove at ccs.neu.edu Northeastern University10
Two Basic Components Detecting congestion Rate adjustment algorithm (change cwnd size) depends on congestion or not Alan Mislove amislove at ccs.neu.edu Northeastern University11
Detecting Congestion Alan Mislove amislove at ccs.neu.edu Northeastern University12
Detecting Congestion Packet dropping is best sign of congestion delay-based methods are hard and risky How do you detect packet drops? ACKs TCP uses ACKs to signal receipt of data ACK denotes last contiguous byte received actually, ACKs indicate next segment expected Two signs of packet drops No ACK after certain time interval: time-out Several duplicate ACKs (ignore for now) Alan Mislove amislove at ccs.neu.edu Northeastern University12
Detecting Congestion Packet dropping is best sign of congestion delay-based methods are hard and risky How do you detect packet drops? ACKs TCP uses ACKs to signal receipt of data ACK denotes last contiguous byte received actually, ACKs indicate next segment expected Two signs of packet drops No ACK after certain time interval: time-out Several duplicate ACKs (ignore for now) Alan Mislove amislove at ccs.neu.edu Northeastern University12
Detecting Congestion Packet dropping is best sign of congestion delay-based methods are hard and risky How do you detect packet drops? ACKs TCP uses ACKs to signal receipt of data ACK denotes last contiguous byte received actually, ACKs indicate next segment expected Two signs of packet drops No ACK after certain time interval: time-out Several duplicate ACKs (ignore for now) May not work well for wireless networks, why? Alan Mislove amislove at ccs.neu.edu Northeastern University12
Sliding (Congestion) Window Sliding window: each ACK = permission to send a new packet Ex. cwnd = 3 Alan Mislove amislove at ccs.neu.edu Northeastern University13
Self-clocking If we have a large window, ACKs self-clock the data to the rate of the bottleneck link Observe: received ACK spacing bottleneck bandwidth P b P r sender receiver A s A b A r Tiny ACK (very thin) Alan Mislove amislove at ccs.neu.edu Northeastern University14
Rate Adjustment Basic structure: Upon receipt of ACK (of new data): increase rate Data successfully delivered, perhaps can send faster Upon detection of loss: decrease rate But what increase/decrease functions should we use? Depends on what problem we are solving Alan Mislove amislove at ccs.neu.edu Northeastern University15
Fairness? R Connection 2 throughput Connection 1 throughput R Alan Mislove amislove at ccs.neu.edu Northeastern University16
Fairness? R equal bandwidth share Connection 2 throughput Connection 1 throughput R Alan Mislove amislove at ccs.neu.edu Northeastern University16
Fairness? Two competing sessions: R equal bandwidth share Connection 2 throughput Connection 1 throughput R Alan Mislove amislove at ccs.neu.edu Northeastern University16
Fairness? Two competing sessions: Additive increase (AI) gives slope of 1, as throughout increases R equal bandwidth share Connection 2 throughput Connection 1 throughput R Alan Mislove amislove at ccs.neu.edu Northeastern University16
Fairness? Two competing sessions: Additive increase (AI) gives slope of 1, as throughout increases multiplicative decrease (MD) decreases throughput proportionally R equal bandwidth share Connection 2 throughput Connection 1 throughput R Alan Mislove amislove at ccs.neu.edu Northeastern University16
Fairness? Two competing sessions: Additive increase (AI) gives slope of 1, as throughout increases multiplicative decrease (MD) decreases throughput proportionally R equal bandwidth share Connection 2 throughput congestion avoidance: additive increase Connection 1 throughput R Alan Mislove amislove at ccs.neu.edu Northeastern University16
Fairness? Two competing sessions: Additive increase (AI) gives slope of 1, as throughout increases multiplicative decrease (MD) decreases throughput proportionally R equal bandwidth share Connection 2 throughput Connection 1 throughput R Alan Mislove amislove at ccs.neu.edu Northeastern University16
Fairness? Two competing sessions: Additive increase (AI) gives slope of 1, as throughout increases multiplicative decrease (MD) decreases throughput proportionally R equal bandwidth share Connection 2 throughput loss: decrease window by factor of 2 Connection 1 throughput R Alan Mislove amislove at ccs.neu.edu Northeastern University16
Fairness? Two competing sessions: Additive increase (AI) gives slope of 1, as throughout increases multiplicative decrease (MD) decreases throughput proportionally R equal bandwidth share Connection 2 throughput Connection 1 throughput R Alan Mislove amislove at ccs.neu.edu Northeastern University16
Fairness? Two competing sessions: Additive increase (AI) gives slope of 1, as throughout increases multiplicative decrease (MD) decreases throughput proportionally R equal bandwidth share Connection 2 throughput Fair and link fully utilized (rate R) Connection 1 throughput R Alan Mislove amislove at ccs.neu.edu Northeastern University16
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University17
A D AIMD x y C B E Limit rates: x = y Alan Mislove amislove at ccs.neu.edu Northeastern University17
Alan Mislove amislove at ccs.neu.edu Northeastern University18 AIMD Sharing Dynamics A B x D E 0 15.0000 30.0000 45.0000 60.0000 123456789 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 No congestion à rate increases by one packet/rtt every RTT Congestion à decrease rate by factor 2 Rates equalize à fair share y
A D AIAD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University19
A D AIAD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University19
A D AIAD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University19
A D AIAD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University19
A D AIAD x y C B E Alan Mislove amislove at ccs.neu.edu Northeastern University19
A D AIAD x y C B E Limit rates: x and y depend on initial values Alan Mislove amislove at ccs.neu.edu Northeastern University19
Alan Mislove amislove at ccs.neu.edu Northeastern University20 AIAD Sharing Dynamics A B x D E No congestion à x increases by one packet/rtt every RTT Congestion à decrease x by 1 0 15 30 45 60 123456789 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 y
Adapting cwin So far: sliding window + self-clocking of ACKs How to know the best cwnd (and best transmission rate)? Phases of TCP congestion control 1.Slow start (getting to equilibrium) 1. Want to find this very very fast and not waste time 2.Congestion Avoidance Additive increase - gradually probing for additional bandwidth Multiplicative decrease - decreasing cwnd upon loss/timeout Alan Mislove amislove at ccs.neu.edu Northeastern University21
Phases of Congestion Control Congestion Window (cwnd) Initial value is 1 MSS (=maximum segment size) counted as bytes Slow-start threshold Value (ss_thresh) Initial value is the advertised window size slow start (cwnd < ssthresh) congestion avoidance (cwnd >= ssthresh) Alan Mislove amislove at ccs.neu.edu Northeastern University22
TCP: Slow Start Goal: discover roughly the proper sending rate quickly Whenever starting traffic on a new connection, or whenever increasing traffic after congestion was experienced: Intialize cwnd =1 Each time a segment is acknowledged, increment cwnd by one (cwnd++). Continue until Reach ss_thresh Packet loss Alan Mislove amislove at ccs.neu.edu Northeastern University23
The congestion window size grows very rapidly Slow Start Illustration TCP slows down the increase of cwnd when cwnd >= ss_thresh Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! Alan Mislove amislove at ccs.neu.edu Northeastern University24
Slow Start Illustration The congestion window size grows very rapidly cwnd = 1 segment 1 TCP slows down the increase of cwnd when cwnd >= ss_thresh Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! Alan Mislove amislove at ccs.neu.edu Northeastern University24
Slow Start Illustration The congestion window size grows very rapidly cwnd = 1 segment 1 ACK for segment 1 TCP slows down the increase of cwnd when cwnd >= ss_thresh Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! Alan Mislove amislove at ccs.neu.edu Northeastern University24
Slow Start Illustration The congestion window size grows very rapidly TCP slows down the increase of cwnd when cwnd >= ss_thresh cwnd = 1 cwnd = 2 segment 1 ACK for segment 1 Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! Alan Mislove amislove at ccs.neu.edu Northeastern University24
Slow Start Illustration The congestion window size grows very rapidly TCP slows down the increase of cwnd when cwnd >= ss_thresh cwnd = 1 cwnd = 2 segment 1 ACK for segment 1 segment 2 segment 3 Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! Alan Mislove amislove at ccs.neu.edu Northeastern University24
Slow Start Illustration The congestion window size grows very rapidly TCP slows down the increase of cwnd when cwnd >= ss_thresh cwnd = 1 cwnd = 2 segment 1 ACK for segment 1 segment 2 segment 3 ACK for segments 2 + 3 Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! Alan Mislove amislove at ccs.neu.edu Northeastern University24
Slow Start Illustration The congestion window size grows very rapidly TCP slows down the increase of cwnd when cwnd >= ss_thresh cwnd = 1 cwnd = 2 cwnd = 4 segment 1 ACK for segment 1 segment 2 segment 3 ACK for segments 2 + 3 Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! Alan Mislove amislove at ccs.neu.edu Northeastern University24
Slow Start Illustration The congestion window size grows very rapidly TCP slows down the increase of cwnd when cwnd >= ss_thresh Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! cwnd = 1 cwnd = 2 cwnd = 4 segment 1 ACK for segment 1 segment 2 segment 3 ACK for segments 2 + 3 segment 4 segment 5 segment 6 segment 7 Alan Mislove amislove at ccs.neu.edu Northeastern University24
Slow Start Illustration The congestion window size grows very rapidly TCP slows down the increase of cwnd when cwnd >= ss_thresh Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! cwnd = 1 cwnd = 2 cwnd = 4 segment 1 ACK for segment 1 segment 2 segment 3 ACK for segments 2 + 3 segment 4 segment 5 segment 6 segment 7 ACK for segments 4+5+6+7 Alan Mislove amislove at ccs.neu.edu Northeastern University24
Slow Start Illustration The congestion window size grows very rapidly TCP slows down the increase of cwnd when cwnd >= ss_thresh Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! cwnd = 1 cwnd = 2 cwnd = 4 cwnd = 8 segment 1 ACK for segment 1 segment 2 segment 3 ACK for segments 2 + 3 segment 4 segment 5 segment 6 segment 7 ACK for segments 4+5+6+7 Alan Mislove amislove at ccs.neu.edu Northeastern University24
Congestion Avoidance (After Slow Start) Slow Start figures out roughly the rate at which the network starts getting congested Congestion Avoidance continues to react to network condition Probes for more bandwidth, increase cwnd if more bandwidth available If congestion detected, aggressive cut back cwnd Alan Mislove amislove at ccs.neu.edu Northeastern University25
Congestion Avoidance: Additive Increase After exiting slow start, slowly increase cwnd to probe for additional available bandwidth Competing flows may end transmission May have been unlucky with an early drop If cwnd > ss_thresh then each time a segment is acknowledged increment cwnd by 1/cwnd (cwnd += 1/cwnd). cwnd is increased by one only if all segments have been acknowledged Increases by 1 per RTT, vs. doubling per RTT Alan Mislove amislove at ccs.neu.edu Northeastern University26
Example of Slow Start + Congestion Avoidance Assume that ss_thresh = 8 15 Cwnd (in segments) 11 8 4 ssthresh 0 t=0 t=1 t=2 t=3 Roundtrip times t=4 t=5 t=6 t=7 Alan Mislove amislove at ccs.neu.edu Northeastern University27
Detecting Congestion via Timeout If there is a packet loss, the ACK for that packet will not be received The packet will eventually timeout No ack is seen as a sign of congestion Alan Mislove amislove at ccs.neu.edu Northeastern University28
Congestion Avoidance: Multiplicative Decrease Timeout = congestion Each time when congestion occurs, ss_thresh is set to half the current size of the congestion window: ss_thresh = cwnd / 2 cwnd is reset to one: cwnd = 1 and slow-start is entered Alan Mislove amislove at ccs.neu.edu Northeastern University29
TCP illustration cwnd ss_thresh Timeout Slow Start Congestion Avoidance ss_thresh Time Alan Mislove amislove at ccs.neu.edu Northeastern University30
Responses to Congestion (Loss) There are algorithms developed for TCP to respond to congestion TCP Tahoe - the basic algorithm (discussed previously) TCP Reno - Tahoe + fast retransmit & fast recovery Most end hosts today implement TCP Reno and many more: TCP Vegas (research: use timing of ACKs to avoid loss) TCP SACK (future deployment: selective ACK) Alan Mislove amislove at ccs.neu.edu Northeastern University31
TCP Reno Problem with Tahoe: If a segment is lost, there is a long wait until timeout Reno adds a fast retransmit and fast recovery mechanism Upon receiving 3 duplicate ACKs, retransmit the presumed lost segment ( fast retransmit ) But do not enter slow-start. Instead enter congestion avoidance ( fast recovery ) Alan Mislove amislove at ccs.neu.edu Northeastern University32
Fast Retransmit Resend a segment after 3 duplicate ACKs remember a duplicate ACK means that an out-of sequence segment was received ACK-n means packets 1,, n all received cwnd = 1 cwnd = 2 ACK 1 ACK 2 segment 1 segment 2 segment 3 Notes: duplicate ACKs due to packet reordering! if window is small don t get duplicate ACKs! 3 duplicate ACKs cwnd = 4 ACK 3 ACK 3 ACK 3 ACK 3 segment 4 segment 5 segment 6 segment 7 Alan Mislove amislove at ccs.neu.edu Northeastern University33
Fast Recovery After a fast-retransmit cwnd = cwnd/2 (vs. 1 in Tahoe) ss_thresh = cwnd i.e. starts congestion avoidance at new cwnd Not slow start from cwnd = 1 After a timeout ss_thresh = cwnd/2 cwnd = 1 Do slow start Same as Tahoe Alan Mislove amislove at ccs.neu.edu Northeastern University34
Fast Retransmit and Fast Recovery cwnd Slow Start Congestion Avoidance Time Retransmit after 3 duplicate ACKs prevent expensive timeouts Slow start only once per session (if no timeouts) In steady state, cwnd oscillates around the ideal window size. Alan Mislove amislove at ccs.neu.edu Northeastern University35
TCP Congestion Control Summary Measure available bandwidth slow start: fast, hard on network AIMD: slow, gentle on network Detecting congestion timeout based on RTT robust, causes low throughput Fast Retransmit: avoids timeouts when few packets lost can be fooled, maintains high throughput Recovering from loss Fast recovery: don t set cwnd=1 with fast retransmits Alan Mislove amislove at ccs.neu.edu Northeastern University36
TCP Reno Quick Review Slow-Start if cwnd < ss_thresh cwnd++ upon every new ACK (exponential growth) Timeout: ss_thresh = cwnd/2 and cwnd = 1 Congestion avoidance if cwnd >= ss_thresh Additive Increase Multiplicative Decrease (AIMD) ACK: cwnd = cwnd + 1/cwnd Timeout: ss_thresh = cwnd/2 and cwnd = 1 Fast Retransmit & Recovery 3 duplicate ACKS (interpret as packet loss) Retransmit lost packet cwnd=cwnd/2, ss_thresh = cwnd Alan Mislove amislove at ccs.neu.edu Northeastern University37
TCP Reno Saw Tooth Behavior Congestion Window Timeouts may still occur Initial Slowstart Slowstart to pace packets Fast Retransmit and Recovery Time Alan Mislove amislove at ccs.neu.edu Northeastern University38