You are on page 1of 12

Advanced Computer Networks

TCP Congestion Control

Thanks to Kamil Sarac

What is congestion?
 Increase in network load results in decrease
of useful work done
 Different sources compete for resources inside
network
 Why is it a problem?
 Sources are unaware of current state of resource
 Sources are unaware of each other
 In many situations, this will result in decrease in
throughput
Source (congestion collapse)
1 1 0 -M
bps
Ethe
rnet Router Destination
1.5-Mbps T1 link
FD DI
ps
Source -Mb
100
2

Issues  How to deal with congestion?  pre-allocate resources so as to avoid congestion (avoidance)  control congestion if (and when) it occurs (control)  Two points of implementation  hosts at the edges of the network (transport protocol)  routers inside the network (queuing discipline)  Underlying service model  best-effort data delivery TCP Congestion Control  Idea  assumes best-effort network (FIFO or FQ routers)  each source determines network capacity for itself  uses implicit feedback  ACKs pace transmission (self-clocking)  Challenge  determining the available capacity in the first place  adjusting to changes in the available capacity .

AdvertisedWindow) EffWin = MaxWin . Slow Start 2. Additive Increase Multiplicative Decrease (AIMD) 3.(LastByteSent - LastByteAcked) . Fast Recovery  TCP Vegas  Introduces Congestion Avoidance TCP Congestion Control  Objective: adjust to changes in the available capacity  New state variables per connection: CongestionWindow and (slow start)threshold  limits how much data source has in transit MaxWin = MIN(CongestionWindow. TCP Congestion Control  TCP sender is in one of two states:  slow start OR congestion avoidance  Three components of implementation Original TCP (TCP Tahoe)  1. Fast Retransmit  TCP Reno  3.

 Does Slow Start increment slowly? Not really.  Even if ACK acknowledges a segment that is smaller than MSS bytes long. a TCP receiver sends an ACK for every other segment. we cwnd = 2 segm ent 2 segm ent 3 increase cwnd by 1 ents 2 ACK for segm irrespective of the ACK for segm ents 3 cwnd = 4 number of segm ent 4 segm ent 5 segments ACK’ed segm ent 6 segm ent 7  TCP slows down ents 4 ACK for segm the increase of ACK for segm ents 5 ents 6 ACK for segm cwnd when cwnd = 8 ACK for segm ents 7 cwnd > ssthresh . cwnd is still increased by only 1 segment. the congestion window is increased by 1 segment: cwnd = cwnd + 1  If an ACK acknowledges two segments.  Each time an ACK is received by the sender. Slow Start  Initial value: Set cwnd = 1  Note: Unit is a segment size. In fact. the increase of cwnd is exponential (why?) Slow Start Example  The congestion window size grows segm ent 1 cwnd = 1 very rapidly ACK for segm ent 1  For every ACK. cwnd is increased by 1. TCP actually is based on bytes and increments by 1 MSS (maximum segment size)  The receiver sends an acknowledgement (ACK) for each packet  Note: Generally.

increment cwnd as follows:  cwnd = cwnd + 1/ cwnd  So cwnd is increased by one only if all cwnd segments have been acknowledged. Congestion Avoidance via AIMD  Congestion avoidance phase is started if cwnd has reached the slow-start threshold value  If cwnd >= ssthresh then each time an ACK is received. Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 cw nd = 1 cw nd = 2 14 cw nd = 4 12 10 ssthresh cw nd = 8 Cwnd (in segments) 8 6 4 cw nd = 9 2 0 0 2 4 6 t= t= t= t= Roundtrip times cw nd = 10 .

the sender performs:  cwnd is reset to one: cwnd = 1  ssthresh is set to half the current size of the congestion window: ssthresh = cwnd / 2  and slow-start is entered Summary of TCP congestion control Initially: cwnd = 1. Responses to Congestion  So. ssthresh = advertised window size. . Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2. New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1. When a timeout occurs. Avoidance */ cwnd = cwnd + 1/cwnd. TCP assumes there is congestion if it detects a packet loss  A TCP sender can detect lost packets via:  Expiration of a retransmission timer  Receipt of a duplicate ACK (why?)  TCP interprets a Timeout as a binary congestion signal. else /* Cong. cwnd = 1.

the TCP 1K SeqNo=10 sender believes that a 24 1K SeqNo=204 segment has been lost. FreeBSD 4. Fast Retransmit  If three or more 1K SeqNo=0 duplicate ACKs are AckNo=1024 received in a row. 8 1K SeqNo=30 72 AckNo=1024  Then TCP performs a retransmission of what AckNo=1024 seems to be the missing 1K SeqNo=10 24 segment.3 Reno)  Fast Recovery  New Reno (1996)  SACK (1996)  RED (Floyd and Jacobson 1993) . AckNo=40 96 1K SeqNo=40 96  Enter slow start: ssthresh = cwnd/2 cwnd = 1 Flavors of TCP Congestion Control  TCP Tahoe (1988.3 Tahoe)  Slow Start  Congestion Avoidance  Fast Retransmit  TCP Reno (1990. FreeBSD 4. without waiting for a timeout to happen.

Fast Recovery  Fast recovery avoids slow 1K SeqNo=0 start after a fast retransmit AckNo=1024 1K SeqNo=10 24  Intuition: Duplicate ACKs 1K SeqNo=204 8 indicate that data is getting through AckNo=1024 1K SeqNo=30 72  After three duplicate ACKs set: AckNo=1024  Retransmit “lost packet” 1K SeqNo=10 24 1K SeqNo=4 096 AckNo=4069  On packet loss detected by 3 dup ACKs:  ssthresh = cwnd/2  cwnd=ssthresh enter congestion avoidance . TCP Reno  Duplicate ACKs:  Fast retransmit  Fast recovery  Fast Recovery avoids slow start  Timeout:  Retransmit  Slow Start  TCP Reno improves upon TCP Tahoe when a single packet is dropped in a round-trip time.

TCP Tahoe and TCP Reno cwnd (for single segment losses) Tahoe time Reno cwnd time TCP CC .

TCP New Reno  When multiple packets are dropped. Sender retransmits the next segment from the list of segments that are deemed lost. 1024-2047)  Multiple blocks can be sent in a single segment. .  TCP SACK:  Enters fast recovery upon 3 duplicate ACKs  Sender keeps track of SACKs and infers if segments are lost. Reno has problems  Partial ACK:  Occurs when multiple packets are lost  A partial ACK acknowledges some. but not all packets that are outstanding at the start of a fast recovery. takes sender out of fast recovery Sender has to wait until timeout occurs  New Reno:  Partial ACK does not take sender out of fast recovery  Partial ACK causes retransmission of the segment following the acknowledged segment  New Reno can deal with multiple lost segments without going to slow start SACK  SACK = Selective acknowledgment  Issue: Reno and New Reno retransmit at most 1 lost packet per round trip time  Selective acknowledgments: The receiver can acknowledge non-continuous blocks of data (SACK 0- 1023.

e.5 5.5 4.0 7.5 2.5 6.0 1. Congestion Avoidance  TCP’s strategy  control congestion once it happens  repeatedly increase load in an effort to find the point at which congestion occurs and then back off  Alternative strategy  predict when congestion is about to happen  reduce rate before packets start being discarded  call this congestion avoidance.0 2.0 7.5 4.5 3.0 4.5 1.0 4.0 1.5 1.5 8.5 2.0 4. instead of congestion control  Two possibilities  host-centric: TCP Vegas  router-centric: DECbit and RED Gateways Congestion Avoidance in TCP (TCP Vegas)  Idea: source watches for some sign that router’s queue is building up and congestion will happen.0 8.5 5.5 7.5 7.0 3.5 6.5 6.5 8..0 5.5 3.0 8.0 6.5 4.0 8.g.5 3.5 7.0 2.0 3.5 i Time (seconds) e z i 10 s buffer at e 5 bottleneck router u e u Q 0.0 2.0 5.0 6.0 5.5 B Time (seconds) K g1100 nr ie 900 sending dt 700 n 500 u rate eo 300 Sr 100 n 0.5 Time (seconds) .0 1.0 3.5 1.0 7.  RTT grows  sending rate flattens 70 60 50 congestion B 40 K 30 window 20 10 s p 0.5 2.5 8.5 5.0 6.

then ExpectRate = CongestionWindow/BaseRTT  Source calculates sending rate (ActualRate) once per RTT  Source compares ActualRate with ExpectRate Diff = ExpectRate .ActualRate if Diff < a increase CongestionWindow linearly else if Diff > b decrease CongestionWindow linearly else leave CongestionWindow unchanged . Algorithm  Let BaseRTT be the minimum of all measured RTTs (commonly the RTT of the first packet)  If not overflowing the connection.