Regarding the probing part, you can actually use Perl to do your probing outside opensips as well. You can use a sip stack such as sipsak to send ping messages to all your ip addresses and flip a flag in DB if they don&#39;t respond. You perl script would have to be a daemon and run in the back ground though.<div>
<br></div><div>Regards,</div><div>Ali Pey</div><br><div class="gmail_quote">On Tue, Sep 4, 2012 at 1:39 AM, SamyGo <span dir="ltr">&lt;<a href="mailto:govoiper@gmail.com" target="_blank">govoiper@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Please read my in-line comments.<br><br><div class="gmail_quote"><div class="im">On Sun, Sep 2, 2012 at 5:25 PM, Shaahin Madani <span dir="ltr">&lt;<a href="mailto:shaahin.madani@gmail.com" target="_blank">shaahin.madani@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><font><font face="verdana,sans-serif">Hi Sammy,</font></font></div><div><font><font face="verdana,sans-serif"><br>

</font></font></div><div><font face="verdana, sans-serif">It made perfect sense, and is actually very close to my requirement. Thanks for sharing your experience. Please find my replies below.</font></div>
<font><div><div style="font-family:verdana,sans-serif"><font><font face="verdana,sans-serif"><br></font></font></div><div><div><font face="arial, helvetica, sans-serif" color="#006600">&gt; I see what you are trying to do here, get a list of gateways to be used for a particular destination(or any other logic) </font></div>


<div><font face="arial, helvetica, sans-serif" color="#006600">&gt; and then based on that list involve the drouting module. What I can imagine here is this would result in something </font></div><div><font face="arial, helvetica, sans-serif" color="#006600">&gt; like inserting the returned list into opensips first and then asking the module(insert into module table, refresh the </font></div>


<div><font face="arial, helvetica, sans-serif" color="#006600">&gt; module list and then) to do the processing for you.</font></div><div><font face="arial, helvetica, sans-serif" color="#006600">&gt; If you have something like above in your mind, then it will be a performance overhead on per call basis !</font></div>


</div><div style="font-family:verdana,sans-serif"><font><font face="verdana,sans-serif"><br></font></font></div></div><div><font><font face="verdana,sans-serif" style="font-family:verdana,sans-serif">That is exactly what I had in mind, with only a small difference. I was hoping to find a way to let the </font><font face="courier new, monospace">drouting</font><font face="verdana,sans-serif" style="font-family:verdana,sans-serif"> module know about the gateway list without going through the database channel, i.e. inserting the gateway list into database with every call. If I could do that, it would reduce the performance overhead by avoiding unnecessary queries for reloading data into </font><font face="courier new, monospace">drouting </font><font face="verdana,sans-serif" style="font-family:verdana,sans-serif">module.</font></font></div>


<div style="font-family:verdana,sans-serif"><font><font face="verdana,sans-serif"><br></font></font></div></font></div></blockquote></div><div><font color="#3366ff">I can imagine these two possibilities to feed the gateway-list to the drouting table/module is a) FIFO/MI_XML method !? b) Do some customization with the module to connect to memcache/redis based gateway-list table and do memcache operation from the perl script (Not easy I assume, but much efficient than (a) )</font></div>
<div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font><div style="font-family:verdana,sans-serif"><font><font face="verdana,sans-serif"></font></font></div>

<div style="font-family:verdana,sans-serif"><font><font face="verdana,sans-serif"><br></font></font></div><div><div><div style="font-family:arial">
<font color="#006600">&gt; I&#39;d suggest you to go without the Drouting module, in your perl script do all the gateway processing and send back </font></div><div style="font-family:arial"><font color="#006600">&gt; results to opensips in AVPs and develop the &quot;Drouting like&quot; functionality in opensips.</font></div>


<div><font face="verdana, sans-serif"><br></font></div></div><div><font face="verdana, sans-serif">I am implementing it like this now. One feature that I believe I cannot implement with the combination of script+Perl is monitoring the status of gateway using SIP probing. I need this feature, and the only way I can imagine it can be activated is to let the</font><font face="verdana, sans-serif"> </font><font face="courier new, monospace">drouting</font><font face="verdana, sans-serif"> module have the list of all gateways (say by direct access to the external database), but then the </font><font face="courier new, monospace">drouting</font><font face="verdana, sans-serif"> module would want to load the whole database entries into memory all the time - but, before jumping to conclusion, I&#39;d better test and see the memory penalty. </font></div>

</div></font></div></blockquote><div><br></div></div><div><font color="#3366ff">I think this memory load is and will always be there for all possible solutions, just keep it out of mind. How many gateways could you possibly have !!? 100,300 ? The feature you need (SIP probing/keepalive for gateway) has higher priority than 1~2 MB memory consumption.</font></div>
<div class="im">
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font><div>
</div><div><div><font><font face="verdana,sans-serif"><br></font></font></div><div style="font-family:verdana,sans-serif"><font><font face="verdana, sans-serif"><br></font></font></div><div><font face="arial, helvetica, sans-serif" color="#006600">&gt; Though I&#39;m not sure about your whole scenario precisely, what I can tell you is how I had done somewhat similar </font></div>


<div><font face="arial, helvetica, sans-serif" color="#006600">&gt; setup. I had all the gateways in a different DB and was using OpenSIPS-RADIUS integration. RADIUS used perl </font></div><div><font face="arial, helvetica, sans-serif" color="#006600">&gt; scripts and returned a list of sorted gateways to try. The list was processed in opensips in serial-forking manner.</font>
</div><div style="font-family:verdana,sans-serif"><span style="font-family:arial"><br></span></div></div><font face="verdana, sans-serif">Did you have the requirement for probing too?</font></font></div></blockquote><div>

<br></div><div><br></div></div><div><font color="#3366ff">No, not really. The gateways are assumed to be all carries which don&#39;t usually go down, even if they do shut down we&#39;ve failure_route to route the call out to some other carrier and keep this loop untill our carrier list exhausts or call gets established.</font></div>
<div class="im">
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><font><font face="verdana, sans-serif"><br>
</font></font></div><div><font><font face="verdana, sans-serif"><br></font></font></div><div><font face="arial, helvetica, sans-serif" color="#006600">&gt; Another possibility, that I can think for you, is tell your Drouting module to connect to the DB containing the table </font></div>


<div><font face="arial, helvetica, sans-serif" color="#006600">&gt; with ALL the gateways in it. The perl script will just return you the prefixes or enough logic to be input to the DROUTING </font></div><div><font face="arial, helvetica, sans-serif" color="#006600">&gt; functions and Drouting decides the actual gateway. (Make sure in your perl script you put intelligent logic which will </font></div>


<div><font face="arial, helvetica, sans-serif" color="#006600">&gt; ensure that DROUTING module selects from only your desired gateways)</font>
</div><div><font><font face="verdana, sans-serif"><br></font></font></div></div><div><font><font face="verdana, sans-serif">Thanks for pointing this out. I need to feed a strict list into the </font><font face="courier new, monospace">drouting</font><font face="verdana, sans-serif"> module; and the only somewhat related parameter I found is the </font><font face="courier new, monospace">gw_whitelist</font><font face="verdana, sans-serif"> of the </font><font face="courier new, monospace">do_routing(...)</font><font face="verdana, sans-serif"> function, which seems to be able to do the job if I can fill it with a </font></font><font><font face="verdana, sans-serif">list </font></font><span style="font-family:verdana,sans-serif">of gateway ID or IP values (the </span><a href="http://www.opensips.org/html/docs/modules/devel/drouting.html#id293431" style="font-family:verdana,sans-serif" target="_blank">documentation</a><span style="font-family:verdana,sans-serif"> doesn&#39;t clearly say what is expected in that parameter). </span></div>

</div></blockquote><div><br></div></div><div><a href="http://www.opensips.org/html/docs/modules/devel/drouting.html#id293561" target="_blank">http://www.opensips.org/html/docs/modules/devel/drouting.html#id293561</a> <font color="#3366ff">Well there&#39;s your function, clearly states needs a CSV &quot;- a comma separated white list of gateways. This will force routing over this list of carriers or gateways (a subset of what found in the prefix rules).&quot;</font></div>

<div><font color="#3366ff"><br></font></div><div><font color="#3366ff">Just use your perl script to finalize carriers in a CSV, then return into and AVP in opensips and use this function ! - All the gateways are already loaded by drouting module and their statuses are maintained automatically- All you need in your perl script is select the Active gateways fitting your business logic.</font></div>
<div><div class="h5">
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
<div><span style="font-family:verdana,sans-serif"><br></span></div><div><span style="font-family:verdana,sans-serif">Kind regards,</span></div><div><span style="font-family:verdana,sans-serif">Shaahin Madani</span></div>

<div><div><div>
<font><font face="verdana, sans-serif"><br></font></font></div><div><font><font face="verdana, sans-serif"><br></font></font></div><div><font><font face="verdana, sans-serif"><br></font></font><br><div class="gmail_quote">


On Fri, Aug 31, 2012 at 4:28 PM, SamyGo <span dir="ltr">&lt;<a href="mailto:govoiper@gmail.com" target="_blank">govoiper@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi Shaahin,<div><br></div><div>I see what you are trying to do here, get a list of gateways to be used for a particular destination(or any other logic) and then based on that list involve the drouting module. What I can imagine here is this would result in something like inserting the returned list into opensips first and then asking the module(insert into module table, refresh the module list and then) to do the processing for you.</div>



<div><br></div><div>If you have something like above in your mind, then it will be a performance overhead on per call basis !</div><div><br></div><div>I&#39;d suggest you to go without the Drouting module, in your perl script do all the gateway processing and send back results to opensips in AVPs and develop the &quot;Drouting like&quot; functionality in opensips.</div>



<div><br></div><div>Though I&#39;m not sure about your whole scenario precisely, what I can tell you is how I had done somewhat similar setup. I had all the gateways in a different DB and was using OpenSIPS-RADIUS integration. RADIUS used perl scripts and returned a list of sorted gateways to try. The list was processed in opensips in serial-forking manner.</div>



<div><br></div><div>Another possibility, that I can think for you, is tell your Drouting module to connect to the DB containing the table with ALL the gateways in it. The perl script will just return you the prefixes or enough logic to be input to the DROUTING functions and Drouting decides the actual gateway. (Make sure in your perl script you put intelligent logic which will ensure that DROUTING module selects from only your desired gateways)</div>



<div><br></div><div>I hope I made some sense here.</div><div><br></div><div>Regards,</div><div>Sammy</div><div><div><div><br></div><div><br><div class="gmail_quote">On Fri, Aug 31, 2012 at 7:55 AM, Shaahin Madani <span dir="ltr">&lt;<a href="mailto:shaahin.madani@gmail.com" target="_blank">shaahin.madani@gmail.com</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font><font face="verdana,sans-serif">Greetings,</font></font><div><font><font face="verdana,sans-serif"><br>



</font></font></div><div><font><font face="verdana,sans-serif">Thanks for the helpful replies. Presently, the list of gateways cannot be retrieved using a direct query on the external database, and hence I need the Perl script to act as the middle-ware too. Some changes in the external database may fix this, and then I would be able to use the </font></font><font face="courier new, monospace">avops</font><font face="verdana, sans-serif"> module as Ali suggested, </font><span style="font-family:verdana,sans-serif">but I need to first thoroughly study all the consequences ...</span></div>




<div><font><font face="verdana,sans-serif"><br></font></font></div><div><font><font face="verdana,sans-serif">Regarding the bottleneck issue, I don&#39;t see any way that I can avoid the queries (or Perl). In case it turns out to be a real bottleneck, then is there any way to go around it, or will I actually be hitting an OpenSIPS limitation?</font></font></div>




<div><font><font face="verdana,sans-serif"><br></font></font></div><div><font><font face="verdana,sans-serif">Cheers,</font></font></div><div><font><font face="verdana,sans-serif">Shaahin</font></font></div><div><font><font face="verdana,sans-serif"><br>




</font></font></div><div><font face="verdana, sans-serif">P.S. [to Ali and Rudy]: It&#39;s &quot;Shaahin&quot;, not &quot;Shaheen&quot; :-)</font></div><div><div><div><font><font face="verdana,sans-serif"><br>
</font></font></div><div>
<font><font face="verdana,sans-serif"><br></font></font><br><div class="gmail_quote">On Fri, Aug 31, 2012 at 2:03 AM, Rudy <span dir="ltr">&lt;<a href="mailto:rudy@dynamicpacket.com" target="_blank">rudy@dynamicpacket.com</a>&gt;</span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Brett,<br>
<br>
 Any complex logic, perl, sql or otherwise can impact performance and<br>
create a bottleneck. Regarding the perl module in particular, I can<br>
tell you that it works pretty well.<br>
<br>
Thanks in advance,<br>
<div>--Rudy<br>
Dynamic Packet<br>
Toll-Free: 888.929.VOIP ( 8647 )<br>
<br>
<br>
</div><div><div>On Thu, Aug 30, 2012 at 11:58 AM, Brett Nemeroff &lt;<a href="mailto:brett@nemeroff.com" target="_blank">brett@nemeroff.com</a>&gt; wrote:<br>
&gt; If you can sum up the logic in an SQL query I&#39;d recommend doing that. If you<br>
&gt; can cache the results in memcache, even better. Just keep in mind that any<br>
&gt; complicated logic can serve as a significant bottleneck. Depending on your<br>
&gt; traffic load, that may or may not be an issue.<br>
&gt;<br>
&gt; I know there are a few recommendations for the perl module here, but I&#39;m not<br>
&gt; sure of the status of the module and if it&#39;s actively maintained. I&#39;d love<br>
&gt; to hear from others about their own experiences using it. I haven&#39;t used it<br>
&gt; myself in maybe 6 years or so.<br>
&gt; -Brett<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Aug 30, 2012 at 9:09 AM, Shaahin Madani &lt;<a href="mailto:shaahin.madani@gmail.com" target="_blank">shaahin.madani@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi Bogdan and Brett,<br>
&gt;&gt;<br>
&gt;&gt; Thanks for your replies. The issue here is that my OpenSIPS simply does<br>
&gt;&gt; not have the list of gateways, that is the gateways are *not* available in<br>
&gt;&gt; the dr_gateways table. For every INVITE request, the list of gateways must<br>
&gt;&gt; be dynamically built, and only afterwards the actual dynamic routing can<br>
&gt;&gt; take place. The logic behind building the list of gateways relies on a<br>
&gt;&gt; totally separate database.<br>
&gt;&gt; To sum it up, I would say the desired scenario would resemble the steps<br>
&gt;&gt; below:<br>
&gt;&gt;<br>
&gt;&gt; 1) OpenSIPS receives an INVITE<br>
&gt;&gt; 2) OpenSIPS asks an external system (e.g. the Perl script) for the<br>
&gt;&gt; gateways available for this specific INVITE request<br>
&gt;&gt; 3) A list of gateways is returned to OpenSIPS (based on some black-box<br>
&gt;&gt; logic)<br>
&gt;&gt; 4) OpenSIPS dynamically routes the INVITE to the specified gateways,<br>
&gt;&gt; prioritising based on cost, time, or ...<br>
&gt;&gt;<br>
&gt;<br>
</div></div><div><div>&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</div></div></blockquote></div><br></div></div></div></div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div></div></div></div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div></div></div><br>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br>