Updated: 2008/01/17

Setting up a "Conferenece call" server using Asterisk

This note presents some hints and information necessary to build a conference call server using Asterisk. It is a very niche document which does not intened to provide step by step procedures, but may be useful in understanding backgrounds and what is going on for those who are studying Astersisk specifically for this purpose.

What is Asterisk?

Asterisk is an open source server application which replacea a conventional PBX. In fact, since most of the communication is IP based, there is no physical restriction on where the phone units are located. Once you have a running system, you can call other phone units (maybe IP based hardware phones, or desktop applications similar to Skype) using local extension numbers or transfer incoming calls. Take an office for example. If there is a staff telecommuting (working at home), he/she can join the PBX over IP. This person will be reachable via local extension numbers, and customers calling into the office can be transferred, all scemelessly. Imagine transferring the incoming caller to a center located overseas. The segment between the Asterisk server (which the caller originally dialed) and the call center located overseas is IP based, therefore no additional costs for either parties involved.

Now days, Skype maybe be practical in setting up a basic conference call.
Here are some advantages that Asterisk may have in such applications

Prior to installing.. Some background

* Be aware that there are three different versioning schemes, 1.2, 1.4, 1.6 which are all current in a sense.
I believe there is no major difference in terms of the scope of this article (Although I have not yet tried 1.6)
* You need extra hardware (PCI cards) to connect to analog or ISDN phone lines.
Or to be specific, my understanding is that this is exactly where the developpers of this application expect a profit from while making the software free and open.

Now, it is important to understand that the above mentioned interface cards also function as a timing (clock) source to drive some of the features. For example, in the case of establishing a "one on one" call, timing is less critical as it is only the matter of tranfering the audio packets from one client to another. In the case of a conference call, tasks held by the server such as decoding, mixing, and re-encoding audio involves synchronization of multiple calls. This demands that you either have at least one of these cards along with its drivers installed, or else a "dummy" kernel module which provides the clock.

It may also help to know that this driver kernel module has two different names for historical reasons. During major updates of version 1.4, the developpers had learned that the old naming "Zaptel" was a trademark of an exisiting corporate of the same name. This had been later renamed to DAHDI. Therefore, in older versions, you will find terms among drivers and configuration files such as "Zapata", or altered to "Zap", "Zaptel." If you come across such terms in older documentation, you can almost always assume that it can be read as DAHDI. Version 1.2 -> Zapata (or Zaptel, Zap, etc)
Version 1.4 -> Zapata, DAHDI both coexist.
Version 1.6 -> Only DAHDI

Installation

If your Linux distribution provides binary packages, it is probably a valid option. There are also 1CD installers that setup an Asterisk dedicated server on fresh drives. On Debian 4.0 Etch which I oftenuse, an Asterisk package based on version 1.2is available.
This article explains basic procedures of installing a 1.4 based distribution on a Debian 4.0 Etch, as one of the purposes of my setup was to confirmwhat is new in 1.4, relative to 1.2 which I have run for a few years.

Assuming you have a clean installation of Debian Etch, here are the minimum packages you want to install using apt-get.

The kernel headers are necessary to build the dahdi-linux kernel modules.
doxygen is only necessary to build the documents and is optional.

* Required tar ball
http://www.asterisk.org/downloads
(You will find "Asterisk Downloads" on the right side of this page)

Unless you already have the DAHDI modules installed at the time of building Asterisk, it does not allow you the option to buildthe MeetMe (conference) application.
I thereforeadvise to install the above three packages in the listed order.

As mentioned in the README file, the the basic procedure for building these packages will be,

$ ./confiugre
$ make menuselect <-- Attention!!
$ make
# make install
Note the second line, "make menuselect".
This launches a console based application which displays a menu full of options on what to build and what not to. As mentioned earlier, if you enter this menu without installing the DAHDI packages, you will notice that the option to build the MeetMe option is crossed out.

Also be aware that default voice messages are automatically downloaded via HTTP from the developer'sweb site in the process of "make install." You probably want to confirm you have a connecting to the Internet at this point of installation.

Configuration files

The default path to store configuration files is "/etc/asterisk"
However, by default Asterisk does not create a single file under this path.
The easiest way to prepare a set of configuration files is to follow the message which appears after "make install" succeeds by entering the following command.

# make samples
Be aware that some of the examples in the created files are NOT commented out enabling features for demonstration, and may cause security risks.
Since the settings are dividedinto multiple files for each feature, I suggest that after creating the setting files, you once evacuate them to another directory, then copy them back as necessary.
# mkdir /etc/asterisk/backup
# mv /etc/asterisk/*.conf /etc/asterisk/backup
# cp /etc/asterisk/backup/(Preferred setting file) /etc/asterisk/

Here are the files I had setup for this specific project.

chan_dahdi.conf DAHDI related
extensions.conf Configure extensions
iax.conf Register clients
logger.conf Log related
manager.conf Settings to permit remote manager applications
meetme.conf Conference call related settings
modules.conf Specify modules to load or not load.
musiconhold.conf Required to play MOH(Music On Hold)
oss.conf Enable sound cardso that I can audit conferences from the server's LineOut
The rest are files, I have retrieved only to avoid warning messages and have not yet dug their features.

Create a conference room

Simply add the following line to meetme.conf.

conf => 1000
You have now created "conference room 1000"
Be aware that at this point, you are only tagging the room with a number, and not specifically creating a room which can be entered by dialingextension 1000.

Setting up clients

Each client registering itself to the PBX must have an account.
The many ways of connecting to the PBX are referred to as "channels", which each also have their own configuration channels.

Here is a list of some options to choose from.

In this setupI am registering clients connecting using IAX2 for its conveniencein remote access. (Port 4569:UDP)
Clients must be listed in iax.conf.

[user01] <= The text between brackets is the user name.
type=friend <= Specify that this client can both "call out" and also "be called."
host=dynamic <= Specify that the client will be connecting from random addresses.
secret=pass <= Login password of your choice.
context=default <= A list of extension numbers this user can dial.(Details are noted later)

[user02]
type=friend
host=dynamic
secret=pass
context=default
We now have two user accountsready to be connected.
At this point, you should be able to connect to the PBX server using software clients supporting the IAX2 protocol such as Zoiper and iaxComm.

Setting up extensionnumbers

So, now we have two clients that can connect to the PBX. However, since neither have an extensionnumber assigned, there is no way to call each other. To assign an extensionnumber to specific functions (including calling others), we modify extensions.conf.

A typicalline in this file will look like this.

[context_name]
exten => Extension number, Priority, Command
To be correct, "Command", the action to be taken when dialed, is referred to as "Application." To learn available actions you will want to look into what the community calls the "Application reference."

Also, context_name in the above example is what matches the "context" parameter previously specified in iax.conf.
In this case, users belonging to the [default] context can only dial extensions listed under [default] in extensions.conf.

In the case you want to setup so that dialing extension 100 will,
1. Answer the phone
2. Playback a recording
3. Hangup
you will need to write as follows.
exten => 100, 1, Answer()
exten => 100, 2, Playback(file_name)
exten => 100, 3, Hangup()

<= Do not specify file extension of audio file (Reasons noted later)

As this example shows, dialing an extension will call the commands in order of the priority.
Priorities of the second line and beyond can be substituted with a simple 'n' as seen in the next example.

Here is what I had setup this time.

[default]
exten => 1000, 1, Answer()
exten => 1000, n, Wait(1)
exten => 1000, n, MeetMe(1000, rM)
<= The following applies to clients having their context set to "default"
<= Answer
<= A short wait for older clients who do not respond right after the connection is established
<= Enter conference room 1000

*Options of MeetMe
r = Start recording when someone enters conference
M = Playback MOH(Music On Hold) when there is only a single person in conference
exten => 01, 1, Dial(IAX2/user01, 60, tT) Assign extension 01 and 02 to each of the user.
exten => 02, 1, Dial(IAX2/user02, 60, tT)
Take a close look at these two lines. When specifying a connected client such as in the case of using the Dial() application, you specify by "Channel/User name." The above example can be read as "user01 connected via the IAX2 channel(protocol)."
It is probably more accurate to think of extensions.conf as "a list of actions to take when a specific number is dialed" rather than "what extension number is assigned to who."

Running Asterisk

Although I own a TDM400(2FXO, 1FXS analog card), since for this project I only intend to have software clients connected, I will use the dummy timing source.

# modprobe dahdi_dummy

Launch Asterisk
# asterisk

To control and monitor the server, you can use the CLI based interface that the same binary provides. Two commands that maybe worth knowing is "help" and "exit."

# asterisk -vvvrThe multiple 'v's are specify the verbosity level and is optional.

Others

About omitting extensions on file names

When playingback or recording audio files within asterisk, the file extension is generallyomitted.
This is because of the format conversion that is almost always by the server prior to streaming it to/from clients, Asterisk is designed to search for the format with the least cost in terms of CPU time.
For example, you want to play a file named "voice_message" to a client connected via the GSM codec, asterisk will first look for "voice_message.gsm". If not present, it will then search for a file of another format.