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-Constantin Mierla
*
http://www.asipto.com/