Asterisk Integrated Services Digital Network

Integrated Services Digital Network

ISDN is a twisted-pair, digital multiplexing standard for PSTN and data applications. Although used widely around the world, it is not well known in North America. For most data applications, ISDN has been displaced by ADSL, coaxial cable, and FTTH (fiber-to-the-home) technologies, which offer much larger bandwidth at competitive rates. It remains in use for voice and video applications. We’ll look at those here.

ISDN itself is a giant topic, and because it is an older technology, it is well covered in other texts. Do not expect much depth here. We discuss ISDN only in the context of its relevance to Asterisk.

ISDN Basics

An ISDN connection provides two basic channel types: B and D. (More specialized channel types exist but are not in wide use, and are not covered here.) A single B (bearer) channel can be equated, roughly, with a single analog telephone line: You can carry on one conversation on that channel. Where it differs is that a single physical line pair can carry multiple B channels, making better use of the existing wiring. The data is transported in digital and not analog format, which means you can’t connect an analog telephone to the line and expect to hear anything. The digital transport usually delivers better sound quality when everything is properly configured.

The D (data) channel carries signaling information about the B channels on the circuit.

The differences between the B and D channels are as follows:

    • The B channel is, for our purposes, a voice channel. (In a non-Asterisk installation, it could carry data.) A B channel provides 64kbps of bandwidth.
    • The D channel is data only, but is dedicated for signaling purposes. Depending on the interface type, the D channel can be 16kbps or 64kbps. The ISDN device—be it a telephone, PBX, or interface card—uses the D channel for call setup and teardown.

The following sections cover the two major types of ISDN connection: the basic rate interface and primary rate interface.

ISDN Basic Rate Interface

The entry-level ISDN service is called basic rate interface, or BRI, and is used in homes (in the world outside of North America) and small businesses. It provides two 64kbps B channels and one 16kbps D channel (which is why some refer to it as 2B+D) over a single line pair (two wires). You can attach ISDN phones, BRI ports on PBX devices, ISDN-BRI terminal adapters (which provide FXS ports for analog telephones), or ISDN-BRI adapter cards to a BRI.

To install and use BRI, you need to know what signaling type the carrier expects. There are two types:

    • 2B1Q

This (2 binary, 1 quaternary) is the signaling type used in North America. It is a linear coding type that supports a loop length of up to 5,500 meters (about 18,000 feet).

    • 4B3T

This (4 binary, 3 ternary) is the signaling type used in the rest of the world, including Europe. It is a block coding type that supports a loop length of up to 4,200 meters (about 13,700 feet).

BRI in the United States

ISDN never really caught on at the subscriber level in North America. Although there are many opinions why, the most common explanation given is that the size of the existing network made implementing ISDN to the suburbs prohibitively expensive. In North America, average loop lengths are much longer when compared to Europe, where ISDN circuits now make up more than 80% of installations.

Still, sometimes BRI makes sense, and in most jurisdictions it is a tariffed service, which means that some carrier (usually the incumbent telephone company) must provide it if it is technically feasible. Here are some reasons why you might consider BRI:

    • You are faxing and your analog lines are poor quality.

Faxing does not work well over IP, Analog is an option, but if your analog lines are noisy, you should consider BRI.

    • You need the sound quality and call-signaling features that only ISDN provides, but don’t need enough channels to justify PRI.

Features such as Explicit Call Transfer, DNIS (Dialed Number Identification Service), and COLP (COnnected Line identification Presentation) are ISDN services that can’t easily be replicated on analog lines. If you need these but don’t need more than six to ten channels, BRI is a real option. One thing is beyond dispute: In the circuit-switched, PSTN world, ISDN offers unparalleled sound quality.

Of course, the economics will vary depending on your location and the carrier. Be warned that most carriers that offer BRI don’t actively market it, so you may face challenges in getting anyone in the sales department to acknowledge that the service exists.

ISDN Primary Rate Interface

You can think of the PRI as the bigger, flashier brother of the BRI. In North America, PRI is provided over a T1 (23 B channels, 1 64kbps D channel) with 2 or 3 pairs (4 or 6 wires); in Europe, the E1 (30 B channels, 1 64kbps D channel). Again, you can only connect ISDN devices to a PRI circuit. Examples include the PRI interface on a PBX, a channel bank (which provides FXS ports for analog telephones), or an ISDN-PRI interface card. The PRI is intended for larger installations.

Nothing says a PRI must use all 24 channels. Some carriers provide partial PRI service (usually ten channels), sometimes at considerable cost savings.

PRI always implies ISDN. PRI service is supplied via a T1, but not all T1 circuits are PRI. Non-ISDN T1 circuits (also called in-band T1) can still be found in North America. In such circuits, call setup and teardown signaling is sent in the channel (CAS, or channel associated signaling) instead of via a separate D channel. This steals some bandwidth from each channel but makes all 24 channels available.

For voice applications, PRI is on its way to replacing non-PRI T1 connections completely. Its broad support and extremely fast signaling make it the easy choice.

Choosing an ISDN Card

This is a difficult question, and the answer depends on your specific circumstances and requirements. Here are some things you need to consider:

    • A card that’s excellent today may be mediocre tomorrow, particularly when compared with newer product in the marketplace.
    • Card performance can depend heavily on the driver software, which can change over time.
    • Support quality is subjective.
    • Performance requirements will depend on the intended use. Some products that would not be a good choice for the business market may be perfectly acceptable for the residential market.

Actually using an ISDN card in an Asterisk server is really quite simple, even if installation and configuration aren’t always trivial. There are a few different ways to get an ISDN card running with Asterisk. We touch on a few variations below.


All the installation examples in this book use a Debian Linux system. The installation procedure will differ on other Linux systems and may not work at all on BSD systems. If you are starting out, we recommend you follow the instructions completely and begin with a fresh Debian installation.

Determining Your Quality Needs

Most private Asterisk users are not hung up on sound quality and availability. Cost is likely the primary consideration here. If you aren’t planning to fax over the card, and you only need two B channels, any generic HFC-based BRI card will do. The cards are cheap and widely available. You’ve been warned, however: Installation can be challenging with these cards, and you shouldn’t expect amazing sound quality. If you can live with these limitations, this is a real option.

For business systems, the bar rises substantially. If you are replacing an older system you must at least match it in quality, unless you like doing battle with users and clients. If you value your career in this business, you’d best steer clear of generic cards.

Hardware Echo

Sadly, the echo problem remains. Any professional system connected to the outside world must have the highest-quality echo cancellation available, and this is generally achieved through a hardware echo canceler integrated into the card itself. The advantage over software echo cancellation is clear: The performance of hardware echo cancelers is historically better, and they don’t need to steal CPU cycles to achieve it.

Because echo cancellation is not easy to do well, these modules are accordingly more expensive. Nevertheless, in business applications, hardware echo cancellation is not negotiable for any system you intend to connect to the PSTN. Cards providing PRI to internal servers can get away without it because echo in local trunks is rare, but if you’re buying a card anyway, spend the extra money. You never know how you might need to use the card in the future.

Tail length is a performance parameter to consider when evaluating hardware echo cancelers. It determines the length of the reference sample when calculating echo cancellation. The rule of thumb is that the longer the tail length, the better the echo cancellation. In practice, it’s difficult to hear a difference beyond 128 milliseconds.

Server Load and Interrupts

In the early years of Asterisk, there was no affordable echo cancellation, so Mark Spencer and others wrote software to perform the cancellation. This necessitated breaking the in- and outbound audio streams into 1ms chunks. For this reason, all the standard ISDN cards in use today set interrupts at 1ms intervals for each B channel.

This historical artifact can lead to problems in some applications. You probably won’t notice this if you use a single PRI or BRI connected to modern server hardware. If you’re using a compact, embedded system, however, even a simple BRI with two B channels can cause problems under load. If you have a large system with multiple PRIs and interface cards, similar problems can occur. Enough interrupts can bring the most powerful system to its knees.

If you are faced with either of these circumstances, you have these options:

    • Find out how much a single system can handle and cluster them.
    • Install an ISDN-SIP gateway. These are black-box systems with an ISDN interface on one side and a SIP interface on the other, which connects to your Asterisk server. Be careful, though: Some of these systems are just Asterisk boxes themselves! You want real, dedicated translation.
    • Buy an ISDN card that solves the interrupt problem at the driver level. For example, Sangoma produced a special driver for its cards that sets an interrupt at 10ms intervals on a by-port, rather than by-B-channel, basis.
Internal Analog Fax Devices

If you’re connected to the PSTN via an ISDN connection but still use analog fax devices internally, you might run into another timing problem, particularly with long faxes. This is caused by different clock timings on the audio channels. The ISDN cards use the PSTN for their clock source; the analog interface cards use their own, usually internal (and often cheap and unstable) clock source. The result is a clock differential that is managed using a buffer. After two pages (on average), the buffer empties, and you lose a bit of audio, often enough to overwhelm the fax error correction. The result is usually a black line or gap in the fax image. In the best case, nothing is visible; in the worst case, the transmission ends prematurely.

Here are some things you can do to address faxing problems:

    • If you can do without a fax machine, going to software faxing on the server is a cost-effective alternative.
    • An ISDN terminal adapter attached to the same ISDN card as the incoming service will also solve the problem. If you attach the device to a different ISDN card in the same machine, you need to verify that the cards will operate in sync.
    • Cards from some manufacturers can be synced to each other via an internal cable that provides the clock signal from the ISDN card to the analog card.
Manufacturers and Drivers

There seem to be as many ISDN card manufacturers as people with an opinion about them. The products described here are a subjective selection, but have been chosen because they are used widely. Further exploration of the subject could fill another book.


Hardware and driver information provided here was current at the time of printing. Check this book’s website (, where we will post updates.


As the parent company and home of Asterisk, Digium ( has offered digital interface cards for several years now. (The early cards were analog only.) The advantage for the Digium cards is obvious: You always have drivers updated for the most current Asterisk release. In the past, these drivers have been middling in quality and there have been problems. With the new DAHDI driver generation, Digium is promising better performance.


Sangoma ( is a popular alternative manufacturer in North America, and was, until recently, purely a hardware company. They make both analog and ISDN interface cards and have a reputation for good technical support.

Open source purists may take exception to Sangoma’s use of a binary-only ISDN stack (for BRI). Sangoma’s response is that the commercial stack is certified for ISDN and has demonstrably fewer issues than the open source mISDN stack.

Generic HFC-Based BRI Cards

These cards have been sold in Europe for many years now, usually at bargain-basement prices. Support is rarely if ever provided, and at $100 to $150, it can hardly be expected. They are almost always used with mISDN.

Media Gateways

Just as you might use an ATA in place of an analog interface card for regular phones, you could use a “media gateway” for ISDN connections. This gateway converts an ISDN connection into one or more SIP accounts and vice versa. These are usually “black box” solutions, which are configured via a web GUI or over SSH.

Purely analog media gateways are simply ATAs (analog telephone adapters).


One major advantage is that a media gateway is often easier to configure than an interface card. You don’t have to open up the server and install the card, either. Configuring Asterisk is simpler because you only have to configure SIP. Finally, you don’t have to run telephone lines of any kind to the server; you install the gateway device in the wire room, connect it to the network patch panel, and put the server anywhere on the network that is practical.


Media gateways are generally sold on price and not on the quality of installed components, so manufacturers are tempted to use lower-quality interface cards, which can be problematic. Asterisk works best when using the ISDN clock; the clock signal is very stable, and a stable clock signal is vital, especially for conferencing. A media gateway does not pass this signal over Ethernet; the Asterisk server must rely on the system clock, which will vary in stability. Updating a media gateway is also more difficult, if it’s possible at all.

Whether one should choose an interface card or a media gateway is a regular topic of discussion in the Asterisk community. Both sides make good arguments, and you can run a successful system with either. What is best for you depends on the circumstances. If you need stable clock (you are conferencing or you have existing ISDN cards in your system), you’ll need an ISDN card. If you have physical access problems, or you need to maximize the simplicity of the system, go with a media gateway.

Asterisk Commonly Used Codecs

Commonly Used Codecs

The CLI command core show translation, which displays the table shown earlier, will show you which codecs are available on your system (namely, all those with numbers in their respective columns). The following list briefly examines the most commonly used codecs in Asterisk:


An Asterisk “classic” and familiar to anyone with GSM mobile phone service. The bandwidth is 13.3kbps, and the quality is acceptable, if not exactly overwhelming.

    • iLBC

iLBC is a sort of secret weapon for use in low-bandwidth situations. The sound quality is excellent, and the bandwidth is limited to between 13.3kbps and 15kbps (depending on frame size). Skype uses a variant of this codec. The problem with iLBC is that it is processor intensive; that is also why it is not implemented in very many hardphones.

    • G.711

Another classic, from the suite of ISDN codecs. This codec offers superb sound quality and requires 64kbps of bandwidth. This is standard for most calls traveling in corporate intranets and is also widely used for calls over the public Internet.

    • G.722

The chances are good that G.722 will eventually replace G.711; at the highest resolution, it offers a much better sound quality than G.711, but while requiring the same bandwidth (only 64kbps). Unfortunately, it not, as yet, supported by many telephones.

    • G.726

Offers the same sound quality as G.711 while needing only half the bandwidth (32kbps). In contrast to G.711, only the data that has changed relative to the previous voice packet is transmitted (similar to the way MPEG video works). The result is the same information transmitted with half the bandwidth. G.726 is not too burdensome, but still requires more processing than G.711.

    • G.729a

G.729a is a patented codec that needs only 8kbps and offers sound quality comparable to GSM. Licenses for Asterisk can be purchased from Digium ( It is not exceptional either in voice quality or performance, but offers a fair balance and is implemented in many VoIP telephones. As such, it is a good option when you need to conserve bandwidth.

    • G.729.1

G.729.1 is an extension offering bitstream interoperability with existing G.729 codecs, as well as a high level of configurability (it supports 8kpbs to 32kbps streams). Of particular interest are the wide-band extensions, which can offer very close to CD-quality sound; as yet, only a few phones support them. To use the wideband extensions, all the devices in the media path must support them.

How to Install Asterisk on centos 5

Install Process of Asterisk and Free PBX on Centos 5

1. Install CentOS, enabling the following packages:

*DNS Server

*Web Server

*Mail Server

*MySQL Database

*Development Tools

yum install nano


2. Edit Network settings

nano /etc/sysconfig/network (Set your internal hostname name here)

Ctrl-X to save, ‘Y’ to confirm

nano /etc/sysconfig/network-scripts/ifcfg-eth0





Ctrl-X to save, ‘Y’ to confirm

echo “options {” >> /etc/named.conf

echo ” directory \”/var/named\”;” >> /etc/named.conf

echo ” dump-file \”/var/named/data/cache_dump.db\”;” >> /etc/named.conf

echo ” statistics-file \”/var/named/data/named_stats.txt\”;” >> /etc/named.conf

echo “};” >> /etc/named.conf

echo “include \”/etc/rndc.key\”;” >> /etc/named.conf

service named start

chkconfig named on

nano /etc/resolv.conf

search (Set your internal domain name here)



nano /etc/hosts (Set your internal hostname name here) asterisk1.local localhost

Ctrl-X to save, ‘Y’ to confirm

iptables -P INPUT ACCEPT



iptables -F

iptables -X

/etc/init.d/iptables save

service network restart

3. Update:

yum -y update

4. Disable Selinux:

echo “selinux=disabled” > /etc/selinux/config


5. Install dependencies and extra packages:

yum install e2fsprogs-devel keyutils-libs-devel krb5-devel libogg libselinux-devel libsepol-devel libxml2-devel libtiff-devel gmp php-pear php-pear-DB php-gd php-mysql php-pdo kernel-devel ncurses-devel audiofile-devel libogg-devel openssl-devel mysql-devel zlib-devel perl-DateManip sendmail-cf sox

cd /usr/src


tar zxvf lame-3.97.tar.gz

cd lame-3.97



make install

6. Install Asterisk and FreePBX:

cd /usr/src






tar zxvf asterisk-1.4-current.tar.gz

tar zxvf asterisk-addons-1.4-current.tar.gz

tar zxvf dahdi-linux-complete-current.tar.gz

tar zxvf libpri-1.4-current.tar.gz

tar zxvf freepbx-2.6.0.tar.gz

cd /var/lib/asterisk/sounds


tar zxvf asterisk-extra-sounds-en-gsm-current.tar.gz

cd /usr/src/dahdi-linux-complete-CURRENT


make install

make config


echo “/sbin/ztcfg” >> /etc/rc.d/rc.local

cd /usr/src/libpri-1.4-CURRENT

make clean


make install

cd /usr/src/asterisk-1.4-CURRENT

useradd -c “Asterisk PBX” -d /var/lib/asterisk asterisk

mkdir /var/run/asterisk

mkdir /var/log/asterisk

chown -R asterisk:asterisk /var/run/asterisk

chown -R asterisk:asterisk /var/log/asterisk

chown -R asterisk:asterisk /var/lib/php/session/

nano +231 /etc/httpd/conf/httpd.conf

Change User apache and Group apache to User asterisk and Group asterisk.

Ctrl-X to save, ‘Y’ to confirm

nano +329 /etc/httpd/conf/httpd.conf

Change AllowOverride None to AllowOverride All

Ctrl-X to save, ‘Y’ to confirm



make install

/etc/init.d/mysqld start

cd /usr/src/freepbx-2.6.0

mysqladmin create asterisk

mysqladmin create asteriskcdrdb

mysql asterisk < SQL/newinstall.sql

mysql asteriskcdrdb < SQL/cdr_mysql_table.sql


GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY ‘SOMEPASSWORD’;


flush privileges;


mysqladmin -u root password ‘SOMEPASSWORD’

cd /usr/src/asterisk-addons



make install

cd /usr/src/freepbx-2.6.0

./start_asterisk start

yum install php-pear-DB

yum install php-mysql

./install_amp –username=asteriskuser –password=SOMEPASSWORD

echo “/usr/local/sbin/amportal start” >> /etc/rc.local

chkconfig httpd on

chkconfig mysqld on

Open browser to http://ipaddressofpbx/admin

Click red bar in FreePBX

7. Fix ARI password:

nano -w /var/www/html/recordings/includes/main.conf.php

$ari_admin_password = “SOMEPASSWORD”;

Ctrl-X to save, ‘Y’ to confirm

8. Configure Sendmail:

nano /etc/mail/

define(`SMART_HOST’, `



Ctrl-X to save, ‘Y’ to confirm

make -C /etc/mail

9. Edit sip_nat.conf for proper NAT:

nano /etc/asterisk/sip_nat.conf

localnet= (Set your external hostname name here)

externrefresh=10 (Set your external domain name here)




Ctrl-X to save, ‘Y’ to confirm

10. Add extra codecs to config:

nano /etc/asterisk/sip_custom.conf






Ctrl-X to save, ‘Y’ to confirm

nano /etc/asterisk/iax_custom.conf






Ctrl-X to save, ‘Y’ to confirm

asterisk -rx reload

11. Edit voicemail config:

nano /etc/amportal.conf

If the web interface on your PBX will be accessible on the internet: (Set your external hostname name here)

If the web interface on your PBX will be accessible only on your internal network: (Set your internal hostname name here)

Ctrl-X to save, ‘Y’ to confirm

or if your users will NOT have access to the web interface:

nano /etc/asterisk/

remove “Visit http://AMPWEBADDRESS/cgi-bin/vmail.cgi?action=login&mailbox=${VM_MAILBOX} to check your voicemail with a web browser.\n”

Ctrl-X to save, ‘Y’ to confirm

nano /etc/asterisk/ ; Who the e-mail notification should appear to come from

fromstring=DOMAIN PBX ; Real name of email sender

Ctrl-X to save, ‘Y’ to confirm

12. Fix MOH directory:

ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3

asterisk -rx reload

14. Open browser to http://ipaddressofpbx