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 flows with rates : It is 1 if all rates are equal and if one flow uses everything.
Example. Three flows on 30 Mbit/s: gives ; gives ; gives .
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 unacknowledged packets per RTT, so adapting adapts the injection rate. Variables:
- cwnd: congestion window, chosen by the sender from network feedback;
- rwnd: window announced by the receiver (flow control: TCP - Connection, Reliability and Flow ControlTCP is the connection-oriented, reliable transport protocol that turns IP's unreliable service into an ordered byte stream without errors or duplicates; the connection opens with a three-way handshake (SYN, SYN+ACK, ACK) and closes with FIN segments, bytes are numbered (sequence number = first byte of the segment, cumulative ACK = next byte expected), the sender may transmit min(rwnd, cwnd) unacknowledged bytes (rwnd, the receiver window in a 16-bit field, is flow control), errors are handled with checksum, ACKs, retransmission timeout and fast retransmit after three duplicate ACKs, and to fill the pipe the window must reach the bandwidth-delay product, with maximum throughput MSS times Wmax over RTT.TCP - Connection, Reliability and Flow Control →);
- ssthresh: slow start threshold, a current estimate of available capacity.
Formula. .
Example. ssthresh MSS and rwnd MSS: 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 MSS and (very large).
Rules for every new ACK.
- if (SS): ;
- if (CA): .
Per RTT: in SS cwnd doubles; in CA it grows by 1 MSS.
In a round the sender sends segments and gets ACKs: SS gives , CA gives . Hence after rounds in SS, and rounds are needed to reach .
Example. From with : rounds , then (in SS segments sent after round : ).
- With delayed ACKs () SS grows by a factor per round and CA by MSS per round (this is why appears in Analytical Model of TCP Send RateThe analytical model gives the long-term send rate B (segments per second) of a TCP Reno flow as a function of the loss probability p, the RTT, the delayed-ACK parameter b and the timeout T0; time is divided into rounds of one RTT, the window cycle between two losses signalled by three duplicate ACKs (TDP) has mean window E[W] = (2-3b)/(3b) + sqrt(((3b-2)/(3b))^2 + 8(1-p)/(3bp)) and the rate is B = E[Y]/E[A], which for small p gives the square-root formula B = (1/RTT) sqrt(3/(2bp)) (about 1.22/(RTT sqrt p) for b=1 and 0.87/(RTT sqrt p) for b=2); timeouts add the probability Q that a loss ends in timeout, giving B = (E[Y] + Q E[R]) / (E[A] + Q E[Z_TO]), and a maximum window Wmax caps the rate at Wmax/RTT.Analytical Model of TCP Send Rate →).
- After a timeout slow start restarts and continues up to half the window at which congestion occurred.
Convention for round-based exercises. At each RTT: if go to ; if add 1. The actual sending window is .
How TCP detects losses
- Retransmission timeout (RTO): one timer per connection (TCP Retransmission Timeout EstimationTCP retransmits a segment when its ACK does not arrive within the retransmission timeout RTO, which must track the round-trip time: too short causes spurious retransmissions, too long slows recovery; the RTT is measured with one timer per connection, smoothed with an exponential moving average SRTT = (1-alpha) SRTT + alpha rtt with alpha = 1/8, the mean deviation MAD = (1-rho) MAD + rho |rtt - SRTT| with rho = 1/4 is added four times, RTO = SRTT + 4 MAD with a minimum of 1 s, Karn's algorithm ignores samples of retransmitted segments and doubles the RTO at each consecutive timeout up to 64 times, and for a Gaussian RTT the mean deviation equals sigma times the square root of 2 over pi, about 0.797 sigma.TCP Retransmission Timeout Estimation →).
- Duplicate ACKs: with packets and packet 4 lost, packets produce four times . After (usually 3) dupACKs TCP assumes loss and resends: fast retransmit.
A timeout signals severe congestion (nothing arrives); three dupACKs signal mild congestion.
Basic reactions. With dupACKs: . With a timeout: and (new slow start). 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 -th dupACK: resend the missing segment, , , 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: ; resend the missing segment; MSS (the three packets that caused the dupACKs left the network).
- At each further dupACK: and send a packet if cwnd allows.
- On an ACK of new data: , leave fast recovery (continue in CA).
- After a timeout: as Tahoe.
Example. : three dupACKs give , ; two more dupACKs give ; the new ACK sets and CA continues (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 .
- At the -th dupACK: ; ; MSS; reset the retransmission timer; resend the missing segment.
- At each new dupACK: , send if allowed.
- On an ACK of new data: if (full ACK), and exit; otherwise it is a partial ACK acknowledging packets: , reset the timer, resend the packet with , send if allowed.
Example. in CA, in flight ; and are lost; delayed ACKs . Receiver sends , , then dupACK for each out-of-order packet (). At the third dupACK the sender has sent up to : , , , ; resend . More dupACKs bring cwnd to and release . The arrival of generates (partial, , ): , in flight (8 packets), so is sent and resent. When arrives: full ACK, . Two losses recovered in two RTTs without timeout.
SACK (selective acknowledgment). The receiver reports the received blocks. Negotiated in the SYN only (Kind , Length ); used in ACKs with Kind and a list of blocks (left edge = first byte of the block, right edge = first byte after it, 4 bytes each).
Formula. With blocks the option length is bytes. Options are at most 40 bytes, so (); with the timestamp option (12 bytes) only 28 bytes remain and .
Example. Receiver has - (ACK ), lacks -, has -, lacks -, has -: Kind , Length , blocks and .
NewReno with SACK. At the -th dupACK: ; ; (no , since the packets in the network are tracked by the variable pipe); resend the missing segment; minus packets SACK says arrived. While : if the SACK list shows a hole resend the first missing packet, otherwise send a new one, and grows by 1; at every new ACK .
| 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 () a timeout: , (same for both). At round 16 () 3 dupACKs: ; 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 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 : , , .
cwnd, SS, CA
Per ACK: (SS): (doubles per RTT); (CA): ( MSS per RTT). Round rule: then .
- With : SS per round, CA . Rounds to reach in SS: .
- Loss detection: RTO (severe, TCP Retransmission Timeout EstimationTCP retransmits a segment when its ACK does not arrive within the retransmission timeout RTO, which must track the round-trip time: too short causes spurious retransmissions, too long slows recovery; the RTT is measured with one timer per connection, smoothed with an exponential moving average SRTT = (1-alpha) SRTT + alpha rtt with alpha = 1/8, the mean deviation MAD = (1-rho) MAD + rho |rtt - SRTT| with rho = 1/4 is added four times, RTO = SRTT + 4 MAD with a minimum of 1 s, Karn's algorithm ignores samples of retransmitted segments and doubles the RTO at each consecutive timeout up to 64 times, and for a Gaussian RTT the mean deviation equals sigma times the square root of 2 over pi, about 0.797 sigma.TCP Retransmission Timeout Estimation →) or 3 dupACKs (mild, fast retransmit).
Dupacks: . Timeout: , .
Variants
- Tahoe: fast retransmit then (like timeout). Reno (fast recovery): 3rd dupACK , , per extra dupACK, new ACK . then CA. Fails with several losses per window.
- NewReno: , , ; partial ACK (): and resend; full ACK exits. Example lost: , , .
- SACK: option length (, or with timestamp); sender tracks pipe, , 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 gives ; 3 dupACKs at give , Tahoe , Reno (round 24: versus ).
- Typical errors: using after a timeout; resetting to 1 after dupACKs in Reno; forgetting with rwnd.