blob: ea2b4b8d7745b63a876153454ed7f9c051e022e3 [file] [log] [blame]
<!--
Documentation/_templates/layout.html
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. The
ASF licenses this file to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE html>
<html class="writer-html5" lang="en">
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Congestion Control NewReno &mdash; NuttX latest documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="../../_static/design-style.1e8bd061cd6da7fc9cf755528e8ffc24.min.css" />
<link rel="stylesheet" type="text/css" href="../../_static/custom.css" />
<link rel="shortcut icon" href="../../_static/favicon.ico"/>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/sphinx_highlight.js"></script>
<script src="../../_static/clipboard.min.js"></script>
<script src="../../_static/copybutton.js"></script>
<script src="../../_static/design-tabs.js"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="Notifier Chain" href="notifier.html" />
<link rel="prev" title="Mutual Exclusion lock" href="mutex.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home"> NuttX
</a>
<!-- this version selector is quite ugly, should be probably replaced by something
more modern -->
<div class="version-selector">
<select onchange="javascript:location.href = this.value;">
<option value="../../../latest" selected="selected">latest</option>
<option value="../../../10.0.0" >10.0.0</option>
<option value="../../../10.0.1" >10.0.1</option>
<option value="../../../10.1.0" >10.1.0</option>
<option value="../../../10.2.0" >10.2.0</option>
<option value="../../../10.3.0" >10.3.0</option>
<option value="../../../11.0.0" >11.0.0</option>
<option value="../../../12.0.0" >12.0.0</option>
<option value="../../../12.1.0" >12.1.0</option>
<option value="../../../12.2.0" >12.2.0</option>
<option value="../../../12.2.1" >12.2.1</option>
<option value="../../../12.3.0" >12.3.0</option>
<option value="../../../12.4.0" >12.4.0</option>
<option value="../../../12.5.0" >12.5.0</option>
<option value="../../../12.5.1" >12.5.1</option>
<option value="../../../12.6.0" >12.6.0</option>
<option value="../../../12.7.0" >12.7.0</option>
<option value="../../../12.8.0" >12.8.0</option>
<option value="../../../12.9.0" >12.9.0</option>
<option value="../../../12.10.0" >12.10.0</option>
<option value="../../../12.11.0" >12.11.0</option>
</select>
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Table of Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../index.html">Home</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../introduction/index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contributing/index.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../introduction/inviolables.html">The Inviolable Principles of NuttX</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../platforms/index.html">Supported Platforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../components/index.html">OS Components</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../applications/index.html">Applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/index.html">Implementation Details</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">API Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../user/index.html">Userspace API</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="index.html">Architecture APIs</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="addrenv.html">Address Environments</a></li>
<li class="toctree-l3"><a class="reference internal" href="app_vs_os.html">Application OS vs. Internal OS Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="arch.html">APIs Exported by Architecture-Specific Logic to NuttX</a></li>
<li class="toctree-l3"><a class="reference internal" href="board.html">APIs Exported by Board-Specific Logic to NuttX</a></li>
<li class="toctree-l3"><a class="reference internal" href="conventions.html">Naming and Header File Conventions</a></li>
<li class="toctree-l3"><a class="reference internal" href="iob.html">I/O Buffer Management</a></li>
<li class="toctree-l3"><a class="reference internal" href="led.html">LED Support</a></li>
<li class="toctree-l3"><a class="reference internal" href="mutex.html">Mutual Exclusion lock</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">Congestion Control NewReno</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#workflow">Workflow</a></li>
<li class="toctree-l4"><a class="reference internal" href="#configuration-options">Configuration Options</a></li>
<li class="toctree-l4"><a class="reference internal" href="#test">Test</a><ul>
<li class="toctree-l5"><a class="reference internal" href="#test-topology">Test topology</a></li>
<li class="toctree-l5"><a class="reference internal" href="#test-steps">Test steps</a></li>
<li class="toctree-l5"><a class="reference internal" href="#test-results">Test results</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="notifier.html">Notifier Chain</a></li>
<li class="toctree-l3"><a class="reference internal" href="nuttx.html">APIs Exported by NuttX to Architecture-Specific Logic</a></li>
<li class="toctree-l3"><a class="reference internal" href="paging.html">On-Demand Paging</a></li>
<li class="toctree-l3"><a class="reference internal" href="shm.html">Shared Memory</a></li>
<li class="toctree-l3"><a class="reference internal" href="smp.html">Symmetric Multiprocessing (SMP) Application</a></li>
<li class="toctree-l3"><a class="reference internal" href="time_clock.html">System Time and Clock</a></li>
<li class="toctree-l3"><a class="reference internal" href="wqueue.html">Work Queues</a></li>
<li class="toctree-l3"><a class="reference internal" href="events.html">Events</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../debugging/index.html">Debugging</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../guides/index.html">Guides</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../logos/index.html">NuttX Logos</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../_tags/tagsindex.html">Tags</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">NuttX</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">API Reference</a></li>
<li class="breadcrumb-item"><a href="index.html">Architecture APIs</a></li>
<li class="breadcrumb-item active">Congestion Control NewReno</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/apache/nuttx/blob/master/Documentation/reference/os/newreno.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="congestion-control-newreno">
<h1>Congestion Control NewReno<a class="headerlink" href="#congestion-control-newreno" title="Permalink to this heading"></a></h1>
<dl>
<dt>NewReno congestion control algorithm is used to solve the problem of network congestion breakdown, which includes:</dt><dd><ul class="simple">
<li><p>Slow Start</p></li>
<li><p>Congestion Avoidance</p></li>
<li><p>Fast Retransmission</p></li>
<li><p>Fast Recovery.</p></li>
</ul>
<p>The implementation refers to RFC6582 and RFC5681. In addition, we optimize the congestion algorithm. In the congestion avoidance state, the maximum congestion window (max_cwnd) is used to limit the excessive growth of cwnd and prevent network jitter caused by congestion. Maximum congestion window (max_cwnd) is updated with the current congestion window (cwnd) and the update weight is 0.875 when an RTO timeout occurs.</p>
</dd>
</dl>
<section id="workflow">
<h2>Workflow<a class="headerlink" href="#workflow" title="Permalink to this heading"></a></h2>
<p>The NewReno on the tcp sender adjusts the cwnd and ssthresh based on received ack and Retransmitted Timeout (RTO) events.</p>
<p>Using the cwnd, together with snd_wnd, controls the number of bytes sent to the network. Here’s how newreno works, as following:</p>
<ul class="simple">
<li><p>Initialize the ssthresh and cwnd, on establishing the tcp connection.</p></li>
<li><p>When the ack is received, check whether the ack is repeated.</p></li>
</ul>
<blockquote>
<div><ul class="simple">
<li><p>If yes, increase the dupack counts. If the dupack exceeds the Fast Retransmission Threshold 3, after retransmitting the lost segments (Fast Retransmission), enter to the Fast Recovery state.</p></li>
<li><p>If no, receive the new ack.</p>
<ul>
<li><p>If the current ackno is bigger than fr_ack which is the snd_seq when Fast Retransmission occurs, exit the Fast Recovery state and enter to congestion avoidance.</p></li>
<li><p>If the cwnd is less than ssthresh, increase the cwnd on slow start state.</p></li>
<li><p>If the cwnd is greater than or equal to ssthresh, the increased cwnd can not exceed max_cwnd.</p></li>
</ul>
</li>
</ul>
</div></blockquote>
<ul class="simple">
<li><p>when RTO times out, reset the values of cwnd and ssthresh, update the max_cwnd, and enter to Slow Start state.</p></li>
<li><p>When sending a segment, the minimum value of cwnd and snd_wnd is used to calculate the number of bytes that can be sent.</p></li>
</ul>
<p>The simple state transition diagram of the NewReno is shown below.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> | ^
| ------------------------
| initialize cwnd ssthresh
V
+------------+
.---------------&gt;| Slow Start |-----------------.
| +------------+ |
| | | |
| timeout | | recv dup ack | recv new ack
|------------------ | | --------------- | ----------------
|reset cwnd ssthresh | | dupack &gt;= 3 | cwnd &gt;= ssthresh
|update max_cwnd | | fr_ack = snd_seq |
|&lt;--------------------&#39; |&lt;------------------. |
| | | |
| v | V
| +--------+ +--------------------+
| | FT | |Congestion Avoidance|
| +--------+ +--------------------+
| | ^ |
| retransmit|lost segment | |
| | | |
| | recv new ack | |
| v ------------ | |
| +--------+ ack &gt; fr_ack | |
| | FR |--------------&#39; |
| +--------+ |
| | |
| v v
&#39;-----------------------------------------------&#39;
</pre></div>
</div>
</section>
<section id="configuration-options">
<h2>Configuration Options<a class="headerlink" href="#configuration-options" title="Permalink to this heading"></a></h2>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">NET_TCP_CC_NEWRENO</span></code></dt><dd><p>Enable or disable NewRenofunction.</p>
<p>Depends on <code class="docutils literal notranslate"><span class="pre">NET_TCP_FAST_RETRANSMIT</span></code>.</p>
</dd>
</dl>
</section>
<section id="test">
<h2>Test<a class="headerlink" href="#test" title="Permalink to this heading"></a></h2>
<section id="test-topology">
<h3>Test topology<a class="headerlink" href="#test-topology" title="Permalink to this heading"></a></h3>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> IP:10.0.1.1
+--------+
--------| nuttx0 |--------
| +--------+ |
| /|\ |
| | |
| +-------+ |
| | ifb0 | |
| +-------+ |
\|/ /|\ \|/
+-------+ | +-------+
| tap0 |------/ \-------| tap1 |
+-------+ +-------+
/|\ /|\
| |
\|/ \|/
+-------+ +-------+
sim1 | eth0 | | eth0 | sim2
+-------+ +-------+
IP:10.0.1.3 IP:10.0.1.4
</pre></div>
</div>
</section>
<section id="test-steps">
<h3>Test steps<a class="headerlink" href="#test-steps" title="Permalink to this heading"></a></h3>
<p>Test the function on the Ubuntu 22.04 x86_64 with NuttX SIM by following steps:</p>
<dl class="field-list simple">
<dt class="field-odd">1.Configure the test environment<span class="colon">:</span></dt>
<dd class="field-odd"><p></p></dd>
</dl>
<ul class="simple">
<li><p>Set the nuttx0 inbound speed to 10Mbps.</p></li>
</ul>
<blockquote>
<div><div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># Load fib module, and start ifb0 interface</span>
modprobe<span class="w"> </span>ifb
ip<span class="w"> </span>link<span class="w"> </span><span class="nb">set</span><span class="w"> </span>dev<span class="w"> </span>ifb0<span class="w"> </span>up
<span class="c1"># Import the nuttx0 ingress packets into ifb0</span>
tc<span class="w"> </span>qdisc<span class="w"> </span>add<span class="w"> </span>dev<span class="w"> </span>nuttx0<span class="w"> </span>handle<span class="w"> </span>ffff:<span class="w"> </span>ingress
tc<span class="w"> </span>filter<span class="w"> </span>add<span class="w"> </span>dev<span class="w"> </span>nuttx0<span class="w"> </span>parent<span class="w"> </span>ffff:<span class="w"> </span>u32<span class="w"> </span>match<span class="w"> </span>u32<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">0</span><span class="w"> </span>action<span class="w"> </span>mirred<span class="w"> </span>egress<span class="w"> </span>redirect<span class="w"> </span>dev<span class="w"> </span>ifb0
<span class="c1"># Limit nuttx0 ingress 10Mbps</span>
tc<span class="w"> </span>qdisc<span class="w"> </span>add<span class="w"> </span>dev<span class="w"> </span>ifb0<span class="w"> </span>root<span class="w"> </span>tbf<span class="w"> </span>rate<span class="w"> </span>10Mbit<span class="w"> </span>latency<span class="w"> </span>50ms<span class="w"> </span>burst<span class="w"> </span><span class="m">1540</span>
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li><p>configure the sim simulator.</p></li>
</ul>
<blockquote>
<div><ul class="simple">
<li><p>Start iperf3 server on ubuntu.</p></li>
</ul>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>iperf3<span class="w"> </span>-s<span class="w"> </span>-i1<span class="w"> </span>-p10003<span class="w"> </span><span class="c1">#for sim1</span>
iperf3<span class="w"> </span>-s<span class="w"> </span>-i1<span class="w"> </span>-p10004<span class="w"> </span><span class="c1">#for sim2</span>
</pre></div>
</div>
<ul class="simple">
<li><p>start the emulators sim1 and sim2 and configure ip addresses.</p></li>
</ul>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># start and configure sim1</span>
start<span class="w"> </span>gdb<span class="w"> </span>nuttx
ifconfig<span class="w"> </span>eth0<span class="w"> </span><span class="m">10</span>.0.1.3
<span class="c1"># start and configure sim2</span>
start<span class="w"> </span>gdb<span class="w"> </span>nuttx
ifconfig<span class="w"> </span>eth0<span class="w"> </span><span class="m">10</span>.0.1.4<span class="w"> </span><span class="c1"># sim2</span>
</pre></div>
</div>
</div></blockquote>
<dl class="field-list simple">
<dt class="field-odd">2.Stream Testing<span class="colon">:</span></dt>
<dd class="field-odd"><p></p></dd>
</dl>
<ul class="simple">
<li><p>Use iperf3 to perform the stream testing.</p></li>
</ul>
<blockquote>
<div><div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>iperf3<span class="w"> </span>-c<span class="w"> </span><span class="m">10</span>.0.1.1<span class="w"> </span>-i1<span class="w"> </span>-t60<span class="w"> </span>-p10003<span class="w"> </span><span class="c1"># sim1</span>
iperf3<span class="w"> </span>-c<span class="w"> </span><span class="m">10</span>.0.1.1<span class="w"> </span>-i1<span class="w"> </span>-t60<span class="w"> </span>-p10004<span class="w"> </span><span class="c1"># sim2</span>
</pre></div>
</div>
</div></blockquote>
<dl class="field-list simple">
<dt class="field-odd">3.Comparison Testing<span class="colon">:</span></dt>
<dd class="field-odd"><p>Compares the test results of enabling and disabling NewReno.</p>
</dd>
</dl>
</section>
<section id="test-results">
<h3>Test results<a class="headerlink" href="#test-results" title="Permalink to this heading"></a></h3>
<blockquote>
<div><p>The test results should indicate that the total network throughput was significantly increased when NewReno congestion control was enabled, which was close to the actual total network bandwidth, and the rates of both sim devices were stable.</p>
</div></blockquote>
</section>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="mutex.html" class="btn btn-neutral float-left" title="Mutual Exclusion lock" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="notifier.html" class="btn btn-neutral float-right" title="Notifier Chain" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2023, The Apache Software Foundation.</p>
</div>
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>