Real Least Cost Routing (multiple trunks)

Here’s a thought, and after being awake for 30+ hours i don’t think i can tackle it right now. I was thinking to myself, how can i build some more suitable LCR rules. Well here’s what I’m thinking…

configure multiple trunks

/etc/hosts:
IP ADDY sip1.provider.com
IP ADDY sip2.provider.com
IP ADDY sip3.provider.com

TRUNK1=sip1.provider.com ; proxy 1
TRUNK2=sip2.provider.com ; proxy 2
TRUNK3=sip3.provider.com ; proxy 3

in some calling context…

exten => _NXXNXXXXXX,1,System(ping -c 3 $TRUNK1 > trunk.ping)
exten => _NXXNXXXXXX,n,Read(trunk.ping)
exten => _NXXNXXXXXX,n,GoToIf($sumofping =< 30ms?n:50)
exten => _NXXNXXXXXX,n,Dial($TRUNK1/$EXTEN,30,trf)
exten => _NXXNXXXXXX,n,Congestion()
exten => _NXXNXXXXXX,n,Hangup()
exten => _NXXNXXXXXX,50,System(ping -c 3 $TRUNK2 > trunk.ping)
exten => _NXXNXXXXXX,n,Read(trunk.ping)
exten => _NXXNXXXXXX,n,GoToIf($sumofping =< 30ms?n:100)
exten => _NXXNXXXXXX,n,Dial($TRUNK2/$EXTEN,30,trf)
exten => _NXXNXXXXXX,n,Congestion()
exten => _NXXNXXXXXX,n,Hangup()
exten => _NXXNXXXXXX,100,etc etc

ok i guess ya get the drift of what im doing. yeah im not sure how $sumofping is going to work yet but im sure ill think of something simple. anyway, if anyone finds this interesting please feel free to post. i think this would be a good script / help to the community. reguards.

if anyone is interested in this… PM, i wrote my own script which works quite well and very fast, however the code is so ugly id rather not post it. (i am no programmer) :wink: but i would like to discuss this further with anyone who’s as excited as i am