Lecture 21: Congestion ControlCSE 123 –Lecture 21: Congestion control 17! Goal: quickly find the...
Transcript of Lecture 21: Congestion ControlCSE 123 –Lecture 21: Congestion control 17! Goal: quickly find the...
CSE 123: Computer NetworksAaron Schulman
Lecture 21:Congestion Control
! How fast should a sending host transmit data?u Not to fast, not to slow, just right…
! Should not be faster than the sender’s shareu Bandwidth allocation
! Should not be faster than the network can processu Congestion control
! Congestion control & bandwidth allocation are separate ideas, but frequently combined
2
CC Overview
CSE 123 – Lecture 21: Congestion Control
! How much bandwidth should each flow from a source to a destination receive when they compete for resources?
u What is a “fair” allocation?
Router
Source2
Source1
Source3
Router
Router
Destination2
Destination110Mbps
4Mbps
10Mbps
6Mbps
100Mbps
10Mbps
3
Bandwidth Allocation
CSE 123 – Lecture 21: Congestion Control
! Buffer intended to absorb bursts when input rate > output! But if sending rate is persistently > drain rate, queue builds! Dropped packets represent wasted work; goodput < throughput
Destination1.5-Mbps T1 link
Router
Source2
Source1
100-Mbps FDDI
10-Mbps Ethernet
Packets dropped here
4
Congestion
CSE 123 – Lecture 21: Congestion Control
Network Load
Thro
ughp
utLa
tenc
y
Congestion collapse
5
Drop-Tail QueuingLoss due toCongestion
CSE 123 – Lecture 21: Congestion Control
! Rough definition: “When an increase in network load produces a decrease in useful work”
! Why does it happen?u Sender sends faster than bottleneck link speedu Packets queue until droppedu In response to packets being dropped, sender retransmitsu All hosts repeat in steady state…
6
Congestion Collapse
CSE 123 – Lecture 21: Congestion Control
! Increase network resourcesu More buffers for queuingu Increase link speedu Pros/Cons of these approaches?
! Reduce network loadu Send data more slowly u How much more slowly?u When to slow down?
7
Mitigation Options
CSE 123 – Lecture 21: Congestion Control
! Open loopu Explicitly reserve bandwidth in the network in advance
! Closed loopu Respond to feedback and adjust bandwidth allocation
! Network-basedu Network implements and enforces bandwidth allocation
! Host-basedu Hosts are responsible for controlling their sending rate
8
Designing a Control
CSE 123 – Lecture 19: Congestion Control
Network Load
Thro
ughp
utLa
tenc
y
“Knee”“Cliff”
Congestion collapse
! Congestion avoidance: try to stay to the left of the knee! Congestion control: try to stay to the left of the cliff
9
Proactive vs. Reactive
Loss due toCongestion
CSE 123 – Lecture 19: Congestion Control
! How to detect congestion?
! How to limit sending data rate?
! How fast to send?
10
Challenges to Address
CSE 123 – Lecture 21: Congestion Control
! Explicit congestion signalingu Source Quench: ICMP message from router to senderu DECBit / Explicit Congestion Notification (ECN):
» Router marks packet based on queue occupancy (i.e. indication that packet encountered congestion along the way)
» Receiver tells sender if queues are getting too full
! Implicit congestion signalingu Packet loss
» Assume congestion is primary source of packet loss» Lost packets indicate congestion
u Packet delay» Round-trip time increases as packets queue» Packet inter-arrival time is a function of bottleneck link
11
Detecting Congestion
CSE 123 – Lecture 21: Congestion Control
! Window-based (TCP)u Constrain number of outstanding packets allowed in networku Increase window to send faster; decrease to send sloweru Pro: Cheap to implement (already have windowing),
good failure propertiesu Con: Creates traffic bursts (requires bigger buffers)
! Rate-based (many streaming media protocols)u Two parameters (period, packets)u Allow sending of x packets in period yu Pro: smooth trafficu Con: fine-grained per-connection timers, what if receiver fails?
12
Throttling Options
CSE 123 – Lecture 21: Congestion Control
! Ideally: Keep equilibrium at “knee” of power curveu Find “knee” somehowu Keep number of packets “in flight” the sameu Don’t send a new packet into the network until you know one
has left (I.e. by receiving an ACK)u What if you guess wrong, or if bandwidth availability changes?
! Compromise: adaptive approximation u If congestion signaled, reduce sending rate by xu If data delivered successfully, increase sending rate by yu How to relate x and y? Most choices don’t converge…
13
Choosing a Send Rate
CSE 123 – Lecture 21: Congestion Control
! Each source independently probes the network to determine how much bandwidth is availableu Changes over time, since everyone does this
! Assume that packet loss implies congestionu Since errors are rare; also, requires no support from routers
Sink45 Mbps T3 link
RouterSource100 Mbps Ethernet
14
TCP’s Probing Approach
CSE 123 – Lecture 21: Congestion Control
! Window-based congestion controlu Unified congestion control and flow control mechanismu rwin: advertised flow control window from receiveru cwnd: congestion control window
» Estimate of how much outstanding data network can deliver in a round-trip time
u Sender can only send MIN(rwin,cwnd) at any time
! Idea: decrease cwnd when congestion is encountered; increase cwnd otherwiseu Question: how much to adjust?
15
Basic TCP Algorithm
CSE 123 – Lecture 21: Congestion Control
! Goal: Adapt to changes in available bandwidth
! Additive Increase, Multiplicative Decrease (AIMD)u Increase sending rate by a constant (e.g. MSS)u Decrease sending rate by a linear factor (e.g. divide by 2)
! Rough intuition for why this worksu Let Li be queue length at time iu In steady state: Li = N, where N is a constantu During congestion, Li = N + yLi-1, where y > 0u Consequence: queue size increases multiplicatively
» Must reduce sending rate multiplicatively as well
16
Congestion Avoidance
CSE 123 – Lecture 21: Congestion Control
TCP Bandwidth Probing! TCP uses AIMD to adjust congestion window
u Converges to fair share of bottleneck linku Increases modestly in good timesu Cuts drastically in bad times
! But what rate should a TCP flow use initially?u Need some initial congestion windowu We’d like to TCP to work on all manner of linksu Need to span 6+ orders of magnitude, e.g., 10 K to 10 Gbps.u Starting too fast is catastrophic!
17CSE 123 – Lecture 21: Congestion control
! Goal: quickly find the equilibrium sending rate
! Quickly increase sending rate until congestion detectedu Remember last rate that worked and don’t overshoot it
! TCP Reno Algorithm: u On new connection, or after timeout, set cwnd=1 MSSu For each segment acknowledged, increment cwnd by 1 MSSu If timeout then divide cwnd by 2, and set ssthresh = cwndu If cwnd >= ssthresh then exit slow start
! Why called slow? Its exponential after all…
18
Slow Start
CSE 123 – Lecture 21: Congestion control
1
2Ack 2
3Ack 3
4567
cwnd=1
cwnd=2
cwnd=4
cwnd=8
Sender Receiver
0
50
100
150
200
250
300
0 1 2 3 4 5 6 7 8round-trip times
cwnd
Ack 4
Ack 5Ack 6Ack 7Ack 8
19
Slow Start Example
CSE 123 – Lecture 20: Scheduling & QoS
Slow Start + Congestion Avoidance
0
2
4
6
8
10
12
14
16
18
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
round-trip times
cwnd
Timeout
ssthresh
Slow start
Congestionavoidance
20
Basic Mechanisms
CSE 123 – Lecture 21: Congestion control
! Fast retransmitu Timeouts are slow (default often 200 ms or 1 second)u When packet is lost, receiver still ACKs last in-order packetu Use 3 duplicate ACKs to indicate a loss; detect losses quickly
» Why 3? When wouldn’t this work?
! Fast recoveryu Goal: avoid stalling after loss u If there are still ACKs coming in, then no need for slow startu If a packet has made it through -> we can send another oneu Divide cwnd by 2 after fast retransmitu Increment cwnd by 1 MSS for each additional duplicate ACK
21
Fast Retransmit & Recovery
CSE 123 – Lecture 21: Congestion control
1
2Ack 2
3
4567
Sender Receiver
Ack 4
Ack 4Ack 4Ack 4Ack 4
Ack 3
4
3 Dup Acks
Fast retransmit
Fast recovery(increase cwnd by 1)
8
22
Fast Retransmit Example
CSE 123 – Lecture 21: Congestion control
Slow Start + Congestion Avoidance +Fast Retransmit + Fast Recovery
0
2
4
6
8
10
12
14
16
18
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
round-trip times
cwnd
Fast recovery
23
More Sophistication
CSE 123 – Lecture 21: Congestion control
! Short connection: only contains a few pkts! How do short connections and Slow-Start interact?
u What happens when a packet is lost during Slow-Start?u What happens when the SYN is dropped?
! Bottom line: Which packet gets dropped matters a lotu SYNu Slow-Startu Congestion avoidance
! Do you think most flows are short or long?! Do you think most traffic is in short flows or long flows?
24
Short Connections
CSE 123 – Lecture 20: Scheduling & QoS
! TCP is designed around the premise of cooperationu What happens to TCP if it competes with a UDP flow?u What if we divide cwnd by 3 instead of 2 after a loss?
! There are a bunch of magic numbersu Decrease by 2x, increase by 1/cwnd, 3 duplicate acks, initial
timeout = 3 seconds, etc.
! But overall it works really well!u Still being constantly tweaked…
25
Open Issues
CSE 123 – Lecture 20: Scheduling & QoS
! TCP Probes the network for bandwidth, assuming thatloss signals congestion
! The congestion window is managed with an additive increase/multiplicative decrease policyu It took fast retransmit and fast recovery to get thereu Fast recovery keeps pipe “full” while recovering from a loss
! Slow start is used to avoid lengthy initial delaysu Ramp up to near target rate, then switch to AIMD
26
TCP CC Summary
CSE 123 – Lecture 20: Scheduling & QoS
For next time…
! RP&D 6.5
! Keep going on Project 2
27CSE 123 – Lecture 19: Congestion Control