# Congestion Control

简单理解一下congestion control

* Congestion control&#x20;
  * Congestion: "too many sources sending too much data too fast for network to handle"&#x20;
  * Manifestations&#x20;
    * Long delays (queueing in router buffers)
    * Packet loss (buffer overflow at routers)&#x20;
* Different from flow control&#x20;
  * One sender too fast for one receiver&#x20;
* Causes / costs of congestion: scenario 1&#x20;
  * Simplest scenario&#x20;
    * One router, infinite buffers
    * Input, output link capacity: R&#x20;
    * Two flows&#x20;
    * No retransmissions needed&#x20;
    * ![](/files/fNwPpHDf7zI32lByInHs)
    * ![](/files/HysaYbfuBMvSbFnlI2yi)
    * ![](/files/KZB6AS4Tz8p68GeUcWUS)
  * Another scenario
    * One router, finite buffer&#x20;
    * Sender retransmits lost, timed-out packet
      * Application-layer input&#x20;
      * Transport-layer input includes retransmissions&#x20;
      * Perfect knowledge: sender sends only when router buffers available&#x20;
      * Or some perfect knowledge&#x20;
        * Packets can be lost (dropped at router) due to full buffers&#x20;
        * Sender knows when packet has dropped: only resends if packet known to be lost&#x20;
        * ![](/files/2SmixuVgvxkn23TelXE7)
    * ![](/files/KNcfcKFqojUhWp62Dj8L)
  * Relasitic scenario: un-needed duplicates&#x20;
    * Packets can be lost, dropped at router due to full buffers - requiring retransmissions&#x20;
    * But sender times can time out prematurely, sending two copies, both of which are delivered&#x20;
    * ![](/files/dcclOPtqcWROAQnHTjPZ)
* Costs of congestion&#x20;
  * More work (retransmission) for given receiver throughput&#x20;
  * Unneeded retransmissions: link carries multiple copies of the packet&#x20;
    * Decreasing maximum achievable throughput&#x20;
  * When packet dropped, any upstream transmission capacity and buffering used for that packet was wasted!&#x20;
* Insights&#x20;
  * Throughput can never exceed capacity (link)
  * Delay increases as capacity approached&#x20;
  * Loss / retransmission decreases effective throughput&#x20;
  * Un-needed duplicates further decreases effective throughput&#x20;
  * Upstream transmission capacity / buffering wasted for packets lost downstream (congestion collapse)&#x20;
* Apporaches towards congestion control
  * End-to-end congestion control
    * No explicit feedback from network
    * Congestion inferred from observed loss, delay (i.e. timeout, ACKs)&#x20;
    * Approach taken by TCP&#x20;
  * Network-assisted congestion control
    * Router provide direct feedback to sending / receiving hosts with flows passing through congested router&#x20;
    * May indicate congestion level or explicitly set sending rates&#x20;
    * TCP ECN, ATM, DECbit protocols&#x20;

#### TCP Congestion control: AIMD

* approach: senders can increase sending rate until packet loss (congestion) occurs, then decreasing sending rate on loss event&#x20;
* ![](/files/zqV4VzkhOyuQo4U3sTJ7)
* **Additive increase: increase sending rate by 1 maximum segment size every RTT until loss detected**
* **Multiplicative decrease: cut sending rate in half at each loss event**&#x20;
  * Cut in half on loss detected by triple duplicate ACK (TCP Reno)&#x20;
  * Cut to 1 MSS (maximum segment size) when loss detected by timeout (tcp Tahoe)&#x20;
* AIMD: probing for bandwidth&#x20;
  * A distributed, async algorithm - has been shown to
    * Optimize congested flow rates network wide
    * Have desirable stability properties&#x20;
* Implementation&#x20;
  * Sender sequence number space&#x20;
  * ![](/files/95f8R70LastpF1RCfsxs)
  * TCP sender limits transmission: LastByteSent - LastByteAcked <= cwnd&#x20;
  * cwnd is dynamically adjusted in response to observed network congestion&#x20;
  * ![](/files/DW6RX7U1qvYnQv3lZNCo)
* TCP slow start
  * When connection begins, increase rate exponentially until first loss event&#x20;
  * ![](/files/fvDvyj9U5RtTYKM6ZsDi)
* **TCP from slow start to congestion avoidance**&#x20;
  * When should the exponential increase switch to linear?
    * When cwnd gets to 1/2 of its value before timeout
  * Implementation&#x20;
    * Variable ssthresh
    * On loss event, ssthresh is set to 1/2 of cwnd just before loss event&#x20;
    * ![](/files/sSilocCH7xQDD2FbvV8L)&#x20;

#### TCP CUBIC

* Is there a better way than AIMD to "probe" for usable bandwidth?
* Insight / intuition&#x20;
  * W\_max: sending rate at which congestion loss was detected
  * Congestion state of bottleneck link probably (?) hasn't changed much&#x20;
  * After cutting rate / window in half on loss, initially ramp to W\_max faster, but then approach W\_max more slowly&#x20;
  * ![](/files/UZqG7U4GMw56K5SgufYD)
* Operation
  * K: point in time when TCP window size will reach W\_max
    * K itself is tunable&#x20;
  * Increase W as a functino of the cube of the distance between current time and K
    * Larger increases when further away from K
    * Smaller increases when nearest K&#x20;
* Default in Linux, most popular for web services&#x20;

#### TCP and the congested "bottleneck link"

* TCP (classic, CUBIC) increase TCP's sending rate until packet loss occurs at some router's output: the bottleneck link&#x20;
* Understanding congestion: useful to focus on congested bottleneck link&#x20;
* Goal: keep the end-end pipe just full, but not fuller&#x20;
* Delay-based TCP congestion control&#x20;

  * Keeping sender-to-receiver pipe "just full enough"
  * RTT\_min - minimum observed RTT (uncongested path)&#x20;
  * Uncongested throughput with congestion window cwnd is cwnd / RTT\_min&#x20;
  * ![](/files/L73OtDJ7mhvhkb4UI5SB)
  *

  ```
  <figure><img src="/files/pZTKXKHURf0hpeaE4KpL" alt=""><figcaption></figcaption></figure>
  ```

  * BBR deployed on Google's (internal) backbone network&#x20;
* Explicit congestion notification (ECN)
  * TCP deployments often implement network-assisted congestion control&#x20;
    * Two bits in IP header (ToS field) marked by network router to indicate congestion&#x20;
      * policy to determine marking chosen by network operator&#x20;
    * Congestion indication carried to destination
    * Destination sets ECE bits on ACK segment to notify sender of congestion&#x20;
    * &#x20;

      <figure><img src="/files/3ES5DhR6rBUU0Eg3VQRb" alt=""><figcaption></figcaption></figure>
    * both IP (IP header ECN bit marking) and TCP (TCP header, C,E bit marking)

### Fairness&#x20;

* Fairness goal: if K TCP sessions share the same bottleneck link of bandwidth R, each should have average rate of R / K&#x20;
* ![](/files/HYy2c5wKnplHe1rOzxVv)

#### Is TCP fair?&#x20;

* Example: two competing TCP sessions
  * Additive increase gives slope of 1, as throughput increases&#x20;
  * Multiplicative decrease decreases throughput proportionally&#x20;
*

```
<figure><img src="/files/yhoBHZCCnLfj4eTvKPgQ" alt=""><figcaption></figcaption></figure>
```

* Fairness and UDP
  * Multimedia apps often do not use TCP&#x20;
    * Do not want rate throttled by congestion control
  * Instead use UDP
    * Send audio / video at constant rate, tolerate packet loss
  * There is no "Internet police" policing use of congestion control&#x20;
* Fairness, parallel TCP connections&#x20;
  * Application can open multiple parallel connections between two hosts
  * Web browsers do this, e.g., link of rate R with 9 existing connections
    * New app asks for 1 TCP, gets rate R / 10&#x20;
    * New app asks for 11 TCP, gets rate R / 2&#x20;
  * Is it fair??


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sliu583.gitbook.io/blog/networking/index/cs-268-adv-network/congestion-control.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
