190 likes | 362 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 Fairness & TCP Congestion Control Comnet 2010
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 Comnet 2010
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 Comnet 2010
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 Comnet 2010
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 Comnet 2010
Connection Establishment Active participant Passive participant (client) (server) SYN, SequenceNum = x , y 1 + SYN + ACK, SequenceNum = x Acknowledgment = ACK, Acknowledgment = y + 1 Comnet 2010
Connection Termination Active participant Passive participant (server) (client) FIN, SequenceNum = x 1 + x Acknowledgment = y FIN, SequenceNum= Acknowledgment = y + 1 Comnet 2010
Detecting Congestion • Packet drops indicate congestion • Is that really true? • Why does it work? Packet Dst Src Drop Ack Timeout! No Ack = Congestion! Comnet 2010
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 Comnet 2010
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 Comnet 2010
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) Comnet 2010
Additive Increase Src D D A A D D D A A A D A Dest Comnet 2010
Leads to the TCP “sawtooth” Timeouts Rate halved Could take a long time to get started! t Comnet 2010
“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 Comnet 2010
Slow Start 3 Dupacks 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. Comnet 2010
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 Comnet 2010
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 Comnet 2010
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 Comnet 2010
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 Comnet 2010