
In this article, using the example of a single-port E1
Digium TE121P card,
we consider an example of connecting it to FreeSWITCH on the CentOS operating system.
Physical connection
The physical connection you are supposed to provide a telephony provider. The card has a 75 ohm RJ-45 connector.
We, for example, use NSGate NS-200 / SB-LE modems with E1 + LAN + V.35 ports to connect to the provider, I highly recommend that you can immediately connect one dedicated line and E1 and Ethernet to the provider.
Cable pinout can be viewed
here .
When the card connects to the provider, the light on it lights up green, of course, if you configure everything correctly, as described below.
Customization
For the board to work, you need to install and configure three components:
- libPRI is a library designed to work with ISDN TDM streaming interfaces: PRI (Primary Rate Interface) and BRI (Basic Rate Interface).
- DAHDI - drivers for Digium boards.
- FreeTDM - FreeSWITCH module for working with telephony cards.
libPRI
Download libpri from here:
downloads.asterisk.org/pub/telephony/libpriFor example:
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
And install:
make make install
Actually install and everything. It does not require any special configuration.
FreeSWITCH interacts with DAHDI via libPRI.
')
DAHDI
Also, the DAHDI installation process is described here:
wiki.freeswitch.org/wiki/OpenZap_DahdiSo, after installing the card, check it in the system.
lspci -v
And we look at what interruption the card is sitting on:
cat /proc/interrupts
If wctdm takes a separate irq, then it’s good, but if it shares it with someone, then it can affect the card’s performance and voice quality, so it’s best to separate the drivers across different interrupts.
Download DAHDI from here:
downloads.asterisk.org/pub/telephony/dahdi-linux-completeFor example:
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
Add Asterisk User
adduser asterisk
And create a folder in / etc
mkdir /etc/asterisk
We will not need it, but this will have to be done to avoid errors when installing drivers.
make all make install
If it was the first installation, you need to run the config to install the sample configuration files
make config
You can immediately enable DAHDI in autoload.
chkconfig dahdi on
Run the DAHDI configuration generator
/usr/sbin/dahdi_genconf
Editing the / etc / dahdi / modules file
There should be one uncommented line:
wcte12xp
The rest of the modules we do not need, they need to be commented out so as not to load.
Next, configure /etc/dahdi/system.conf:
Connection setup:span = <span num>, <timing source>, <line build out (LBO)>, <framing>, <coding> [, yellow]
span num - the serial number of the span
timing source — select the source for timer synchronization. 0 - master, 1 or more - master is the remote side. The higher the number, the lower the priority.
line build out (LBO) - selection depending on the distance to the remote side. I do not know if it works in this case, but the table is as follows:
0: 0 db (CSU) / 0-133 feet (DSX-1)
1: 133-266 feet (DSX-1)
2: 266-399 feet (DSX-1)
3: 399-533 feet (DSX-1)
4: 533-655 feet (DSX-1)
5: -7.5db (CSU)
6: -15db (CSU)
7: -22.5db (CSU)
framing is a type of telephone alarm. For E1, select ccs or cas.
coding - line coding. For E1, choose ami or hdb3.
yellow - check and generation of crc4 is performed.
All these E1 parameters should be reported to your telephony provider (of course, except for span num).
Next comes
the channel configuration:<device> = <channel list>
For the E1 stream, we will be interested in the device only bchan and dchan. For E1, the following setting is used:
bchan = 1-15,17-31
dchan = 16
The following describes the
time zone:loadzone = <zone>
defaultzone = <zone>
The time zone is indicated by a two-letter code. The default is us.
The following describes the PCM encoding on the channels:
The choice between mulaw (G.711u = PCMU) and alaw (G.711a = PCMA).
The following describes
echo cancellers:echocanceller = <echocanceller name>, <channel's>
echocanceller name - mg2, kb1, sec2, sec.
Here is my /etc/dahdi/system.conf file for example:
Now you can start DAHDI:
service dahdi start
When installing DAHDI in / usr / sbin, several utilities are written:
dahdi_test dahdi_test Opened pseudo dahdi interface, measuring accuracy... 99.999% 99.995% 99.999% 99.999% 99.999% 99.999% 99.999% --- Results after 7 passes --- Best: 99.999 -- Worst: 99.995 -- Average: 99.998506, Difference: 99.998507
Values ​​below 99.9 are bad results. It means that the DAHDI device has to compete with other processes for interruptions and processor time, which can lead to a deterioration in sound quality.
dahdi_toolShows the status of the card and errors in its work.
dahdi_scanShows information about the map, for example, like this:
[1] active=yes alarms=OK description=Wildcard TE121 Card 0 name=WCT1/0 manufacturer=Digium devicetype=Wildcard TE121 (VPMADT032) location=PCI Bus 05 Slot 09 basechan=1 totchans=31 irq=169 type=digital-E1 syncsrc=1 lbo=0 db (CSU)/0-133 feet (DSX-1) coding_opts=AMI,HDB3 framing_opts=CCS,CRC4 coding=HDB3 framing=CCS
dahdi_cfg [options]
Shows the configuration
dahdi_hardwareShows information about the installed card
FreeTDM
To work with the board you have to have the freetdm module installed on FreeSWITCH. Moreover, it must be compiled with libpri support. If it is compiled without libpri, you will have to recompile:
cd libs/freetdm ./configure --with-libpri make make install
To configure FreeTDM, you need to adjust three files in the conf folder: freetdm.conf, zt.conf, and autoload_configs / freetdm.conf.xml. Well, naturally, the FreeTDM module should be included in the autoload_configs / modules.conf.xml file.
Configure freetdm.conf
Configure the Zaptel / DAHDI section. To do this, create (by default, it has already been created) the following section:
[span zt myDAHDISpan]
myDAHDISpan - any name you choose can be here.
Please note that in this file the parameter is separated from the value by the “=>” sign.
name - your chosen name.
trunk_type — Determines the type, possible values: E1, T1, J1, BRI, BRI_PTMP, FXO, FXS, EM.
group - A conditional group name for outgoing calls, must begin with a letter. Further, in the example of dialplan, we will see how it can be used.
txgain - Gain or attenuate sound for transmission. Type float. Too much value may lead to distortion. Typical values ​​range from -5.0 to 5.0
rxgain - Gain or attenuate sound for reception. Type float. Too much value may lead to distortion. Typical values ​​range from -5.0 to 5.0
The
analog-start-type and
number options for E1 streams are not needed.
b-channel -
b-channel numbers. From the bchan parameter (/etc/dahdi/system.conf file)
d-channel — The d-channel number. From the dchan parameter (/etc/dahdi/system.conf file)
The
fxo-channel ,
fxs-channel and
em-channel parameters are not needed in our case.
The parameters
cas-channel and
debugdtmf may also be useful.
An example of my working freetdm.conf:
[span zt pri] name => pri trunk_type => E1 group => e1group b-channel => 1-15 d-channel => 16 b-channel => 17-31
Configuring zt.conf
I did not bother with it and took all the default values:
[defaults] codec_ms => 20 wink_ms => 150 flash_ms => 750 echo_cancel_level => 64 rxgain => 0.0 txgain => 3.0
Configure freetdm.conf.xml
<configuration name="freetdm.conf" description="Freetdm Configuration"> <settings> <param name="debug" value="7"/> </settings> <libpri_spans> <span id="1" name="pri"> <param name="node" value="network"/> <param name="switch" value="euroisdn"/> <param name="l1" value="alaw"/> <param name="dp" value="international"/> <param name="debug" value="all"/> <param name="dialplan" value="XML"/> <param name="context" value="default"/> </span> </libpri_spans> </configuration>
The
name attribute is the name of the span that matches the name we specified in the freetdm.conf file.
The remaining parameters can take the following values:
node or mode is the node type (in brackets are valid synonyms): cpe (user), network (net)
switch or dialect (in brackets - acceptable synonyms): ni1, ni2, dms100, lucent5e (5ess), att4ess (4ess), euroisdn (q931), gr303eoc, gr303tmc
l1 or layer1 : alaw, ulaw
dp or ton : international, national, local, private, unknown
As you understand these parameters, the provider to which you connect the E1 stream must inform.
Next, specify where to send calls:
dialplan -
dialplan to which the call will be sent: XML, YAML, Asterisk (?)
context - the context to which the call will be sent.
The following parameters are optional:
debug : q921_all, q921_raw, q921_dump, q921_state, q931_all, q931_dump, q931_state, q931_anomaly, config, apdu, aoc
overlapdial (in brackets - valid synonyms): yes (both), incoming (receive), outgoing (send), no
opts : suggest_channel, omit_display, omit_redirecting_number, aoc
service_message_support : true, false
The parameters of the node type, dialect, encoding, should be given to you by the telephony provider.
And yes, parameter names have synonyms, i.e. node = mode, switch = dialect.
Dialplan setup
Outgoing calls are written according to the following rule:
freetdm / <span name or group name> / a / <destination_number>
The letter "a" can be small, and maybe even big. The size of the letter (hehe) determines how FreeTDM will select free channels in the span. "A" - upwards, i.e. from the first to the maximum, and “A” from top to bottom, i.e. from the maximum (31, in our case) to the first.
For example, all numbers starting with 9 are sent to our map.
<extension name="outgoing_pri"> <condition field="destination_number" expression="^9(\d+)$"> <action application="bridge" data="freetdm/e1group/a/$1"/> </condition> </extension>
The following example sends all incoming calls to an extension card with the name ivr_main (in my case the IVR menu):
<extension name="pri_input"> <condition field="chan_name" expression="^(FreeTDM)"> <action application="set" data="ringback=${ru-ring}"/> <action application="set" data="transfer_ringback=${ru-ring}"/> <action application="transfer" data="ivr_main XML default"/> </condition> </extension>
Well, in general, something like that.
The main source of information, of course, is here:
http://wiki.freeswitch.org/wiki/FreeTDMThere is also a lot of additional information, such as: CLI commands, SIP headers, channel variables, etc.