这里先来个开场白,写这个博客,是因为近来,研究车联网,涉及到语音通话的需求,所以就想基于IP的通话解决方案,为用户和公司打个经济算盘。
VoIP通话,相关的背景介绍,就不浪费时间了,自己问度娘,这里我选择比较经典的稳定性比较高的asterisk(Linux版本)作为VoIP通话的服务端解决方案,客户端,也就是电话工具,选择的是Yate Client(Window版本)。
基础环境信息:
Linux:CentOS7,1C4G100G
Windows:Win10, 8C16G1T
Asterisk:asterisk-17-current.tar.gz
YateClient:yate-5.4.0-1-setup.exe
1.下载asterisk,libpri,dahdi(linux,tools,合并为complete)
https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-17-current.tar.gz (http://downloads.asterisk.org/pub/telephony/asterisk/或者在这里自行选择) https://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz https://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
2.下面按顺序安装各个组件
2.1 安装dahdi
先tar解压,然后make,遇到下面的错误。缺乏kernel-devel
[root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]# make make -C linux all make[1]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux' make -C drivers/dahdi/firmware firmware-loaders make[2]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/drivers/dahdi/firmware' make[2]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/drivers/dahdi/firmware' You do not appear to have the sources for the 3.10.0-514.el7.x86_64 kernel installed. make[1]: *** [modules] Error 1 make[1]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux' make: *** [all] Error 2
安装上即可,kernel-devel在CentOS的安装镜像里面有,配置为yum源安装即可。
[root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]# yum install kernel-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package kernel-devel.x86_64 0:3.10.0-514.el7 will be installed --> Finished Dependency Resolution
然后,继续make
[root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]# make make -C linux all make[1]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux' make -C drivers/dahdi/firmware firmware-loaders make[2]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/drivers/dahdi/firmware' make[2]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/drivers/dahdi/firmware' make -C /lib/modules/3.10.0-514.el7.x86_64/build KBUILD_EXTMOD=/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/drivers/dahdi DAHDI_INCLUDE=/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/include DAHDI_MODULES_EXTRA=" " HOTPLUG_FIRMWARE=yes modules DAHDI_BUILD_ALL=m make[2]: Entering directory `/usr/src/kernels/3.10.0-514.el7.x86_64' .... make[3]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' CC libtonezone_la-version.lo CCLD libtonezone.la CCLD fxstest CCLD patlooptest CC version.o CCLD dahdi_maint CCLD dahdi_cfg make -f ./Makefile.legacy top_srcdir=. srcdir=. all make[4]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[4]: Nothing to be done for `all'. make[4]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[3]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[2]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[1]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' [root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]#
然后,make install
.... ################################################### ### ### DAHDI installed successfully. ### If you have not done so before, install the package ### dahdi-tools. ### ################################################### .... ################################################### ### ### DAHDI tools installed successfully. ### If you have not done so before, install init scripts with: ### ### make install-config ### ################################################### .... mkdir -p /etc/bash_completion.d install -m 644 ./dahdi-bash-completion /etc/bash_completion.d/dahdi make[4]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[3]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[2]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[1]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' [root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]#
然后, make config
[root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]# make config make: Nothing to be done for `config'
2.2 安装libpri
用tar命令解压,然后安装
[root@tkiot-isc1 libpri-1.6.0]# make [root@tkiot-isc1 libpri-1.6.0]# make install
2.3 安装asterisk
2.3.1 配置configure
[root@tkiot-isc1 asterisk-17.5.0]# ./configure checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking whether char is unsigned... no checking for uname... /usr/bin/uname checking for g++... no checking for c++... no checking for gpp... no checking for aCC... no checking for CC... no checking for cxx... no checking for cc++... no checking for cl.exe... no checking for FCC... no checking for KCC... no checking for RCC... no checking for xlC_r... no checking for xlC... no checking whether we are using the GNU C++ compiler... no checking whether g++ accepts -g... no checking how to run the C preprocessor... gcc -E checking how to run the C++ preprocessor... /lib/cpp configure: error: in `/usr/local/src/voip/asterisk-17.5.0': configure: error: C++ preprocessor "/lib/cpp" fails sanity check See `config.log' for more details [root@tkiot-isc1 asterisk-17.5.0]#
上述错误,是系统缺乏插件
yum install glibc-headers
yum install gcc-c++
安装结束后,再次configure,依然报错
configure: error: patch is required to configure bundled pjproject
需要安装patch依赖
yum install patch
依然报错:
checking for a sed that does not truncate output... (cached) /usr/bin/sed checking whether gcc is Clang... no checking whether pthreads work with -pthread... yes checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE checking whether more special flags are required for pthreads... no checking for PTHREAD_PRIO_INHERIT... yes checking for RAII support... checking for gcc -fnested-functions... no checking for clang strsep/strcmp optimization... no checking for embedded pjproject (may have to download)... configuring [pjproject] Downloading https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/2.9/pjproject-2.9.tar.bz2 to /tmp/pjproject-2.9.tar.bz2 [pjproject] Retrying download [pjproject] Downloading https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/2.9/pjproject-2.9.tar.bz2 to /tmp/pjproject-2.9.tar.bz2 make: *** [/tmp/pjproject-2.9.tar.bz2] Error 4 make: *** Deleting file `/tmp/pjproject-2.9.tar.bz2' failed configure: Unable to configure third-party/pjproject configure: error: Re-run the ./configure command with 'NOISY_BUILD=yes' appended to see error details.
显示pjproject下载不下来,我只能选择手动下载安装,因为我的机器不能上外网。https://github.com/pjsip/pjproject/releases/tag/2.9,从这里下载2.9版本,当前最新的版本是2.10. 解压tar包后,进行安装,三步走(configure,make,make install)
1) 参考文档(https://wiki.asterisk.org/wiki/display/AST/PJSIP-pjproject),有些注意细节
./configure --libdir=/usr/lib64 CFLAGS='-O2 -DNDEBUG'
2) make dep & make
3) make install
4) ldconfig (更新库的链接)
5) ldconfig -p | grep pj (校验动态库链接的更新情况)
然后继续上面的asterisk的configure。提示还是存在上述pjproject-2.9.tar.bz2配置不成功的问题,于是,按照下面的指令操作。这里--without-pjproject-bundled表示不用asterisk自带的pjproject包,可以采用外部安装的pjproject,如前面已经安装的。
[root@tkiot-isc1 asterisk-17.5.0]# ./configure --without-pjproject-bundled --libdir=/usr/lib64 .... checking utime.h usability... yes checking utime.h presence... yes checking for utime.h... yes checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for LIBEDIT... no checking for history_init in -ledit... no configure: error: *** Please install the 'libedit' development package.
参考网上的经验,在CentOS下安装asterisk,需要的依赖都装上
yum install -y epel-release dmidecode gcc-c++ ncurses-devel libxml2-devel make wget openssl-devel newt-devel kernel-devel sqlite-devel libuuid-devel gtk2-devel jansson-devel binutils-devel
这里,我的机器yum install libedit-devel不成功,后来,下载libedit的rpm包安装成功,继续configure,还是报下面的错误:
checking uuid/uuid.h presence... yes checking for uuid/uuid.h... yes checking for JANSSON... no checking for json_sprintf in -ljansson... no configure: *** Asterisk requires libjansson >= 2.11 and no system copy was found. configure: *** Please install the 'libjansson' development package or configure: *** use './configure --with-jansson-bundled'
在这里,我从http://digip.org/jansson/releases/网站下载了2.12版本的,解压,configure&&make&&make install后,再进行asterisk的configure就ok了,得到下面的期待的效果:
checking for ncurses.h... (cached) yes checking for a sed that does not truncate output... /usr/bin/sed checking for xml2-config... /bin/xml2-config checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for GTK2... yes configure: creating ./config.status config.status: creating makeopts config.status: creating autoconfig.h configure: Menuselect build configuration successfully completed .$$$$$$$$$$$$$$$=.. .$7$7.. .7$$7:. .$$:. ,$7.7 .$7. 7$$$$ .$$77 ..$$. $$$$$ .$$$7 ..7$ .?. $$$$$ .?. 7$$$. $.$. .$$$7. $$$$7 .7$$$. .$$$. .777. .$$$$$$77$$$77$$$$$7. $$$, $$$~ .7$$$$$$$$$$$$$7. .$$$. .$$7 .7$$$$$$$7: ?$$$. $$$ ?7$$$$$$$$$$I .$$$7 $$$ .7$$$$$$$$$$$$$$$$ :$$$. $$$ $$$$$$7$$$$$$$$$$$$ .$$$. $$$ $$$ 7$$$7 .$$$ .$$$. $$$$ $$$$7 .$$$. 7$$$7 7$$$$ 7$$$ $$$$$ $$$ $$$$7. $$ (TM) $$$$$$$. .7$$$$$$ $$ $$$$$$$$$$$$7$$$$$$$$$.$$$$$$ $$$$$$$$$$$$$$$$. configure: Package configured for: configure: OS type : linux-gnu configure: Host CPU : x86_64 configure: build-cpu:vendor:os: x86_64 : pc : linux-gnu : configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :
2.3.2 编译asterisk
[root@tkiot-isc1 asterisk-17.5.0]# make ...... [CC] stasis_recording/stored.c -> stasis_recording/stored.o [LD] res_stasis_recording.o stasis_recording/stored.o -> res_stasis_recording.so Building Documentation For: third-party channels pbx apps codecs formats cdr cel bridges funcs tests main res addons +--------- Asterisk Build Complete ---------+ + Asterisk has successfully been built, and + + can be installed by running: + + + + make install + +-------------------------------------------+
2.3.3 安装asterisk
[root@tkiot-isc1 asterisk-17.5.0]# make install Installing modules from channels... Installing modules from pbx... Installing modules from apps... Installing modules from codecs... Installing modules from formats... Installing modules from cdr... Installing modules from cel... Installing modules from bridges... Installing modules from funcs... Installing modules from tests... Installing modules from main... Installing modules from res... Installing modules from addons... ...... +---- Asterisk Installation Complete -------+ + + + YOU MUST READ THE SECURITY DOCUMENT + + + + Asterisk has successfully been installed. + + If you would like to install the sample + + configuration files (overwriting any + + existing config files), run: + + + + For generic reference documentation: + + make samples + + + + For a sample basic PBX: + + make basic-pbx + + + + + +----------------- or ---------------------+ + + + You can go ahead and install the asterisk + + program documentation now or later run: + + + + make progdocs + + + + **Note** This requires that you have + + doxygen installed on your local system + +-------------------------------------------+
2.3.4 生成asterisk的配置文件
[root@tkiot-isc1 asterisk-17.5.0]# make samples Installing adsi config files... /usr/bin/install -c -d "/etc/asterisk" Installing configs/samples/asterisk.adsi Installing configs/samples/telcordia-1.adsi Installing other config files... Installing file configs/samples/acl.conf.sample Installing file configs/samples/adsi.conf.sample Installing file configs/samples/agents.conf.sample Installing file configs/samples/alarmreceiver.conf.sample Installing file configs/samples/alsa.conf.sample Installing file configs/samples/amd.conf.sample ...... Installing file configs/samples/xmpp.conf.sample Updating asterisk.conf /usr/bin/install -c -d "/var/spool/asterisk/voicemail/default/1234/INBOX" build_tools/make_sample_voicemail "//var/lib/asterisk" "//var/spool/asterisk" Installing file phoneprov/000000000000.cfg Installing file phoneprov/000000000000-directory.xml Installing file phoneprov/000000000000-phone.cfg Installing file phoneprov/polycom_line.xml Installing file phoneprov/polycom.xml Installing file phoneprov/snom-mac.xml
从日志中可以看出,配置文件,主要在目录/etc/asterisk下面
2.3.5 生成配置项菜单列表menuselect
[root@tkiot-isc1 asterisk-17.5.0]# make menuselect ************************************************** Asterisk Module and Build Option Selection ************************************************** Press 'h' for help. ---> Add-ons (See README-addons.txt) Applications Bridging Modules Call Detail Recording Channel Event Logging Channel Drivers Codec Translators Format Interpreters Dialplan Functions PBX Modules Resource Modules Test Modules Compiler Flags Utilities AGI Samples Core Sound Packages Music On Hold File Packages Extras Sound Packages
这是一个字符菜单,光标上下滑动选择,回车键确认,进入子菜单,向左键回退上一级菜单
2.3.6 安装asterisk的初始化脚本
[root@tkiot-isc1 asterisk-17.5.0]# make config
2.3.7 安装日志工具logrotate
[root@tkiot-isc1 asterisk-17.5.0]# make install-logrotate
主要是方便日志的回滚管理,方便后续问题追溯
2.3.8 查看asterisk所需的依赖是否都在
[root@tkiot-isc1 asterisk-17.5.0]# cd contrib/scripts [root@tkiot-isc1 scripts]# ./install_prereq install Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile No package jansson-devel available. No package speex-devel available. No package speexdsp-devel available. No package libogg-devel available. No package libvorbis-devel available. No package portaudio-devel available. No package xmlstarlet available. No package neon-devel available. No package gmime-devel available. No package lua-devel available. No package uriparser-devel available. Package 1:mariadb-devel-5.5.52-1.el7.x86_64 already installed and latest version No package bluez-libs-devel available. No package radcli-devel available. No package freetds-devel available. No package jack-audio-connection-kit-devel available. No package iksemel-devel available. No package corosynclib-devel available. No package newt-devel available. No package spandsp-devel available. No package libresample-devel available. No package uw-imap-devel available. No package libsrtp-devel available. No package gsm-devel available. No package hoard available. No package codec2-devel available. No package libsndfile-devel available. No package unbound-devel available. Nothing to do ############################################# ## install completed successfully #############################################
自己在网上,将上述依赖的包,都装上即可
这里需要说明一个小小的技巧,针对rpm安装中出现A依赖B,但是B又依赖A的问题,可以通过将要安装的包在一个命令里面进行安装,并且在命令行后面加上参数 -aid。下面是freetds依赖freetds-libs,但是freetds-libs又依赖freetds的场景。
[root@tkiot-isc1 voip]# rpm -ivh freetds-1.1.20-1.el7.x86_64.rpm warning: freetds-1.1.20-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY error: Failed dependencies: freetds-libs(x86-64) = 1.1.20-1.el7 is needed by freetds-1.1.20-1.el7.x86_64 libsybdb.so.5()(64bit) is needed by freetds-1.1.20-1.el7.x86_64 [root@tkiot-isc1 voip]# rpm -ivh freetds-libs-1.1.20-1.el7.x86_64.rpm warning: freetds-libs-1.1.20-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY error: Failed dependencies: freetds = 1.1.20-1.el7 is needed by freetds-libs-1.1.20-1.el7.x86_64
解决的办法如下:
[root@tkiot-isc1 voip]# rpm -ivh freetds-* -aid warning: freetds-1.1.20-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:freetds-libs-1.1.20-1.el7 ################################# [ 33%] 2:freetds-1.1.20-1.el7 ################################# [ 67%] 3:freetds-devel-1.1.20-1.el7 ################################# [100%]
说明:对于仅仅是打通IP之间的电话,即纯粹的网络电话,这一步中的prerequisite的package,是不用全都安装完安装好的
3. 验证安装的效果
3.1 首先看asterisk的安装是否OK
[root@tkiot-isc1 asterisk-17.5.0]# service asterisk start Starting asterisk (via systemctl): [ OK ] [root@tkiot-isc1 asterisk-17.5.0]# [root@tkiot-isc1 asterisk-17.5.0]# service asterisk status ● asterisk.service - LSB: Asterisk PBX Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled) Active: active (running) since Thu 2020-06-18 16:57:55 CST; 4s ago Docs: man:systemd-sysv-generator(8) Process: 21876 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS) Main PID: 21905 CGroup: /system.slice/asterisk.service ├─21901 /bin/sh /usr/sbin/safe_asterisk └─21911 sleep 4 Jun 18 16:57:54 tkiot-isc1 systemd[1]: Starting LSB: Asterisk PBX... Jun 18 16:57:55 tkiot-isc1 asterisk[21876]: Starting asterisk: Jun 18 16:57:55 tkiot-isc1 systemd[1]: PID file /var/run/asterisk/asterisk.pid not readable (yet?) after start. Jun 18 16:57:55 tkiot-isc1 systemd[1]: asterisk.service: Supervising process 21905 which is not our child. We'll most likely not notice when it exits. Jun 18 16:57:55 tkiot-isc1 systemd[1]: Started LSB: Asterisk PBX.
3.2 远程连接验证
[root@tkiot-isc1 asterisk-17.5.0]# asterisk -rvvv
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)
这里遇到了问题,怎么解决呢?在网上查询了很多方法,都试过了不能解决问题,什么文件权限,什么配置啥的,都不管用。我是在执行asterisk -cvvv的指令时,有提示下面的信息得到的启发:
[root@tkiot-isc1 ~]$ asterisk -cvvv Asterisk 17.5.0, Copyright (C) 1999 - 2018, Digium, Inc. and others. Created by Mark Spencer <markster@digium.com> Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details. ========================================================================= Manager registered action DBGet Manager registered action DBPut Manager registered action DBDel Manager registered action DBDelTree PBX UUID: 66ed4c43-ba2e-467c-b2b6-0ad8705d02d8 There was a problem finding jansson 2.11 runtime libraries. Please rebuild Asterisk using ./configure --with-jansson-bundled. libjansson initialization failed. ASTERISK EXITING! Manager unregistered action DBGet Manager unregistered action DBPut Manager unregistered action DBDel Manager unregistered action DBDelTree
说明啥呢,jansson这个插件没有安装好。于是,我再次进入到jansson的包,从configure,make,make install再次执行了边。这里最大的可能就是configure出了问题,因为其他的安装,我都制定了--libdir=/usr/lib64,唯独这个安装没有指定,于是乎,这么一来,还真就解决了问题。
[root@tkiot-isc1 asterisk-17.5.0]# asterisk -rvvvv Asterisk 17.5.0, Copyright (C) 1999 - 2018, Digium, Inc. and others. Created by Mark Spencer <markster@digium.com> Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details. ========================================================================= Connected to Asterisk 17.5.0 currently running on tkiot-isc1 (pid = 3717) tkiot-isc1*CLI> tkiot-isc1*CLI> core show help ! -- Execute a shell command acl show -- Show a named ACL or list all named ACLs ael reload -- Reload AEL configuration ael set debug {read|tokens|macros|contexts|off} -- Enable AEL debugging flags agent logoff -- Sets an agent offline agent show all -- Show status of all agents agent show online -- Show status of online agents agent show -- Show information about an agent agi dump html -- Dumps a list of AGI commands in HTML format agi exec -- Add AGI command to a channel in Async AGI agi set debug [on|off] -- Enable/Disable AGI debugging agi show commands [topic] -- List AGI commands or specific help aoc set debug -- enable cli debugging of AOC messages ari mkpasswd -- Encrypts a password ari set debug -- Enable/disable debugging of an ARI application ari show apps -- List registered ARI applications ari show app -- Display details of a registered ARI application ari show status -- Show ARI settings ari show users -- List ARI users ari show user -- List single ARI user bridge kick -- Kick a channel from a bridge bridge show all -- List all bridges bridge show -- Show information about a bridge bridge technology show -- List registered bridge technologies bridge technology {suspend|unsuspend} -- Suspend/unsuspend a bridge technology calendar dump sched -- Dump calendar sched context calendar show calendar -- Display information about a calendar calendar show calendars -- Show registered calendars calendar show types -- Show all calendar types loaded cc cancel [core|all] -- Kill a CC transaction cc report status -- Reports CC stats cdr set debug [on|off] -- Enable debugging in the CDR engine cdr show active -- Display active CDRs for channels cdr show pgsql status -- Show connection status of the PostgreSQL CDR driver (cdr_pgsql) cdr show status -- Display the CDR status cdr submit -- Posts all pending batched CDR data cel show status -- Display the CEL status channel originate -- Originate a call channel redirect -- Redirect a call channel request hangup -- Request a hangup on a given channel cli check permissions -- Try a permissions config for a user cli reload permissions -- Reload CLI permissions config cli show aliases -- Show CLI command aliases cli show permissions -- Show CLI permissions confbridge kick -- Kick participants out of conference bridges. confbridge list -- List conference bridges and participants. confbridge lock -- Lock a conference. confbridge mute -- Mute participants. confbridge record start -- Start recording a conference confbridge record stop -- Stop recording a conference. confbridge show menu -- Show a conference menu confbridge show menus -- Show a list of conference menus confbridge show profile bridge -- Show a conference bridge profile. confbridge show profile bridges -- Show a list of conference bridge profiles. confbridge show profile user -- Show a conference user profile. confbridge show profile users -- Show a list of conference user profiles. confbridge unlock -- Unlock a conference. confbridge unmute -- Unmute participants. config list -- Show all files that have loaded a configuration file config reload -- Force a reload on modules using a particular configuration file config show help -- Show configuration help for a module console answer -- Answer an incoming console call console boost -- Sets/displays mic boost in dB console dial -- Dial an extension on the console console flash -- Flash a call on the console console hangup -- Hangup a call on the console console {mute|unmute} [toggle] -- Disable/Enable mic input console send text -- Send text to the remote device console transfer -- Transfer a call to a different extension console {device} -- Generic console command console {set|show} autoanswer [on|off] -- Sets/displays autoanswer console {set|show} active [<device>] -- Sets/displays active console core abort shutdown -- Cancel a running shutdown core clear profile -- Clear profiling info core ping taskprocessor -- Ping a named task processor core reload -- Global reload core reset taskprocessor -- Reset a named task processor's stats core reset taskprocessors -- Reset all task processors' stats core restart gracefully -- Restart Asterisk gracefully core restart now -- Restart Asterisk immediately core restart when convenient -- Restart Asterisk at empty call volume core set debug channel -- Enable/disable debugging on a channel core set debug -- Set level of debug chattiness core set verbose -- Set level of verbose chattiness core show applications [like|describing] -- Shows registered dialplan applications core show application -- Describe a specific dialplan application core show calls [uptime] -- Display information on calls core show channels [concise|verbose|count] -- Display information on channels core show channel -- Display information on a specific channel core show channeltypes -- List available channel types core show channeltype -- Give more details on that channel type core show codecs [audio|video|image|text] -- Displays a list of registered codecs core show codec -- Shows a specific codec core show config mappings -- Display config mappings (file names to config engines) core show file formats -- Displays file formats core show functions [like] -- Shows registered dialplan functions core show function -- Describe a specific dialplan function core show hanguphandlers all -- Show hangup handlers of all channels core show hanguphandlers -- Show hangup handlers of a specified channel core show help -- Display help list, or specific help on a command core show hints -- Show dialplan hints core show hint -- Show dialplan hint core show image formats -- Displays image formats core show license -- Show the license(s) for this copy of Asterisk core show profile -- Display profiling info core show settings -- Show some core settings core show sounds -- Shows available sounds core show sound -- Shows details about a specific sound core show switches -- Show alternative switches core show sysinfo -- Show System Information core show taskprocessor alerted subsystems -- List task processor subsystems in alert core show taskprocessors [like] -- List instantiated task processors and statistics core show threads -- Show running threads core show translation -- Display translation matrix core show uptime [seconds] -- Show uptime information core show version -- Display version info core show warranty -- Show the warranty (if any) for this copy of Asterisk core stop gracefully -- Gracefully shut down Asterisk core stop now -- Shut down Asterisk immediately core stop when convenient -- Shut down Asterisk at empty call volume core waitfullybooted -- Wait for Asterisk to be fully booted database del -- Removes database key/value database deltree -- Removes database keytree/values database get -- Gets database value database put -- Adds/updates database value database query -- Run a user-specified query on the astdb database show -- Shows database contents database showkey -- Shows database contents devstate change -- Change a custom device state devstate list -- List currently known custom device states dialplan add extension -- Add new extension into context dialplan add ignorepat -- Add new ignore pattern dialplan add include -- Include context in other context dialplan debug -- Show fast extension pattern matching data structures dialplan reload -- Reload extensions and *only* extensions dialplan remove context -- Remove a specified context dialplan remove extension -- Remove a specified extension dialplan remove ignorepat -- Remove ignore pattern from context dialplan remove include -- Remove a specified include from context dialplan save -- Save current dialplan into a file dialplan set chanvar -- Set a channel variable dialplan set extenpatternmatchnew false -- Use the Old extension pattern matching algorithm. dialplan set extenpatternmatchnew true -- Use the New extension pattern matching algorithm. dialplan set global -- Set global dialplan variable dialplan show -- Show dialplan dialplan show chanvar -- Show channel variables dialplan show globals -- Show global dialplan variables dnsmgr refresh -- Performs an immediate refresh dnsmgr reload -- Reloads the DNS manager configuration dnsmgr status -- Display the DNS manager status dundi flush [stats] -- Flush DUNDi cache dundi lookup -- Lookup a number in DUNDi dundi precache -- Precache a number in DUNDi dundi query -- Query a DUNDi EID dundi set debug {on|off} -- Enable/Disable DUNDi debugging dundi show cache -- Show DUNDi cache dundi show entityid -- Display Global Entity ID dundi show hints -- Show DUNDi hints in the cache dundi show mappings -- Show DUNDi mappings dundi show peers [registered|include|exclude|begin] -- Show defined DUNDi peers dundi show peer -- Show info on a specific DUNDi peer dundi show precache -- Show DUNDi precache dundi show requests -- Show DUNDi requests dundi show trans -- Show active DUNDi transactions dundi store history {on|off} -- Enable/Disable DUNDi historic records fax set debug {on|off} -- Enable/Disable FAX debugging on new FAX sessions fax show capabilities -- Show the capabilities of the registered FAX technology modules fax show session -- Show the status of the named FAX sessions fax show sessions -- Show the current FAX sessions fax show settings -- Show the global settings and defaults of both the FAX core and technology modules fax show stats -- Summarize FAX session history fax show version -- Show versions of FAX For Asterisk components features show -- Lists configured features file convert -- Convert audio file group show channels -- Display active channels with group(s) hangup request -- <no description available> help -- <no description available> http show status -- Display HTTP server status iax2 provision -- Provision an IAX device iax2 prune realtime -- Prune a cached realtime lookup iax2 reload -- Reload IAX configuration iax2 set debug {on|off|peer} -- Enable/Disable IAX debugging iax2 set debug jb {on|off} -- Enable/Disable IAX jitterbuffer debugging iax2 set debug trunk {on|off} -- Enable/Disable IAX trunk debugging iax2 set mtu -- Set the IAX systemwide trunking MTU iax2 show cache -- Display IAX cached dialplan iax2 show callnumber usage -- Show current entries in IP call number limit table iax2 show channels -- List active IAX channels iax2 show firmware -- List available IAX firmware iax2 show netstats -- List active IAX channel netstats iax2 show peer -- Show details on specific IAX peer iax2 show peers -- List defined IAX peers iax2 show provisioning -- Display iax provisioning iax2 show registry -- Display IAX registration status iax2 show stats -- Display IAX statistics iax2 show threads -- Display IAX helper thread info iax2 show users [like] -- List defined IAX users iax2 test losspct -- Set IAX2 incoming frame loss percentage iax2 unregister -- Unregister (force expiration) an IAX2 peer from the registry indication add -- Add the given indication to the country indication remove -- Remove the given indication from the country indication show -- Display a list of all countries/indications keys init -- Initialize RSA key passcodes keys show -- Displays RSA key information local show channels -- List status of local channels logger add channel -- Adds a new logging channel logger mute -- Toggle logging output to a console logger reload -- Reopens the log files logger remove channel -- Removes a logging channel logger rotate -- Rotates and reopens the log files logger set level {DEBUG|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off} -- Enables/Disables a specific logging level for this console logger show channels -- List configured log channels malloc trim -- Return excess memory to the OS manager reload -- Reload manager configurations manager set debug [on|off] -- Show, enable, disable debugging of the manager code manager show command -- Show a manager interface command manager show commands -- List manager interface commands manager show connected -- List connected manager interface users manager show eventq -- List manager interface queued events manager show events -- List manager interface events manager show event -- Show a manager interface event manager show settings -- Show manager global settings manager show users -- List configured manager users manager show user -- Display information on a specific manager user media cache create -- Create an item in the media cache media cache delete -- Remove an item from the media cache media cache refresh -- Refresh an item in the media cache media cache show all -- Show all items in the media cache media cache show -- Show a single item in the media cache mgcp audit endpoint -- Audit specified MGCP endpoint mgcp reload -- Reload MGCP configuration mgcp set debug {on|off} -- Enable/Disable MGCP debugging mgcp show endpoints -- List defined MGCP endpoints minivm list accounts [for] -- List defined mini-voicemail boxes minivm list templates -- List message templates minivm list zones -- List zone message formats minivm reload -- Reload Mini-voicemail configuration minivm show settings -- Show mini-voicemail general settings minivm show stats -- Show some mini-voicemail statistics mixmonitor {start|stop|list} -- Execute a MixMonitor command module load -- Load a module by name module reload -- Reload configuration for a module module show [like] -- List modules and info module unload -- Unload a module by name moh reload -- Reload MusicOnHold moh show classes -- List MusicOnHold classes moh show files -- List MusicOnHold file-based classes moh unregister class -- Unregister realtime MusicOnHold class no debug channel -- Disable debugging on channel(s) odbc read -- Test reading a func_odbc function odbc show -- List ODBC DSN(s) odbc write -- Test setting a func_odbc function originate -- <no description available> parking show -- Show a parking lot or a list of all parking lots. phoneprov show routes -- Show registered phoneprov http routes pjproject set log level {default|0|1|2|3|4|5|6} -- Set the maximum active pjproject logging level pjproject show buildopts -- Show the compiled config of the pjproject in use pjproject show log level -- Show the maximum active pjproject logging level pjproject show log mappings -- Show pjproject to Asterisk log mappings pjsip dump endpt -- Dump the res_pjsip endpt internals pjsip export config_wizard primitives [to] -- Export config wizard primitives pjsip list aors -- List PJSIP Aors pjsip list auths -- List PJSIP Auths pjsip list channels -- List PJSIP Channels pjsip list ciphers -- List available OpenSSL cipher names pjsip list contacts -- List PJSIP Contacts pjsip list endpoints -- List PJSIP Endpoints pjsip list identifies -- List PJSIP Identifies pjsip list registrations -- List PJSIP Registrations pjsip list subscriptions {inbound|outbound} [like] -- List active inbound/outbound subscriptions pjsip list transports -- List PJSIP Transports pjsip qualify -- Send an OPTIONS request to a PJSIP endpoint pjsip reload qualify aor -- Synchronize the PJSIP Aor qualify options pjsip reload qualify endpoint -- Synchronize the qualify options for all Aors on the PJSIP endpoint pjsip reload -- <no description available> pjsip send notify -- Send a NOTIFY request to a SIP endpoint pjsip send register -- Registers an outbound registration target pjsip send unregister -- Unregisters outbound registration target pjsip set history {on|off|clear} -- Enable/Disable PJSIP History pjsip set logger {on|off|host|add|verbose|pcap} -- Enable/Disable PJSIP Logger Output pjsip show aors -- Show PJSIP Aors pjsip show aor -- Show PJSIP Aor pjsip show auths -- Show PJSIP Auths pjsip show auth -- Show PJSIP Auth pjsip show channels -- Show PJSIP Channels pjsip show channel -- Show PJSIP Channel pjsip show channelstats -- Show PJSIP Channel Stats pjsip show contacts -- Show PJSIP Contacts pjsip show contact -- Show PJSIP Contact pjsip show endpoints -- Show PJSIP Endpoints pjsip show endpoint -- Show PJSIP Endpoint pjsip show history -- Display PJSIP History pjsip show identifiers -- List registered endpoint identifiers pjsip show identifies -- Show PJSIP Identifies pjsip show identify -- Show PJSIP Identify pjsip show qualify aor -- Show the PJSIP Aor current qualify options pjsip show qualify endpoint -- Show the current qualify options for all Aors on the PJSIP endpoint pjsip show registrations -- Show PJSIP Registrations pjsip show registration -- Show PJSIP Registration pjsip show scheduled_tasks -- Show all scheduled tasks pjsip show settings -- Show global and system configuration options pjsip show subscription {inbound|outbound} -- Show active subscription details pjsip show subscriptions {inbound|outbound} [like] -- Show active inbound/outbound subscriptions pjsip show transports -- Show PJSIP Transports pjsip show transport -- Show PJSIP Transport pjsip show unidentified_requests -- Show PJSIP Unidentified Requests pjsip show version -- Show the version of pjproject in use presencestate change -- Change a custom presence state presencestate list -- List currently know custom presence states pri intense debug span -- <no description available> prometheus show metrics -- Display the current metrics and their values prometheus show status -- Display the status of Prometheus metrics collection queue add member -- Add a channel to a specified queue queue priority caller -- Change priority caller on queue queue reload {parameters|members|rules|all} -- Reload queues, members, queue rules, or parameters queue remove member -- Removes a channel from a specified queue queue reset stats -- Reset statistics for a queue queue set penalty -- Set penalty for a channel of a specified queue queue set ringinuse -- Set ringinuse for a channel of a specified queue queue show -- Show status of a specified queue queue show rules -- Show the rules defined in queuerules.conf queue {pause|unpause} member -- Pause or unpause a queue member realtime destroy -- Delete a row from a RealTime database realtime load -- Used to print out RealTime variables. realtime show pgsql cache -- Shows cached tables within the PostgreSQL realtime driver realtime show pgsql status -- Shows connection information for the PostgreSQL RealTime driver realtime store -- Store a new row into a RealTime database realtime update -- Used to update RealTime variables. realtime update2 -- Used to test the RealTime update2 method reload -- <no description available> rtcp set debug {on|off|ip} -- Enable/Disable RTCP debugging rtcp set stats {on|off} -- Enable/Disable RTCP stats rtp set debug {on|off|ip} -- Enable/Disable RTP debugging rtp show settings -- Display RTP settings say load [new|old] -- Set or show the say mode skinny message clear -- Clear message to devices skinny message set -- Send message to devices skinny reload -- Reload Skinny config skinny reset -- Reset Skinny device(s) skinny show devices -- List defined Skinny devices skinny show device -- List Skinny device information skinny show lines [verbose] -- List defined Skinny lines per device skinny show line -- List Skinny line information skinny show settings -- List global Skinny settings sorcery memory cache dump -- Dump all objects within a sorcery memory cache sorcery memory cache expire -- Expire a specific object or ALL objects within a sorcery memory cache sorcery memory cache populate -- Clear and populate the sorcery memory cache with objects from the backend sorcery memory cache show -- Show sorcery memory cache information sorcery memory cache stale -- Mark a specific object or ALL objects as stale within a sorcery memory cache stasis show topics -- Show all topics stasis show topic -- Show topic stun set debug {on|off} -- Enable/Disable STUN debugging stun show status -- Show STUN servers and statuses timing test -- Run a timing test udptl set debug {on|off|ip} -- Enable/Disable UDPTL debugging udptl show config -- Show UDPTL config options ulimit -- Set or show process resource limits unistim reload -- Reload UNISTIM configuration unistim send packet -- Send packet (for reverse engineering) unistim set debug {on|off} -- Toggle UNITSTIM debugging unistim show devices -- Show UNISTIM devices unistim show info -- Show UNISTIM info voicemail reload -- Reload voicemail configuration voicemail show aliases -- List mailbox aliases voicemail show users [for] -- List defined voicemail boxes voicemail show zones -- List zone message formats xmldoc dump -- Dump the XML docs to the specified file
3.3 做最基本的语音呼叫配置
3.3.1 编辑/etc/asterisk/sip.conf
若没有这个文件,应该有一个sip.conf.sample,将其重命名为sip.conf,配置内容如下:
[general] context=default allowoverlap=no udpbindaddr=0.0.0.0 tcpenable=no tcpbindaddr=0.0.0.0 transport=udp srvlookup=yes
然后在此配置文件的下方,配置用户section的地方,配置上3个用户
[1001] type=friend callerid=user1 secret=1001 host=dynamic canreinvite=no dtmfmode=rfc2833 mailbox=1001 disallow=all allow=ulaw transport=udp [1002] type=friend callerid=user2 secret=1002 host=dynamic canreinvite=no dtmfmode=rfc2833 mailbox=1002 disallow=all allow=ulaw transport=udp [1003] type=friend callerid=user3 secret=1003 host=dynamic canreinvite=no dtmfmode=rfc2833 mailbox=1003 disallow=all allow=ulaw transport=udp
3.3.2 编辑/etc/asterisk/extensions.conf
配置通话的基本路由
[general] static=yes writeprotect=no
其他的都不变,保持默认状态,然后,在default对应的section部分的末尾,添加下面的路由信息:
[default] exten => 1001,1,Answer() exten => 1001,n,Dial(SIP/1001,20,tr) exten => 1001,n,Hangup exten => 1002,1,Answer() exten => 1002,n,Dial(SIP/1002,20,tr) exten => 1002,n,Hangup exten => 1003,1,Answer() exten => 1003,n,Dial(SIP/1003,20,tr) exten => 1003,n,Hangup
3.3.3 配置asterisk的logger模块(/etc/asterisk/logger.conf)
asterisk安装完毕后,默认的日志文件名为messages,级别如下(notice,warning,error):
messages => notice,warning,error
我们的修改策略是,在asterisk的尾部,添加一行(文件名为mylog):
mylog => notice,warning,error,debug,verbose,dtmf
3.4 加载chan_sip.so模块
基本指令操作
tkiot-isc1*CLI> sip show peers No such command 'sip show peers' (type 'core show help sip show' for other possible commands) tkiot-isc1*CLI> tkiot-isc1*CLI> sip No such command 'sip' (type 'core show help sip' for other possible commands)
上述反馈,没有sip指令,解决办法如下:
tkiot-isc1*CLI> module load chan_sip.so Loaded chan_sip.so SIP channel loading... == SIP Listening on 0.0.0.0:5060 == Using SIP CoS mark 4 == Using SIP CoS mark 4 -- Message technology 'sip' registered. == Registered channel type 'SIP' (Session Initiation Protocol (SIP)) == Registered RTP glue 'SIP' == Registered application 'SIPDtmfMode' == Registered application 'SIPAddHeader' == Registered application 'SIPRemoveHeader' == Registered custom function 'SIP_HEADER' == Registered custom function 'SIP_HEADERS' == Registered custom function 'SIPPEER' == Registered custom function 'CHECKSIPDOMAIN' == Manager registered action SIPpeers == Manager registered action SIPshowpeer == Manager registered action SIPqualifypeer == Manager registered action SIPshowregistry == Manager registered action SIPnotify == Manager registered action SIPpeerstatus [Jun 19 17:53:59] WARNING[26933]: chan_sip.c:35476 deprecation_notice: chan_sip has no official maintainer and is deprecated. Migration to [Jun 19 17:53:59] WARNING[26933]: chan_sip.c:35477 deprecation_notice: chan_pjsip is recommended. See guides at the Asterisk Wiki: [Jun 19 17:53:59] WARNING[26933]: chan_sip.c:35478 deprecation_notice: https://wiki.asterisk.org/wiki/display/AST/Migrating+from+chan_sip+to+res_pjsip [Jun 19 17:53:59] WARNING[26933]: chan_sip.c:35479 deprecation_notice: https://wiki.asterisk.org/wiki/display/AST/Configuring+res_pjsip Loaded chan_sip.so => (Session Initiation Protocol (SIP))
再次查看sip指令操作的结果(前述配置完毕后,需要将asterisk重启一次):
tkiot-isc1*CLI> sip show peers Name/username Host Dyn Forcerport Comedia ACL Port Status Description 1001/1001 (Unspecified) D Auto (No) No 0 Unmonitored 1002/1002 (Unspecified) D Auto (No) No 0 Unmonitored 1003/1003 (Unspecified) D Auto (No) No 0 Unmonitored 3 sip peers [Monitored: 0 online, 0 offline Unmonitored: 0 online, 3 offline]
3.5 安装sip客户端
这里采用的是yate client(http://old.yate.ro/pmwiki/index.php?n=Main.Download),我这里的版本是windows的5.4.0,安装就不说了。
3.6 IP电话验证
这里对应的配置也很简单,Settings->Accounts->New. 参照图例,其他的都不变,保持默认,配置完毕后,点击OK按钮即可。若没有什么问题,Accounts的配置界面,应该像下面的图
这里,有一点,需要非常的注意,yate client的默认传输协议是UDP,所以,在SIP客户端register的时候,一定要确保客户端和服务端之间的网络权限是否开启,默认SIP的端口是5060.若传输协议,两边配置的不一样,或者网络权限没有开启,最后那个register的流程出现timeout的问题,如下图
下面,就来看看,1001用户给1002用户(两个yate client在同一个PC机器上进行的模拟)打个语音电话,接通后的截图如下
接通成功后的效果如下:
对应的asterisk的后台日志:
[Jun 23 15:34:12] VERBOSE[12019] chan_sip.c: Registered SIP '1001' at 10.95.177.137:63637 [Jun 23 15:34:16] VERBOSE[12019] chan_sip.c: Registered SIP '1002' at 10.95.177.137:61809 [Jun 23 15:34:36] VERBOSE[12019][C-00000006] netsock2.c: Using SIP RTP CoS mark 5 [Jun 23 15:34:36] VERBOSE[12019][C-00000006] res_rtp_asterisk.c: 0x7fb478010fd0 -- Strict RTP learning after remote address set to: 10.95.177.137:31494 [Jun 23 15:34:36] VERBOSE[13571][C-00000006] pbx.c: Executing [1002@default:1] Answer("SIP/1001-0000000a", "") in new stack [Jun 23 15:34:36] VERBOSE[13571][C-00000006] pbx.c: Executing [1002@default:2] Dial("SIP/1001-0000000a", "SIP/1002,20,tr") in new stack [Jun 23 15:34:36] VERBOSE[13571][C-00000006] netsock2.c: Using SIP RTP CoS mark 5 [Jun 23 15:34:36] VERBOSE[13571][C-00000006] app_dial.c: Called SIP/1002 [Jun 23 15:34:36] VERBOSE[13571][C-00000006] app_dial.c: SIP/1002-0000000b is ringing [Jun 23 15:34:42] VERBOSE[12019][C-00000006] res_rtp_asterisk.c: 0x7fb48000c5a0 -- Strict RTP learning after remote address set to: 10.95.177.137:29882 [Jun 23 15:34:42] VERBOSE[13571][C-00000006] app_dial.c: SIP/1002-0000000b answered SIP/1001-0000000a [Jun 23 15:34:42] VERBOSE[13574][C-00000006] bridge_channel.c: Channel SIP/1002-0000000b joined 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5> [Jun 23 15:34:42] VERBOSE[13571][C-00000006] bridge_channel.c: Channel SIP/1001-0000000a joined 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5> [Jun 23 15:36:00] VERBOSE[13574][C-00000006] bridge_channel.c: Channel SIP/1002-0000000b left 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5> [Jun 23 15:36:00] VERBOSE[13571][C-00000006] bridge_channel.c: Channel SIP/1001-0000000a left 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5> [Jun 23 15:36:00] VERBOSE[13571][C-00000006] pbx.c: Spawn extension (default, 1002, 2) exited non-zero on 'SIP/1001-0000000a'
asterisk的CLI窗口显示的日志,体现了注册1002,从1001呼叫1002的过程:
tkiot-isc1*CLI> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
1001/1001 10.95.177.137 D Auto (No) No 63637 Unmonitored
1002/1002 10.95.177.137 D Auto (No) No 61809 Unmonitored
1003/1003 (Unspecified) D Auto (No) No 0 Unmonitored
3 sip peers [Monitored: 0 online, 0 offline Unmonitored: 2 online, 1 offline]
-- Registered SIP '1001' at 10.95.177.137:63637
-- Registered SIP '1002' at 10.95.177.137:61809
== Using SIP RTP CoS mark 5
> 0x7fb478010fd0 -- Strict RTP learning after remote address set to: 10.95.177.137:31494
-- Executing [1002@default:1] Answer("SIP/1001-0000000a", "") in new stack
-- Executing [1002@default:2] Dial("SIP/1001-0000000a", "SIP/1002,20,tr") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/1002
-- SIP/1002-0000000b is ringing
> 0x7fb48000c5a0 -- Strict RTP learning after remote address set to: 10.95.177.137:29882
-- SIP/1002-0000000b answered SIP/1001-0000000a
-- Channel SIP/1002-0000000b joined 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5>
-- Channel SIP/1001-0000000a joined 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5>
-- Channel SIP/1002-0000000b left 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5>
-- Channel SIP/1001-0000000a left 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5>
== Spawn extension (default, 1002, 2) exited non-zero on 'SIP/1001-0000000a'
wireshark抓包:
请看下面的截图,这个过程包含1002用户的注册register过程,在1001电话机上给1002拨号打call(invite),1001方响铃,接起通话,然后挂断通话,最后1002解除在线(offline) 。
到此,asterisk+yateclient的基础IP通话环境搭建完毕,验证成功,总结注意事项:
1. 网络权限,5060端口默认,SIP默认传输协议是UDP协议
2. asterisk 17的SIP模块,默认是没有的,需要通过CLI进行指令的加载chan_sip.so
3. 当前这种基础模式存在明显的缺陷,用户的创建和呼叫路由,必须在sip.conf和extensions.conf文件里面,静态的配置,每次创建用户后,必须重启asterisk,重新load chan_sip.so,然后才能工作,这个操作,影响已经存在用户的正常业务
欢迎评论,欢迎关注,转帖请注明出处!