LCR Route Prefixes -> Gateways (From Scratch)

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

LCR Route Prefixes -> Gateways (From Scratch)

symack
Hello Everyone,

We are currently building our route deck using multiple carriers, and
prefixes. Looking over the modules, I am not sure if we should be
using the:

1) Carrier Route Module: carrierroute, carrierfailureroute
2) Dynamic Routing Module: dr_rules, dr_gateways

The two modules have some common overlap, and I wanted to make sure I
was making the right choice. What we need is the ability to:

* Insert the entire (overlapping) prefixes (i.e., 49) for the multiple carriers
* Bind those prefixes to the specific carrier
* Use pre-processing LCR to choose the order of which gateway the call
is routed to first
* Failover to the next least expensive gateway when first selection fails

Since we are doing LCR, we would also like to add additional fields
(list_price, retail_price, effective_date, etc.. ) to the table which
contains the prefixes (ie, dr_rules vs. carrierroute).

One thing I noticed about DR vs Carrier Route is that with Dynamic
Routing we have `gw_list` in `dr_rules`. This is especially important
for LCR since the order of gateways will
reflect LCR for a given prefix. Could not see a `gw_list` for carrierroute.

I should mention that we are using 1.8, and have some additional
questions but for the sake of brevity....


Kind Regards,

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

symack
Anyone?

N.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

shaheryarkh
Well, i would prefer and recommend drouting module, for a number of reasons,

1. its actively maintained and updated with new stuff, while carrierroute isn't so active for a long time.
2. it has less overhead, especially with respect to db, this would matter a lot if you have a lot of traffic and too many prefixes / rules.
3. Theoretically its designed for routing, regardless if its internal (within your own network) or external routing (to carrier networks), so its a good choice if you a large network with many VAS served on dedicated servers, e.g. voicemail, ivr, transcoding and so on. Although carrierroute can also do same, but its considers all servers as carrier network (even ones within your own network).

Thank you.





On Wed, Jul 31, 2013 at 3:11 AM, Nick Khamis <[hidden email]> wrote:
Anyone?

N.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




--
Mit freundlichen Grüßen
Muhammad Shahzad
-----------------------------------
CISCO Rich Media Communication Specialist (CRMCS)
CISCO Certified Network Associate (CCNA)
Cell: +49 176 99 83 10 85
MSN: [hidden email]
Email: [hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

symack
Muhammad this email slipped through my list, and I am glad I saw your
response. For this particular OpenSIPS instance, all routes will be
service provider bound. Looking at the carrierroute module, it does
seem like it has not been maintained in a while, and that's part of
the reason I reached out to the list.

What I am worried about is the how the DR module would scale vs
Carrier. As you know :), these will be lists of ~60,000 prefixes per
service provider, and we will keep appending to it whenever we take on
a new interconnection agreement.

Kind Regards,

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

Muhammad Shahzad Shafi
You should worry about it when you have 1M+ records. :-)

But anyways, if you are a good DBA or know a good DBA, then just have a
look at SQL queries made by opensips to db tables and optimize them as
needed and create appropriate indexes etc. Though that may not be
necessary, as i think they are pretty much optimized already but just
for sake of confidence you can check them. Don't forget to share those
optimized queries with this forum here, so opensips developers may
include them in next release. :-)

Thank you.


On 2013-08-02 03:13, Nick Khamis wrote:

> Muhammad this email slipped through my list, and I am glad I saw your
> response. For this particular OpenSIPS instance, all routes will be
> service provider bound. Looking at the carrierroute module, it does
> seem like it has not been maintained in a while, and that's part of
> the reason I reached out to the list.
>
> What I am worried about is the how the DR module would scale vs
> Carrier. As you know :), these will be lists of ~60,000 prefixes per
> service provider, and we will keep appending to it whenever we take
> on
> a new interconnection agreement.
>
> Kind Regards,
>
> Nick.
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

--
Mit freundlichen Grüßen
Muhammad Shahzad
-----------------------------------
CISCO Rich Media Communication Specialist (CRMCS)
CISCO Certified Network Associate (CCNA)
Cell: +49 176 99 83 10 85
MSN: [hidden email]
Email: [hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

symack
Hello Muhammad,

I have no problem updating the DB script and relevant code using optimized indexing/views, and sharing that with the community. It's about time I contribute in some form or another... :)

Furthermore, I would also like to share the final DB schema and script in charge of creating an OpenSIPS LCR instance with the community. And would be happy to see it posted on the OpenSIPS Tut section. I will have some questions to steer me to the right direction however, will keep them short and connect the dots without taking too much of the community's time.

My first question will be, is it safe to add additional fields to the `dr_rules` table. What I will need are things like (bill_minimum, bill_increment, list/retail_rate etc..). Things we usually see in a rate deck ;). What I am asking is do the OpenSIPS code use index based queries or actual field names when querying the database. The latter would be safer and thus pose no problem when adding extra fields...

PS I will use this email as a thread to this subject.

Kind Regards,

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

shaheryarkh
Well, a very basic sign of good piece of software, that is driven by database,is that it ALWAYS uses column names, instead of index numbers. OpenSIPS not only confirm to this very basic standard but it further improves it by allowing user to define table and column names as module parameter that will be internally called by module through SQL queries. So, yes adding more columns should not and will not effect its processing. However, be sure to only add columns that are really need or at least fit to the philosophy of the module.

In my personal view routing and rating are two distinct entities and for sake of data independence they should not be mixed together in a single table. Perhaps you should to be interested in call-control module or something similar. If you are good in PERL or LUA you can even write up your own module for rating and billing, and it would work like a charm even for high loads, as long as you keep your database optimized. And yes, you can make such rating / billing module on commercial license.

Thank you.




On Mon, Aug 5, 2013 at 6:00 PM, Nick Khamis <[hidden email]> wrote:
Hello Muhammad,

I have no problem updating the DB script and relevant code using optimized indexing/views, and sharing that with the community. It's about time I contribute in some form or another... :)

Furthermore, I would also like to share the final DB schema and script in charge of creating an OpenSIPS LCR instance with the community. And would be happy to see it posted on the OpenSIPS Tut section. I will have some questions to steer me to the right direction however, will keep them short and connect the dots without taking too much of the community's time.

My first question will be, is it safe to add additional fields to the `dr_rules` table. What I will need are things like (bill_minimum, bill_increment, list/retail_rate etc..). Things we usually see in a rate deck ;). What I am asking is do the OpenSIPS code use index based queries or actual field names when querying the database. The latter would be safer and thus pose no problem when adding extra fields...

PS I will use this email as a thread to this subject.

Kind Regards,

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




--
Mit freundlichen Grüßen
Muhammad Shahzad
-----------------------------------
CISCO Rich Media Communication Specialist (CRMCS)
CISCO Certified Network Associate (CCNA)
Cell: +49 176 99 83 10 85
MSN: [hidden email]
Email: [hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

symack
Hello Muhammad,

Thanks again for your response. I took a look at call-control, and since we handle call duration on our Asterisk server using AGI script, we are not worried about limiting calls on this server (or did I miss something?). Basically what we have is:

OpenSIPS-In(Security, Internal Routing, LB, CDR)-->Asterisk(Billing, Prepaid, CDR)-->OpenSIPS-Out(LCR,CDR)

Now in OpenSIPS-Out we load all the external service provider routes. As you know :), the data we are working with looks something like:

County,           Prefix, Price, Carrier
AFGHANISTAN, 93,    0.1789, 0
AFGHANISTAN, 93,    0.1989, 1
AFGHANISTAN, 93,    0.1189, 2
AFGHANISTAN, 93,    0.1289, 3

You are correct!!! The one-one relationship will not work for obvious reasons, and also because of the `gw_list` field in dr_rules. In essence (and I am asking here), we would have (note: gw_list reflects LCR above):

*dr_rules*

 ruleid | groupid | prefix | timerec | priority | routeid | gwlist | attrs | description|
+--------+---------+--------+---------+----------+---------+--------+-------+-------------------------------------+
|     1   | 1       |     93   |         |        1 | 0       | 1      | 2,3,0,1   | Route for Afghanistan |
+--------+---------+--------+---------+----------+---------+--------+-------+-------------------------------------+

And an additional table (call it dr_rates for example), and it would have:

id, country, prefix (FK to dr_rules.prefix), price, carrier

*dr_gateways*

+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
| id | gwid | type | address                    | strip | pri_prefix | attrs | probe_mode | description     |
+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
|  1 | 1    |    2    | carrier_address:5060 |     0 | 0011101    | yes   |          0 | Carrier 0           |
+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
|  1 | 1    |    2    | carrier_address:5060 |     0 |                 | yes   |          0 | Carrier 1           |
+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+

...

Now we can either determine the `gw_list` order using data pre-processing or perl-script that fires for every call. Either solution should be easy to implement however, the former would prove better performance but would require additional manual process (i.e., running the script that would order the gateway list based on rate). Any thoughts would be greatly appreciated.

On a side note, I would really hate to know that I am re-inventing the wheel so if there is something that already does this *PLEASE*, let us know...


Kind Regards,

Nick.



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

symack
Correction,

*dr_gateways*


+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
| id | gwid | type | address                    | strip | pri_prefix | attrs | probe_mode | description     |
+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
|  1 | 0    |    2    | carrier_address:5060 |     0 | 0011101    | yes   |          0 | Carrier 0           |
+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
|  1 | 1    |    2    | carrier_address:5060 |     0 |                 | yes   |          0 | Carrier 1           |
+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
.....

N.

...


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

shaheryarkh
Well, for flat rate countries like Afghanistan, that will work, either way. You can pre-process the data like you mentioned above or let some script do it at run time. But think about countries with much messed up telecom architecture like Mexico or Caribbeans countries or even worst Brazil. And if you have inbound carriers as well, like DID / Access number providers, GIS etc. then things like LCR would literally become hell. However if you ignore Spanish America for now, then all is OK and you can move on with it, either way, it doesn't matter much.

And don't worry about reinventing the wheel, A tractor and car both run on wheels, but this does not mean you can fit in a tractor's wheel in car or vice versa. ;-)

Thank you.




On Mon, Aug 5, 2013 at 7:53 PM, Nick Khamis <[hidden email]> wrote:
Correction,

*dr_gateways*


+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
| id | gwid | type | address                    | strip | pri_prefix | attrs | probe_mode | description     |
+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
|  1 | 0    |    2    | carrier_address:5060 |     0 | 0011101    | yes   |          0 | Carrier 0           |
+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
|  1 | 1    |    2    | carrier_address:5060 |     0 |                 | yes   |          0 | Carrier 1           |
+----+------+------+-------------------+-------+------------+-------+------------+----------------------------------------+
.....

N.

...


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




--
Mit freundlichen Grüßen
Muhammad Shahzad
-----------------------------------
CISCO Rich Media Communication Specialist (CRMCS)
CISCO Certified Network Associate (CCNA)
Cell: +49 176 99 83 10 85
MSN: [hidden email]
Email: [hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

symack
Muhammad,

I'm sorry to do this, but by flat rate, are you referring to the per-second vs. per minute and per six seconds billing?
I just don't want to assume or overlook anything when you mention countries with messed up telecom infrastructure.

I am learning a lot from the few words that we are exchanging. I know you're busy, you can respond when you
get a chance... 

>> A tractor and car both run on wheels, but this does not mean you can fit in a tractor's wheel in car or vice versa. 

I love proverbs. Especially ones from the east that are, or derive from ones, that are thousands of years old :)

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

shaheryarkh
Sorry, by mistake i wrote "flat-rate", what i actually meant was "flat-base", it has nothing to do with billing interval, its mostly Dynamic Routing and LCR stuff. Let me try to explain here.

Nearly in all countries of the world we have two mediums, namely Mobile Line and Fixed Line and a subscriber's full number format structure is quite simply, e.g.

Mobile Line => CC + Operator Code + Subscriber Number (SIM Card Number)
Fix Line => CC + City Code + Subscriber Number (can be expended as Exchange Number + Actual Subscriber Number, generally insignificant for third party operator)

The pattern remains constant regardless of time and space of the subscriber, For example if my cell number is +49 176 12345678, then any one who wants to call me can simply dial complete number and can reach me regardless if temporarily,

I move from Wiesbaden to Frankfurt (change of city)
I move from Frankfurt to Berlin (change of state)
I move from Berlin to Paris (change of country)
i move from Paris to NY (change of continent)

But for South American countries the story is completely different, i try to explain with a fake example. The full number format is something like this,

+CC ABC... 12345678

Where,

A if present is operator code of 1 to say 5 digits,
B if present is state code of 1 to say 2 digits,
C if present is city code of 1 to say 3 digits,
and so on, many more such variable (both count and range is different in each country), each changes with subscriber location and even on time of day or day of week basis...

Also there is inter-city roaming, inter-state roaming, international roaming and so on. And the worst of all, people can call you even without any of these variables by simply dialing +CC 12345678. How you route this number? Well, in this case you have to look on to caller-id to determine values of A, B, C and so on, which is another painful story of its kind.

Hope this briefly explains the problem. So be prepared, flat base billing that works perfect in 90% of the world, would not work in Spanish America, at least not without good-will and assistance from a local operator (or its partner), that manages all these complexities for you (at probably very high cost).

Thank you.




On Mon, Aug 5, 2013 at 10:58 PM, Nick Khamis <[hidden email]> wrote:
Muhammad,

I'm sorry to do this, but by flat rate, are you referring to the per-second vs. per minute and per six seconds billing?
I just don't want to assume or overlook anything when you mention countries with messed up telecom infrastructure.

I am learning a lot from the few words that we are exchanging. I know you're busy, you can respond when you
get a chance... 

>> A tractor and car both run on wheels, but this does not mean you can fit in a tractor's wheel in car or vice versa. 

I love proverbs. Especially ones from the east that are, or derive from ones, that are thousands of years old :)

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




--
Mit freundlichen Grüßen
Muhammad Shahzad
-----------------------------------
CISCO Rich Media Communication Specialist (CRMCS)
CISCO Certified Network Associate (CCNA)
Cell: +49 176 99 83 10 85
MSN: [hidden email]
Email: [hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

symack
Hello Muhammad,

After thinking about it some more, it seems that pre-processing in the
manner that I described earlier lacks a lot of flexibility, your
scenario included, even if I did it just temporarily. That is why I
would like to implement the LCR using a simple perl program
that basically:

* Queries the database for the route using shortest matching prefix
* Orders them from least expensive to more

Once I have the gateway list, openSIPS would route the call, and fail over
to the next available gateway.

If this was c++ or Java it would be quite simple. However, perl, and
OpenSIPS scripting is another story... I saw the following unrelated
tutorial which I will start with:

http://www.opensips.org/Documentation/Tutorials-Perl-183-to-180

If anyone has more helpful tips/examples, they would be greatly appreciated.

Kind Regards,

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

Камиль Нигматуллин
15.08.2013 0:34, Nick Khamis пишет:

> Hello Muhammad,
>
> After thinking about it some more, it seems that pre-processing in the
> manner that I described earlier lacks a lot of flexibility, your
> scenario included, even if I did it just temporarily. That is why I
> would like to implement the LCR using a simple perl program
> that basically:
>
> * Queries the database for the route using shortest matching prefix
> * Orders them from least expensive to more
>
> Once I have the gateway list, openSIPS would route the call, and fail over
> to the next available gateway.
>
> If this was c++ or Java it would be quite simple. However, perl, and
> OpenSIPS scripting is another story... I saw the following unrelated
> tutorial which I will start with:
>
> http://www.opensips.org/Documentation/Tutorials-Perl-183-to-180
>
> If anyone has more helpful tips/examples, they would be greatly appreciated.
>
> Kind Regards,
>
> Nick.
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
In my experiance perl works perfectly with Opensips only when it is used
with brain :). However I would recomend not to use queries to databases,
(especially MongoDB that has broken driver for perl) from perl and do a
lot of other complicated things. Just send variables to  perl, process
it as perl does it very well with its regex and other tools, and return
back to opensips as AVP. There is clearly a lot of issues in XS.
Sometimes I face bugs that cannot be explained. The main problem in my
view that eval block cannot be handled when it is compiled as XS.

Regards;

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

symack
Hello Камиль

Thank you so much for your response. Basically, what I have done is created a table `dr_rates`:

+--------+----------------------------------------+--------+--------------+----------+------------------+-------------+----------+
| rateid | destination                         | cc     | prefix      | listrate | retailrate     | currency | carrier |
+--------+----------------------------------------+--------+--------------+----------+------------------+--------------+---------+
|   5839 | Canada 416 Metro Toronto | 1      |        1416 |   0.0028 |    0.00364 | USD        | TN1 |
+--------+----------------------------------------+--------+--------------+----------+------------------+--------------+---------+

And in `dr_rules`

+---------+-----------+--------+---------+--------------+---------+--------+-------------+------------------------------------------------------+
| ruleid  | groupid | prefix | timerec | priority | routeid | gwlist | attrs    | description                                        |
+---------+-----------+--------+---------+--------------+---------+--------+-------------+-------------------------------------------------------+
|   5839 | 0         | 1416   |           |        1     | 0       |        | yes          |   Route for Canada 416 Metro Toronto |
+---------+-----------+--------+---------+--------------+---------+--------+-------------+-------------------------------------------------------+


​For scalability reasons as mentioned with Muhammad, we would like on every call to fire a perl script that would
query the database, and pull all the prefix for the dialled number order by price ascending. I don't know much about
prefixes and types of tricks carrier like to play longest vs. shortest matching etc however, what I am thinking about is:


1) Pull up all records for the dialed CC
2) If CC is 1 digit substring the first four digits of prefix
2) If CC is 2 digits substring the first five digits of prefix
2) If CC is 3 digits substring the first six digits digits of prefix

From all those relevant records, order by price ascending.

If the gateway for least expensive route fails, try the next route etc...

Nice and simple I think? If anyone feels there is anything wrong with this, I would really
appreciate your input. Also, if anyone can write this perl script easily, I would be happy
to compensate for it.

Kind Regards,

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: LCR Route Prefixes -> Gateways (From Scratch)

symack
On 8/25/13, Lucky Santiago <[hidden email]> wrote:
> Hi Nick,
>
> Can you please share me the procedure or guide on how you build your
> kamailio, i am new in this technology and i want to learn it as well, i
> am more of a asterisk person.  Hope you can help and thank you in advance.

Hello Lucky,

OpenSIPS and Kamailio are two different projects. We only use
OpenSIPS here. Maybe you need the Kamailio mailing list?

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users