Asterisk/sangoma/dahdi/SS7

来自最权威最新完整开源SIP,语音通信,融合通信中文技术文档资料,提供详细的Asterisk Freepbx, FreeSBC, 免费会话边界控制器,网关,语音板卡,IPPBX,SBC配置资料-asterisk,freepbx,freesbc 用户手册 界面配置,呼叫路由,IVR, 网关对接,拨号规则,SIP 分机呼叫,pjsip, IVR, 录音, CDR, 队列呼叫,振铃组,CLI 命令中文资料手册
跳转至: 导航搜索

环境准备-检查运营商服务类型,检测对接设备接口,检测服务器类型,检查Asterisk以及相关版本,检查功能需求

检查运营商服务类型,配置开源SS7的经典9条意见

1)开源chan_ss7目前仅支持中国变种的IUSP,不支持TUP协议。请和运营商沟通确认支持的服务
2)确认运营商提供的服务是否支持CRC校验,目前dahdi解支持CRC4和NCRC
3)当然目前还有libss7 支持中国ISUP,但是没有经过太多测试。建议不要使用
4)确认OPC和DPC点码,如果订阅了运营商的SS7服务,运营商会提供OPC和DPC点码,DPC和OPC需要在ss7.conf文件中配置
5)具体关于点码的介绍,请参考:http://zh.wikipedia.org/wiki/%E7%82%B9%E7%A0%81
6)点码格式的转换方式,可通过此链接做相应的转换:http://jhartman.webd.pl/pc/
7)需要和运营商确认firstCIC,我们配置是需要对应和运营商的第一个CIC对应
8)在线路实施过程中,实施人员必须确认端口的顺序,一定要保证端口顺序是正确的
9)因为SS7 需要dahdi,chan_ss7 和asterisk 3个软件包的支持,版本组合是需要用户认真考虑到问题

检测对接设备接口

Sangoma提供的语音板卡支持RJ48接口,我们也配置一根RJ45-BNC(75欧姆-120欧姆)的转接线。
具体如何做RJ48线,请参考网站链接。http://wiki.sangoma.com/Cablepinouts
确认运营商给定的线路端口顺序,必须和板卡端口一一对应,否则可能出现呼叫问题

检测服务器类型

Sangoma板卡支持2U以上机箱,和PCI或PCI接口的主板插插。建议使用PCI-E插槽的主板。因为目前主流服务器都仅支持PCI-E 插槽。

检查Asterisk以及相关版本

到文档写作时,建议使用asterisk主流版本是asterisk-1.8和以上版本,支持dahdi-2.0以上版本,wanpipe-7.0 以上。
不建议使用更低的asterisk版本。zaptel或者asterisk更低版本不建议使用。除非用户经过完整的功能测试。
强烈建议用户安装前咨询我们技术人员 asterisk, dahdi chan_ss7 版本,避免出现不必要的问题。
另外,此文档适应于所有的sangoma E1板卡,具体端口数量可能不同,所以请安装时注意。

检查功能需求

如果客户安装了chan_ss7,然后需要安装界面管理系统,建议仅使用freepbx支持,通过自定义界面配置呼入和呼出的路由规则。
另外,请用户注意,文档中使用的所有软件版本不是最终版本,涉及到命令和安装路径可能不同,请选择最新的安装版本,或者咨询相关
技术人员。
最后,强烈建议用户使用文档中默认的安装路径和源代码保存路径,方便支持人员安装调试

第1章:下载Asterisk/dahdi/chan_ss7

为asterisk/dahdi安装必要的支持包

安装asterisk/dahdi 之前。必须确认完全安装以下支持包,否则编译报错

yum -y install kernel-devel-$(uname -r) libtool* make gcc patch perl bison flex-devel gcc-c++ 
ncurses-devel flex libtermcap-devel autoconf* automake* autoconf libxml2-devel cmake

从asterisk 官方网站下载asterisk 和dahdi 源代码

下载稳定版本,减压压缩文件到 /usr/src 目录,以下是安装时的举例版本,客户根据自己的实际环境做调整

DAHDI dahdi-linux-2.1.0.4.tar.gz,dahdi-tools-2.1.0.1.tar.gz
ASTERISK asterisk-1.4.24.1.tar.gz

注意,这里用户可以下载dahdi-linux-complete 版本,这个版本已经包括了dahdi-linux和dahdi-tool。

做链接

ln -s /usr/src/dahdi-linux-2.1.0.4 /usr/src/dahdi
ln -s /usr/src/asterisk-1.4.24.1 /usr/src/asterisk

下载SS7的支持包chan_ss7

从官方网站下载chan_ss7的支持包:www.dicea.dk/company/downloads
此次下载的版本是chan_ss7-1.1.tar.gz,用户可以根据实际的环境进行版本的调整。
1) 解压压缩文件到 /usr/src 目录。

2) 使用VI 编辑器修改Makefile

vi /usr/src/chan_ss7-1.1/Makefile

3) 修改源代码包含路径分别到asterisk/dahdi的减压目录

INCLUDE+=-I../dahdi/include   // 指到 dahdi 源代码路径
INCLUDE+=-I../asterisk/include   // 指到 asterisk 源代码路径

保存文件,退出。

第2章:编译Asterisk/dahdi/chan_ss7

编译dahdi-linux 和dahdi-tools

执行命令到相应的dahdi-linux,dahdi-tools 目录
执行命令:make,make install 完成dahdi内核和用户部分的安装

编译asterisk

执行命令 cd asterisk 源代码目录下:

./configure
make
make install
make samples   // 生成配置文件,将覆盖原来的文件!

编译chan_ss7

执行命令 cd chan_ss7 源代码目录下,执行命令

make
make install
cp chan_ss7.so /usr/lib/asterisk/modules/

第3章:配置驱动/dahdi模块/SS7 模块

安装Sangoma驱动

1) 下载sangoma wanpipe 驱动,以下版本可能是旧的版本,用户建议用户下载最新驱动

  wget ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-7.0.5

2) 减压tar 文件到 /usr/src
3) 安装wanpipe支持包

yum install perl-devel
yum install awk
yum install flex
yum install libtermcap-devel

4) 安装wanpipe驱动

tar xvfz wanpipe-<version>.tgz
cd wanpipe-<version>
./Setup install  // 执行脚本安装编译,确认没有任何报错信息。

执行setup安装过程时的选项:

[root@localhost wanpipe-7.0.5]# ./Setup install
----------------------------------------------------------
          WANPIPE v7.0.5 Installation Script
    Copyright (c) 1995-2013, Sangoma Technologies Inc.
----------------------------------------------------------

WANPIPE INSTALLATION

You are about to install WANPIPE Multi-Protocol
TDM Voice & WAN Router into your system.

This script will examine your system, then install, create
and/or modify necessary files and directories.

You must have Linux Kernel Headers along with
full development tools (i.e. GNU C compiler and utilities)
installed in order to be able to install this product.

This script will automatically compile all WANPIPE kernel
drivers and install them in their appropriate directory.

If you are installing Wanpipe for ASTERISK/ZAPTEL this
script will will prompt you for zaptel source location.

If you have previoulsy installed WANPIPE, this release
will overrite/upgrade full release without the need to
uninstall first!

IMPORTANT:
It is always recommended to say YES to all options
prompted during the install!

Please visit: http://wiki.sangoma.com for more info.

Would you like to install WANPIPE now? [y] (y/n) y    // 选择y
----------------------------------------------------------
          WANPIPE v7.0.5 Installation Script
    Copyright (c) 1995-2013, Sangoma Technologies Inc.
----------------------------------------------------------

Fixing file permissions...

Verifying files and fixing permissions ...Done

Warning: Wanpipe Modules are currently running!
Its recommended to unload Wanpipe Modules before proceeding
with installation.


Would you like to proceed? (y/n) y
Checking for C developement tools ...(gcc) OK
Checking for C++ developement tools ...OK
Checking for Make utility ...OK
Checking for ncurses library ... OK
Checking for Perl developement tools ...OK
Checking for AWK ...OK
Checking for FLEX ...OK
Checking for Patch ...OK
Checking for libtermcap-devel...OK
Checking for bison...OK
Checking for libtool...OK

Press [Enter] to continue...   // 确认以上支持包成功安装。输入 Enter 键
----------------------------------------------------------
          WANPIPE v7.0.5 Installation Script
    Copyright (c) 1995-2013, Sangoma Technologies Inc.
----------------------------------------------------------


Installing WANPIPE Device Drivers: Linux KERNEL

To integrate WANPIPE Multi-Protocol Voice & WAN Router 
modules into the Linux kernel, the kernel has to be 
updated with latest wanpipe sources.  Install will only
modify existing wanpipe source that is already in the
Kernel. 

IMPORTANT:
It is always recommended to say YES to all options 
prompted during the install!

----------------------------------------------------------
          WANPIPE v7.0.5 Installation Script
    Copyright (c) 1995-2013, Sangoma Technologies Inc.
----------------------------------------------------------


Please specify absolute path name of your linux headers/source directory

Press Enter for Default: /lib/modules/2.6.32-358.23.2.el6.x86_64/build

#>
Setting linux directory to /lib/modules/2.6.32-358.23.2.el6.x86_64/build



Upgrading WANPIPE kernel documentation ...Done.


Installing WANPIPE include headers ...Done.

WANPIPE device drivers upgraded successfully!

Press [Enter] to continue...   // 输入Enter 键
----------------------------------------------------------
          WANPIPE v7.0.5 Installation Script
    Copyright (c) 1995-2013, Sangoma Technologies Inc.
----------------------------------------------------------

WANPIPE KERNEL DRIVER COMPILATION

The next step in WANPIPE installation involves compiling 
WANPIPE kernel modules.  

This script will compile and install WANPIPE modules
into the currently running linux kernel.

For greater customization you will be prompted to
select which Protocol/Drivers you would like to
build into the WANPIPE kernel modules.

Wanpipe for Asterisk/Dahdi/Zaptel
Default for Asterisk/Dahdi/Zaptel
Wanpipe for Wan Routing/API 
Default for Wan/IP Routing and Data API
Wanpipe for Asterisk SMG/SS7
Default for Asterisk SS7
Wanpipe for TDM API
Default for FreeSwitch and Voice API 

Custom Compilation:
------------------
  Customise WANPIPE driver compilation to add only the
  protocols that you need.  This way one can reduce
  the size of the WANPIPE kernel drivers.

Refer to http://wiki.sangoma.com for more info

grep: /lib/modules/2.6.32-358.23.2.el6.x86_64/build/include/include/autoconf.h: No such file or directory
grep: /lib/modules/2.6.32-358.23.2.el6.x86_64/build/include/include/autoconf.h: No such file or directory
----------------------------------------------------------
          WANPIPE v7.0.5 Installation Script
    Copyright (c) 1995-2013, Sangoma Technologies Inc.
----------------------------------------------------------


Please Select Compilation Mode

1. WAN Protocols Support 
       Protocols: Frame Relay, CHDLC, PPP, ATM, X25, ADSL, TDM API
       Default for: Wan Routing, Data & Voice API devel.

2. Asterisk/Dahdi Support 
       Asterisk protocols: libpri (PRI,BRI), Analog (FXO/FXS), libss7 (SS7)
       Default for: Asterisk 

3. Asterisk/Dahdi + WAN Protocol Support

4. TDM API (libsangoma)  
       Protocols: TDM API (libsangoma) on AFT adapters:
       Default for: FreeSWITCH, Yate, Sunrise
                    Custom voice development 

5. Custom Compilation Mode
       Specify protocols to be added into the WANPIPE
       kernel drivers.

6. Deprecated: SMG (BRI) (Asterisk SMG/BRI [Use Asterisk/Dahdi option 2 instead])

7. Deprecated: SMG (BRI) + Asterisk/Dahdi [Use Asterisk/Dahdi option 2 instead]


Please select (1-7) [Default: 1]: 2  // 现在2在asterisk环境下安装E1 卡

Looking for zaptel/dahdi directory in /usr/src ...
-------------------------------------------
1 : /usr/src/dahdi-linux-complete-2.7.0.1+2.7.0.1 
------------------------------------------ 
------------------------------------------ 
m : Enter zaptel path manually

(ctrl-c to Exit)
Please select working zaptel directory [1-1][m]: 1  // 输入 1 选择 dahdi 源代码安装路径,如果dahdi 没有安装在默认的路径下,需要手动添加路径

Enabling the TDM Voice Asterisk Support
                                                      
Dahdi HW HDLC Support Detected: Enabling DCHAN Feature
Native Dahdi HW HDLC Support Detected - No patch required
Dahdi source unmodified
                        
Checking for UDEV Zaptel compatibility...     Dahdi installed, no need to add UDEV rules
Enabling the AFT TE1 Support

Checking for SMP support ...Enabled.

Checking current processor type ...x86_64

Wan Update Flags:  -DAF_WANPIPE_2612_FORCE_UPDATE -DWANPIPE_MOD_266_FORCE_UPDATE
Checking fo regparm: Disabled


--------------------------------------------------
CFLAGS: gcc -Wp,-MD,.wanpipe.o.d -nostdinc -iwithprefix include -D__LINUX__ -Dlinux -D__KERNEL__ -I/usr/include/wanpipe -I/lib/modules/2.6.32-358.23.2.el6.x86_64/build/include  -DMODULE   -DAF_WANPIPE_2612_FORCE_UPDATE -DWANPIPE_MOD_266_FORCE_UPDATE     
--------------------------------------------------

Compiling General WANPIPE Driver for 2.6.X Kernel .....Done.


WAN HWEC module enabled and compiled!
Linking Wanpipe Driver and protocols ...Done.

Updating Kernel Modules ...Done.

Visually Confirm that driver compilation was successful! (y/n) y  // 选择 y
Compilation Successful.
----------------------------------------------------------
          WANPIPE v7.0.5 Installation Script
    Copyright (c) 1995-2013, Sangoma Technologies Inc.
----------------------------------------------------------

WANPIPE META CONFIGURATION

There are two configuration files associated with WANPIPE.  

1) /usr/src/wanpipe-7.0.5/wanrouter.rc: 
- defines locations of important files such as lock
  and configuration files as well as start/stop 
  order of multiple WANPIPE devices.
2) /usr/src/wanpipe-7.0.5/wanpipe1.conf:
- main configuration file for each WANPIPE device.
- defines interfaces, hardware and protocol information.
- this file can be created using the 'wancfg' GUI
  utility or manually based on sample files located
  in /etc/wanpipe/samples.
  
Please read the WanpipeInstallation.(pdf/txt) manual for further
information.

Press [Enter] to continue...  // 输入 Enter

Wanpipe META config file found in /etc/wanpipe directory

Wanpipe startup sequence: wanpipe1

Would you like to keep the original wanpipe startup sequence? (y/n) y //  选择 y

Please specify a desired location for WANPIPE configuration files.

(Press Enter for Default: /etc/wanpipe)

<specify path:>

Please specify a desired location for WANPIPE interface files.

(Press Enter for Default: /etc/wanpipe/interfaces)

<specify path:>  // 摁Enter 键, 板卡配置文件路径


Please specify a location for WANPIPE binary, firmware files.

(Press Enter for Default: /etc/wanpipe/firmware)

<specify path:>  //摁 Enter 键。
----------------------------------------------------------
          WANPIPE v7.0.5 Installation Script
    Copyright (c) 1995-2013, Sangoma Technologies Inc.
----------------------------------------------------------

WANPIPE UTILITIES SETUP

WANPIPE utilities are used to:
1) create configuration files: for Zaptel and Asterisk
/usr/sbin/wancfg_dahdi#Dahdi and Asterisk
/usr/sbin/wancfg_zaptel#Zaptel and Asterisk
/usr/sbin/wancfg_smg#BRI/SS7, Dahdi/Zaptel and Asterisk
/usr/sbin/wancfg_tdmapi#TDM API
2) create WANPIPE WAN/IP configuration files.
(/usr/sbin/wancfg)
3) start,stop,restart individual/all devices and interfaces.
(/usr/sbin/wanrouter)
4) debug line, protocol and driver problems.
(/usr/sbin/wanpipemon)
5) aid in WANPIPE API development
(/etc/wanpipe/api)

Refer to the WanpipeInstallation.(pdf/txt) for more information.

Press [Enter] to continue... // 摁 Enter
Compiling WANPIPE LibSangoma API library ...Done.


Compiling WANPIPE LibStelephony API library ...Done.



Compiling WANPIPE Utilities ...Done.


Compiling WANPIPE WanCfg Utility ...Done.


Compiling WANPIPE LibStelephony API Library ... skipped, not required.


Compiling WANPIPE API Development Utilities ... skipped, not required.


Compiling WANPIPE HWEC Utilities ...Done.


WANPIPE Environment Setup Complete !!!

Press [Enter] to continue...  // 摁 Enter 键
Installing WANPIPE Files ... !
Installing  WANPIPE Utilities in /usr/sbin
Installing wanrouter.rc in /etc/wanpipe
Installing wanpipe libraries in /etc/wanpipe
Installing firmware in /etc/wanpipe/firmware
Installing documentation in /usr/share/doc/wanpipe
cp: omitting directory `doc/man'
Installing sample api code in /etc/wanpipe/api
Installing AFT Firmware update utility in /etc/wanpipe/util
Installing driver headers in /etc/wanpipe/api/include/linux
Installing Hardware Echo Cancel Utilites
Press [Enter] to continue...  // 摁 Enter 键
----------------------------------------------------------
          WANPIPE v7.0.5 Installation Script
    Copyright (c) 1995-2013, Sangoma Technologies Inc.
----------------------------------------------------------


WANPIPE BOOTSTRAP CONFIGURATION

Your system uses System V -style initialization scripts.  You have an option
to add router start-up script to those scripts so that the router will start
automatically when system enters multi-user mode and shut down when it enters
single-user mode or when it is halted.

i.e. By selecting this option WANPIPE will startup on system bootup and 
     stop on system shutdown.

Would you like to install WANPIPE start-up scripts? (y/n) y  // 输入 y

########################################################################
#               Sangoma Wanpipe                                  #
#        Dahdi/Zaptel/SMG/TDMAPI/BOOT Configuration Script             #
#                             v2.39                                    #
#                     Sangoma Technologies Inc.                        #
#                        Copyright(c) 2013.                            #
########################################################################

Current boot level is 3

Wanrouter boot scripts configuration...

Removing existing wanrouter boot scripts...OK
Verifying Zaptel boot scripts...
Enabling wanrouter boot scripts ...(level:8)
Enabling wanrouter shutdown scripts ...(level:91)
----------------------------------------------------------
          WANPIPE v7.0.5 Installation Script
    Copyright (c) 1995-2013, Sangoma Technologies Inc.
----------------------------------------------------------

WANPIPE INSTALLATON: COMPLETE

WANPIPE installation is now complete. WANPIPE kernel drivers 
and configuration/debug utilities have been compiled and installed.

1) Proceed to configure the WANPIPE drivers:
Asterisk/Dahdi   : /usr/sbin/wancfg_dahdi
Asterisk/Zaptel  : /usr/sbin/wancfg_zaptel
TDM API          : /usr/sbin/wancfg_tdmapi
SMG SS7/BRI/PRI  : /usr/sbin/wancfg_smg
WAN Routing/API  : /usr/sbin/wancfg
2) Use the /usr/sbin/wanrouter startup script to start and stop
   the router. (eg: wanrouter start)
3) To uninstall WANPIPE package run ./Setup remove

Please read http://wiki.sangoma.com for further instructions.


Wanpipe / Zaptel Configuration
==============================

wancfg_zaptel configurator can create all wanpipe config files
for ZAPTEL including /etc/zaptel.conf file.
Optionally: the configurator can also create Asterisk zapata.conf
-----------------------------------------------------
Would you like to configure wanpipe devices for DAHDI? (y/n) y  // 输入 y

########################################################################
#               Sangoma Wanpipe                                  #
#        Dahdi/Zaptel/SMG/TDMAPI/BOOT Configuration Script             #
#                             v2.39                                    #
#                     Sangoma Technologies Inc.                        #
#                        Copyright(c) 2013.                            #
########################################################################

Would you like to generate /etc/asterisk/chan_dahdi.conf
 1. YES
 2. NO
[1-2]:1  // 输入1 , 创建默认chan_dahdi.conf 文件

-------------------------------------------------------
Configuring T1/E1 cards [A101/A102/A104/A108/A116/T116]
-------------------------------------------------------
A101 detected on slot:4 bus:4

-----------------------------------------------------------
Configuring port 1 on A101 slot:4 bus:4.
-----------------------------------------------------------

Select media type for AFT-A101 on port 1 [slot:4 bus:4 span:1]
 1. T1
 2. E1
 3. Unused
 4. Exit
[1-4]:2  // 选择 2, 配置为E1 类型

Configuring port 1 on AFT-A101 as E1, line coding:HDB3, framing:CRC4 
 1. YES - Keep these settings
 2. NO  - Configure line coding and framing
[1-2, ENTER='YES']:2  // 是否安装HDB3, CRC4 方式创建文件;如果不带CRC4, 选择2, 修改配置文件

Select line coding for port 1 on 101
 1. HDB3
 2. AMI
[1-2, ENTER='HDB3']:1 // 选择 1

Select framing for port 1 on 101
 1. CRC4
 2. NCRC4
 3. UNFRAMED
[1-3, ENTER='CRC4']:2  // 选择不支持CRC4

Select clock for AFT-101 on port 1 [slot:4 bus:4 span:1]
 1. NORMAL
 2. MASTER
[1-2]:1  // 选择 1

Select signalling type for AFT-101 on port 1 [slot:4 bus:4 span:1]
 1. Zaptel/Dahdi - PRI CPE
 2. Zaptel/Dahdi - PRI NET
 3. Zaptel/Dahdi - E & M
 4. Zaptel/Dahdi - E & M Wink
 5. Zaptel/Dahdi - FXS - Loop Start
 6. Zaptel/Dahdi - FXS - Ground Start
 7. Zaptel/Dahdi - FXS - Kewl Start
 8. Zaptel/Dahdi - FX0 - Loop Start
 9. Zaptel/Dahdi - FX0 - Ground Start
 10. Zaptel/Dahdi - FX0 - Kewl Start
 11. Sangoma SMG/sangoma_prid- PRI CPE
 12. Sangoma SMG/sangoma_prid- PRI NET
[1-12]:1  // 选择CPE 用户侧。运营商是网络侧

Select switchtype for AFT-101 on port 1 
 1. National ISDN 2
 2. Nortel DMS100
 3. AT&T 4ESS
 4. Lucent 5ESS
 5. EuroISDN
 6. Old National ISDN 1
 7. Q.SIG
[1-7]:5 // 选择5


Would you like to enable hardware DTMF detection?
 1. YES
 2. NO
[1-2, ENTER='YES']:1  // 选择 1

Would you like to enable hardware fax detection?
 1. YES
 2. NO
[1-2, ENTER='NO']:1 // 选择 1

Configuring port 1 on AFT-101 as a full E1
 1. YES - Use all channels
 2. NO  - Configure for fractional
[1-2, ENTER='YES']:1 // 使用所有通道

Select dialplan context for AFT-101 on port 1
 1. from-pstn
 2. from-internal
 3. Custom
[1-3]:1  // 选择1


Port 1 on AFT-A101 configuration complete...
Press any key to continue:  // 摁Enter 继续检测安装

T1/E1 card configuration complete.
Press any key to continue:  // 摁 Enter 键,进行其他板卡检测
-------------------------------------------
Configuring ISDN BRI cards [A500/B500/B700]
-------------------------------------------

No Sangoma ISDN BRI cards detected

Press any key to continue: // 摁 enter
------------------------------------
Configuring GSM cards [W400]
------------------------------------

No Sangoma GSM cards detected

Press any key to continue: // 摁Enter
------------------------------------
Configuring analog cards [A200/A400/B600/B610/B700/B800]
------------------------------------
------------------------------------
Configuring USB devices [U100]
------------------------------------

###################################################################
#                             SUMMARY                             #
###################################################################

  1 T1/E1 port(s) detected, 1 configured
  0 ISDN BRI port(s) detected, 0 configured
  0 analog card(s) detected, 0 configured
  0 GSM card(s) detected, 0 configured
  0 usb device(s) detected, 0 configured

Configurator will create the following files:
1. Wanpipe config files in /etc/wanpipe
2. Dahdi config file /etc/dahdi/system.conf
3. chan_dahdi config file /etc/asterisk/chan_dahdi.conf


Your original configuration files will be saved to:
1. /etc/dahdi/system.conf.bak 
2. /etc/asterisk/chan_dahdi.conf.bak 


Your configuration has been saved in /etc/wanpipe/debug-2013-11-21.tgz.
When requesting support, email this file to techdesk@sangoma.com


###################################################################

Configuration Complete! Please select following:
 1. YES - Continue
 2. NO - Exit
[1-2]:1  // 选择 1, 继续配置


Dahdi and Wanpipe configuration complete: choose action
 1. Save cfg: Restart Asterisk & Wanpipe now
 2. Save cfg: Restart Asterisk & Wanpipe when convenient
 3. Save cfg: Stop Asterisk & Wanpipe now
 4. Save cfg: Stop Asterisk & Wanpipe when convenient
 5. Save cfg: Save cfg only (Not Recommended!!!)
 6. Do not save cfg: Exit
[1-6]:2  // 选择 2 或者 3。


Stopping Asterisk...
Waiting for inactivity to perform halt

Stopping Wanpipe...


Shutting down wanpipe1 interface: w1g1
Shutting down device: wanpipe1
No devices running, Unloading Modules


Unloading Dahdi modules...
FATAL: Module dahdi is in use.
Error executing command:
modprobe -r dahdi   // 忽略这些错误

Would you like to continue?
 1. No - exit
 2. YES  
[1-2, ENTER='No']:1 2  // 选择2


Removing old configuration files...

Copying new Wanpipe configuration files...

Copying new Dahdi configuration file (/etc/dahdi/system.conf)...

Copying new chan_dahdi configuration files (/etc/asterisk/chan_dahdi.conf)...

Starting Wanpipe...

Starting WAN Router...
Loading WAN drivers: wanpipe done.
Starting up device: wanpipe1
--> Loading ec image OCT6116-64S.ima...
Configuring interfaces: w1g1 
done.

Loading Dahdi...
DAHDI Tools Version - 2.7.0.1

DAHDI Version: 2.7.0.1
Echo Canceller(s): HWEC
Configuration
======================

SPAN 1: CCS/HDB3 Build-out: 0 db (CSU)/0-133 feet (DSX-1)

31 channels to configure.

Setting echocan for channel 1 to mg2
Setting echocan for channel 2 to mg2
Setting echocan for channel 3 to mg2
Setting echocan for channel 4 to mg2
Setting echocan for channel 5 to mg2
Setting echocan for channel 6 to mg2
Setting echocan for channel 7 to mg2
Setting echocan for channel 8 to mg2
Setting echocan for channel 9 to mg2
Setting echocan for channel 10 to mg2
Setting echocan for channel 11 to mg2
Setting echocan for channel 12 to mg2
Setting echocan for channel 13 to mg2
Setting echocan for channel 14 to mg2
Setting echocan for channel 15 to mg2
Setting echocan for channel 16 to none
Setting echocan for channel 17 to mg2
Setting echocan for channel 18 to mg2
Setting echocan for channel 19 to mg2
Setting echocan for channel 20 to mg2
Setting echocan for channel 21 to mg2
Setting echocan for channel 22 to mg2
Setting echocan for channel 23 to mg2
Setting echocan for channel 24 to mg2
Setting echocan for channel 25 to mg2
Setting echocan for channel 26 to mg2
Setting echocan for channel 27 to mg2
Setting echocan for channel 28 to mg2
Setting echocan for channel 29 to mg2
Setting echocan for channel 30 to mg2
Setting echocan for channel 31 to mg2

Starting Asterisk...
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

Listing Asterisk channels...

   Chan Extension  Context         Language   MOH Interpret        Blocked    State      Description                     
 pseudo            default                    default                         In Service                                 
      1            from-pstn                  default                         In Service                                 
      2            from-pstn                  default                         In Service                                 
      3            from-pstn                  default                         In Service                                 
      4            from-pstn                  default                         In Service                                 
      5            from-pstn                  default                         In Service                                 
      6            from-pstn                  default                         In Service                                 
      7            from-pstn                  default                         In Service                                 
      8            from-pstn                  default                         In Service                                 
      9            from-pstn                  default                         In Service                                 
     10            from-pstn                  default                         In Service                                 
     11            from-pstn                  default                         In Service                                 
     12            from-pstn                  default                         In Service                                 
     13            from-pstn                  default                         In Service                                 
     14            from-pstn                  default                         In Service                                 
     15            from-pstn                  default                         In Service                                 
     17            from-pstn                  default                         In Service                                 
     18            from-pstn                  default                         In Service                                 
     19            from-pstn                  default                         In Service                                 
     20            from-pstn                  default                         In Service                                 
     21            from-pstn                  default                         In Service                                 
     22            from-pstn                  default                         In Service                                 
     23            from-pstn                  default                         In Service                                 
     24            from-pstn                  default                         In Service                                 
     25            from-pstn                  default                         In Service                                 
     26            from-pstn                  default                         In Service                                 
     27            from-pstn                  default                         In Service                                 
     28            from-pstn                  default                         In Service                                 
     29            from-pstn                  default                         In Service                                 
     30            from-pstn                  default                         In Service                                 
     31            from-pstn                  default                         In Service                                 

Type "asterisk -r" to connect to Asterisk console 


Wanrouter start complete...
Current boot level is 3

Wanrouter boot scripts configuration...

Removing existing wanrouter boot scripts...OK
Would you like wanrouter to start on system boot?
 1. YES
 2. NO
[1-2]:1 // 选择 1

Verifying Dahdi boot scripts...
Verifying Dahdi boot scripts...Enabled (level:13)
Verifying Dahdi shutdown scripts...Enabled (level:87)
Enabling wanrouter boot scripts ...(level:12)
Enabling wanrouter shutdown scripts ...(level:86)

Would you like to execute 'dahdi_cfg' each time wanrouter starts?
 1. YES
 2. NO
[1-2]:1  // 选择 1

Removing old smg_ctrl boot.....OK
Removing old smg_ctrl_safe boot.....OK
Sangoma cards configuration complete, exiting...

You have new mail in /var/spool/mail/root
[root@localhost wanpipe-7.0.5]#  

到此,板卡配置完成。如果是2,4,8,或者16E1板卡,脚本在安装过程中会自动检测
第2口,第3口,依此类推。重复执行相应的次数。

以下信息是驱动安装时的提示一些特别说明信息,请选择正确的选项。如果选择错误,可以重新执行Setup-sangoma 来重新配置.
以下信息是安装过程中对中国用户的选项,如果成功安装,可以跳过 步骤 4.

4)'''执行脚本安装过程中,中国用户需要选择的选项''',请小心操作:
Select media type->E1  // 支持中国E1
Select linecode-> HDB3  // E1接口支持两种线路编解码格式:AMI格式和HDB3格式。默认HDB3
Select framing-> NCRC4  // 是否需要支持CRC4 校验,如果不支持选择此项。大多数中国客户使用NCRC4
Select Clock-> Normal
Select Signalling type-> PRI CPE  // 运营商端上NET 网络侧,本地必须选择CPE 用户侧
Select switchtype -> EuroISDN
Select Configure port for full use->yes
Select Dialplan context-> PSTN   // 注意,到这一步,一个端口就算配置完成了,脚本会重复配置 第2 口,3口。。直到配置完所有的板卡端口。
Configuration complete-> Yes
Dahdi and Wanpepe configuration complete-> 选择 2
would you like to continue->Yes
would you like  wanrouter to start on system boot-> yes
would you like to execute dahdi_cfg each time wanrouter starts-> 选择 1


5) 注意,在sangoma+asterisk+Dahdi+chan_ss7 环境下,系统仅仅需要3个核心的配置文件:
1)/etc/wanpipe 目录下的 Sangoma 板卡的驱动每个端口的配置文件(wanpipe1.conf wanpipe2.conf wanpipeX.conf),板卡 CRC4,主时钟,硬件板卡的回声DSP, HDB3配置
2)/etc/dahdi/system.conf 控制 bchan mtp2 语音通道配置文件
3)/etc/asterisk/ss7.conf 控制asterisk 环境下的应用层(ISPUP,CIC,OPC,DPC 等等)文件,不需要chan_dahdi.conf 文件
用户需要在/etc/asterisk/ modules.conf 文件中,禁止chan_dahdi.so 启动加载。

修改wanpipe.conf 文件

注意,如果用户修改了wanpipeX.conf 文件或者 system.conf, 要求用户重新启动wanpipe 驱动(建议重新启动服务器环境)。
具体wanpipe.conf 参数配置的具体信息,请参考:http://wiki.sangoma.com/Wanpipe-Asterisk-Configuration-File

[devices]
wanpipe1 = WAN_AFT, Comment

[interfaces]
w1g1 = wanpipe1, , TDM_VOICE, Comment

[wanpipe1]
CARD_TYPE = AFT
S514CPU = A
CommPort = PRI
AUTO_PCISLOT = NO
PCISLOT = 9
PCIBUS = 2
FE_MEDIA = E1
FE_LCODE = HDB3
FE_FRAME = NCRC4
FE_LINE = 1
TE_CLOCK = NORMAL
TE_REF_CLOCK = 0
ACTIVE_CH = ALL
TE_HIGHIMPEDANCE = NO
FE_TXTRISTATE = NO
MTU = 1500
UDPPORT = 9000
TTL = 255
IGNORE_FRONT_END = NO
TDMV_SPAN = 1
TDMV_DCHAN = 0  //修改到0,则代表关闭了dchan,默认设置为16。 
//这里的配置要和/etc/dahdi/systemc.onf文件配置匹配。
//chan_ss7环境下,system.conf中,大部分dchan设置是必须关闭的。如果使用dchan是这里设置为16。
//如果在system.conf 文件中设置了MTP2=16而不使用dchan,那么这里设置为0。

[w1g1]
ACTIVE_CH = ALL
TDMV_ECHO_OFF = NO

修改system.conf 文件配置

注意,以下配置是以A104D 举例,支持4个span.

#autogenerated by /usr/sbin/wancfg_dahdi do not hand edit
#autogenrated on 2012-8-09
#Dahdi Channels Configurations 
#For detailed Dahdi options, view /etc/dahdi/system.conf.bak
loadzone=cn
defaultzone=cn

#Sangoma A104 port 1 [slot:4 bus:22 span:1] <wanpipe1>
span=1,1,0,ccs,hdb3
bchan=1-31
#可以使用 bchan=1-15,17-31和 MTP2=16 来对接SS7
#hardhdlc=16  // 注释hardhdlc 或者 dchan
#Sangoma A104 port 2 [slot:4 bus:22 span:2] <wanpipe2>
span=2,2,0,ccs,hdb3
bchan=32-62
#echocanceller=mg2,32-46,48-62
#hardhdlc=47 // 注释hardhdlc 或者 dchan

#Sangoma A104 port 3 [slot:4 bus:22 span:3] <wanpipe3>
span=3,3,0,ccs,hdb3
bchan=63-93
#echocanceller=mg2,63-77,79-93
#hardhdlc=78

#Sangoma A104 port 4 [slot:4 bus:22 span:4] <wanpipe4>
span=4,4,0,ccs,hdb3
bchan=94-124
#echocanceller=mg2,94-108,110-124
#hardhdlc=109 // 注释hardhdlc 或者 dchan

检查ss7.conf 文件配置

[linkset-ls1]
enabled => yes
enable_st => yes
use_connect => no
hunting_policy => even_mru // 支持 even_mru或 odd_lru。CIC呼叫策略,正确选择呼叫策略,可以避免CIC电路双抢的问题,减少呼出语音不同的情况。
context => ss7_call // 对应 extensions.conf 文件的标签
language => en
subservice => auto  // 主叫地址属性,支持国内有效,国际有限。如果是其他用户属性,需要打补丁。查看文档最后的代码。
variant => CHINA  //设置为中国变种-SS7 ISUP
[link-l1]
linkset => ls1
channels => 1-15,17-31
schannel => 16
firstcic => 1
enabled => yes

echocancel => no
echocan_train => 350
echocan_taps => 128

[link-l2]
linkset => ls1
channels => 1-31
schannel =>
firstcic => 33
enabled => yes

[link-l3]
linkset => ls1
channels => 1-31
schannel =>
firstcic => 65
enabled => yes

[link-l4]
linkset => ls1
channels => 1-31
schannel =>
firstcic => 97
enabled => yes

[host-sangoma]    // host 名称必须是本地服务器的主机名称,请修改到相应的主机名称。否则,asterisk 启动后会显示主机名称不符报错信息。
enabled => yes
opc => 0xXXXXXX ;      // 和运营商获取源点码
dpc => ls1:0xXXXXXX ;  // 和运营商获取目的地点码
links => l1:1,l2:2,l3:3,l4:4  // 对应link数量

配置呼叫测试的拨号规则

打开呼叫配置文件 vi /etc/extensions.conf,添加以下拨号规则,然后使用分机拨100呼出测试

[ss7_call]   // 对应 ss7.conf 文件里面的context 
exten => 100,1,Dial(ss7/XXXXXXXXX)  // 呼出到XXXXXXXX你的呼出号码
exten => 100,2,Hangup

第4章:检查SS7 状态

启动sangoma语音板卡的顺序

Sangoma 的驱动的卸载,加载顺序特别特别,需要用户特别留意。
卸载的流程:

asterisk -r 进入后台,执行 core stop now
amportal stop // 如果是elastix 或者 tribox 执行此命令停止asterisk 服务
wanrouter stop 
service dahdi stop

加载的流程:

wanrouter start
dahdi_cfg -vvvv
safe_asterisk
asterisk -r  // 进入Asterisk 后台

具体参看资料: http://wiki.sangoma.com/wanpipe-asterisk-operation#wan-ast-zap-stop-start 10

确认链路连接正常

执行asterisk -r 进入到asterisk CLI

CLI> ss7 link status  // 如果显示 INSERVICE, 说明链路成功连接,否则检查线路配置。
linkset siuc, link l1, schannel 16, sls 0, INSERVICE, rx: 0, tx: 3/3, sentseq/lastack: 85/85, total 806579120, 806579216
CLI> ss7 status
linkset        idle busy initiating resetting total incoming total outgoing
ls1              30    0          0         0              0              0
gw1*CLI> ss7 linestat // 无呼叫,显示 IDLE 闲置状态
Linkset: ls1
CIC   1 Idle
CIC   2 Idle
CIC   3 Idle
CIC   4 Idle
CIC   5 Idle
CIC   6 Idle
CIC   7 Idle
CIC   8 Idle
CIC   9 Idle
CIC  10 Idle
CIC  11 Idle
CIC  12 Idle
CIC  13 Idle
CIC  14 Idle
CIC  15 Idle
CIC  17 Idle
CIC  XX Idle

以上命令检查无错误,就可以开始测试呼叫。如果出现以下错误日志信息,请联系james.zhu@hiastar.com 获取补丁文件。

Jan 16 10:30:37] NOTICE[2756] mtp.c: Excessive poll delay 5003!
[Jan 16 10:30:38] NOTICE[2756] mtp.c: Excessive poll delay 5032!
[Jan 16 10:30:39] NOTICE[2756] mtp.c: Excessive poll delay 5016!
[Jan 16 10:30:40] NOTICE[2756] mtp.c: Excessive poll delay 5012!

第5章:呼叫测试语音线路

添加拨号规则以后,重新reload asterisk 模块,使用分机拨打100就可以测试呼出。

第6章:7号信令常见问题排查

1)如果链路正常,呼叫有振令,但是互相听不到语音,检查CIC配置。默认是0,询问运营商此项配置的具体值
2) 使用线芯:1245。
3)BNC长头,短头用法:短头-Rx-12, 长头-Tx-45。
4) 通常使用的E1线包括:直通线(连接运营商),交叉线(两张板卡对测),回环测试线(板卡端口之间对接测试)。
5) 直通线/交叉线/回环测试线的做法:E1线的做法和线序
6)SS7 开源的协议栈包括chan_ss7 和libss7。
7) chan_ss7 支持中国SS7 ISUP。TUP模块不建议使用。
8)原号码透传在asterisk-1.6 版本可以支持,发送到对端。asterisk-1.8 不支持。
建议使用比较旧的版本,然后修改运营商设置的用户属性,重新设置rdnis
9)chan_ss7 可以在elastix 上重新配置,但是应用层的模块可能出现错误,例如CDR,FOP。
10)目前ss7 除了支持sangoma,digium 以外还可以支持openvox,Atcom,三汇语音板卡。
11)除了Sangoma语音板卡可以实现SS7进入方案,可以选择sangoma ss7设备进入的方式:
7号信令设备
12)chan_ss7 如何提高修改代码支持用户属性:
关于主叫地址性质的修改,参见l4isup.c

/* Calling party's category Q.763 (3.11). */
- param[0] = 0x0a; /* Ordinary calling subscriber */ 这里是普通用户属性 001010 由 6个 bit组成.
+ param[0] = 0x0c; /*  修改到 数据呼叫属性 001100 */
isup_msg_add_fixed(msg, sizeof(msg), &current, param, 1);

13)解决原呼叫号码透传问题,建议使用asterisk-1.4,1.6版本,修改用户属性,然后重新设置rdnis。
14) 如何通过不同的链路组或者指定的CIC呼出
语法:

Dial(SS7/Linkset1:33/number)
Dial(SS7/Linkset1/number)

patch:

--- l4isup.c.orig	2010-04-14 13:32:30.000000000 +0200
+++ l4isup.c	2010-04-14 13:31:39.000000000 +0200
@@ -525,7 +525,7 @@
 
 /* This implements the policy: Primary hunting group odd CICs, secondary
    hunting group even CICs. Choose least recently used CIC. */
-static struct ss7_chan *cic_hunt_odd_lru(struct linkset* linkset) {
+static struct ss7_chan *cic_hunt_odd_lru(struct linkset* linkset, int first_cic, int last_cic) {
   struct ss7_chan *cur, *prev, *best, *best_prev;
   int odd;
 
@@ -537,6 +537,10 @@
       if(!cur->reset_done || (cur->blocked & (BL_LH|BL_RM|BL_RH|BL_UNEQUIPPED|BL_LINKDOWN))) {
         continue;
       }
+      /* is this cic within the selected range? */
+      if(cur->cic < first_cic || cur->cic > last_cic) {
+        continue;
+      }
       if((cur->cic % 2) == odd) {
         best = cur;
         best_prev = prev;
@@ -558,7 +562,7 @@
 
 /* This implements the policy: Primary hunting group even CICs, secondary
    hunting group odd CICs. Choose most recently used CIC. */
-static struct ss7_chan *cic_hunt_even_mru(struct linkset* linkset) {
+static struct ss7_chan *cic_hunt_even_mru(struct linkset* linkset, int first_cic, int last_cic) {
   struct ss7_chan *cur, *prev, *best, *best_prev;
 
   best = NULL;
@@ -569,6 +573,10 @@
     if(!cur->reset_done || (cur->blocked & (BL_LH|BL_RM|BL_RH|BL_UNEQUIPPED|BL_LINKDOWN))) {
       continue;
     }
+    /* is this cic within the selected range? */
+    if(cur->cic < first_cic || cur->cic > last_cic) {
+      continue;
+    }
     if((cur->cic % 2) == 0) {
       /* Choose the first idle even circuit, if any. */
       best = cur;
@@ -597,7 +605,7 @@
 }
 
 /* This implements the policy: Sequential low to high CICs */
-static struct ss7_chan *cic_hunt_seq_lth_htl(struct linkset* linkset, int lth)
+static struct ss7_chan *cic_hunt_seq_lth_htl(struct linkset* linkset, int lth, int first_cic, int last_cic)
 {
   struct ss7_chan *cur, *prev, *best = NULL, *best_prev = NULL;
 
@@ -606,6 +614,10 @@
     if(!cur->reset_done || (cur->blocked & (BL_LH|BL_RM|BL_RH|BL_UNEQUIPPED|BL_LINKDOWN))) {
       continue;
     }
+    /* is this cic within the selected range? */
+    if(cur->cic < first_cic || cur->cic > last_cic) {
+      continue;
+			          }
     if (!best) {
       best = cur;
       continue;
@@ -815,21 +827,30 @@
 }
 
 /* hunt free CIC */
-static struct ss7_chan* cic_hunt(struct linkset* linkset)
+static struct ss7_chan* cic_hunt(struct linkset* linkset, int first_cic, int last_cic)
 {
+  if(first_cic > last_cic) {
+     ast_log(LOG_ERROR, "first CIC: %d greater than last CIC: %d\n", first_cic, last_cic);
+     return NULL;
+  }
+  if(first_cic < linkset->first_cic || first_cic > linkset->last_cic || last_cic > linkset->last_cic) {
+     ast_log(LOG_ERROR, "CICs not in valid range, first: %d last: %d\n", first_cic, last_cic);
+     return NULL;
+  }
+
   struct ss7_chan* pvt;
   switch(linkset->hunt_policy) {
   case HUNT_ODD_LRU:
-    pvt = cic_hunt_odd_lru(linkset);
+    pvt = cic_hunt_odd_lru(linkset, first_cic, last_cic);
     break;
   case HUNT_EVEN_MRU:
-    pvt = cic_hunt_even_mru(linkset);
+    pvt = cic_hunt_even_mru(linkset, first_cic, last_cic);
     break;
   case HUNT_SEQ_LTH:
-    pvt = cic_hunt_seq_lth_htl(linkset, 1);
+    pvt = cic_hunt_seq_lth_htl(linkset, 1, first_cic, last_cic);
     break;
   case HUNT_SEQ_HTL:
-    pvt = cic_hunt_seq_lth_htl(linkset, 0);
+    pvt = cic_hunt_seq_lth_htl(linkset, 0, first_cic, last_cic);
     break;
   default:
     pvt = NULL;
@@ -847,6 +868,7 @@
   struct ss7_chan *pvt;
   struct linkset* linkset = this_host->default_linkset;
   char *sep = strchr(arg, '/');
+  char *cic_sep = strchr(arg, ':');
 
   ast_log(LOG_DEBUG, "SS7 request (%s/%s) format = 0x%X.\n", type, arg, format);
 
@@ -857,16 +879,58 @@
   }
   if (sep) {
     char name_buf[100];
-    strncpy(name_buf, arg, sep-arg);
-    name_buf[sep-arg] = 0;
+
+    // linkset:cics -> link1:10-21
+    if(cic_sep != NULL) {
+       strncpy(name_buf, arg, cic_sep-arg);
+       name_buf[cic_sep-arg] = 0;
+    }
+    else {
+        strncpy(name_buf, arg, sep-arg);
+        name_buf[sep-arg] = 0;
+    }
+
     linkset = lookup_linkset(name_buf);
+
     if (!linkset) {
       ast_log(LOG_ERROR, "SS7 requester: No such linkset: '%s', using default\n", name_buf);
       linkset = this_host->default_linkset;
     }
   }
   lock_global();
-  pvt = cic_hunt(linkset);
+
+  // CIC selection via dial parameter
+  // TODO check if cics extracted are numeric before calling atoi()
+  if(cic_sep != NULL) {
+      // use specific cics
+      char cics[100];
+      char first_cic[10], last_cic[10];
+
+      // copy xxx:xxx part
+      strncpy(cics, cic_sep + 1, sep-cic_sep-1);
+      cics[sep-cic_sep] = '\0';
+
+      char *cics_sep = strchr(cics, '-');
+
+      if(cics_sep != NULL) {
+     	// copy cic parts
+      	strncpy(first_cic, cics, cics_sep-cics);
+      	strncpy(last_cic, cics_sep + 1, strlen(cics) - (cics_sep-cics) - 2);
+
+	first_cic[cics_sep-cics] = '\0';
+	last_cic[strlen(cics) - (cics_sep-cics) - 2] = '\0';
+
+        pvt = cic_hunt(linkset, atoi(first_cic), atoi(last_cic));
+      }
+      else {
+	  // single CIC
+	  int cic = atoi(cics);
+          pvt = cic_hunt(linkset, cic, cic);
+      }
+  }
+  else {
+      pvt = cic_hunt(linkset, linkset->first_cic, linkset->last_cic);
+  }
 
   if(pvt == NULL) {
     unlock_global();
@@ -2789,7 +2853,9 @@
   t7_clear(pvt);
   pvt->owner = NULL;
   chan->tech_pvt = NULL;
-  newpvt = cic_hunt(pvt->link->linkset);
+  ast_log(LOG_WARNING, "Reattempt call: hunting on all cics\n");
+  // todo: use cics specified in dial parameters
+  newpvt = cic_hunt(pvt->link->linkset, pvt->link->linkset->first_cic, pvt->link->linkset->last_cic);
   if (newpvt) {
     ast_mutex_lock(&newpvt->lock);
     ast_log(LOG_DEBUG, "Reattempt call: Got cic %d\n", newpvt->cic);

15)如何查看E1线路物理连接状态是否正常,请参考 http://wiki.voip88.com/index.php/Sangoma
16) Sangoma wanpipe 命令使用手册,请参考 http://wiki.voip88.com/index.php/Sangoma
17)打包Sangoma 系统日志,请参考 http://wiki.voip88.com/index.php/Sangoma