[asterisk-users] Multiple Outbound SIP Trunks

Joshua Colp jcolp at digium.com
Fri Jul 28 04:12:54 MST 2006


----- Original Message -----
From: Aaron Anderson
[mailto:webmaster at psphacks.net]
To: Asterisk Users Mailing List -
Non-Commercial Discussion [mailto:asterisk-users at lists.digium.com]
Sent:
Fri, 28 Jul 2006 03:52:59 -0300
Subject: [asterisk-users] Multiple Outbound
SIP Trunks


> I have 3 sip trunks registered with an outside provider, however 
> asterisk always seems to work when going out the third trunk.  Any way 
> to round-robin this so that we can make more than one outbound call at a 
> time?

Currently chan_sip has no capability to group together "outbound trunks" as you can in zaptel. This is mostly due to the fact that on SIP you don't know that you can't send someone a call until you send it to them, or you keep track on your side based on predetermined rules.

You might need to end up using the GROUP capability to limit each trunk to one call each and have failover to the next. 

[macro-call-trunk]
exten => s,1,GotoIf($[${GROUP_COUNT(${ARG1})}=0]?avail:busy)
exten => s,n(avail),Set(GROUP()=${ARG1})
exten => s,n,Dial(${ARG2}||t)
exten => s,n,Hangup
exten => s,n(busy),Noop()

exten => _1NXXNXXXXXX,1,Macro(call-trunk|trunk-1|SIP/${EXTEN}@trunk1)
exten => _1NXXNXXXXXX,n,Macro(call-trunk|trunk-2|SIP/${EXTEN}@trunk2)
exten => _1NXXNXXXXXX,n,Macro(call-trunk|trunk-3|SIP/${EXTEN}@trunk3)

This is just really quickly done... 

Basically the macro checks to see if the group count for the trunk is 0, if it is then the current call is set to use the group (which means the next time group_count gets called while this call is up, it'll return 1) and the destination is dialed. Otherwise it gets returned to the dialplan and it tries the next trunk.

There may be other solutions out there but you could expand on this one so that a trunk could support, for example, 2 outbound calls at a time. You would just see if the group_count is equal to 2 and if so jump to busy, otherwise avail.

> Thanks in advance,
> Aaron

Joshua Colp
Digium



More information about the asterisk-users mailing list