Hi,
what do you want exactly? you want a maximum of 50 concurrent calls through one trunk and then go to the other trunk?
Or do you want just first 1-50 calls through the first trunk, 51-100 calles through the second trunk?
First solution:
you can set a call-limit in sip.conf at the peer configuration of your trunk:
call-limit=50
Then you could set in the dialplan
exten => _X.,1,Dial(SIP/trunk1/${exten})
exten => _X.,n,GotoIf($["${DIALSTATUS}" = “CONGESTION”]?trunk2)
exten => _X.,n(trunk2),Dial(SIP/trunk2/${exten})
exten => _X.,n,GotoIf($["${DIALSTATUS}" = “CONGESTION”]?trunk3)
exten => _X.,n(trunk3),Dial(SIP/trunk3/${exten})
exten => _X.,n,Hangup()
Second solution:
I would work with the asterisk database.
exten => _X.,1,Set(COUNT=$[${DB(test/count)}+1])
exten => _X.,n,Set(TRUNK=$[${COUNT}%150])
exten=> _X.,n,GotoIf($[${TRUNK}<50]?trunk1)
exten=> _X.,n,GotoIf($[${TRUNK}<100]?trunk2)
exten=> _X.,n,GotoIf($[${TRUNK}<150]?trunk3)
exten => _X.,n(trunk1),Dial(SIP/trunk1/${exten})
exten => _X.,n(trunk2),Dial(SIP/trunk2/${exten})
exten => _X.,n(trunk3),Dial(SIP/trunk3/${exten})
exten=> _X.,n,Hangup()
The dialplan i wrote has not been tested, so some errors can be in!