<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<font face="monospace">Hi Jon,<br>
<br>
thank you for the contribution.<br>
Really good approach and documentation.<br>
<br>
We will for sure consider it.<br>
<br>
<br>
Cheers<br>
Marco<br>
<br>
</font><br>
<div class="moz-cite-prefix">On 08/08/22 23:07, Jon Bonilla (Manwe)
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20220808230728.09ef454b@multivac.sipdoc.net">
<pre class="moz-quote-pre" wrap="">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's <a class="moz-txt-link-freetext" href="sip:carrier">sip:carrier</a> 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
</pre>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<div style="line-height:16px; margin:6px 0; padding:8px 8px 8px
8px; border-top:1px #aeb1a6 dotted; border-bottom:1px #aeb1a6
dotted; font-family: 'Lucida Sans', Lucida Grande, Verdana,
Arial, Sans-Serif; font-size:11px; color:#555555;"> <strong
style="color:#333333; text-transform:uppercase;
font-size:10px;"> Marco Capetta </strong> <br>
Head Of VoIP Development Team
<p> <a href="http://www.sipwise.com" style="color:rgb(0, 136,
204) !important; text-decoration:none !important;
border-bottom:1px dotted #AAA;"> Sipwise GmbH | an ALE
Company </a><br>
c/o ALE International – Austria Branch<br>
Saturn Tower<br>
Leonard-Bernstein-Straße 10<br>
1220 Vienna, Austria </p>
<p> Phone: <a href="tel:+43130120444" style="color:rgb(0, 136,
204) !important; text-decoration:none !important;
border-bottom:1px dotted #AAA;"> +43(0)1 301 2044 </a> <br>
Email: <a href="mailto:mcapetta@sipwise.com"
style="color:rgb(0, 136, 204) !important;
text-decoration:none !important; border-bottom:1px dotted
#AAA;" class="moz-txt-link-freetext"> mcapetta@sipwise.com </a>
<br>
Website: <a href="http://www.sipwise.com"
style="color:rgb(0, 136, 204) !important;
text-decoration:none !important; border-bottom:1px dotted
#AAA;"> www.sipwise.com </a>
</p>
</div>
</div>
</body>
</html>