Presentation on theme: "1 Comnet 2010 Communication Networks Recitation 9 Fairness & TCP Congestion Control."— Presentation transcript:
1 Comnet 2010 Communication Networks Recitation 9 Fairness & TCP Congestion Control
2 Comnet 2010 Max-Min Fairness The intuition: to maximize the bandwidth allocated to the session with the minimum allocationThe 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 iMore 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
3 Comnet 2010 Example of max-min fair flow Capacity=1 Session 1 Session 2 Session 3 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 Capacity=1
4 Comnet 2010 TCP Overview Connection- orientedConnection- oriented Byte-streamByte-stream –app writes bytes –TCP sends segments –app reads bytes Reliable data transferReliable data transfer Full duplexFull duplex Flow control: keep sender from overrunning receiverFlow control: keep sender from overrunning receiver Congestion control: keep sender from overrunning networkCongestion control: keep sender from overrunning network
5 Comnet 2010 TCP Segment Structure source port # dest port # 32 bits application data (variable length) sequence number acknowledgement number rcvr window size ptr urgent data checksum F SR PAU head len not used Options (variable length) URG: urgent data (generally not used) PSH: push data now (generally not used) RST, SYN, FIN: connection management (reset, setup teardown commands) # bytes rcvr willing to accept ACK: ACK # valid counting by bytes of data (not segments!) Also in UDP
6 Comnet 2010 Connection Establishment Active participant (client) Passive participant (server) SYN, SequenceNum = x SYN + ACK, SequenceNum = y, ACK, Acknowledgment = y + 1 Acknowledgment = x + 1
7 Comnet 2010 Connection Termination Active participant (server) Passive participant (client) FIN, SequenceNum = x Acknowledgment = y + 1 x + 1 FIN, SequenceNum= y
8 Comnet 2010 Internet Congestion Collapse In the late 80s, the Internet suffered a congestion collapseIn the late 80s, the Internet suffered a congestion collapse Host Congestion! Packet drops!! Data+ Retransmissions More Drops!!! Collapse
9 Comnet 2010 Detecting Congestion Packet drops indicate congestionPacket drops indicate congestion –Is that really true? –Why does it work? Src Dst Packet Ack Drop Timeout! No Ack = Congestion!
10 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).Note that sender’s window is equal to the number of sender packets in flight (in the network). A Window’s worth of packets X acks Window X more packets Source Destination
11 Comnet 2010 Controlling Congestion Reduce window less packets in the networkReduce window less packets in the network Increase window more packets in the networkIncrease window more packets in the network Idea: Concept of a congestion window – window is smaller when congestion is larger and vice versaIdea: Concept of a congestion window – window is smaller when congestion is larger and vice versa
12 Comnet 2010 Additive Increase, Multiplicative Decrease Each time a packet drop occurs, slash window size in half (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)When no losses are observed, gradually increase window size (additive increase)
13 Comnet 2010 Additive Increase D A DDAADDAADA Src Dest
14 Comnet 2010 Leads to the TCP “sawtooth” t Rate halved Timeouts Could take a long time to get started!
15 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. D A DDAADD AA D A Src Dest D A 1 2 4 8
16 Comnet 2010 Slow Start halved 3 Dupacks Exponential “slow start” t Rate 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. Slow start in operation until it reaches half of previous cwnd.
17 Comnet 2010 Fast Retransmit & Recovery Upon 3 duplicate ACKs, TCP retransmits.Upon 3 duplicate ACKs, TCP retransmits. Do not enter slow- start.Do not enter slow- start. Packet 1 Packet 2 Packet 3 Packet 4 Packet 5 Packet 6 Retransmit packet 3 ACK 1 ACK 2 ACK 6 ACK 2 SenderReceiver
18 Comnet 2010 TCP Vegas Uses congestion avoidance instead of congestion controlUses 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
19 Comnet 2010 Observation Packet accumulation in the network can be inferred by monitoring RTT and sending ratePacket accumulation in the network can be inferred by monitoring RTT and sending rate Bottleneck Link Overloaded Router Sending Rate cwnd Sending Rate = cwnd / RTT
20 Comnet 2010 TCP Vegas Congestion Control BaseRTT is the minimum of all measured RTTs (commonly the RTT of the first packet)BaseRTT is the minimum of all measured RTTs (commonly the RTT of the first packet) If not overflowing the connection, thenIf not overflowing the connection, then ExpectRate = CongestionWindow/BaseRTT Source calculates ActualRate once per RTTSource calculates ActualRate once per RTT Source compares ActualRate with ExpectRateSource compares ActualRate with ExpectRate Diff = ExpectedRate - ActualRate if Diff < increase CongestionWindow linearly else if Diff > decrease CongestionWindow linearly else leave CongestionWindow unchanged