Limit Concurrent Calls per DID using one peer in sip.conf

We have an ivr setup on Asterisk using SIP connectivity from Telco. The Telco has given us 50 did numbers for a single trunk. Now if i want to limit the number of concurrent calls per did, which should be the best way. The number of concurrent calls will be different for all dids.
I cannot use call-limit in sip.conf, as there is only one peer for the trunk and all the dids use the same config.
So i can only think of implementing this using a database table or a flat-file, and doing a select-insert-update every time a call comes-in and every-time the call hangs-up.
But is there any more suitable and less latency method that i am not aware of?

call-limit is a deprecated option you can use the dial plan function GROUP_COUNT() in combination with GotoIf()

But still I am wondering. Why you want to do something like that? Give the users enough channels so they can use the telephony system with no issues. One phone can use up one or two lines anyways.

Thanks for the answers !!
I wish to give the users as many channels possible but i have to accommodate more number of users in this limited setup, and i do not want user-A complaining of busy tones, while user-B consumes all the bandwidth. So i want to assure each user a fixed number of channels and make sure that no one else is using those channels.

How can a user consume more bandwith that he needs if he only has ONE PHONE? Usually that means one user <-> one call. OK, with call waiting, it’s two calls. But that is it. I still can’t see how a user can take up too much bandwidth on a VoIP phone system.

Its an IVR setup, as i wrote in my first post. ivr setups are not for the client to call and listen to the audio clips :smile: . Its for the end-users who call on the advertised number to gain some information. Here i think i have wrongly used the word ‘user’, it should be ‘client’. A client takes a did number from us and upload an audio file for their end-users. Now each client can have many end-users calling on their respective dids at the same time, and all these calls will land on our platform and after doing a db look up based on the did number on which the call has come, asterisk will play out the respective client’s audio file.
Hope its clear now :smile:

As ‘ambiorixg12’ mentioned, GROUP and GROUP_COUNT functions are your best friends in this case.
Have some thing like this in your dialplan to limit the number of calls on DID. It is assumed MY_DID and DID_LIMIT are some dialplan variables set with proper values.

… …
… …
same => n,Set(GROUP()=${MY_DID}) ;Set Group for your DID.
same => n,GotoIf($[${GROUP_COUNT(${MY_DID})} > ${DID_LIMIT}]?limit_exceeded,s,1:) ;If Call Limit Exceeded
… …

–Satish Barot
satish4asterisk@gmail.com