Hello,
First I would like to say thank you for the helpful members here, I have got useful tips and suggestions here. I am trying to implement some kind of "protection" for me, let me describe what is my problem at the moment. I know I ask a bit much questions here .)
I would like to limit the number of incoming calls from my customers, but on a customer basis. I have a subscriber with an Asterisk, so it will be a bad idea to set a limit to 1 concurrent call for this customer, but limit 1 will work for a customer with an IP phone (remember the 100rel thing what I posted here? that was a workaround for this subscriber... I mean to remove 100rel from the supported header).
So basically I would like to limit every subscriber, on a per customer basis.
The next big thing is the lcr gateways, so where I send the calls. I have 2 peers, one of then have a limit for me, it's 20 concurrent calls. They don't limit me, so I can send out 30-40-50 calls to them, but they will charge me a big amount of Lei (Romanian currency) for every calls above 20 at the same time. They have freeswitch.... doesn't matter, I'm just saying they have freeswitch :) But they have very very good price(for 20 calls what i mentioned), so I would like to fill that "20 calls" space.
I have asked them to give some limits for me, so refuse calls above 20 (so this way lcr can send out to the another gateway), but they don't want to do it (well, they need money I think)
I would like to store values for these limits in mysql (column "limit" in subscriber table, and column "calllimit" in gw table, or I can store it in a separate table). Right now I store these values in a mysql table called "iplimits"
I am not perfectly sure about how I can select these values from the table, and how can I "play" with these values. Even don't know how to retrieve the current number of concurrent calls per gateway or per subscriber.
And what to do with these selected values? Store it in an avp and then do some checks against it?
I am reading the module docs, especially sqlops, but I think I can't see the wood for the trees.
I hope somebody can give me suggestions (or an example) about this.
Kind regards,
Dmitri
Hello,
On 20.08.2009 3:31 Uhr, Dmitri G. wrote:
Hello,
First I would like to say thank you for the helpful members here, I have got useful tips and suggestions here. I am trying to implement some kind of "protection" for me, let me describe what is my problem at the moment. I know I ask a bit much questions here .)
I would like to limit the number of incoming calls from my customers, but on a customer basis. I have a subscriber with an Asterisk, so it will be a bad idea to set a limit to 1 concurrent call for this customer, but limit 1 will work for a customer with an IP phone (remember the 100rel thing what I posted here? that was a workaround for this subscriber... I mean to remove 100rel from the supported header).
So basically I would like to limit every subscriber, on a per customer basis.
The next big thing is the lcr gateways, so where I send the calls. I have 2 peers, one of then have a limit for me, it's 20 concurrent calls. They don't limit me, so I can send out 30-40-50 calls to them, but they will charge me a big amount of Lei (Romanian currency) for every calls above 20 at the same time. They have freeswitch.... doesn't matter, I'm just saying they have freeswitch :) But they have very very good price(for 20 calls what i mentioned), so I would like to fill that "20 calls" space.
I have asked them to give some limits for me, so refuse calls above 20 (so this way lcr can send out to the another gateway), but they don't want to do it (well, they need money I think)
I would like to store values for these limits in mysql (column "limit" in subscriber table, and column "calllimit" in gw table, or I can store it in a separate table). Right now I store these values in a mysql table called "iplimits"
I am not perfectly sure about how I can select these values from the table, and how can I "play" with these values. Even don't know how to retrieve the current number of concurrent calls per gateway or per subscriber.
And what to do with these selected values? Store it in an avp and then do some checks against it?
I am reading the module docs, especially sqlops, but I think I can't see the wood for the trees.
I hope somebody can give me suggestions (or an example) about this.
using dialog module is one way.
Personally I am using the htable module for this purpose, preferring a lighter version. When a new call comes, I store the user id using the call id as key. Then using the user is as key I count the active calls. When bye goes through, a decrease the number of calls. The limits you can store in another htable or database. Auto-expire deals nicely with missing bye.
Same you can achieve by replacing htable with a database table, at the expense of more db queries.
Also, check ratelimit module of other kind of limits that you may find useful.
Cheers, Daniel
Daniel,
Daniel-Constantin Mierla wrote:
using dialog module is one way.
Personally I am using the htable module for this purpose, preferring a lighter version. When a new call comes, I store the user id using the call id as key. Then using the user is as key I count the active calls. When bye goes through, a decrease the number of calls. The limits you can store in another htable or database. Auto-expire deals nicely with missing bye.
I used to do it this way before the 'dialog' module came along. :-)
Do you run into any complications from doing this that arise from potentially complicated dialog states, which the dialog module can handle but not this implementation? What about forking etc?
-- Alex
Hi Alex,
On 20.08.2009 13:51 Uhr, Alex Balashov wrote:
Daniel,
Daniel-Constantin Mierla wrote:
using dialog module is one way.
Personally I am using the htable module for this purpose, preferring a lighter version. When a new call comes, I store the user id using the call id as key. Then using the user is as key I count the active calls. When bye goes through, a decrease the number of calls. The limits you can store in another htable or database. Auto-expire deals nicely with missing bye.
I used to do it this way before the 'dialog' module came along. :-)
Do you run into any complications from doing this that arise from potentially complicated dialog states, which the dialog module can handle but not this implementation? What about forking etc?
parallel forking is same case as for dialog. I am using it a lot for channel reservation, like: when invite comes, I reserve the channel, in failure route or when getting bye, I free the channel. The rare case when parallel forking happens upstream, config becomes a bit more complex, but had no situation like this so far. However, if I have to limit on destination basis, some branches might be dropped as no more channels are available.
This solution can be updated nicely in case of a farm of sip server, by replacing the htable with memcached module (new in devel).
Cheers, Daniel
Daniel-Constantin Mierla wrote:
This solution can be updated nicely in case of a farm of sip server, by replacing the htable with memcached module (new in devel).
Well, memcached may be a much faster and distributed key-value cache store, but I think using it for IPC (as opposed to, say, a cache!) is fundamentally committing the same fallacy as the "Database as an IPC mechanism" anti-pattern. Except that the outcome is not quite as harmful from a quantitative perspective.
On 20.08.2009 14:34 Uhr, Alex Balashov wrote:
Daniel-Constantin Mierla wrote:
This solution can be updated nicely in case of a farm of sip server, by replacing the htable with memcached module (new in devel).
Well, memcached may be a much faster and distributed key-value cache store, but I think using it for IPC (as opposed to, say, a cache!) is fundamentally committing the same fallacy as the "Database as an IPC mechanism" anti-pattern. Except that the outcome is not quite as harmful from a quantitative perspective.
right, sometimes we have to live with what we have :-). anyhow, shared memory is clearly defined as IPC mechanism
Cheers, Daniel