Salta al contenuto
Note per Studenti TCP Congestion Control Report

TCP Congestion Control

In questa pagina 7
In questa pagina 3

What congestion is

Congestion occurs when the load offered to the network exceeds its capacity. Routers have queues; if they cannot process packets as fast as they arrive the queues fill. Typical case: two sources on 100 Mbit/s links feed a router that forwards on a 10 Mbit/s link.

Consequences: queue overflow (packets dropped); delay of queued packets (growing fast as utilisation approaches 1); poor throughput; possible network collapse, where flows send whole windows but progress very little and most packets are retransmissions (also caused by sources not controlled by feedback, such as UDP: UDP - User Datagram ProtocolUDP is the connectionless, unreliable transport protocol that adds to IP only process-to-process communication through ports and an optional checksum; its header is 8 bytes (source port, destination port, length, checksum), the checksum covers a pseudo-header (IP addresses, protocol 17, length), the UDP header and the data as a one's complement sum (0 means not computed and a computed 0 is sent as 0xFFFF), and UDP has no connection setup, sequence numbers, flow, error or congestion control, which makes it suitable for short messages (DNS, DHCP, RIP, SNMP) and real-time applications.UDP - User Datagram Protocol →).

Knee and cliff. Throughput versus offered load rises linearly, then flattens at the knee (more load only adds delay), and beyond the cliff it collapses. Congestion avoidance means operating near the knee; congestion control means operating at the cliff and slowing down when capacity drops (a loss is the indication). Requirements: efficiency, fairness (equal shares if flow needs are unknown), no collapse.

Formula (Jain fairness index). For NN flows with rates x1,…,xNx_1,\dots,x_N: FI=(∑i=1Nxi)2N∑i=1Nxi2,1N≤FI≤1.\text{FI}=\frac{\left(\sum_{i=1}^{N}x_i\right)^2}{N\sum_{i=1}^{N}x_i^2},\qquad\frac1N\le\text{FI}\le1. It is 1 if all rates are equal and 1/N1/N if one flow uses everything.

Example. Three flows on 30 Mbit/s: (10,10,10)(10,10,10) gives 302/(3⋅300)=130^2/(3\cdot300)=1; (18,1,1)(18,1,1) gives 400/(3⋅326)=0.409400/(3\cdot326)=0.409; (8,6,4)(8,6,4) gives 324/(3⋅116)=0.931324/(3\cdot116)=0.931.

The idea of TCP

TCP probes the channel to find the point just before the cliff and slows down when it exceeds it. It is a window protocol: at most WW unacknowledged packets per RTT, so adapting WW adapts the injection rate. Variables:

Formula. W=min⁡(cwnd,rwnd)W=\min(\text{cwnd},\text{rwnd}).

Example. ssthresh =4=4 MSS and rwnd =6=6 MSS: W=1,2,4,5,6W=1,2,4,5,6 and then stays at 6 even if cwnd keeps growing.

Slow start and congestion avoidance

Slow start (SS): exponential growth; controls the start of a connection and the phase after a timeout. Congestion avoidance (CA): linear growth once capacity is reached. Start with cwnd=1\text{cwnd}=1 MSS and ssthresh=Wmax⁡\text{ssthresh}=W_{\max} (very large).

Rules for every new ACK.

  • if cwnd≤ssthresh\text{cwnd}\le\text{ssthresh} (SS): cwnd←cwnd+1\text{cwnd}\leftarrow\text{cwnd}+1;
  • if cwnd>ssthresh\text{cwnd}>\text{ssthresh} (CA): cwnd←cwnd+1cwnd\text{cwnd}\leftarrow\text{cwnd}+\dfrac1{\text{cwnd}}.

Per RTT: in SS cwnd doubles; in CA it grows by 1 MSS.

In a round the sender sends WW segments and gets WW ACKs: SS gives W+W⋅1=2WW+W\cdot1=2W, CA gives W+W⋅1W=W+1W+W\cdot\frac1W=W+1. Hence W=2iW=2^i after ii rounds in SS, and log⁡2W\log_2W rounds are needed to reach WW.

Example. From cwnd=1\text{cwnd}=1 with ssthresh=8\text{ssthresh}=8: rounds 1,2,4,81,2,4,8, then 9,10,11,…9,10,11,\dots (in SS 2i+1−12^{i+1}-1 segments sent after round ii: 1+2+4+8=151+2+4+8=15).

Convention for round-based exercises. At each RTT: if cwnd<ssthresh\text{cwnd}<\text{ssthresh} go to min⁡(2 cwnd,ssthresh)\min(2\,\text{cwnd},\text{ssthresh}); if cwnd≥ssthresh\text{cwnd}\ge\text{ssthresh} add 1. The actual sending window is min⁡(cwnd,rwnd)\min(\text{cwnd},\text{rwnd}).

How TCP detects losses

A timeout signals severe congestion (nothing arrives); three dupACKs signal mild congestion.

Basic reactions. With KK dupACKs: ssthresh=W/2\text{ssthresh}=W/2. With a timeout: ssthresh=W/2\text{ssthresh}=W/2 and cwnd=1\text{cwnd}=1 (new slow start). WW is the window at the event.

Variants

Old Tahoe: slow start and congestion avoidance, recovery only by timeout (restarts from the first unacknowledged packet, essentially Go-Back-N).

Tahoe: adds fast retransmit. At the KK-th dupACK: resend the missing segment, ssthresh=W/2\text{ssthresh}=W/2, cwnd=1\text{cwnd}=1, restart slow start (same as a timeout). Restarting from 1 is inefficient since the dupACKs show later packets arrived.

Reno: fast recovery.

  • At the third dupACK: ssthresh=cwnd/2\text{ssthresh}=\text{cwnd}/2; resend the missing segment; cwnd=ssthresh+3\text{cwnd}=\text{ssthresh}+3 MSS (the three packets that caused the dupACKs left the network).
  • At each further dupACK: cwnd←cwnd+1\text{cwnd}\leftarrow\text{cwnd}+1 and send a packet if cwnd allows.
  • On an ACK of new data: cwnd=ssthresh\text{cwnd}=\text{ssthresh}, leave fast recovery (continue in CA).
  • After a timeout: as Tahoe.

Example. cwnd=12\text{cwnd}=12: three dupACKs give ssthresh=6\text{ssthresh}=6, cwnd=9\text{cwnd}=9; two more dupACKs give 1111; the new ACK sets cwnd=6\text{cwnd}=6 and CA continues 7,8,…7,8,\dots (Tahoe would restart from 1).

Limit of Reno: if several segments are lost in one window, the first ACK of new data (partial) ends fast recovery; recovering the second needs three more dupACKs and often a timeout occurs.

NewReno stays in fast recovery until everything that was in flight at the start is acknowledged. Variables: recover (highest sequence number sent when recovery starts) and flightsize=lastseqno−ack_no+1\text{flightsize}=\text{lastseqno}-\text{ack\_no}+1.

  • At the KK-th dupACK: recover=lastseqno\text{recover}=\text{lastseqno}; ssthresh=max⁡(flightsize/2, 2 MSS)\text{ssthresh}=\max(\text{flightsize}/2,\ 2\,\text{MSS}); cwnd=ssthresh+3\text{cwnd}=\text{ssthresh}+3 MSS; reset the retransmission timer; resend the missing segment.
  • At each new dupACK: cwnd←cwnd+1\text{cwnd}\leftarrow\text{cwnd}+1, send if allowed.
  • On an ACK of new data: if ack_no>recover\text{ack\_no}>\text{recover} (full ACK), cwnd=ssthresh\text{cwnd}=\text{ssthresh} and exit; otherwise it is a partial ACK acknowledging nackedn_{\text{acked}} packets: cwnd←cwnd−nacked+1\text{cwnd}\leftarrow\text{cwnd}-n_{\text{acked}}+1, reset the timer, resend the packet with seq_no=ack_no\text{seq\_no}=\text{ack\_no}, send if allowed.

Example. W=9W=9 in CA, in flight P3,…,P11P_3,\dots,P_{11}; P6P_6 and P8P_8 are lost; delayed ACKs b=2b=2. Receiver sends ACK 5\text{ACK}\,5, ACK 6\text{ACK}\,6, then dupACK 66 for each out-of-order packet (P7,P9,P10,P11P_7,P_9,P_{10},P_{11}). At the third dupACK the sender has sent up to P14P_{14}: recover=P14\text{recover}=P_{14}, flightsize=14−6+1=9\text{flightsize}=14-6+1=9, ssthresh=4\text{ssthresh}=4, cwnd=7\text{cwnd}=7; resend P6P_6. More dupACKs bring cwnd to 8,9,108,9,10 and release P15P_{15}. The arrival of P6P_6 generates ACK 8\text{ACK}\,8 (partial, 8≤148\le14, nacked=2n_{\text{acked}}=2): cwnd=10−2+1=9\text{cwnd}=10-2+1=9, in flight P8,…,P15P_8,\dots,P_{15} (8 packets), so P16P_{16} is sent and P8P_8 resent. When ACK 16>14\text{ACK}\,16>14 arrives: full ACK, cwnd=ssthresh=4\text{cwnd}=\text{ssthresh}=4. Two losses recovered in two RTTs without timeout.

SACK (selective acknowledgment). The receiver reports the received blocks. Negotiated in the SYN only (Kind =4=4, Length =2=2); used in ACKs with Kind =5=5 and a list of blocks (left edge = first byte of the block, right edge = first byte after it, 4 bytes each).

Formula. With nn blocks the option length is 8n+28n+2 bytes. Options are at most 40 bytes, so n≤4n\le4 (8⋅4+2=348\cdot4+2=34); with the timestamp option (12 bytes) only 28 bytes remain and n≤3n\le3.

Example. Receiver has 11-10001000 (ACK =1001=1001), lacks 10011001-20002000, has 20012001-30003000, lacks 30013001-40004000, has 40014001-50005000: Kind =5=5, Length =2+2⋅8=18=2+2\cdot8=18, blocks [2001,3001)[2001,3001) and [4001,5001)[4001,5001).

NewReno with SACK. At the KK-th dupACK: recover=lastseqno\text{recover}=\text{lastseqno}; ssthresh=max⁡(flightsize/2,2 MSS)\text{ssthresh}=\max(\text{flightsize}/2,2\,\text{MSS}); cwnd=ssthresh\text{cwnd}=\text{ssthresh} (no +3+3, since the packets in the network are tracked by the variable pipe); resend the missing segment; pipe=lastseqno−lastackno+1\text{pipe}=\text{lastseqno}-\text{lastackno}+1 minus packets SACK says arrived. While pipe<cwnd\text{pipe}<\text{cwnd}: if the SACK list shows a hole resend the first missing packet, otherwise send a new one, and pipe\text{pipe} grows by 1; at every new ACK pipe=pipe−nacked\text{pipe}=\text{pipe}-n_{\text{acked}}.

variant slow start CA fast retransmit fast recovery several losses
Old Tahoe yes yes no no no
Tahoe yes yes (after timeout) yes no no
Reno yes yes yes yes no
NewReno yes yes yes yes yes

Tahoe and Reno over time

ssthresh initially 16. At round 9 (cwnd=20\text{cwnd}=20) a timeout: ssthresh=10\text{ssthresh}=10, cwnd=1\text{cwnd}=1 (same for both). At round 16 (cwnd=12\text{cwnd}=12) 3 dupACKs: ssthresh=6\text{ssthresh}=6; Tahoe restarts at 1, Reno at 6 (CA).

round Tahoe cwnd Reno cwnd note
1-5 1, 2, 4, 8, 16 same slow start to ssthresh 16
6-9 17, 18, 19, 20 same CA; timeout at round 9
10-14 1, 2, 4, 8, 10 same SS to ssthresh 10
15-16 11, 12 same 3 dupACKs at round 16
17-24 1, 2, 4, 6, 7, 8, 9, 10 6, 7, 8, 9, 10, 11, 12, 13 Reno loses less window

Four losses in one window

Experimental comparison (Fall and Floyd): (1) Tahoe ≈\approx NewReno (Tahoe restarts from 1, NewReno recovers one loss per RTT); (2) Reno struggles with several losses in one window and ends in timeout; (3) SACK is best: selective retransmissions recover all losses in about one RTT.

Versione ripasso

Congestion

  • Load above capacity: queues overflow, delay, low throughput, possible collapse (mostly retransmissions). Knee (stop at more delay) and cliff (collapse). Avoidance = near knee; control = at cliff.
  • Jain index FI=(∑xi)2N∑xi2∈[1/N,1]\text{FI}=\dfrac{(\sum x_i)^2}{N\sum x_i^2}\in[1/N,1]: (10,10,10)→1(10,10,10)\to1, (18,1,1)→0.409(18,1,1)\to0.409, (8,6,4)→0.931(8,6,4)\to0.931.

cwnd, SS, CA

Per ACK: cwnd≤ssthresh\text{cwnd}\le\text{ssthresh} (SS): +1+1 (doubles per RTT); cwnd>ssthresh\text{cwnd}>\text{ssthresh} (CA): +1/cwnd+1/\text{cwnd} (+1+1 MSS per RTT). Round rule: min⁡(2 cwnd,ssthresh)\min(2\,\text{cwnd},\text{ssthresh}) then +1+1.

Dupacks: ssthresh=W/2\text{ssthresh}=W/2. Timeout: ssthresh=W/2\text{ssthresh}=W/2, cwnd=1\text{cwnd}=1.

Variants

  • Tahoe: fast retransmit then cwnd=1\text{cwnd}=1 (like timeout). Reno (fast recovery): 3rd dupACK ssthresh=cwnd/2\text{ssthresh}=\text{cwnd}/2, cwnd=ssthresh+3\text{cwnd}=\text{ssthresh}+3, +1+1 per extra dupACK, new ACK ⇒cwnd=ssthresh\Rightarrow\text{cwnd}=\text{ssthresh}. cwnd=12→6→9→11→6\text{cwnd}=12\to6\to9\to11\to6 then CA. Fails with several losses per window.
  • NewReno: recover=lastseqno\text{recover}=\text{lastseqno}, ssthresh=max⁡(flightsize/2,2MSS)\text{ssthresh}=\max(\text{flightsize}/2,2\text{MSS}), cwnd=ssthresh+3\text{cwnd}=\text{ssthresh}+3; partial ACK (ack≤recover\text{ack}\le\text{recover}): cwnd−nacked+1\text{cwnd}-n_{\text{acked}}+1 and resend; full ACK exits. Example P6,P8P_6,P_8 lost: recover=P14\text{recover}=P_{14}, ssthresh=4\text{ssthresh}=4, cwnd=7\text{cwnd}=7.
  • SACK: option length 8n+28n+2 (n≤4n\le4, or n≤3n\le3 with timestamp); sender tracks pipe, cwnd=ssthresh\text{cwnd}=\text{ssthresh}, resends only holes. Best with several losses.
  • Table: Old Tahoe (timeout only), Tahoe (+fast retransmit), Reno (+fast recovery), NewReno (+several losses).
  • Tahoe versus Reno trace: timeout at cwnd=20\text{cwnd}=20 gives ssthresh=10\text{ssthresh}=10; 3 dupACKs at 1212 give ssthresh=6\text{ssthresh}=6, Tahoe 11, Reno 66 (round 24: 1010 versus 1313).
  • Typical errors: using +3+3 after a timeout; resetting to 1 after dupACKs in Reno; forgetting min⁡\min with rwnd.

Teoria collegata