<pre><code>In this new algorithm a window is held per every pipe,
</code></pre>

<p>which is defined by two parameters: window_size(seconds) and<br>
slot_period(microseconds). The number of slots is<br>
window_size*1000/slot_period. The window is updated with every<br>
call received and it's implemented as a circular vector, which<br>
modifies it's start based on the elements that were dropped.</p>

<p>How is the window updated:</p>

<ul>
<li>if no message comes in 2*window_time from when the window start
was set , it means we can't use the values from any of the slots
and we set the value from any of the slots to 0; the window start
time is updated;</li>
<li>if the message comes in t=[start+window_time; start+2*window_time)
it means that we can keep the values in slots in the interval
[t-window_time;start+window_time) and drop the ones in
[window_time; t-window_time); the window start time is updated;</li>
<li>it the message come in t=[start; start+window_time) we don't
do any update do the window, only to the value of the slot corresponding
to time t;</li>
</ul>

<p>The algorithm also shares this value through bin interface, allowing<br>
having the values from all the replicas. Also, before sending the<br>
value through the interface, the replica checks the window in order<br>
to send only the values in valid slots. Two different functions<br>
were made because of efficiency reasons. When replicating<br>
we only do some very short loops or maybe nothing.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>&nbsp;&nbsp;<a href='https://github.com/OpenSIPS/opensips/pull/728'>https://github.com/OpenSIPS/opensips/pull/728</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Slot Based Taildrop algorithm for ratelimit</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/728/files#diff-0">modules/ratelimit/README</a>
    (61)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/728/files#diff-1">modules/ratelimit/doc/ratelimit_admin.xml</a>
    (91)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/728/files#diff-2">modules/ratelimit/ratelimit.c</a>
    (129)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/728/files#diff-3">modules/ratelimit/ratelimit.h</a>
    (19)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/728/files#diff-4">modules/ratelimit/ratelimit_helper.c</a>
    (81)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/OpenSIPS/opensips/pull/728.patch'>https://github.com/OpenSIPS/opensips/pull/728.patch</a></li>
  <li><a href='https://github.com/OpenSIPS/opensips/pull/728.diff'>https://github.com/OpenSIPS/opensips/pull/728.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/pull/728">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AFOciYUKAhPopDLtKeowJw5OQSHYaGQIks5pQtErgaJpZM4G3c6v.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/OpenSIPS/opensips/pull/728"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>