[Spce-user] Limit CPS per peer gw

Marco Capetta mcapetta at sipwise.com
Tue Aug 9 02:37:30 EDT 2022


Hi Jon,

thank you for the contribution.
Really good approach and documentation.

We will for sure consider it.


Cheers
Marco


On 08/08/22 23:07, Jon Bonilla (Manwe) wrote:
> Hi all
>
> Recently a customer of mine (Questblue Inc) asked me a way of limiting CAPS
> to their peer gateways. So I created a custom preference and a patch for them.
>
> Here's de howto:
>
> - Create a peer preference custom_caps to set the maximum number of INVITE
> request per second a peer gateway could allow (attached
> custompreferences_caps.sql)
>
> - Send the preference to the lb in proxy.cfg:
>
> if(pv_isset("$xavp(callee_peer_prefs[0]=>custom_caps)")) {
>    $(x_hdr(P-QB-CAPS)[*]) = $xavp(callee_peer_prefs[0]=>custom_caps);
> }
>
> - whitelist the header in sems sbcprofile (trivial)
>
> - Add a new htable entry in lb (I also added separate timer processes for high
>    load):
>
> modparam("htable", "htable", "caps=>size=11;initval=0;autoexpire=5;")
> modparam("htable", "timer_interval", 10)
> modparam("htable", "timer_procs", 4)
>
>
> - Set the logic in the kamailio lb to check for caps:
>
> if(is_present_hf("P-QB-CAPS")) {
>    $var(cps) = $rd + ":" + $timef(%S);
>    $var(cps) = $shtinc(caps=>$var(cps));
>    $var(capslimit) = $hdr(P-QB-CAPS);
>    if ($var(cps) > $var(capslimit)) {
>       sl_send_reply("503", "CAPS limit reached for this destination $rd");
>       exit;
>    }
> }
>
>
> I'm using $rd because my customer doesn't use "hostname" in the gw definition
> but it could be changed for destination IP based on P-D-URI or similar.
>
> This setup has been running in Questblue'ssip:carrier  like spce cluster with
> more than 1500CAPS of traffic without issues.
>
> Questblue agrees on upstreaming this patch if Sipwise is interested on it. I
> think it can be a useful feature.
>
>
> cheers,
>
> Jon
>
>
>

-- 
*Marco Capetta *
Head Of VoIP Development Team

Sipwise GmbH | an ALE Company <http://www.sipwise.com>
c/o ALE International – Austria Branch
Saturn Tower
Leonard-Bernstein-Straße 10
1220 Vienna, Austria

Phone: +43(0)1 301 2044 <tel:+43130120444>
Email: mcapetta at sipwise.com
Website: www.sipwise.com <http://www.sipwise.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sipwise.com/pipermail/spce-user_lists.sipwise.com/attachments/20220809/11e0249b/attachment.html>


More information about the Spce-user mailing list