
| Linux System Administration |
| Home | Tech | Linux | Links | Consulting |
|
Asterisk: ISDN PRI support with a Sangoma A108 PCI Express card
One of the most reliable ways to connect Asterisk, or any Private Branch Exchange (PBX), to the Public Switched Telephone Network (PSTN) is with ISDN: Integrated Services Digital Network. In Europe, this service is available in two main flavors: ISDN-30/PRI (Primary Rate Interface) and ISDN-2/BRI (Basic Rate Interface). PRI connections are widely used for office PBX connections, while BRI is more affordable and often considered a good choice for SoHo use. Euro-ISDN PRI connections have thirty 64 kbps B- (Bearer/data) channels for voice or data connections and one 64 kbps D- (Delta/control) channel for the transmission of signaling information: to connect/disconnect calls and negotiate special calling parameters, such as caller-ID, call waiting and data protocol. The Sangoma A108 Four-Port T1/E1/J1 card can support up to eight PRI spans (physical connections) for a total of 240 ISDN B-channels. Although is has only four RJ-45 ports, it can accommodate eight physical connections when a set of Y-cables are used that are included with the card. These make use of the fact that ISDN cables need only four wires, while RJ-45 connectors have eight contacts. The Sangoma support wiki includes a diagram of these Y-cables.
Also called the A108 Octal Voice and Data Card, this is an active ISDN card, capable of handling most of the ISDN connection protocols, such as dialing and accepting calls, through the use of dedicated microprocessors and firmware, which is efficient when many channels see heavy use. With passive ISDN cards, these tasks are instead performed by PC software. As can be seen in the image, the A108 consists of two printed circuit boards. The lower half, with the PCI edge connectors, is referred to by Sangoma as the base card, while they call the upper half the main board. The A108 shares its base card with the A104, but has a different main board. Of the A108, both PCI and PCI Express versions are available. This article describes how to configure Debian 5.0 (lenny) and Asterisk with a Sangoma A108 card for use with a single ISDN PRI connection in the Netherlands, while explaining a bit about the technology from this point of view. It builds on a previous article, Asterisk: minimal SIP configuration, in which Asterisk 1.4.21, Zaptel 1.4.11 and the zaptel-modules package were installed and configured. The installation procedures below assume that an A108 card has already been installed and that both the operating system and Asterisk are up and running. 1. Wanpipe install This card is supported by a proprietary Sangoma package, called Wanpipe. This is the software used for their AFT (Advanced Flexible Telecommunications) and legacy S-series product lines. The software must be downloaded from the Sangoma site and installed separately, but it does have a few software requirments of its own. These can be met in advance by installing four Debian packages: ~# apt-get install libncurses5-dev bison libtool flex A total of six packages are installed as a result, including two dependencies:
autotools-dev 20080123.1 Update infrastructure for config.{guess,sub} files
bison 1:2.3.dfsg-5 A parser generator that is compatible with YACC
flex 2.5.35-6 A fast lexical analyzer generator.
libltdl3-dev 1.5.26-4+lenny1 A system independent dlopen wrapper for GNU libtool
libncurses5-dev 5.7+20081213-1 developer's libraries and docs for ncurses
libtool 1.5.26-4+lenny1 Generic library support script
Next, download the latest version of the Wanpipe software, in this case v3.5.11 (dated 2010-04-19), and save it in the /usr/src directory. Unpack it and run the Wanpipe setup script: ~# cd /usr/src ~# wget -q ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-3.5.11.tgz ~# tar -xzf wanpipe-3.5.11.tgz ~# cd wanpipe-3.5.11 ~# ./Setup install --with-zaptel=/usr/src/modules/zaptel/ When the Setup script is run, a series of questions are asked, most of which can all be answered with either an affirmative, or a confirmation of a default setting. There are, however, some important selections to be made. First, regarding the Compilation Mode, choose:
2. TDM Voice (Dahdi/Zaptel) Support
Protocols: TDMV (Dahid/Zaptel), TDM API on AFT adatpers.
Default for: Asterisk & CallWeaver
Towards the end of the installation script, the option is offered to "create wanpipe devices for ZAPTEL." Accept this offer, as well as to generate a new version of /etc/asterisk/zapata.conf, which is the configuration file for Asterisk Zaptel channels. Once this option has been selected, answer the next questions regarding the specifications of the ISDN PRI connection as follows: Select media type for AFT-A108 on port 1 E1 Configuring port 1 on 108 as E1, line coding:HDB3, framing:CRC4 NO - Configure line coding and framing Select line coding for port 1 on 108 HDB3 Select framing for port 1 on 108 NCRC4 Select clock for AFT-A108 on port 1 NORMAL Select signalling type for AFT-A108 on port 1 Zaptel/Dahdi - PRI CPE Select switchtype for AFT-A108 on port 1 EuroISDN Configuring port 1 on AFT-A108 as a full E1 YES - Use all channels Select dialplan context for AFT-AA108 on port 1 from-pstn Select dialplan context for AFT-AA108 on port 1 Custom: use "incoming" Input the group for this port 1 Select media type for AFT-A108 on port 2 Unused See below for an explanation of these settings. As for the last answer, the same one − Unused − is also given for ports 3 through 8, since they will not be used either. 2. Wanpipe config The Wanpipe setup script, when run as described above, creates a number of configuration files, including /etc/wanpipe/wanpipe1.conf, /etc/zaptel.conf and /etc/asterisk/zapata.conf. The first of these contains the parameters that are required for Wanpipe to establish the ISDN PRI connection: [devices] wanpipe1 = WAN_AFT_TE1, Comment [interfaces] w1g1 = wanpipe1, , TDM_VOICE, Comment [wanpipe1] CARD_TYPE = AFT S514CPU = A CommPort = PRI AUTO_PCISLOT = NO PCISLOT = 4 PCIBUS = 13 FE_MEDIA = E1 FE_LCODE = HDB3 FE_FRAME = NCRC4 FE_LINE = 1 TE_CLOCK = NORMAL TE_REF_CLOCK = 0 TE_SIG_MODE = CCS TE_HIGHIMPEDANCE = NO TE_RX_SLEVEL = 430 LBO = 120OH FE_TXTRISTATE = NO MTU = 1500 UDPPORT = 9000 TTL = 255 IGNORE_FRONT_END = NO TDMV_SPAN = 1 TDMV_DCHAN = 16 TDMV_HW_DTMF = NO TDMV_HW_FAX_DETECT = NO [w1g1] ACTIVE_CH = ALL TDMV_HWEC = NO MTU = 8 Partial explanation:
3. Zaptel config The Wanpipe setup script compiles its modules against the Zaptel source. This is because it is the Zaptel telephony infrastructure that provides the virtual TDM bus through which Asterisk communicates with any telephony cards. For this reason, all such cards must be mentioned in the Zaptel configuration file, /etc/zaptel.conf. In this case, the task of adding the correct entry to this file − an entry that must agree with the settings in wanpipe1.conf − has already been performed by the Wanpipe setup script: loadzone=nl defaultzone=nl span=1,1,0,ccs,hdb3 bchan=1-15,17-31 hardhdlc=16 Explanation:
4. Zap channel config All Zap channels must be defined in the /etc/asterisk/zapata.conf configuration file before they can be used by Asterisk. If one does not yet exist, the Wanpipe setup script also creates this file: [trunkgroups] [channels] context=incoming usecallerid=yes hidecallerid=no callwaiting=yes usecallingpres=yes callwaitingcallerid=yes threewaycalling=yes transfer=yes canpark=yes cancallforward=yes callreturn=yes echocancel=yes echocancelwhenbridged=yes relaxdtmf=yes rxgain=0.0 txgain=0.0 group=1 callgroup=1 pickupgroup=1 immediate=no ;Sangoma A108 port 1 [slot:4 bus:13 span:1] <wanpipe1> switchtype=euroisdn context=incoming group=1 signalling=pri_cpe channel =>1-15,17-31 Explanation (in the exact same order as above):
5. OS-level diagnostics The output from the lspci -vv command is misleading:
0d:04.0 Network controller: Sangoma Technologies Corp. A104d QUAD T1/E1 AFT card
Subsystem: Unknown device a114:4113
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B-
Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
Latency: 255 (1250ns min, 3750ns max)
Interrupt: pin A routed to IRQ 169
Region 0: Memory at fc4e0000 (32-bit, non-prefetchable) [size=128K]
This shows the presence of a Sangoma A104 instead of an A108. The reason for this is because the A108 and the A104 share the same base card. According to Sangoma technical support, when using the A108 this information can be ignored and they recommend using lspci only to check for the presence of the card and for conducting a card count. The Wanpipe setup script compiles a number of modules for the running kernel. The ones currently loaded in memory are revealed with the following command and are (excluding the last two): ~# lsmod Module Size Used by wanec 328088 0 af_wanpipe 41664 0 wanpipe 716896 32 wanrouter 49512 12 wanec,af_wanpipe,wanpipe sdladrv 206580 4 wanec,af_wanpipe,wanpipe,wanrouter zaptel 190980 65 wanpipe crc_ccitt 6337 1 zaptel ... The modinfo utility gives the following descriptions for these modules:
The Wanpipe software also allows the card to be used for routing data. Not that it is used for this purpose here, but towards this end it does create a network interface that should appear:
# ifconfig w1g1
w1g1 Link encap:Point-to-Point Protocol
UP POINTOPOINT RUNNING NOARP MTU:8 Metric:1
RX packets:87600513 errors:0 dropped:0 overruns:0 frame:0
TX packets:87600532 errors:0 dropped:0 overruns:1 carrier:7
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:169 Memory:f8bc0000-f8bc1fff
# _
6. Wanpipe diagnostics Check the version of the software: ~# wanrouter version WANPIPE Release: 3.5.11 # _ If the software is working properly, the following command will load all Wanpipe and Zaptel modules and then print a list of all Sangoma hardware installed on the system: ~# wanrouter hwprobe verbose ----------------------------------------- | Wanpipe Hardware Probe Info (verbose) | ----------------------------------------- 1 . AFT-A108-SH : SLOT=4 : BUS=13 : IRQ=6 : CPU=A : PORT=1 : HWEC=0 : V=41 +01:DS26528: PCIe: PLX1 2 . AFT-A108-SH : SLOT=4 : BUS=13 : IRQ=6 : CPU=A : PORT=2 : HWEC=0 : V=41 +02:DS26528: PCIe: PLX1 3 . AFT-A108-SH : SLOT=4 : BUS=13 : IRQ=6 : CPU=A : PORT=3 : HWEC=0 : V=41 +03:DS26528: PCIe: PLX1 4 . AFT-A108-SH : SLOT=4 : BUS=13 : IRQ=6 : CPU=A : PORT=4 : HWEC=0 : V=41 +04:DS26528: PCIe: PLX1 5 . AFT-A108-SH : SLOT=4 : BUS=13 : IRQ=6 : CPU=A : PORT=5 : HWEC=0 : V=41 +05:DS26528: PCIe: PLX1 6 . AFT-A108-SH : SLOT=4 : BUS=13 : IRQ=6 : CPU=A : PORT=6 : HWEC=0 : V=41 +06:DS26528: PCIe: PLX1 7 . AFT-A108-SH : SLOT=4 : BUS=13 : IRQ=6 : CPU=A : PORT=7 : HWEC=0 : V=41 +07:DS26528: PCIe: PLX1 8 . AFT-A108-SH : SLOT=4 : BUS=13 : IRQ=6 : CPU=A : PORT=8 : HWEC=0 : V=41 +08:DS26528: PCIe: PLX1 Card Cnt: A108=1 ~# _ Among other things, this shows that the software detects the PCI Express (PCIe) version of a Sangoma A108 card with all eight PRI spans available. A PCI version of the A108 is also available. Show the status of the card:
~# wanrouter status
Devices currently active:
wanpipe1
Wanpipe Config:
Device name | Protocol Map | Adapter | IRQ | Slot/IO | If's | CLK | Baud rate |
wanpipe1 | N/A | A101/1D/A102/2D/4/4D/8| 169 | 4 | 1 | N/A | 0 |
Wanrouter Status:
Device name | Protocol | Station | Status |
wanpipe1 | AFT TE1 | N/A | Connected |
~# _
The most important item displayed here is the status, which should be Connected. Read E1/T1 alarms: ~# wanpipemon -i w1g1 -c Ta ***** w1g1: E1 Alarms (Framer) ***** ALOS: OFF | LOS: OFF RED: OFF | AIS: OFF LOF: OFF | RAI: OFF ***** w1g1: E1 Alarms (LIU) ***** Short Circuit: OFF Open Circuit: OFF Loss of Signal: OFF ***** w1g1: E1 Performance Monitoring Counters ***** Line Code Violation : 244 Far End Block Errors : 0 CRC4 Errors : 0 FAS Errors : 0 Rx Level : > -2.5db ~# _ This is the Wanpipe AFT Hardware Level Debugging Utility. The options used above are to specify the name of the interface, followed by a command: Ta. The T is for T1/E1 Configuration/Statistics, while the a is to Read T1/E1 alarms. In this case there are no alarms and the number of Line Code Violation errors is small (these should not be seen to increase). 7. Zaptel diagnostics Read all files in the /proc/zaptel/ directory structure: ~# cat /proc/zaptel/* Span 1: WPE1/0 "wanpipe1 card 0" (MASTER) HDB3/CCS 1 WPE1/0/1 Clear (In use) 2 WPE1/0/2 Clear (In use) 3 WPE1/0/3 Clear (In use) 4 WPE1/0/4 Clear (In use) 5 WPE1/0/5 Clear (In use) 6 WPE1/0/6 Clear (In use) 7 WPE1/0/7 Clear (In use) 8 WPE1/0/8 Clear (In use) 9 WPE1/0/9 Clear (In use) 10 WPE1/0/10 Clear (In use) 11 WPE1/0/11 Clear (In use) 12 WPE1/0/12 Clear (In use) 13 WPE1/0/13 Clear (In use) 14 WPE1/0/14 Clear (In use) 15 WPE1/0/15 Clear (In use) 16 WPE1/0/16 Hardware-assisted HDLC (In use) 17 WPE1/0/17 Clear (In use) 18 WPE1/0/18 Clear (In use) 19 WPE1/0/19 Clear (In use) 20 WPE1/0/20 Clear (In use) 21 WPE1/0/21 Clear (In use) 22 WPE1/0/22 Clear (In use) 23 WPE1/0/23 Clear (In use) 24 WPE1/0/24 Clear (In use) 25 WPE1/0/25 Clear (In use) 26 WPE1/0/26 Clear (In use) 27 WPE1/0/27 Clear (In use) 28 WPE1/0/28 Clear (In use) 29 WPE1/0/29 Clear (In use) 30 WPE1/0/30 Clear (In use) 31 WPE1/0/31 Clear (In use) ~# _
At the data link layer (OSI layer 2), ISDN uses two variants of the Link Access Procedure (LAP): LAP D-channel (LAPD, defined in ITU-T Q.920 and Q.921) for the D-channel, and LAP Balanced (LAPB) for data connections over the B-channels. Actually, LAP was the original data link protocol for X.25 before it was replaced by LAPB. Because LAP is derived from HDLC (High-level Data Link Control), the Sangoma A108 processes both LAPB and LAPD using HDLC controllers implemented in hardware. LAPB, however, is irrelevant for Asterisk, because when the B-channels are used for voice they carry no signaling at all: they are clear. With Asterisk, this is why it is necessary to specify a line coding scheme for the B-channels. 8. Asterisk diagnostics Display general status information on all PRI spans: ~# asterisk -rx "pri show spans" PRI span 1/0: Provisioned, Up, Active ~# _ Display more detailed information regarding a specific PRI span: ~# asterisk -rx "pri show span 1" Primary D-channel: 16 Status: Provisioned, Up, Active Switchtype: EuroISDN Type: CPE Window Length: 0/7 Sentrej: 0 SolicitFbit: 0 Retrans: 0 Busy: 0 Overlap Dial: 0 T200 Timer: 1000 T203 Timer: 10000 T305 Timer: 30000 T308 Timer: 4000 T309 Timer: -1 T313 Timer: 4000 N200 Counter: 3 ~# _ Show the status of all Zaptel cards: ~# asterisk -rx "zap show status" Description Alarms IRQ bpviol CRC4 wanpipe1 card 0 OK 0 0 0 ~# _ Show the status of all Zaptel channels:
~# asterisk -rx "zap show channels"
Chan Extension Context Language MOH Interpret
pseudo incoming default
1 incoming default
2 incoming default
3 incoming default
4 incoming default
5 incoming default
6 incoming default
7 incoming default
8 incoming default
9 incoming default
10 incoming default
11 incoming default
12 incoming default
13 incoming default
14 incoming default
15 incoming default
17 incoming default
18 incoming default
19 incoming default
20 incoming default
21 incoming default
22 incoming default
23 incoming default
24 incoming default
25 incoming default
26 incoming default
27 incoming default
28 incoming default
29 incoming default
30 incoming default
31 incoming default
~# _
Show the status of one specific Zaptel channel: ~# asterisk -rx "zap show channel 1" Channel: 1 File Descriptor: 15 Span: 1 Extension: Dialing: no Context: incoming Caller ID: Calling TON: 0 Caller ID name: Destroy: 0 InAlarm: 0 Signalling Type: ISDN PRI Radio: 0 Owner: <None> Real: <None> Callwait: <None> Threeway: <None> Confno: -1 Propagated Conference: -1 Real in conference: 0 DSP: no Relax DTMF: yes Dialing/CallwaitCAS: 0/0 Default law: alaw Fax Handled: no Pulse phone: no Echo Cancellation: 128 taps, currently OFF PRI Flags: PRI Logical Span: Implicit Hookstate (FXS only): Onhook ~# _ 9. Dial plan Assuming the ISDN line is associated with phone number 0715557890, modify the existing Asterisk dial plan, /etc/asterisk/extensions.conf, as follows:
[incoming]
exten => 0715551234,1,Goto(sp,1)
exten => 0715557890,1,Goto(sp,1)
exten => sp,1,Dial(SIP/sip-phone,60)
exten => sp,n,Hangup()
[outgoing]
exten => 0653123456,1,Dial(ZAP/g1/0653123456)
exten => 0653123456,n,Hangup()
exten => _X.,1,Dial(SIP/${EXTEN}@provider)
exten => _X.,n,Hangup()
Explanation:
Once the new dial plan has been saved, submit the changes to the running Asterisk process with this command: ~# asterisk -rx "dialplan reload" Dialplan reloaded. ~# _ 10. Result It should now be possible to receive ISDN calls for extension 0715557890 through Asterisk. This is in addition to SIP calls for extension 0715551234. In both cases, the calls will be connected on to the channel for the previously configured SIP phone. For outgoing calls, a choice must be made in the dial plan regarding which channel to use. In this example, the ZAP channel is only used for outgoing calls if extension 0653123456 is dialled. For all other numbers the catch-all rule will apply and the SIP channel will be used. 11. See also 12. Further reading
13. Sources
14. Acknowledgements
Last modified: 2017-08-02, 17:50
©2003-2020 RJ Systems. Permission is granted to copy, distribute and/or modify the content of this page under the terms of the OpenContent License, version 1.0. |