rotate outgoing calls through FXO trunks

ameir1
Posts: 3
Member Since:
2010-07-12

We are running Trixbox 2.8.0.1 with a Yeastar TDM1600 card with 6 FXO ports. I would like a way where outbound calls are rotated among the FXO trunks. For example, first outbound call would use trunk 1. Next would use Trunk 2 (regardless if trunk 1 is free or not). Next Trunk 3, etc. Of course, if the trunk is busy, it would roll over to the next available trunk.
I also don't want to set up different outgoing routes for each trunk.
Thanks in advance!



cvander
Posts: 637
Member Since:
2006-06-26
I believe that you specify

I believe that you specify the trunk group as r0 instead of g0, that should cause the trunks to be used in a round-robin fashion.

Asterisk Channel Reference

-Chris



ameir1
Posts: 3
Member Since:
2010-07-12
does that work with Dahdi channels as well

the reference mentions zap channels. Will it work with dahdi channels as well?



cvander
Posts: 637
Member Since:
2006-06-26
Lazy...

It would only take you 30 seconds to try it and find-out.... I'm not running asterisk 1.6, so you'll have to try it yourself.



ameir1
Posts: 3
Member Since:
2010-07-12
server is located in customer's office

Ya, i just don't have access to the server now. but i'll try it later on.



stonet
Posts: 103
Member Since:
2008-02-28
Trunk Rotation

I was not aware of the trunk rotation r0 option and will certainly try it later in the day when the server is lightly loaded.

I have achieved trunk rotation quite simply by placing the following code in extensions_custom.conf:

[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(Start Trunk Rotation - Using trunk: ${OUT_${DIAL_TRUNK}} Caller: ${REALCALLERIDNUM})
exten => s,n,Set(TRUNK_GROUP=${OUT_${DIAL_TRUNK}:0:4})
exten => s,n,Gotoif($["${TRUNK_GROUP}" = "ZAP/"]?rotaryhunting)
exten => s,n,MacroExit()
exten => s,n(rotaryhunting),NoOp(Start Alternating Hunt - Using group: ${TRUNK_GROUP} Caller: ${REALCALLERIDNUM})
exten => s,n,Set(NUMBER_TRUNKS=3)
exten => s,n(loop),SetGlobalVar(NEXTLINE=$[${NEXTLINE} + 1])
exten => s,n,Gotoif($[${NEXTLINE} exten => s,n,SetGlobalVar(NEXTLINE=1)
exten => s,n(noreset),Dial(${TRUNK_GROUP}${NEXTLINE}/${OUTNUM},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,NoOp(Trunk busy retrying)
exten => s,n,Set(NUMBER_TRUNKS=$[${NUMBER_TRUNKS} - 1])
exten => s,n,NoOp(Tries left: ${NUMBER_TRUNKS})
exten => s,n,GotoIf($[${NUMBER_TRUNKS} > 0]?loop)
exten => s,n,NoOp(Run out of trunks)
exten => s,n,Playback(all-circuits-busy-now,noanswer)
exten => s,n,NoOp(Exiting Trunk Rotation)
exten => s,n,Macro(hangupcall,)
exten => h,1,Macro(hangupcall,)

You also need to place NEXTLINE=1 in globals_custom.conf to define a global variable NEXTLINE

Line 2 defines which trunks are to be rotated, here it assumes that it is a number of Zap trunks with name starting with ZAP/, if not you need to adjust
Line 1 TRUNK_GROUP variable to read the required number of characters and Line 2 to the name of the actual trunks you are using. You also need to adjust Line 5 NUMBER_TRUNKS variable to equal the actual number of trunks to be rotated.

This should achieve what you need, it is working consistently for me. Thanks go to gbrook who sowed the seeds of the idea in a post on this forum. Hope it helps.



Astrosmurfer
Posts: 643
Member Since:
2009-12-28
Can I ask...

Can I ask why trunk rotation is needed? I'm not trying to dissuade you from your goal, I just can't see the use case and I'm curious.



stonet
Posts: 103
Member Since:
2008-02-28
The Reason i needed it is

The reason I needed it is because each individual trunk comes with an individual bucket of minutes so I needed to spread the traffic as evenly as possible over the group of trunks.



Astrosmurfer
Posts: 643
Member Since:
2009-12-28
Thanks. I see now.

Thanks. I see now.



bobw
Posts: 2
Member Since:
2008-05-12
trunk rotation sip trunk rotation

thanks for sharing the information.

trying to follow your instruction to rotate server sip trunks but failed. things i have done:
place NEXTLINE=1 in globals_custom.conf to define a global variable NEXTLINE;
placing your code in extensions_custom.conf, and replace ZAP with SIP and updated total number of trunks which i have 8;

After updating, i am no longer making any calls.

Hope you can shed some light on the issue for us.

Many thanks,

Bob



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.