<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:Helvetica;
panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
p.xmsonormal, li.xmsonormal, div.xmsonormal
{mso-style-name:x_msonormal;
margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.xcontentpasted6
{mso-style-name:x_contentpasted6;}
span.EmailStyle25
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Have you read the description of the RED algorithm? Are you sure you are generating appropriate traffic to cause a drop? That algorithm seems like it would be difficult to control/predict the drops accurately for a test. If you are sending
a constant traffic volume to it, it never will drop.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If you are just testing, you may want to go with a simpler algorithm where you can more easily control when/how many are being dropped.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The standard way to use the module for CPS is to use the SBT algorithm with a window_size of 1. [1]<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[1] <a href="https://opensips.org/docs/modules/3.2.x/ratelimit.html#param_window_size">
https://opensips.org/docs/modules/3.2.x/ratelimit.html#param_window_size</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color:black">Ben Newlin</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">From:
</span></b><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">Users <users-bounces@lists.opensips.org> on behalf of Adrien LACOMME <adrien.lacomme@appliwave.com><br>
<b>Date: </b>Friday, October 27, 2023 at 12:03 PM<br>
<b>To: </b>OpenSIPS users mailling list <users@lists.opensips.org><br>
<b>Subject: </b>Re: [OpenSIPS-Users] Ratelimit usage<o:p></o:p></span></p>
</div>
<div>
<div>
<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border:none">
<tbody>
<tr>
<td style="border:solid #B60000 1.0pt;background:white;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:#B60000"> EXTERNAL EMAIL - Please use caution with links and attachments <o:p></o:p></span></b></p>
</td>
</tr>
</tbody>
</table>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:Helvetica;color:black"><o:p> </o:p></span></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="0" width="100%" align="center">
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">Hello,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">I added this line to my code, in fact it's better to decrease the counter if I drop the call.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">But my problem is that the rl_check function never drop calls, I do not enter in the IF condition.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">For the algorithm, I'm actually just trying the module, I will probably not stay with RED.<o:p></o:p></span></p>
</div>
<div>
<div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="0">
<tbody>
<tr>
<td style="padding:0in 0in 0in 0in">
<div id="x_LSI_marker">
<p class="MsoNormal"><span style="font-size:1.0pt"> <o:p></o:p></span></p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="0" width="100%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">De :</span></b><span style="color:black"> Users <users-bounces@lists.opensips.org> de la part de Wadii ELMAJDI | Evenmedia <wadii@evenmedia.fr><br>
<b>Envoyé :</b> vendredi 27 octobre 2023 17:39<br>
<b>À :</b> OpenSIPS users mailling list <users@lists.opensips.org><br>
<b>Objet :</b> Re: [OpenSIPS-Users] Ratelimit usage</span> <o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="xmsonormal">Hello Adrien<br>
<br>
Try : <br>
<br>
<span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">if (!rl_check("test1", 1, "RED"))
</span><span lang="FR"><o:p></o:p></span></p>
<p class="xmsonormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">{</span><span lang="FR"><o:p></o:p></span></p>
<p class="xmsonormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> rl_dec_count("test1")</span><span lang="FR"><o:p></o:p></span></p>
<p class="xmsonormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> send_reply(487, "Request Terminated: CPS limit exceeded");</span><span lang="FR"><o:p></o:p></span></p>
<p class="xmsonormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> exit;</span><span lang="FR"><o:p></o:p></span></p>
<p class="xmsonormal"><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">}</span><br>
<br>
<span style="font-size:9.0pt;font-family:Helvetica;color:black;background:white">* If you are using ratelimit to limit only successful traffic, you need to explicitely decrease the counter for the declined calls using the <em><span style="font-family:Helvetica">rl_dec_count()</span></em> function<br>
also I’m not sure RED is the best algorithm for your usecase.</span><span lang="FR"><o:p></o:p></span></p>
<p class="xmsonormal"> <span lang="FR"><o:p></o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="xmsonormal"><b><span lang="FR">De :</span></b><span lang="FR"> Users <users-bounces@lists.opensips.org>
<b>De la part de</b> Adrien LACOMME<br>
<b>Envoyé :</b> vendredi 27 octobre 2023 17:06<br>
<b>À :</b> users@lists.opensips.org<br>
<b>Objet :</b> [OpenSIPS-Users] Ratelimit usage<o:p></o:p></span></p>
</div>
</div>
<p class="xmsonormal"><span lang="FR"> <o:p></o:p></span></p>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">Hi,</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> </span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">I'm trying to implement CPS limitation on OpenSIPS and I got some difficulties to understand how ratelimit module works.</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> </span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">Here is the setup (I want to limit cps to 1) :</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> </span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">if (!rl_check("test1", 1, "RED")) {</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> send_reply(487, "Request Terminated: CPS limit exceeded");</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">}</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> </span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">I tried to make few calls simultaneously but rl_check return is always FALSE.</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> </span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">Here is the log I got :</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> </span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">2023-10-27T16:52:19.792337 SBC /usr/sbin/opensips[137782]: DBG:ratelimit:w_rl_check: Pipe test1 counter:1 load:0 limit:1 should NOT be blocked (0x7fcae1504888)</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">2023-10-27T16:52:19.804064 SBC /usr/sbin/opensips[137781]: DBG:ratelimit:w_rl_check: Pipe
<span style="background:white">test1</span> counter:2 load:0 limit:1 should NOT be blocked (0x7fcae1504888)</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">2023-10-27T16:52:22.872991 SBC /usr/sbin/opensips[137782]: DBG:ratelimit:w_rl_check: Pipe
<span class="xcontentpasted6"><span style="background:white">test1</span></span> counter:3 load:0 limit:1 should NOT be blocked (0x7fcae1504888)</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">2023-10-27T16:52:22.918123 SBC /usr/sbin/opensips[137781]: DBG:ratelimit:w_rl_check: Pipe
<span style="background:white">test1</span> counter:4 load:0 limit:1 should NOT be blocked (0x7fcae1504888)</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> </span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">Shouldn't the module block calls when the counter goes to 2 ? Or is he checking the load value to block ? If yes, why the load value isn't incremented
?</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> </span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">Regards,</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black"> </span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<p class="xmsonormal"><span lang="FR" style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">Adrien LACOMME</span><span lang="FR"><o:p></o:p></span></p>
</div>
<div>
<div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="0">
<tbody>
<tr>
<td style="padding:0in 0in 0in 0in">
<div id="x_x_LSI_marker">
<p class="xmsonormal"><span style="font-size:1.0pt"> </span><o:p></o:p></p>
</div>
</td>
</tr>
</tbody>
</table>
<p class="xmsonormal"><span lang="FR"> <o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>