week we took a close look at the heart of an Asterisk VoIP server: the dialplan.
Today we’re digging under the hood of Asterisk’s channels. Channels and
dialplans are what make it all go. A channel is any configured connection between
your Asterisk server and another VoIP server. Every individual call is then
placed or received on a separate channel that is created for the call, then
torn down when the call is completed. As you can see, Asterisk terminology can
drive you batty. But it really does make sense as you get used to it.
The two fundamental VoIP channels for Asterisk are SIP and IAX. These are named for the protocols that are used on them. These are configured in sip.conf and iax.conf.
(A peek ahead: Two other channels that you may need to learn about are FXO
and FXS. These interface with the PSTN (Public Switched Telephone Network.)
FXO means “Foreign eXchange Office” and FXS is “Foreign eXchange Station.” Use
an FXS device to connect an analog phone to a VoIP network, and an FXO card
in your Asterisk server to interface with the PSTN over an analog telephone
line. We’ll get into these in more detail in future articles.)
There are a number of VoIP protocols/channels that you’ll encounter. Here are just a few:
There are far more than these, and Asterisk supports all of them (more or less), but the two you’ll use the most are SIP and IAX. You’ll probably see H.323 mentioned a lot. It is the grandmommy of VoIP protocols, designed to move voice, fax, video, and data over IP networks, and to maintain compatibility with the PSTN. Carriers use it a lot; in fact it carries the bulk of the world’s VoIP traffic, but it has not caught on with the do-it-yourself VoIP crowd. Asterisk supports it, with a bit of help. We’re going to focus on SIP and IAX.
SIP is the darling of the VoIP world; virtually all new VoIP devices support
it. SIP stands for Session Initiation Protocol. (See this tutorial
for a detailed look at SIP—and H.323.) SIP connects two VoIP endpoints by setting up and
tearing down both voice and video calls. It does not move the data, which in
VoIP terminology are media– that is handled by RTP, the Real-time Transport
Protocol. SIP sits in the Application Layer of the Internet Protocol Suite,
which I’m not going to get into here, but you should know about. (See Resources
for more information.)
Asterisk acts as a SIP client, SIP server, and media gateway. A media gateway translates between different protocols. This is how your SIP phones connect to the PSTN, and IAX and H.323 channels. We already did this in Getting Free Long Distance by creating incoming and outgoing IAX trunks to Free World Dialup, then creating contexts in the dialplan to connect these trunks to SIP phones. IAX is great for server-to-server because it is very efficient and can handle a much larger number of calls, and it traverses NAT firewalls with ease because it needs only a single port. SIP is very extensible and has more capabilities, but it’s a real pain for traversing NAT, and it can’t carry as much traffic as IAX.
According to the book “Asterisk: The Future of Telephony” the cool kids pronounce it “eeks.” There are two versions: IAX1 and IAX2. IAX1 is long obsolete, so IAX means “IAX2.” IAX is a native Asterisk protocol- “Inter-Asterisk eXchange.”
IAX needs only port UDP 4569, so getting it past even a NAT firewall is easy.
It trunks multiple sessions that are going to the same destination into one
data stream, which saves bandwidth and CPU cycles, and lowers latency. It has
a built-in jitter buffer, and is extremely efficient in encoding and decoding.
IAX won’t leave you hanging if a call is abruptly interrupted, but will make
sure that the call is cleanly terminated.
What it doesn’t have is widespread support in IP phones, though it is growing. Trunking only works with other Asterisk servers. SIP can transport just about anything, but currently IAX is limited to voice and video. It is an open protocol with an active development community, so expect continual improvements.
Putting it all together
So now you know the three magic Asterisk configuration files. sip.conf and iax.conf define your connections to the outside world. extensions.conf tells your local Asterisk server how to process calls inside your network. Next week we’ll start putting it all together.
The OSI Reference Model – Understanding Layers
Asterisk: the Open Source PBX