Congestion Control contd TCP Congestion Control Review n

  • Slides: 43
Download presentation
Congestion Control (cont’d)

Congestion Control (cont’d)

TCP Congestion Control Review n Congestion control consists of 3 tasks ¡ ¡ ¡

TCP Congestion Control Review n Congestion control consists of 3 tasks ¡ ¡ ¡ n Detect congestion Adjust sending rate Determine available bandwidth How does TCP do each of these?

Packets vs. Bytes n n TCP window sizes are in bytes Congestion control works

Packets vs. Bytes n n TCP window sizes are in bytes Congestion control works on packets ¡ ¡ ¡ n Increase by 1 packet every RTT Pcwnd = cwnd / MSS Pcwnd = Pcwnd + 1/Pcwnd on each ACK Multiply by MSS to get byte-sized formula ¡ ¡ cwnd = cwnd + MSS*(MSS/cwnd) on each ACK Increase by 1 MSS every RTT

TCP Start Up n n n How do we set initial window size? Additive

TCP Start Up n n n How do we set initial window size? Additive increase too slow Example: DSL line ¡ ¡ RTT=100 ms, MSS=1500 b, BW=200 KB/s After 1 RTT, rate is 15 KB/s After 1 s, rate is 150 KB/s Takes 8. 3 s to transfer 500 KB file

Slow Start Objective ¡ n Determine initial available capacity Destination Idea ¡ ¡ Begin

Slow Start Objective ¡ n Determine initial available capacity Destination Idea ¡ ¡ Begin with Congestion. Window = 1 packet Double Congestion. Window each RTT n ¡ n Source Increment by 1 packet for each ACK Continue increasing until loss, then switch to AIMD Result ¡ ¡ Exponential growth Slower than all at once … n

Window rate control n Congestion window ensures average rate is cwnd / RTT ¡

Window rate control n Congestion window ensures average rate is cwnd / RTT ¡ Instantaneous rate may be larger window-controlled transmissions time 0 1 RTT 2 RTT rate-controlled transmissions

ACK clocking n ACK clocking spreads out bursts ¡ ¡ Packets sent in a

ACK clocking n ACK clocking spreads out bursts ¡ ¡ Packets sent in a burst arrive spread out ACKs follow the timing of received rate 100 Mbps Sender 5 Mbps Router Receiver

ACK clocking n ACK clocking spreads out bursts ¡ ¡ ¡ Packets sent in

ACK clocking n ACK clocking spreads out bursts ¡ ¡ ¡ Packets sent in a burst arrive spread out ACKs follow the timing of received rate New sending rate follows ACK rate 100 Mbps Sender 5 Mbps Router Receiver

Slow start n ACK clocking, with 2 packets per ACK Sender Router Receiver

Slow start n ACK clocking, with 2 packets per ACK Sender Router Receiver

Slow start n ACK clocking, with 2 packets per ACK Sender Router Receiver

Slow start n ACK clocking, with 2 packets per ACK Sender Router Receiver

Slow start n ACK clocking, with 2 packets per ACK Sender Router Receiver NB:

Slow start n ACK clocking, with 2 packets per ACK Sender Router Receiver NB: There’s a proposed alternative to slow-start that uses ACK clocking

TCP Timeout cwnd x timeout retransmit cumulative ack

TCP Timeout cwnd x timeout retransmit cumulative ack

Timeout Handling n Cumulative ACK opens up entire window ¡ ¡ n Do we

Timeout Handling n Cumulative ACK opens up entire window ¡ ¡ n Do we send entire window all at once? No ACKs to clock transmission Use slow-start to recover ACK clock Reset cwnd to 1 (packet) ¡ Use exponential increase (add 1 packet to cwnd for every ACK) ¡

Congestion Threshold n New variable: Congestion Threshold ¡ ¡ n If cwnd < cthresh,

Congestion Threshold n New variable: Congestion Threshold ¡ ¡ n If cwnd < cthresh, increase exponentially ¡ n n slow start If cwnd > cthresh, increase linearly ¡ n Target window size Estimate network capacity additive increase Initially, ctrhesh = max window At loss, ctrhesh = 1/2 cwnd

Slow Start n Initial values ¡ ¡ n cthresh = 8 cwnd = 1

Slow Start n Initial values ¡ ¡ n cthresh = 8 cwnd = 1 Loss after transmission 7 ¡ ¡ ¡ cwnd currently 12 Set cthresh = cwnd/2 Set cwnd = 1

Slow Start Example trace of Congestion. Window KB n 70 60 50 40 30

Slow Start Example trace of Congestion. Window KB n 70 60 50 40 30 20 10 CW flattens out due to loss Linear increase Slow start until CW = CT 1. 0 2. 0 3. 0 4. 0 5. 0 6. 0 7. 0 8. 0 9. 0 Timeout: CT = CW/2 = 11, CW = 1 n Problem n Have to wait for timeout n Can lose half Congestion. Window of data

Fast Retransmit and Fast Recovery n Problem ¡ n Coarse-grain TCP timeouts lead to

Fast Retransmit and Fast Recovery n Problem ¡ n Coarse-grain TCP timeouts lead to idle periods Solution ¡ Fast retransmit: use duplicate ACKs to trigger retransmission Sender Receiver Packet 1 Packet 2 Packet 3 Packet 4 ACK 1 Packet 5 ACK 2 Packet 6 ACK 2 Retransmit packet 3 ACK 6

Fast Retransmit and Fast Recovery n n Send ACK for each segment received When

Fast Retransmit and Fast Recovery n n Send ACK for each segment received When duplicate ACK’s received ¡ ¡ ¡ n Resend lost segment immediately Do not wait for timeout In practice, retransmit on 3 rd duplicate Fast recovery ¡ ¡ ¡ When fast retransmission occurs, skip slow start Congestion window becomes 1/2 previous Start additive increase immediately

TCP Congestion Window Trace

TCP Congestion Window Trace

TCP Congestion Control Summary n Congestion control mechanisms ¡ ¡ ¡ Timeouts RTT estimation

TCP Congestion Control Summary n Congestion control mechanisms ¡ ¡ ¡ Timeouts RTT estimation Congestion window Slow start Fast retransmit

Fairness n TCP congestion control is fair ¡ ¡ Both senders will settle at

Fairness n TCP congestion control is fair ¡ ¡ Both senders will settle at around 5 Mbps Intuition: flows using more bandwidth more likely to experience loss Sender 1 Receiver 1 20 Mbps Sender 2 Router 10 Mbps Receiver 2

What’s Fair? Flow A Flow B Flow C Which is more fair: Globally Fair:

What’s Fair? Flow A Flow B Flow C Which is more fair: Globally Fair: Fa = Capacity/4, Fb = Fc = Fd = 3 Capacity/4 or Locally Fair: Fa = Fb = Fc = Fd = Capacity/2 Flow D This is the socalled “max-min fair” rate allocation. The minimum rate is maximized.

TCP fairness n TCP is “RTT-fair” ¡ n Intuition: during additive increase, each host

TCP fairness n TCP is “RTT-fair” ¡ n Intuition: during additive increase, each host adds one new packet every RTT ¡ n On each congested link, host gets shared of bandwidth proportional to RTT If RTT twice as large, additive increase is half as fast Is this closer to globally fair or locally fair?

Why is TCP fair? Two competing sessions: n Additive increase improves fairness Multiplicative decrease

Why is TCP fair? Two competing sessions: n Additive increase improves fairness Multiplicative decrease preserves fairness R Connection 2 throughput n equal bandwidth share loss: decrease window by factor of 2 congestion avoidance: additive increase Connection 1 throughput R

Congestion Avoidance Control vs. avoidance ¡ ¡ n Control: minimize impact of congestion when

Congestion Avoidance Control vs. avoidance ¡ ¡ n Control: minimize impact of congestion when it occurs Avoidance: avoid producing congestion In terms of operating point limits optimal load avoidance control power n idealized power curve load

Congestion Avoidance n TCP’s strategy ¡ ¡ n Alternative Strategy ¡ ¡ n Repeatedly

Congestion Avoidance n TCP’s strategy ¡ ¡ n Alternative Strategy ¡ ¡ n Repeatedly cause congestion Control it once it happens Predict when congestion is about to happen and reduce the rate at which hosts send data just before packets start being discarded Congestion avoidance, as compared to congestion control Approaches ¡ ¡ ¡ Routers implement CA (ATM, RSVP) Routers help end-hosts implement CA (DECbit, RED) End-hosts do it themselves (TCP Vegas)

DECbit (Destination Experiencing Congestion Bit) n n Developed for the Digital Network Architecture Basic

DECbit (Destination Experiencing Congestion Bit) n n Developed for the Digital Network Architecture Basic idea ¡ ¡ ¡ n One bit allocated in packet header Any router experiencing congestion sets bit Source adjusts rate based on bits Note that responsibility is shared ¡ ¡ Routers identify congestion Hosts act to avoid congestion

DECbit Router n ¡ ¡ ¡ Monitors length over last busy + idle cycle

DECbit Router n ¡ ¡ ¡ Monitors length over last busy + idle cycle Sets congestion bit if average queue length is greater then 1 when packet arrives Attempts to balance throughput against delay n Queue length n smaller values result in more idle time larger values result in more queueing delay Averaging interval Current time Previous cycle Current cycle Time

DECbit n End Hosts ¡ ¡ ¡ Destination echoes congestion bit back to source

DECbit n End Hosts ¡ ¡ ¡ Destination echoes congestion bit back to source Source records how many packets resulted in set bit If less than 50% of last window had bit set n ¡ If 50% or more of last window had bit set n n Increase Congestion. Window by 1 packet Decrease Congestion. Window by 1/8 th Note: ¡ ¡ Techniques used in DECbit known as explicit congestion notification (ECN) Proposal to add ECN bit to TCP in progress

Router-Based Congestion Avoidance n Random Early Detection (RED) gateways ¡ ¡ Developed for use

Router-Based Congestion Avoidance n Random Early Detection (RED) gateways ¡ ¡ Developed for use with TCP Basic idea n n n ¡ Implicit rather than explicit notification When a router is “almost” congested Drop packets randomly Responsibility is again shared n n Router identifies, host acts Relies on TCP’s response to dropped packets

Random Early Detection (RED) n Hosts ¡ ¡ n Implement TCP congestion control Back

Random Early Detection (RED) n Hosts ¡ ¡ n Implement TCP congestion control Back off when a packet is dropped Routers ¡ Compute average queue length (exponential moving average) n n n Avg. Len = (1 – Weight) * Avg. Len + Weight * Sample. Len 0 < Weight < 1 (usually 0. 002) Sample. Len is queue length at packet arrival time

RED – Dropping Policy n If Avg. Len Min. Threshold ¡ n If Min.

RED – Dropping Policy n If Avg. Len Min. Threshold ¡ n If Min. Threshold < Avg. Len < Max. Threshold ¡ n Enqueue packet Calculate P and drop arriving packet with probability P If Max. Threshold Avg. Len ¡ Drop arriving packet Max. Threshold Avg. Len Min. Threshold Avg. Len

RED – Dropping Probability n Computing P ¡ ¡ ¡ P is a function

RED – Dropping Probability n Computing P ¡ ¡ ¡ P is a function of Avg. Len and Count is the number of packets that have arrived since last reset Reset happens when either a packet is dropped or Avg. Len is above Max. Threshold Temp. P = (Max. P) * (Avg. Len – Min. Threshold) Max. Threshold - Min. Threshold 1. 0 P= Temp. P (1 – count * Temp. P) Max. P P(drop) Avg. Len Min. Thresh Max. Thresh

RED Parameters n Max. P is typically set to 0. 02 ¡ n n

RED Parameters n Max. P is typically set to 0. 02 ¡ n n When the average queue size is halfway between the two thresholds, the gateway drops roughly one out of 50 packets. Min. Threshold is typically max/2 Choosing parameters ¡ ¡ ¡ Carefully tuned to maximize power function Confirmed through simulation But answer depends on accuracy of traffic model

Tuning RED n Probability of dropping a particular flow’s packet(s) ¡ n If traffic

Tuning RED n Probability of dropping a particular flow’s packet(s) ¡ n If traffic is bursty ¡ ¡ n Roughly proportional to the that flow’s current share of the bandwidth Min. Threshold should be sufficiently large to allow link utilization to be maintained at an acceptably high level If no buffer space is available, RED uses Tail Drop Difference between two thresholds ¡ ¡ Should be larger than the typical increase in the calculated average queue length in one RTT Setting Max. Threshold to twice Min. Threshold is reasonable for traffic on today’s Internet

Source-Based Congestion Avoidance n Idea ¡ n Source watches for some sign that some

Source-Based Congestion Avoidance n Idea ¡ n Source watches for some sign that some router’s queue is building up and congestion will happen soon Examples ¡ ¡ RTT is growing Sending rate flattens

Source-Based Congestion Avoidance n Observe RTT ¡ n If current RTT is greater than

Source-Based Congestion Avoidance n Observe RTT ¡ n If current RTT is greater than average of min. RTT and max. RTT, decrease congestion window by one-eigth Observe RTT and Window Size ¡ Adjust window once every two RTT n n Observe sending rate ¡ n If (Curr. Window – Old. Window) * (Curr. RTT – Old. RTT) > 0, decrease window by one-eigth, otherwise increase window my one MSS Increase window and compare throughput to previous value Observe throughput ¡ ¡ Compare measured throughput with observed throughput TCP Vegas

KB TCP Vegas 70 60 50 40 30 20 10 0. 5 1. 0

KB TCP Vegas 70 60 50 40 30 20 10 0. 5 1. 0 1. 5 2. 0 2. 5 3. 0 3. 5 4. 0 4. 5 5. 0 5. 5 6. 0 6. 5 7. 0 7. 5 8. 0 8. 5 Sending KBps Time (seconds) 1100 900 700 500 300 100 0. 5 1. 0 1. 5 2. 0 2. 5 3. 0 3. 5 4. 0 4. 5 Queue size in router Time (seconds) 10 5 0. 5 1. 0 1. 5 2. 0 2. 5 3. 0 3. 5 4. 0 4. 5 Time (seconds)

TCP Vegas n Basic idea ¡ ¡ Watch for signs of queue growth In

TCP Vegas n Basic idea ¡ ¡ Watch for signs of queue growth In particular, difference between n n ¡ increasing congestion window stable throughput (presumably at capacity) Keep just enough “extra data” in the network n n Time to react if bandwidth decreases Data available if bandwidth increases

TCP Vegas n Implementation ¡ Estimate uncongested RTT n n ¡ base. RTT =

TCP Vegas n Implementation ¡ Estimate uncongested RTT n n ¡ base. RTT = minimum measured RTT Expected throughput = congestion window / base. RTT Measure throughput each RTT n n Mark time of sending distinguished packet Calculate data sent between send time and receipt of ACK

TCP Vegas ¡ Act to keep the difference between estimated and actual throughput in

TCP Vegas ¡ Act to keep the difference between estimated and actual throughput in a specified range n Below minimum threshold ¡ n Above maximum threshold ¡ ¡ ¡ Increase congestion window Decrease congestion window Additive decrease used only to avoid congestion Want between 1 and 3 packets of extra data (used to pick min/max thresholds)

TCP Vegas Algorithm n Let Base. RTT be minimum of all measured RTTs ¡

TCP Vegas Algorithm n Let Base. RTT be minimum of all measured RTTs ¡ n If not overflowing the connection, then ¡ n n Commonly the RTT of the first packet Expect. Rate = Congestion. Window/Base. RTT Source calculates sending rate (Actual. Rate) once per RTT Source compares Actual. Rate with Expect. Rate ¡ ¡ Diff = Expected. Rate – Actual. Rate if Diff < a n ¡ else if Diff > b n ¡ Increase Congestion. Window linearly Decrease Congestion. Window linearly else n Leave Congestion. Window unchanged

TCP Vegas Algorithm Parameters ¡ n a = 1 packet b = 3 packets

TCP Vegas Algorithm Parameters ¡ n a = 1 packet b = 3 packets Even faster retransmit ¡ ¡ Keep finegrained timestamps for each packet Check for timeout on first duplicate ACK KB ¡ 70 60 50 40 30 20 10 0. 5 1. 0 1. 5 2. 0 2. 5 3. 0 3. 5 4. 0 4. 5 5. 0 5. 5 6. 0 6. 5 7. 0 7. 5 8. 0 Time (seconds) CAM KBps n 240 200 160 120 80 40 0. 5 1. 0 1. 5 2. 0 2. 5 3. 0 3. 5 4. 0 4. 5 5. 0 5. 5 6. 0 6. 5 7. 0 7. 5 8. 0 Time (seconds)