-
Asterisk and ISDN
[LEFT][SIZE=3][B][URL="http://www.servercare.nl/Lists/Posts/Post.aspx?ID=6"]Asterisk and ISDN[/URL][/B][/SIZE]
As mentioned in the previous article setting up Asterisk isn't that hard if you only want voip. In fact one of the Trixbox distribution is actually a VMWare image that you can start playing with right away.
The real functionality however is found in combining the world of Voip with the hardware telecom lines. Let's face it, most companies still use those and have learned to trust on the reliability of POTS (Plain Old Telephone System i.e. analog phonelines) or ISDN (digital lines: the BRI consumer type that has two B channels and one D (protocol) channel, and the PRI type which is technically similar except for the amount of B channels; in the US and Japan it's 23 B, in Europe and Australia 30). They want the advantages of Voip but are not quite ready to let the reliability of regular phone lines slide.
[IMG]http://www.servercare.nl/Lists/Photos/121307_1455_Asteriskand1.jpg[/IMG]
Always works…
The nice thing about asterisk is that it can function as a bridge between the different technologies. In Holland ISDN is pretty big with most companies. The smaller ones typically get one or more ISDN2 connections the larger ones get ISDN15 or 30. Whatever the number of lines, the technology is basically the same. Asterisk can simply connect Voip to ISDN and vice versa, the only thing needed is a trunk set up in asterisk, some inbound and outbound routes and of course the right hardware to connect to the telecom provider. It's even possible to use ISDN phones with Asterisk this way, but that's for another time. For now we'll stick with the (much nicer) Voip phones…
If you happen to have an ISDN line: good news! Asterisk can work with very cheap basic ISDN cards that are found in any computer shop. To make it even easier, the cards best used are based on the HFC chipset. This chipset is used by a large number of vendors and is easily recognizable by the graphic of the two towers printed on the chip, representing the towers of the Dom cathedral in Cologne.
[IMG]http://www.servercare.nl/Lists/Photos/121307_1455_Asteriskand2.jpg[/IMG][IMG]http://www.servercare.nl/Lists/Photos/121307_1455_Asteriskand3.png[/IMG] [IMG]http://www.servercare.nl/Lists/Photos/121307_1455_Asteriskand4.jpg[/IMG]
If you look closely you can just make out the Dom on the chip on the Sweex ISDN card.
Before we have Asterisk route our calls through this ISDN card however, we need to get Linux to understand it first.
There are two ways to get Linux to play nice with ISDN cards that I know to be functional and working:
[LIST=1][*]trough the Zaptel HFC Bristuff drivers[*]by using mISDN[/LIST]
More information on [URL="http://voip-info.mirrors.bsd.net/wiki/view/Bristuff.html"]Bristuff[/URL] and [URL="http://www.voip-info.org/wiki/view/chan_misdn"]mISDN[/URL] can be found on the excellent [URL="http://www.voip-info.org/wiki/"]voip-info.org[/URL] website.
Both methods have advantages as well as disadvantages. We'll be working with Trixbox, and the older versions (before 2.2.8) have a script installed called 'install-ZAPHFC'. You basically run it and it will install the drivers and make a so called 'ZAP' channel available for you in Asterisk. The downside is that it recompiles asterisk, and makes a number of modifications that make it less compatible with the Trixbox implementation. Most are only cosmetic, but one particularly nasty effect is that the fax recognition no longer works and that the update packages function no longer works.
mISDN doesn't have those downsides, and also supports a larger array of ISDN cards, but is a bit trickier to set up. The downside here is that echo-cancellation is quite limited compared to the zaptel implementation. We will look at mISDN in another article.
[B]ZAPHFC [/B]
For this article let's start with getting an ISN card to work using the install-ZAPHFC script. First step of course is to get the ISDN card in place. I have used a simple Sweex ISDN card (15 to 20 Euro's) for my installation. Once physically installed it's pretty simple to confirm the card is there by using 'lspci':
[COLOR=Black][FONT=Courier New][root@phone ~]# lspci [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]00:00.0 Host bridge: Intel Corporation 82845 845 (Brookdale) Chipset Host Bridge (rev 03) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]00:01.0 PCI bridge: Intel Corporation 82845 845 (Brookdale) Chipset AGP Bridge (rev 03) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 12) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]00:1f.0 ISA bridge: Intel Corporation 82801BA ISA Bridge (LPC) (rev 12) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]00:1f.1 IDE interface: Intel Corporation 82801BA IDE U100 Controller (rev 12) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]00:1f.3 SMBus: Intel Corporation 82801BA/BAM SMBus Controller (rev 12) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]00:1f.5 Multimedia audio controller: Intel Corporation 82801BA/BAM AC'97 Audio Controller (rev 12) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]01:00.0 VGA compatible controller: ATI Technologies Inc Rage 128 Pro Ultra TF [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New][B]02:08.0 Network controller: Cologne Chip Designs GmbH ISDN network controller [HFC-PCI] (rev 02) [/B][/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]02:0c.0 Ethernet controller: 3Com Corporation 3c905C-TX/TX-M [Tornado] (rev 78)[/FONT]
[/COLOR]
Next step is to run the install-ZAPHFC script. If it's not available on the distribution you're using, you can manually download it like this:
Go to the Linux command prompt (make sure you are root)
wget [URL]http://brightheadtechnology.com/other/aah/install-ZAPHFC[/URL]
Now move it to the 'sbin' folder and apply 'chmod + x install-ZAPHFC' to make it executable.
Now simply run it!
Install-ZAPHFC comes with a number of options.
[FONT=Courier New][root@phone ~]# install-ZAPHFC -h [/FONT]
[FONT=Courier New]----------------------------------------------------- [/FONT]
[FONT=Courier New]Searching for HFC Chipset based cards. [/FONT]
[FONT=Courier New]----------------------------------------------------- [/FONT]
[FONT=Courier New]Found a 1 port card (1397:2bd0) with an HFC-PCI chipset. [/FONT]
[FONT=Courier New]install-ZAPHFC: [/FONT]
[FONT=Courier New]Install BRIstuff support. [/FONT]
[FONT=Courier New]Builds zaphfc and configures one, or more, single port HFC cards. [/FONT]
[FONT=Courier New]Builds qozap and configures a 4 port or an 8 port HFC card. [/FONT]
[FONT=Courier New]usage: [/FONT]
[FONT=Courier New]install-ZAPHFC [-a <version> |-l ] [-B |-C ] [-R ] [-m 1|0[1|0[1|0[1|0]]] ] [-f t|u [-t 1|2|3|4] [-s 1|0[1|0[1|0[1|0]]]] ] [/FONT]
[FONT=Courier New]install-ZAPHFC -h [/FONT]
[FONT=Courier New]install-ZAPHFC -V [/FONT]
[FONT=Courier New]Options: [/FONT]
[FONT=Courier New]-a <version>: The version of Asterisk you want to patch with BRIstuff (e.g. 1.2.1) [/FONT]
[FONT=Courier New]The default is to use the version number from the currently installed Asterisk. [/FONT]
[FONT=Courier New]-B Build only. Will disable the configuration module*. [/FONT]
[FONT=Courier New]-C Configure only. Will disable the build module*. [/FONT]
[FONT=Courier New]* if you specify both B & C options the last occurrence on the command line takes presidence [/FONT]
[FONT=Courier New]-f Apply Florz's patch ([URL="http://zaphfc.florz.dyndns.org/"]Florz' Patch for the zaphfc Driver[/URL]). (Default no) [/FONT]
[FONT=Courier New]t (tested) the last tested patch will be applied (this may use an earlier * to do so). [/FONT]
[FONT=Courier New]u (un-tested) patch the latest version of BRIstuff (CAUTION). [/FONT]
[FONT=Courier New]-h This help screen [/FONT]
[FONT=Courier New]-l List the versions of Asterisk that you can build BRIstuff for. [/FONT]
[FONT=Courier New]-M set the mirror to use for downloading the Asterisk sources from. [/FONT]
[FONT=Courier New]-M 0 Use the mirror specified by Junghanns [/FONT]
[FONT=Courier New]-M 1 Use the Digium mirror (default) [/FONT]
[FONT=Courier New]-m Set the NT/TE mode for each card. [/FONT]
[FONT=Courier New]Use 1 for NT mode and 0 for TE mode. [/FONT]
[FONT=Courier New]Specify one or more cards with card 1 as the rightmost digit. Examples: [/FONT]
[FONT=Courier New]-m 1 Card 1 in NT mode. [/FONT]
[FONT=Courier New]-m 10 Card 2 NT mode card 1 TE mode. [/FONT]
[FONT=Courier New]-m 11 Cards 2 & 1 in NT mode. [/FONT]
[FONT=Courier New]-m 1100 Cards 4 & 3 in NT mode cards 2 & 1 in TE mode. [/FONT]
[FONT=Courier New]-R Re-write zapata-BRI-HFC.conf. [/FONT]
[FONT=Courier New]-s Set the Slave/Master mode for each card. [/FONT]
[FONT=Courier New]Use 1 for Slave mode and 0 for Master mode. Only when built with Florz's patch. [/FONT]
[FONT=Courier New]Specify one or more cards with card 1 as the rightmost digit. Examples: [/FONT]
[FONT=Courier New]-s 1 Card 1 in Slave mode. (Assumes you have more than one card). [/FONT]
[FONT=Courier New]-s 10 Card 2 in Slave mode card 1 in Master mode. [/FONT]
[FONT=Courier New]-s 110 Cards 3 & 2 in Slave mode card 1 in Master mode. [/FONT]
[FONT=Courier New]-s 1110 Cards 4, 3 & 2 in Slave mode card 1 in Master mode. [/FONT]
[FONT=Courier New]-t Specify which card will be the timer_card. (Default 1). Only when built with Florz's patch. [/FONT]
[FONT=Courier New]-V Print script version number and exit. [/FONT]
You can see another nice thing about this way of getting ISDN cards to work: the HFC chipset makes it possible to use the ISDN card to actually connect an ISDN phone to it and make it work with Asterisk; this is the NT mode.
We'll focus on the TE mode though, as our objective is to get the Asterisk box to connect to the telco.
Something like:
[FONT=Courier New]Install-ZAPHFC –R [/FONT]
Might very well do the trick. , The '-R' also writes the Zapata-BRI-HFC.conf file for you. (found in /etc/asterisk/ and tells the system about your ISDN configuration)
You can check if things went well by using the ztcfg –vvv command: [COLOR=Black]
[/COLOR] [COLOR=Black][FONT=Courier New][root@phone html]# ztcfg -vvvvv [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]Zaptel Configuration [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]====================== [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]SPAN 1: CCS/ AMI Build-out: 399-533 feet (DSX-1) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]Channel map: [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]Channel 01: Clear channel (Default) (Slaves: 01) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]Channel 02: Clear channel (Default) (Slaves: 02) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]Channel 03: D-channel (Default) (Slaves: 03) [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]3 channels configured.[/FONT]
We're getting close! The card is recognized and we can see the channels…
Next edit the:
'/etc/sysconfig/zaptel' file to exclude all the devices that are not actually in the system (in this case, just leave the zaphfc hardware)
Make sure you have your ISDN line connected and check if things have been installed OK by executing the following from a command prompt:
[/COLOR] [COLOR=black][FONT=Courier New]for PROC in `ls -1 /proc/zaptel/`;do cat /proc/zaptel/$PROC|head -n 1;done[/FONT]
[/COLOR] [COLOR=black]You should see all of the ISDN ports you have connected showing "ACTIVATED". If they don't check your cables/ISDN service.
[/COLOR] [COLOR=Black][FONT=Courier New][root@phone ~]# for PROC in `ls -1 /proc/zaptel/`;do cat /proc/zaptel/$PROC|head -n 1;done [/FONT]
[/COLOR] [COLOR=Black][FONT=Courier New]Span 1: ZTHFC1 "HFC-S PCI A ISDN card 0 [TE] layer 1 ACTIVATED (F7)" AMI/CCS [/FONT]
[/COLOR]
If you disconnect your ISDN line you should see: [COLOR=Black]
[/COLOR] [COLOR=Black][FONT=Courier New]Span 1: ZTHFC1 "HFC-S PCI A ISDN card 0 [TE] layer 1 DEACTIVATED (F15)" AMI/CCS[/FONT]
[/COLOR]
[B]Possible issues [/B]
You should basically have the card running now. There might still be a few problems though…:
If, once you have rebooted, you see a lot of lines scrolling over your screen that look like this:
[FONT=Courier New]zaphfc: dropped audio (z1=2331, z2=2314, wanted 8 got 17, dropped 9). [/FONT]
You might have an interrupt problem. To fix it you should change your grub.conf:
/etc/grub.conf needs to be edited as follows: [COLOR=Black]
[/COLOR] [COLOR=Black]default=1
[/COLOR] [COLOR=Black]timeout=7
[/COLOR] [COLOR=Black]splashimage=(hd0,0)/grub/splash.xpm.gz
[/COLOR] [COLOR=Black]hiddenmenu
[/COLOR] [COLOR=Black]title Red Hat Enterprise Linux AS (2.4.21-20.EL)
[/COLOR] [COLOR=Black] root (hd0,0)
[/COLOR] [COLOR=Black] kernel /vmlinuz-2.4.21-20.EL ro root=LABEL=/ [/COLOR][COLOR=Black][B]apm=off[/B][/COLOR][COLOR=Black]
[/COLOR] [COLOR=Black] initrd /initrd-2.4.21-20.EL.img
[/COLOR] [COLOR=Black]title Red Hat Enterprise Linux AS (2.4.21-20.ELsmp)
[/COLOR] [COLOR=Black] root (hd0,0)
[/COLOR] [COLOR=Black] kernel /vmlinuz-2.4.21-20.ELsmp ro root=LABEL=/ [/COLOR][COLOR=Black][B]apm=off[/B][/COLOR][COLOR=Black]
[/COLOR] [COLOR=Black] initrd /initrd-2.4.21-20.ELsmp.img
[/COLOR]
With a little luck switching off the Advanced Power Management fixes the issue. If you still get the errors mentioned above the next trick to try is to run install-ZAPHFC with the Florz patch (see the install-ZAPHFC options).
If you're in the Netherlands you might experience the system complaining about:
[COLOR=black][FONT=Courier New][B]kernel: zaphfc: empty HDLC frame or bad CRC received [/B][/FONT][/COLOR]
[COLOR=black][FONT=Arial]
[/FONT]In the Netherlands it is common practice by telecom providers (such as KPN) to 'drop' the ISDN D channel every X minutes (I believe it to be 5 minutes).
This results in the error described above. In my case I solved the issue by calling the KPN service number and requesting the D channel to the 'up' constantly. It took them 2 hours (great response time, not sure if I was just lucky) to fix this and my problems were resolved.[/COLOR]
[B]Everything is working! [/B]
That should have taken care of most of the issues that stand in the way of the functionality, now only one (but essential) cosmetic thing needs to be done: adding the two new ISDN channels (every ISDN line has two B channels for voice and one D channel for protocol information) to the FOP.
The FOP is the Flash Operation Panel, and it allows you an overview of what's going on in asterisks, what extensions are calling or being called, and over what trunks.
[IMG]http://www.servercare.nl/Lists/Photos/121307_1455_Asteriskand5.png[/IMG]
[B]Add channels to FOP:[/B]
While you can use the ISDN ZAP channels in FreePBX without issue, FreePBX does not yet write these channels into the FOP configuration files. To do so edit /var/www/html/panel/op_buttons_custom.cfg and add the following section to it:
[FONT=Courier New][Zap/[B]x[/B]]
Position=[B]z[/B]
Label="Zap [B]x[/B]"
Extension=-1
Icon=3
Panel_Context=default [/FONT]
[FONT=Courier New][Zap/[B]y[/B]]
Position=[B]z+1[/B]
Label="Zap [B]y[/B]"
Extension=-1
Icon=3
Panel_Context=default [/FONT]
Where [B]x[/B] & [B]y[/B] are the channel numbers for your ISDN card and [B]z[/B] is the position number (refer to /var/www/html/panel/op_buttons_additional.cfg). Restart Asterisk ([I]amportal restart[/I]) to make the changes effective.
Things should be working!
Last steps is to actually create the trunks (the device is ZAP/g0), and make sure there are inbound and outbound routes that lead somewhere defined in FreePBX[/LEFT]