220 likes | 234 Views
Communication Networks. Recitation 9. Fairness & TCP Congestion Control. Max-Min Fairness. The intuition: to maximize the bandwidth allocated to the session with the minimum allocation
E N D
Communication Networks Recitation 9 Netcomm 2005
Fairness & TCP Congestion Control Netcomm 2005
Max-Min Fairness • The intuition: to maximize the bandwidth allocated to the session with the minimum allocation • More formally: to maximize the allocation of each session i under constrain that an increase in i’s allocation doesn’t cause a decrease in some other session allocation with the same or smaller rate than i Netcomm 2005
Example of max-min fair flow Session 2 Session 3 Session 1 Capacity=1 Capacity=1 Session 0 Maximal fair flow division will be to give for the sessions 0,1,2 a flow rate of 1/3 and for the session 3 a flow rate of 2/3 Netcomm 2005
TCP Overview • Full duplex • Flow control: keep sender from overrunning receiver • Congestion control: keep sender from overrunning network • Connection-oriented • Byte-stream • app writes bytes • TCP sends segments • app reads bytes • Reliable data transfer Netcomm 2005
32 bits URG: urgent data (generally not used) counting by bytes of data (not segments!) source port # dest port # sequence number ACK: ACK # valid acknowledgement number head len not used rcvr window size U A P R S F PSH: push data now (generally not used) # bytes rcvr willing to accept checksum ptr urgent data Options (variable length) RST, SYN, FIN: connection management (reset, setupteardown commands) application data (variable length) Also in UDP TCP Segment Structure Netcomm 2005
Connection Establishment Active participant Passive participant (client) (server) SYN, SequenceNum = x , y 1 + SYN + ACK, SequenceNum = x Acknowledgment = ACK, Acknowledgment = y + 1 Netcomm 2005
Connection Termination Active participant Passive participant (server) (client) FIN, SequenceNum = x 1 + x Acknowledgment = y FIN, SequenceNum= Acknowledgment = y + 1 Netcomm 2005
Internet Congestion Collapse • In the late 80s, the Internet suffered a congestion collapse Data + Retransmissions Host Congestion! Packet drops!! Host Collapse Host More Drops!!! Netcomm 2005
Detecting Congestion • Packet drops indicate congestion • Is that really true? • Why does it work? Packet Dst Src Drop Ack Timeout! No Ack = Congestion! Netcomm 2005
Controlling Congestion – The Effect of Window Size • Note that sender’s window is equal to the number of sender packets in flight (in the network). Source Destination Window A Window’s worth of packets X acks X more packets Netcomm 2005
Controlling Congestion • Reduce window less packets in the network • Increase window more packets in the network • Idea: Concept of a congestion window– window is smaller when congestion is larger and vice versa Netcomm 2005
Additive Increase, Multiplicative Decrease • Each time a packet drop occurs, slash window size in half (multiplicative decrease) • Multiplicative decrease is necessary to avoid congestion • When no losses are observed, gradually increase window size (additive increase) Netcomm 2005
Additive Increase Src D D A A D D D A A A D A Dest Netcomm 2005
Leads to the TCP “sawtooth” Timeouts Rate halved Could take a long time to get started! t Netcomm 2005
“Slow Start” Designed to cold-start connection quickly at startup or if a connection has been halted (e.g. window dropped to zero,or window full, but ACK is lost). How it works: increase cwnd by 1 for each ACK received. 1 2 4 8 Src D D D A A D D D D A A A A A Dest Netcomm 2005
Slow Start Timeouts Rate halved Slow start in operation until it reaches half of previous cwnd. Exponential “slow start” t Why is it called slow-start? Because TCP originally had no congestion control mechanism. The source would just start by sending a whole window’s worth of data. Netcomm 2005
Fast Retransmit & Recovery Sender Receiver • Upon 3 duplicate ACKs, TCP retransmits. • Do not enter slow-start. Packet 1 Packet 2 ACK 1 Packet 3 ACK 2 Packet 4 ACK 2 Packet 5 Packet 6 ACK 2 ACK 2 Retransmit packet 3 ACK 6 Netcomm 2005
Self Clocking • Each packet’s transmission is “clocked” by an ACK – no bursts develop … … Netcomm 2005
TCP Vegas • Uses congestion avoidance instead of congestion control • Reno: Congestion control React to congestion after it occurs • Vegas: Congestion avoidance Predict and avoid congestion before it occurs Netcomm 2005
Observation • Packet accumulation in the network can be inferred by monitoring RTT and sending rate cwnd Overloaded Router Sending Rate Bottleneck Link Sending Rate = cwnd / RTT Netcomm 2005
TCP Vegas Congestion Control • BaseRTT is the minimum of all measured RTTs (commonly the RTT of the first packet) • If not overflowing the connection, then ExpectRate = CongestionWindow/BaseRTT • Source calculates ActualRate once per RTT • Source compares ActualRate with ExpectRate Diff = ExpectedRate - ActualRate if Diff < a increase CongestionWindow linearly else if Diff > b decrease CongestionWindow linearly else leave CongestionWindow unchanged Netcomm 2005