Here are two protocols that I have played with using Asterisk. They are the most common in my opinion as well, IAX and SIP. Of course you’ve also got H.323 but I’ve never played with that one.

So first of all, I bet you are asking yourself, what the hell am I talking about protocols and geese and tear ducts, oh my! Well, a protocol is simply a way that a call is made. It’s the system that it goes through. SIP is going to be through a standard telephone line. If you connected your Asterisk box to your home phone line, that’s SIP, thus you would have to set it up using SIP specific terms and utilizations. IAX however is a bit more interesting to me. IAX is a protocol that Mark Spencer actually created. It’s in the second version now, so it’s usually referred to as IAX2. Basically, it lets two Asterisk servers communicate with each other. I won’t go into much more detail in this post about it.

Now that we know there is a difference between the two, what are we going to do about it? Well, why not learn how to configure them first? So, let’s write a simple configuration file that will enable us to connect using the protocol and actually make our first call. (If you have asterisk installed already.)

You’re going to need a couple of things to write a config file for SIP. First of all, if you’re using linux for this, which I HIGHLY reccomend, your config files will be located in etc/asterisk/ In there you will find lots and lots of .conf files. Right now we will look at SIP.conf. Right now, there is nothing important in there. It’s all sample stuff that you probably will never use. So if you want, feel free to clear out this file at this time. Everything in there is commented out anyway.

In this file you will need some category’s and a couple of context’s. First of all, you need a [general] category which you will see below. Under the “General” category you need a context. Call it “Line1” for now. Under [handset1] you will need a type which we will use “friend” which basically issues a link going back and forth in between the two lines. Then we will set the context for this. It’s going to be “phone1”. Secret will be the password that Asterisk uses to talk to the analog/digital phone line converter. The host is the IP address of the computer you’re running asterisk on. (I really reccomend getting a seperate IP from your internet provider for the Asterisk box if you plan on running with SIP behind a network.) Lastly, the DTMF mode, rfc2833 is a standard for this and it works the best out of the other options, so I reccomend just sticking with it.


; handset1 describes the line in * that connects to the handset

; PSTN is the line that connects the PSTN line into the box.

That is a basic SIP.conf. It will get you in and out of the box pretty well. Now let’s go over an IAX.conf. Firstly, under general, disallow and allow. By using all under disallow, it will disable the use of any and all codecs in compression. But this is a HUGE bandwidth eater. So underneath that, place allow=ulaw. ulaw is probably the best compression out there with the least loss in quality. I would reccomend this highly. DTMF tones come through beautifully with ulaw whereas in others they tend to get kinda garbled.

I reccomend the service Nufone. For IAX they will charge $0.02 per minute throughout the US, Canada and Puerto Rico I believe it is. You’ll notice the register command above the codec allowances. That sends the user:pass combo to that server. When using Nufone, they will provide you with the server name that they want you to register with.

In the second half of this .conf file, you have 3 context’s. First the type, which is a user in this case. Basically it allows you to send information to them. Next is the secret again, which of course is your password. Lastly is the context in which you will be using it in your dial plan. I chose to use incoming because on my dialplan I named the incoming calls “incoming” obviously. We’ll go over that at a different time though.

register =>
; This is how * connects to nufone.

So now that we have gone over the basics of IAX and SIP I know you have some questions. There have been some things that I skipped over because I didn’t think anyone would want to read a 50 page blog post about SIP and IAX. If you have any questions or if I didn’t cover something that needs covering, leave a comment and let me know. Thanks guys!

(Visited 41 times, 1 visits today)

Don't miss a post! Subscribe to the RSS feed or by email today!

AddThis Social Bookmark Button
Related posts:
    No related posts

One Response to “IAX and SIP”

  1. i want to know the technical differences b/w SIP n IAX
    would you please help me in that .This is Kevin over here

© 2007 Asterisk VOIP Tips | Powered by WordPress | Theme originally by Bob, heavily tweaked.