Calls between two different Contexts

Hi All,

Are there any parameters that we could configure inside any given contect example [from-internal] that restrict the number of concurrent calls between phones belonging to that context and phones on other contexts?

like for example: count=5

What Iam trying to achieve is limiting the number of concurrent IP ext-ext calls between extensions registered to the same Asterisk server if these extensions are separated by a limited bandwidth WAN circuit.


Remote corporate office with 10 users registered to Asterisk server that’s hosted at the company’s Head Office across MPLS private WAN.


1- Set a limit of 5 concurrent calls from that remote office over the WAN to other remote extensions, by doing this we guarantee quality by NOT oversubscribing valiable WAN bandwidth.

2- Only use G729 for calls between extensions from different contexts while using G722 for calls between extensions of the same context. This will provide excellent call quality for calls over the LAN, while conserving bandwidth for calls over the WAN.

Has anyone thought about these requirements before?

Your comments are very much appreciated.

The only way I see this is possible is to create a SIP trunk (or multiple trunks one per context) using and on this trunk configure the number of concurrent calls and also specify the CODEC to be used (over the trunk).

Not sure whether this will even work or not, needs testing.

Has anyone done anything like that before?

  1. When extension is dialed You can check global variable. If this variable id >5 then don’t connect and play ‘busy’.
    When call is legal set chacked var+1, when call id disconnect -1. That will handle maximum concurrent calls but You have to write that dialplan yourself.

  2. i have no idea how to set up codec selection depending on context. (i think it is impossible by settig codec=g729,g722)

mmmm have you done this before?

You will also need to use locks, to ensure that you don’t have races between two channels trying to increment or decrement at the same time. Making sure that you decrement at the end of call may be difficult.

I didn’t done exactly this scenario, byt counting, checking and resetting variable to starting positon - yes i did that.
everything can be found here