How do I create a SIP trunk?


#1

I have two accounts (phone numbers) with a voip provider. How do I create a sip trunk or group like you do with zap lines? I’ve found alot of sample configs for zap trunks but can not figure out how to make a sip trunk? Is it possible?


#2

The reason that you have zap ‘groups’ is that you have ‘physical’ channels that need to be grouped together in order to treat them in a certain way. With SIP the channels are ‘virtual’ and therefore no grouping is necessary, with the idea that if you dial ‘SIP/myprovider’ multiple times you will access that provider without any problems (up to the number of channels you have provisioned with your service). Whereas with zap, if you always try to address the same channel it may be busy, therefore you want to ‘hunt’ across via a grouping mechanism to find the next available channel.

If you want to be able to use the two accounts, then you will have to do multiple Dial commands using the n+101 failure scenario to roll over.


#3

Hi,

I got the exactly same problem, I really need something that will work the same way as the zap group. The reason for this, is that I’m using sip devices with multiple channels but I want to round robin the calls between the different device instead of fallback in order in the second one and so on if the first one give me congestion.

If someone have any suggestion on how I can do this, it will be really appreciate.

Thanks !


#4

That’s the thing, the first line will probably not give you congestion, unless your provider limits the number of calls you can make. If so, as suggested previously, use the n+101 concept in your dialplan. See this topic for an example.


forums.digium.com/viewtopic.php?t=6162


#5

Thanks for input, but that does’nt help me more. I still got the same problem. Because I want to load balance my calls thru those sip devices.

Let say I have 4 sip device been able of 4 channels each. Until I reach the 4th channel used, I did’nt get any congestion. That means device #1 will have the more calls and device #4 the less. I would like to be able send calls in round robin to those devices, so the will get balance of the calls.

Please advice.
Thanks !


#6

Hm, the some creative work in your dialplan is still the answer. Use a variable to track the last used line maybe? Each time a call is made, increment the variable and reset it to 0 if it equals 4.

If line 1 then goto line 2
etc.
If line 4 then goto line 1


#7

Thanks for your advise, I finally decide to write a macro using the ramdom app for solving my issue.

For information, i post my macro here, so other people searching for this kind of behaviour will get a start onto how doing it :

[macro-rndvb]
exten => s,1,SetVar(nbvb=0)
exten => s,2,SetVar(connectiona=vb01)
exten => s,3,Random(50:100)

exten => s,4,SetVar(connectiona=vb02)
exten => s,5,Goto(s,100)

exten => s,100,SetVar(nbvb=${MATH(${nbvb}+1)})
exten => s,101,Dial(SIP/${MACRO_EXTEN}@${connectiona})
exten => s,102,GotoIf(${DIALSTATUS} = “CONGESTION” & ${nbvb} < 2?2)
exten => s,103,Hangup

If you have more than 2 devices, you just have to split the random according to it. For example, with 4 device you’ll get Random(25:100)
3 times and the expression will be ${nbvb} < 4?2) instead.

Hope this help somebody !


#8

Muppetmaster showed the only reliable way:

Jump to Siptrunk1, then check for “busy” or “unavailable” and have a
GotoDialstatus jumping to the next SIP trunk.

Do this conditional branching 3 times and you cover all 4 sSIP trunks without “random guessing”.

The last trunk should play a message on “unavai…” like
"All trunks are busy, please play with a bus…"

See the branch of Stegie’s example, this is the state you branch on (either busy or congestion or unavai…depends on ISP).


#9

You’re right, but in my case, I absolutly need the random thing, cause I want to balance my calls going to those sip device, not the first available. This is why a sip trunk working by group exactly like the zap channel would be great.


#10

Well…you could post a feature request to their tracker.

Indeed, a “SIP pool” function could be handy for many peeps.
Like a ZAPATA.conf, where you define many sip provider accounts and then configure them like

group1=trunk1&trunk2&trunk3
strategy=hunting

etc.