810 likes | 822 Views
This article explores congestion control in Transport Layer III, focusing on TCP's unfairness and the potential for cheating. Topics covered include equation-based rate control, TCP's behavior on lossy links, and the concept of getting help from the network.
E N D
CSCI-1680Transport Layer IIICongestion Control Strikes Back Theophilus Benson Based partly on lecture notes byRodrigoFoncesa, David Mazières, Phil Levis, John Jannotti, Ion Stoica
This Week • Congestion Control Continued • Quick Review • TCP Friendliness • Equation Based Rate Control • TCP’s Inherent unfairness • TCP on Lossy Links • Congestion Control versus Avoidance • Getting help from the network • Cheating TCP
Glossary of Terms • RTT = Round Trip Time • MSS = Maximum Segment Size • Largest amount of TCP data in a packet • Sequence Numbers • RTO = Timeout • Dup-Ack = a duplicate Acknowledgement • Transmission Rounds
Duplicate ACK example Seg1: seq-no=0 each segment contains 1460 bytes ACK_1: seq-no=1460 Receiver sends ACKs for the last in-order accepted packet. Seg2: seq-no=1460 Dropped Pkt Seg3: seq-no=2920 Seg4: seq-no=4380 Seg5: seq-no=4380 ACK_1: seq-no=1460 Seg2 re-transmitted after 3-dup-acks Dup-Ack ACK_1: seq-no=1460 Dup-Ack ACK_1: seq-no=1460 ACK_5 after re-transmission acknowledges all packets Dup-Ack Seg2: seq-no=1460 ACK_5: seq-no=5840
Glossary of Terms • RTT = Round Trip Time • MSS = Maximum Segment Size • Largest amount of TCP data in a packet • Sequence Numbers • RTO = Timeout • Dup-Ack = a duplicate Acknowledgement • Transmission Rounds
MSS + Sequence Numbers • Your Code wants to send 146KB over the network • Network MTU = 1500B • Protocol header = IP(20B)+TCP(20B) = 40B • What about link layer header? (ethernet or ATM?) • MSS =1500B-40B = 1460B • # of TCP data segments = 146KB/1460B = 100 • Each TCP Data segment has a sequence number: • Location of first byte in the data segment.
Glossary of Terms • RTT = Round Trip Time • MSS = Maximum Segment Size • Largest amount of TCP data in a packet • Sequence Numbers • RTO = Timeout • Dup-Ack = a duplicate Acknowledgement • Transmission Rounds
Timeout (RTO) example Wait for ACK … if no ACK then packet is lost How long to wait? **some function of RTT
Glossary of Terms • RTT = Round Trip Time • MSS = Maximum Segment Size • Largest amount of TCP data in a packet • Sequence Numbers • RTO = Timeout • Dup-Ack = a duplicate Acknowledgement • Transmission Rounds
Transmission Rounds • From perspective of the sending host • At start of round= All data packets are sent • At end of round = All ACKs received • TCP tracks Window (CWND) in bytes but we may discuss it in MSS to make things simpler
Life of a TCP Connection SYN • TCP Connection Handshake • Agree TCP connection options • Conversation starter: ‘Hi’..’hello’ SYN/ACK ACK
Life of a TCP Connection SYN • TCP Connection Handshake • Agree TCP connection options • Conversation starter: ‘Hi’..’hello’ SYN/ACK Data ACK ACK *Flow Control *Congestion Control Data ACK Data Sequence number (in bytes) .. Data .. Sequence number of first byte in the packet ACK = sequence number of last byte in data packet +1 ACK Data
Life of a TCP Connection SYN • TCP Connection Handshake • Agree TCP connection options • Conversation starter: ‘Hi’..’hello’ • Allocate resources SYN/ACK Data ACK ACK Data ACK *Flow Control *Congestion Control Data ACK Data FIN • TCP Connection Teardown • Conversation end: ‘good bye’ • De-allocate resources FIN/ACK ACK
Quick Review • Flow Control: • Receiver sets Advertised Window • Prevents sender from overfilling receiver buffer • Congestion Control • Two states: Slow Start (SS) and Congestion Avoidance (CA) • A window size threshold governs the state transition • Window <= ssthresh: SS • Window > ssthresh: Congestion Avoidance
States differ in how they respond to acks • Slow start: double w in one RTT • There are w/MSS segments (and acks) per RTT • Increase w per RTT how much to increase per ack? • w / (w/MSS) = MSS • AIMD: Add 1 MSS per RTT • MSS/(w/MSS) = MSS2/w per received ACK
Putting it all together cwnd Timeout Timeout AIMD AIMD ssthresh SlowStart SlowStart SlowStart Time
Fast Recovery and Fast Retransmit cwnd AI/MD Slow Start Fast retransmit Time
This Week • Congestion Control Continued • Quick Review • TCP Friendliness • Equation Based Rate Control • TCP’s Inherent unfairness • TCP on Lossy Links • Congestion Control versus Avoidance • Getting help from the network • Cheating TCP
TCP Friendliness • Can other protocols co-exist with TCP? • E.g., if you want to write a video streaming app using UDP, how to do congestion control? 1 UDP Flow at 10MBps 31 TCP Flows Sharing a 10MBps link
TCP Friendliness • Can other protocols co-exist with TCP? • E.g., if you want to write a video streaming app using UDP, how to do congestion control? • Equation-based Congestion Control • Instead of implementing TCP’s CC, estimate the rate at which TCP would send. Function of what? • RTT, MSS, Loss • Measure RTT, Loss, send at that rate!
TCP Friendliness • Can other protocols co-exist with TCP? • E.g., if you want to write a video streaming app using UDP, how to do congestion control? • Equation-based Congestion Control • Instead of implementing TCP’s CC, estimate the rate at which TCP would send. Function of what? • RTT, MSS, Loss • Measure RTT, Loss, send at that rate! Fair Througput= function( ?, ?, ?)
TCP Friendliness • Can other protocols co-exist with TCP? • E.g., if you want to write a video streaming app using UDP, how to do congestion control? • Equation-based Congestion Control • Instead of implementing TCP’s CC, estimate the rate at which TCP would send. Function of what? • Measure RTT, Loss, MMSS • Calculate and send at fair share rate! Fair Throughput= function( RTT, MSS, Loss_rate)
TCP Throughput • W is congestion window • Assume a TCP congestion of window W (segments), round-trip time of RTT, segment size MSS • Sending Rate S = W / RTT(1) • Drop: W = W/2 • grows by MSS for W/2 RTTs, until another drop at W ≈ W • Steady-state AMID: Average window then 0.75xS • From (1), S = 0.75 W / RTT (2) • Loss rate is 1 in number of packets between losses: • Loss = 1 / ( 1 + (W/2 + W/2+1 + W/2 + 2 + … + W) = 1 / (3/8 W2) (3)
TCP Throughput • W is congestion window • Assume a TCP congestion of window W (segments), round-trip time of RTT, segment size MSS • Sending Rate S = W x MSS / RTT(1) • Drop: W = W/2 • grows by MSS for W/2 RTTs, until another drop at W ≈ W • Steady-state AMID: Average window then 0.75xS • From (1), S = 0.75 W MSS / RTT(2) • Loss rate is 1 in number of packets between losses: • Loss = 1 / ( (W/2 + W/2+1 + W/2 + 2 + … + W) = 1 / (3/8 W2) (3)
Loss happens here w w/2 w/2+4 • Loss rate is 1 in number of packets between losses: • Loss = 1 / ( (W/2 + W/2+1 + W/2 + 2 + … + W) Loss = 1 / (3/8 W2) (3)
Loss happens here w w/2 w/2+4 • Loss rate is 1 in number of packets between losses: • Loss = 1 / ( (W/2 + W/2+1 + W/2 + 2 + … + W) Loss = 1 / (3/8 W2) (3)
Calculating Fair Rate (Fair Throughput) • Loss = 8/(3W2) (4) • Substituting (4) in (2), S = 0.75 *W/ RTT , Throughput ≈ • Equation-based rate control can be TCP friendly and have better properties, e.g., small jitter, fast ramp-up…
This Week • Congestion Control Continued • Quick Review • TCP Friendliness • Equation Based Rate Control • TCP’s Inherent unfairness • TCP on Lossy Links • Congestion Control versus Avoidance • Getting help from the network • Cheating TCP
Assumptions Made by TCP • Loss == congestion • Loss only happens when: • Aggregate sending Rate > capacity • All flows in the network have the same: • RTT • MSS • Same loss rates • Everyone Plays Nicely
TCP Friendliness Fair Throughput= function( RTT, MSS, Loss_rate) • Why would you have different RTTs or MSS? • What happens when you have different RTT/MSS? Throughput =
Implication of Buffering on TCP • W in Bytes • Recall: (1) S= 0.75 *W / RTT • Where 0.75 is average of W and W/2 • If No buffer then max W= BW*RTT (BW delay product) Network capacity BW*RTT BW*RTT Avg 0.5*BW*RTT
Implication of Buffering on TCP • If Buffer = ½*BW*RTT • Then max W= BW*RTT +½*BW*RTT • Avg W~ ((1.5+.75)/2)*BW*RTT = 7.8*BW*RTT • S = 7/8*W/ RTT • If No buffer then W*MSS = capacity • S = 0.75* Capacity/RTT • What is ideal Sending rate? • (2) S = Capacity/RTT • What is ideal buffering? Network capacity BW*RTT 1.5*BW*RTT Avg .75*BW*RTT
Implication of Buffering on TCP • In ideal, min window = bandwidth*RTT • What must buffer be to ensure this? • If No buffer then W*MSS = capacity • S = 0.75* Capacity/RTT • What is ideal Sending rate? • (2) S = Capacity/RTT • What is ideal buffering? ??*BW*RTT Avg = ?? ??*BW*RTT
Implication of Buffering on TCP • In ideal, min = bandwidth*RTT • What must buffer be to ensure this? • Buffer = BW*RTT • Max Window = 2*BW*RTT • Min Window = BW*RTT • If No buffer then W*MSS = capacity • S = 0.75* Capacity/RTT • What is ideal Sending rate? • (2) S = Capacity/RTT • What is ideal buffering? Network capacity BW*RTT 2*BW*RTT Avg = 1.5BW*RTT BW*RTT
This Week • Congestion Control Continued • Quick Review • TCP Friendliness • Equation Based Rate Control • TCP’s Inherent unfairness • TCP on Lossy Links • Congestion Control versus Avoidance • Getting help from the network • Cheating TCP
Buffering and TCP • If Buffer = ¼*BW*RTT • What is TCP throughput • Max Window = • Min Window = • TCP Throughput = • If No buffer then W*MSS = capacity • S = 0.75* Capacity/RTT • What is ideal Sending rate? • (2) S = Capacity/RTT • What is ideal buffering?
Buffering and TCP • If Buffer = ¼*BW*RTT • What is TCP throughput • Max Window =(1+1/4)*BW*RTT • Min Window = (MaxWindow/2)=1/2(5/4)*BW*RTT • TCP Throughput ~ ½(min+max) = 15/16 *BW*RTT • What’s wrong with this throughput? • If No buffer then W*MSS = capacity • S = 0.75* Capacity/RTT • What is ideal Sending rate? • (2) S = Capacity/RTT • What is ideal buffering?
Buffering and TCP • If Buffer = ¼*BW*RTT • What is TCP throughput • Max Window =(1+1/4)*BW*RTT • Min Window = (MaxWindow/2)=1/2(5/4)*BW*RTT • TCP Throughput ~ ½(min+max) = 15/16 *BW*RTT • What’s wrong with this throughput? • Less than Network capacity. • If No buffer then W*MSS = capacity • S = 0.75* Capacity/RTT • What is ideal Sending rate? • (2) S = Capacity/RTT • What is ideal buffering?
Buffering and TCP • If Buffer = 3*BW*RTT • What is TCP throughput • Max Window = • Min Window = • TCP Throughput = • If No buffer then W*MSS = capacity • S = 0.75* Capacity/RTT • What is ideal Sending rate? • (2) S = Capacity/RTT • What is ideal buffering?
Buffering and TCP • If Buffer = 3*BW*RTT • What is TCP throughput • Max Window =(1+3)*BW*RTT • Min Window = (MaxWindow/2)=1/2(4)*BW*RTT • TCP Throughput ~ ½(min+max) ~ 2*BW*RTT • What is wrong with this throughput? • If No buffer then W*MSS = capacity • S = 0.75* Capacity/RTT • What is ideal Sending rate? • (2) S = Capacity/RTT • What is ideal buffering?
Buffering and TCP • If Buffer = 3*BW*RTT • What is TCP throughput • Max Window =(1+3)*BW*RTT • Min Window = (MaxWindow/2)=1/2(4)*BW*RTT • TCP Throughput ~ ½(min+max) ~ 2*BW*RTT • What is wrong with this throughput? • Greater than network capacity • If No buffer then W*MSS = capacity • S = 0.75* Capacity/RTT • What is ideal Sending rate? • (2) S = Capacity/RTT • What is ideal buffering?
How long is Fin-wait-1? ACK Data • How long until you get the Fin/ACK? • If Max-Window is less than network capacity. • If Max-window great than network capacity ACK Data FIN FIN/ACK ACK
How long is Fin-wait-1? ACK Data • How long until you get the Fin/ACK? • If Max-Window is less than network capacity. • Then 1 RTT(No buffering) • If Max-window great than network capacity • Then > 1 RTT. How many RTTs? ACK Data FIN FIN/ACK ACK
What Happens When Link is Lossy? • Throughput ≈ 1 / sqrt(Loss) p = 0 p = 1% p = 10%
Assumptions Made by TCP • TCP works extremely well when its assumptions are valid • Loss == congestion • Loss only happens when: • Aggregate sending Rate > capacity • All flows in the network have the same: • RTT • MSS • Same loss rates • Everyone Plays Nicely • Everyone implements TCP correctly
What can we do about it? • Two types of losses: congestion and corruption • One option: mask corruption losses from TCP • Retransmissions at the link layer • E.g. Snoop TCP: intercept duplicate acknowledgments, retransmit locally, filter them from the sender • Another option: • Network tells the sender about the cause for the drop • Requires modification to the TCP endpoints
Congestion Avoidance • TCP creates congestion to then back off • Queues at bottleneck link are often full: increased delay • Sawtooth pattern: jitter • Alternative strategy • Predict when congestion is about to happen • Reduce rate early • Two approaches • Host centric: TCP Vegas • Router-centric: RED, ECN, DECBit, DCTCP
Insight Congestion Longer queues sending rate flattens out • Host based Approach • Estimate Rate • If flat then congestion • Slow down • Else no congestion • Speed up
TCP Vegas • Idea: source watches for sign that router’s queue is building up (e.g., sending rate flattens)