[OpenSIPS-Users] Ratelimit usage

Adrien LACOMME adrien.lacomme at appliwave.com
Fri Oct 27 16:01:48 UTC 2023


Hello,

I added this line to my code, in fact it's better to decrease the counter if I drop the call.
But my problem is that the rl_check function never drop calls, I do not enter in the IF condition.

For the algorithm, I'm actually just trying the module, I will probably not stay with RED.

________________________________
De : Users <users-bounces at lists.opensips.org> de la part de Wadii ELMAJDI | Evenmedia <wadii at evenmedia.fr>
Envoyé : vendredi 27 octobre 2023 17:39
À : OpenSIPS users mailling list <users at lists.opensips.org>
Objet : Re: [OpenSIPS-Users] Ratelimit usage


Hello Adrien

Try :

if (!rl_check("test1", 1, "RED"))

{

   rl_dec_count("test1")

   send_reply(487, "Request Terminated: CPS limit exceeded");

   exit;

}

* If you are using ratelimit to limit only successful traffic, you need to explicitely decrease the counter for the declined calls using the rl_dec_count() function
also I’m not sure RED is the best algorithm for your usecase.



De : Users <users-bounces at lists.opensips.org> De la part de Adrien LACOMME
Envoyé : vendredi 27 octobre 2023 17:06
À : users at lists.opensips.org
Objet : [OpenSIPS-Users] Ratelimit usage



Hi,



I'm trying to implement CPS limitation on OpenSIPS and I got some difficulties to understand how ratelimit module works.



Here is the setup (I want to limit cps to 1) :



if (!rl_check("test1", 1, "RED")) {

      send_reply(487, "Request Terminated: CPS limit exceeded");

}



I tried to make few calls simultaneously but rl_check return is always FALSE.



Here is the log I got :



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)

2023-10-27T16:52:19.804064 SBC /usr/sbin/opensips[137781]: DBG:ratelimit:w_rl_check: Pipe test1 counter:2 load:0 limit:1 should NOT be blocked (0x7fcae1504888)

2023-10-27T16:52:22.872991 SBC /usr/sbin/opensips[137782]: DBG:ratelimit:w_rl_check: Pipe test1 counter:3 load:0 limit:1 should NOT be blocked (0x7fcae1504888)

2023-10-27T16:52:22.918123 SBC /usr/sbin/opensips[137781]: DBG:ratelimit:w_rl_check: Pipe test1 counter:4 load:0 limit:1 should NOT be blocked (0x7fcae1504888)



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 ?



Regards,



Adrien LACOMME




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20231027/dd64ab5e/attachment.html>


More information about the Users mailing list