lecture 11: congestion controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» assume...
TRANSCRIPT
![Page 1: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/1.jpg)
CSE 123: Computer Networks Alex C. Snoeren
Lecture 11:Congestion Control"
Midterm Tuesday; No class 11/04!
![Page 2: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/2.jpg)
How fast should a sending host transmit data? ◆ Not to fast, not to slow, just right…
Should not be faster than the sender’s share ◆ Bandwidth allocation
Should not be faster than the network can process ◆ Congestion control
Congestion control & bandwidth allocation are separate ideas, but frequently combined
CSE 123 – Lecture 11: Congestion Control 2
Lecture 11 Overview"
![Page 3: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/3.jpg)
How much bandwidth should each flow from a source to a destination receive when they compete for resources?
◆ What is a “fair” allocation?
Router
Source 2
Source 1
Source 3
Router
Router
Destination 2
Destination 1 10Mbps
4Mbps
10Mbps
6Mbps
100Mbps
10Mbps
CSE 123 – Lecture 11: Congestion Control 3
Bandwidth Allocation"
![Page 4: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/4.jpg)
Statistical Multiplexing"
1. The bigger the buffer, the lower the packet loss. 2. If the buffer never goes empty, the outgoing line
is busy 100% of the time.
CSE 123 – Lecture 11: Congestion Control 4
![Page 5: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/5.jpg)
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
Destination 1.5-Mbps T1 link
Router
Source 2
Source 1 10-Mbps Ethernet
Packets dropped here
CSE 123 – Lecture 11: Congestion Control 5
Congestion"
![Page 6: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/6.jpg)
Network Load
Thro
ughp
ut
Late
ncy
Congestion collapse
CSE 123 – Lecture 11: Congestion Control 6
Drop-Tail Queuing"Loss due to Congestion
![Page 7: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/7.jpg)
Rough definition: “When an increase in network load produces a decrease in useful work”
Why does it happen? ◆ Sender sends faster than bottleneck link speed ◆ Packets queue until dropped ◆ In response to packets being dropped, sender retransmits ◆ All hosts repeat in steady state…
CSE 123 – Lecture 11: Congestion Control 7
Congestion Collapse"
![Page 8: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/8.jpg)
Increase network resources ◆ More buffers for queuing ◆ Increase link speed ◆ Pros/Cons of these approaches?
Reduce network load ◆ Send data more slowly ◆ How much more slowly? ◆ When to slow down?
CSE 123 – Lecture 11: Congestion Control 8
Mitigation Options"
![Page 9: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/9.jpg)
Open loop ◆ Explicitly reserve bandwidth in the network in advance
Closed loop ◆ Respond to feedback and adjust bandwidth allocation
Network-based ◆ Network implements and enforces bandwidth allocation
Host-based ◆ Hosts are responsible for controlling their sending rate
CSE 123 – Lecture 11: Congestion Control 9
Designing a Control"
![Page 10: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/10.jpg)
Network Load
Thro
ughp
ut
Late
ncy
“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
CSE 123 – Lecture 11: Congestion Control 10
Proactive vs. Reactive"
Loss due to Congestion
![Page 11: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/11.jpg)
How to detect congestion?
How to limit sending data rate?
How fast to send?
CSE 123 – Lecture 11: Congestion Control 11
Challenges to Address"
![Page 12: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/12.jpg)
Explicit congestion signaling ◆ Source Quench: ICMP message from router to sender ◆ 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 signaling ◆ Packet loss
» Assume congestion is primary source of packet loss » Lost packets indicate congestion
◆ Packet delay » Round-trip time increases as packets queue » Packet inter-arrival time is a function of bottleneck link
CSE 123 – Lecture 11: Congestion Control 12
Detecting Congestion"
![Page 13: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/13.jpg)
Window-based (TCP) ◆ Constrain number of outstanding packets allowed in network ◆ Increase window to send faster; decrease to send slower ◆ Pro: Cheap to implement, good failure properties ◆ Con: Creates traffic bursts (requires bigger buffers)
Rate-based (many streaming media protocols) ◆ Two parameters (period, packets) ◆ Allow sending of x packets in period y ◆ Pro: smooth traffic ◆ Con: fine-grained per-connection timers, what if receiver fails?
CSE 123 – Lecture 11: Congestion Control 13
Throttling Options"
![Page 14: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/14.jpg)
Ideally: Keep equilibrium at “knee” of power curve ◆ Find “knee” somehow ◆ Keep number of packets “in flight” the same ◆ Don’t send a new packet into the network until you know one
has left (I.e. by receiving an ACK) ◆ What if you guess wrong, or if bandwidth availability changes?
Compromise: adaptive approximation ◆ If congestion signaled, reduce sending rate by x ◆ If data delivered successfully, increase sending rate by y ◆ How to relate x and y? Most choices don’t converge…
CSE 123 – Lecture 11: Congestion Control 14
Choosing a Send Rate"
![Page 15: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/15.jpg)
Each source independently probes the network to determine how much bandwidth is available ◆ Changes over time, since everyone does this
Assume that packet loss implies congestion ◆ Since errors are rare; also, requires no support from routers
Sink 45 Mbps T3 link Router Source
100 Mbps Ethernet
CSE 123 – Lecture 11: Congestion Control 15
TCPʼs Probing Approach"
![Page 16: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/16.jpg)
Window-based congestion control ◆ Unified congestion control and flow control mechanism ◆ rwin: advertised flow control window from receiver ◆ cwnd: congestion control window
» Estimate of how much outstanding data network can deliver in a round-trip time
◆ Sender can only send MIN(rwin,cwnd) at any time
Idea: decrease cwnd when congestion is encountered; increase cwnd otherwise ◆ Question: how much to adjust?
CSE 123 – Lecture 11: Congestion Control 16
Basic TCP Algorithm"
![Page 17: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/17.jpg)
Goal: Adapt to changes in available bandwidth
Additive Increase, Multiplicative Decrease (AIMD) ◆ Increase sending rate by a constant (e.g. MSS) ◆ Decrease sending rate by a linear factor (e.g. divide by 2)
Rough intuition for why this works ◆ Let Li be queue length at time i ◆ In steady state: Li = N, where N is a constant ◆ During congestion, Li = N + yLi-1, where y > 0 ◆ Consequence: queue size increases multiplicatively
» Must reduce sending rate multiplicatively as well
CSE 123 – Lecture 11: Congestion Control 17
Congestion Avoidance"
![Page 18: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/18.jpg)
Increase slowly while we believe there is bandwidth ◆ Additive increase per RTT ◆ cwnd += 1 full packet / RTT
Decrease quickly when there is loss (went too far!) ◆ Multiplicative decrease ◆ cwnd /= 2
Source Destination
… CSE 123 – Lecture 11: Congestion Control 18
AIMD"
![Page 19: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/19.jpg)
Only W packets may be outstanding
Rule for adjusting congestion window (W) ◆ If an ACK is received: W ← W+1/W ◆ If a packet is lost: W ← W/2
TCP Congestion Control"
CSE 123 – Lecture 11: Congestion Control 19
![Page 20: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/20.jpg)
Goal: quickly find the equilibrium sending rate
Quickly increase sending rate until congestion detected ◆ Remember last rate that worked and don’t overshoot it
Algorithm: ◆ On new connection, or after timeout, set cwnd=1 MSS ◆ For each segment acknowledged, increment cwnd by 1 MSS ◆ If timeout then divide cwnd by 2, and set ssthresh = cwnd ◆ If cwnd >= ssthresh then exit slow start
Why called slow? Its exponential after all…
CSE 123 – Lecture 11: Congestion Control 20
Slow Start"
![Page 21: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/21.jpg)
1
2 Ack 2
3 Ack 3
4 5 6 7
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 5 Ack 6 Ack 7 Ack 8
CSE 123 – Lecture 11: Congestion Control 21
Slow Start Example"
![Page 22: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/22.jpg)
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
Congestion avoidance
CSE 123 – Lecture 11: Congestion Control 22
Basic Mechanisms"
![Page 23: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/23.jpg)
Fast retransmit ◆ Timeouts are slow (1 second is fastest timeout on many TCPs) ◆ When packet is lost, receiver still ACKs last in-order packet ◆ Use 3 duplicate ACKs to indicate a loss; detect losses quickly
» Why 3? When wouldn’t this work?
Fast recovery ◆ Goal: avoid stalling after loss ◆ If there are still ACKs coming in, then no need for slow start ◆ If a packet has made it through -> we can send another one ◆ Divide cwnd by 2 after fast retransmit ◆ Increment cwnd by 1 MSS for each additional duplicate ACK
CSE 123 – Lecture 11: Congestion Control 23
Fast Retransmit & Recovery"
![Page 24: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/24.jpg)
1
2 Ack 2
3
4 5 6 7
Sender Receiver
Ack 4
Ack 4 Ack 4 Ack 4 Ack 4
Ack 3
4
3 Dup Acks
Fast retransmit
Fast recovery (increase cwnd by 1)
8
CSE 123 – Lecture 11: Congestion Control 24
Fast Retransmit Example"
![Page 25: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/25.jpg)
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
CSE 123 – Lecture 11: Congestion Control 25
More Sophistication"
![Page 26: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/26.jpg)
In request/response programs, want to combine an ACK to a request with a response in same packet ◆ Wait 200ms before ACKing ◆ Must ACK every other packet (or packet burst) ◆ Impact on slow start?
Must not delay duplicate ACKs ◆ Why? What is the interaction with the congestion control
algorithms?
CSE 123 – Lecture 11: Congestion Control 26
Delayed ACKs"
![Page 27: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/27.jpg)
Short connection: only contains a few pkts How do short connections and Slow-Start interact?
◆ What happens when a packet is lost during Slow-Start? ◆ What happens when the SYN is dropped?
Bottom line: Which packet gets dropped matters a lot ◆ SYN ◆ Slow-Start ◆ Congestion avoidance
Do you think most flows are short or long? Do you think most traffic is in short flows or long flows?
CSE 123 – Lecture 11: Congestion Control 27
Short Connections"
![Page 28: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/28.jpg)
TCP is designed around the premise of cooperation ◆ What happens to TCP if it competes with a UDP flow? ◆ What if we divide cwnd by 3 instead of 2 after a loss?
There are a bunch of magic numbers ◆ Decrease by 2x, increase by 1/cwnd, 3 duplicate acks, g=1/8,
initial timeout = 3 seconds, etc.
But overall it works really well! ◆ Still being constantly tweaked…
CSE 123 – Lecture 11: Congestion Control 28
Open Issues"
![Page 29: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/29.jpg)
TCP Probes the network for bandwidth, assuming that loss signals congestion
The congestion window is managed with an additive increase/multiplicative decrease policy ◆ It took fast retransmit and fast recovery to get there ◆ Fast recovery keeps pipe “full” while recovering from a loss
Slow start is used to avoid length initial delays ◆ Ramp up to near target rate, then switch to AIMD
CSE 123 – Lecture 11: Congestion Control 29
Summary"
![Page 30: Lecture 11: Congestion Controlcseweb.ucsd.edu/classes/fa10/cse123/lectures/123-fa10-l...» Assume congestion is primary source of packet loss » Lost packets indicate congestion Packet](https://reader036.vdocuments.mx/reader036/viewer/2022081411/60b34fe5a6366b686541f805/html5/thumbnails/30.jpg)
For next time…" Midterm on Tuesday
No class on Thursday!
Get started on Project 2…
30 CSE 123 – Lecture 11: Congestion Control