asterisk入门资料
- 格式:doc
- 大小:89.00 KB
- 文档页数:20
Asterisk目录及配置文件/etc/asterisk/Asterisk主目录,包含其它关于Asterisk的配置文件;*zaptel.conf这个配置文件放在/etc,因为其它软件也可以使用Zaptel这个硬件及其驱动,所以不是放在/etc/asterisk里./usr/lib/asterisk/modules/这个目录包含所有可以加载Asterisk模块(应用程序\编辑器\格式和有用通道),在Asterisk启运时会加载这些模块(可以编辑modules.conf)./var/lib/asterisk/比较重要的是astdb文件与agi-bin目录;astdb包含Asterisk当地数据库信息.sounds/所有声音提示的文件在里面,包括Asterisk原代码中的sounds.txt文件mohmp3/如果配置了音乐保持,应用程序会在这个目录下查找mp3(用CBR从文件中去除身份标签).keys/使用公钥和私钥系统认证与一个由RSA数字签名形成的一对等连接.公钥和私钥的扩展名分别为.pub和.keyfirmware/这个目录含了很多Asterisk相兼容的设备固件,它只有iax/这个子目录,其中有Digium的IAXy的二进制固件镜像.images/只有在较多的支持并且利用图解式的图像设备被发布,这个目录将会与相应的目录有更大的关联./var/lib/asterisk/agi-bin agi-bin包含所有脚本,可以通过许多已经建立的AGI应用程序与Asterisk连接./var/spool/asteriskoutgoing/gcall/tmp/voicemail/================配置文件================/etc/asterisk/asterisk.conf主要配置文件,/etc/zaptel.conf硬件接口的基本层.修改这个配置文件要用modprobe装载Linux Kernel使用模块./etc/asterisk/zapata.conf为硬件配置Asterisk的接口./etc/asterisk/extensions.conf拨号方案./etc/asterisk/sip.conf SIP协议配置文件/etc/asterisk/iax.conf呼入和呼出IAX通道/etc/asterisk/extensions.conf拨号方案配置文件/etc/asterisk/moduprobe.conf加载模块配置文件Asterisk developer\'s documentation 翻译计划by serva今天,Asterisk已经成为一个VOIP业界使用最广泛的一个集成电信级别P BX的工具,IPPBX如今已经成为VOIP商家争夺的一块重要市场,在我们越来越熟悉使用Asterisk的同时,我们希望能够越来越深入的了解asterisk,特别是对于开发人员,如果有自己特定的需求,在复杂的asterisk文件夹和asteri sk的源代码文件中迷失了方向,不知所措。
CONFIGURING AN ASTERISK SERVERFrom Standard ERP's T elephony module, it is possible to fully configure an Asterisk server, whether it is installed locally on the same server as Standard ERP (only applicable on a Linux-based server) or on a separate remote server.It is also possible to integrate Standard ERP with an existing Asterisk server without managing its configuration directly from Standard ERP. Below are the steps required for a full integration, and will not explain what steps are required for local, remote, and existing servers.PBX ConnectionThe basic setting for integrating your Standard ERP system with an Asterisk server is a PBX Connection. A PBX Connection represents a connection to a unique actual VoIP Server.T o start with, you should create a new PBX Connection from the T elephony module in the PBX Connection register.A PBX Connection is defined primarily by:Code: The PBX unique identifier.Comment: A descriptive text.Type: The type of VoIP server to connect to; this can be chosen from a variety of Asterisk versions, TrixBox, Digium Switchvox, VPBX and 3CX Phone System 12 etc.Hostname: The hostname for the server being used.Host IP address: The IP address for the server being used.Port: The port through which the Asterisk's Management Interface (AMI) can be reached (5038 by default for Asterisk)Username: Username to connect to the AMI.Password:Password to connect to the AMI.Closed: A PBX Connection can be closed when it is no longer in use or valid.In the case of a locally or remotely installed Asterisk server, the T ype should be Asterisk 1.8 (AMI). The username and password can be freely set as they will be configured in the server for you.In case you are connecting to an existing server, the port, username, and password should match the content of your server's manager.conf file. Here is an example of manager configuration usable with Standard ERP:[general]enabled=yesport=5038bindaddr=0.0.0.0allowmultiplelogin=yesdisplayconnects=yestimestampevents=yes[myadmin]secret=passwordxyzdeny=0.0.0.0/0.0.0.0permit=1.2.3.4read=system,call,originatewrite=system,call,originateIn this case Port would be 5038, username myadmin and password passwordxyz. You should replace 1.2.3.4 by the IP address of your Standard ERP server.A PBX Connection has other fields organised in four tabs, and which are used when managing a local or remote server entirely from Standard ERP. Administrators using an existing server fully managed by some external means should skip over to the Contact records section.Dialling SettingsUnder this tab, you can configure the various telephony prefixes in use in your system.International Dial Prefix: T o dial out of your country.Country Code: T o dial in your country.Default Area Code: T o dial in your local area.External Line Prefix: T o dial out of your organisation.Skip Digit for International Calls:As its name indicates, you may also define digits to skip when dialling internationally.These parameters are used to place and receive calls, and to identify contacts based on their caller ID, including when using IAX (see below).RulesThis T ab allows to define a number of rules from various types:Ignore SIP Channel:In case of an existing server, this will ignore possible intermediary SIP channels to handle calls and instead only care about the end points. The Identifier is the name of the intermediary SIP channel to ignore.No Act For Calls Between Extensions Shorter Than: Disables the automatic Activity creation for internal calls (detected by the short length of internal extensions). This is only applicable for PBX Connections of the T ype Digium SwitchVox. The Identifier is the maximum length.Track number: Not used.Unique callers only: With this option, only one call will be displayed in Communicator even if there is more than one call from or to the number configured in Identifier.Remote AdministrationFrom this tab, you can define the following:Remote User: Linux user that will be used to copy the Asterisk configuration files to a remote serverRemote Configuration Directory: The path where to copy said configuration files. As such, it is important that the directory is writable by the Linux user and that your Standard ERP server has been set up to be able to connect directly to the remote Asterisk server without needing to enter a password (namely set up a Public Key Authentication between both servers).AsteriskFrom this final tab, you can enable the connection of your Asterisk server to other Asterisk server using IAX (Inter-Asterisk eXchange).Enable Inter-Asterisk eXchange(IAX):By ticking this option, you will allow all other PBX Connections configured in Standard ERP and set to use IAX to connect to this particular server as well as allow this server to connect to all other servers enabled for IAX and configured in Standard ERP.IAX Password: The password used by this server to connect to other IAX servers.Sending configuration to the serverThis section only applies to the local and remote servers situations.After completing the above configuration of a PBX Connection, you can already send the configuration to an Asterisk server.If you are running a local server, you can dump the configuration files by using the Local Asterisk Server settings from the T elephony module.First, you will need to install the Asterisk server by selecting Setup Asterisk Server in the Operation Menu. This will give you a warning pop-up reading “Starting download and installation of Asterisk server”. Click OK. This will download the binaries for the Asterisk Server from the HansaWorld servers and install them on your local server. The server will then be started. You should never have to use Setup Asterisk Server again after this.If you close the Local Asterisk Inspect window and reopen it, you will see the path where your server is installed.From the Operation Menu, you can also select “Update Asterisk Server Configuration” (which will dump the current configuration on the Asterisk server configuration directory and restart the Asterisk server so that the configuration is applied), Start Asterisk Server, and Stop Asterisk Server (which should both only rarely be used, for instance for external maintenance purposes).If you are running a remote server which is fully configured using Standard ERP, you should instead head to the Asterisk SIP Configuration Files maintenance in the Routines of the T elephony module.Use Paste Special in the PBX Connection to select the server you want to update, and tick Send Files to Server before running. If you do not tick this option, then the files will only be generated locally on your Standard ERP server.Note that this will only work if you have properly setup your PBX Connection and the Linux environment of your Asterisk server (see above).You can also select from the following other Maintenance Routines:!Asterisk SIP trunks.!Asterisk Users.These routines will generate respectively only the configuration files for the SIP trunks of a PBX Connection, or for its users, instead of regenerating all the files.Note that the files are only sent to the server but not applied. An administrator needs to connect manually to the Asterisk server and reload them. For instance by issuing a 'core reload' command from Asterisk's command line interface.Asterisk usersThe next step in setting up your Asterisk server is to create a number of users.This section is applicable for local and remote servers.From the T elephony module, you can create new Asterisk Users for your employees or partners.For each user, you can define:PBX Connections: One or more servers on which the user will be created and allowed to connect to. Leave blank to create the user on all PBX Connections configured.Name: A descriptive name.Username: Will be used to configure their SIP client.Password:Will be used to configure their SIP client.Group: No longer used.Caller ID number: The display number that might be shown to the party this user is calling. Note that this can easily be overridden by the configuration of a SIP client or SIP trunk. Especially when dialling out to international telephone numbers, Caller ID numbers are likely to get lost.Caller ID name: The display name that might be shown to the party this user is calling. Note that this can easilybe overridden by the configuration of a SIP client or SIP trunk.Especially when dialling out to a mobile or landline telephone number, plain text display names will be lost.Closed: A closed user will simply not be configured on the server and as such, it will not be possible to connect to the server using that user.No Queue Fallback: If an Asterisk User is marked as not being part of Queue Fallback, then that user will not be called when a queue is not staffed but is receiving a phone call.Note that after creating one (or more) Asterisk users, it is necessary to send the configuration to the server, as described above.Contact recordsThis section is applicable for all types of servers: local, remote, and existing.As of now, Asterisk users and Standard ERP users (Persons), and their contact cards are not connected and as such, Contact cards for your users will need to be filled in manually with their SIP contact details.In the SIP field of the contact record pertaining to your Asterisk user should be filled in as username@host name. Where username comes from the Asterisk User record, and hostname from the PBX Connection record.SIP TrunksThis section is applicable for local and remote servers.At this point of the configuration, you can place calls between users of your Asterisk server. T o reach out to the outside world, you will need a SIP trunk or VoIP trunk. Each country usually has several providers that can help you get started. As Asterisk is a commonly used VoIP server platform, it is easy to get help from your provider in general.A simple Internet search should allow you to find a number of SIP providers for your country.Using the information provided by your subscriber, you will be able to fill in the SIP Trunk record necessary for you to place calls to the rest of the world. A SIP provider will usually be able to sell you the usage of one, or more phone numbers that your contacts will be able to call to reach you. In some cases, your SIP provider might also allow you to place outgoing calls. Make sure to carefully select the SIP provider that is able to provide you with the capabilities you need to run your business smoothly.Setting up a SIP trunk comes with a wide array of technical possibilities, a number of which are supported inStandard ERP. We will detail some of those here but it is not possible to list all the possible technical configurations one can encounter.Code: Select a unique code for your SIP trunk.PBX Connection: Paste Special the PBX connection on which you want this SIP trunk to be terminated.Host: Fill in the host name or IP address provided by your SIP provider here. It might be that host and domain have the same value.Domain: Fill in the domain name provided by your SIP provider here. It might be that host and domain have the same value.Username: Fill in the username provided by your SIP provider here.Password: Fill in the information provided by your SIP provider here.Skip Digit for International Calls: This parameters operates similarly to that set in the PBX Connection but will apply to calls using the SIP trunk.Country Code:This parameters operates similarly to that set in PBX Connection but will apply to calls using the SIP trunk.Caller ID: The caller ID of your SIP trunk provider (optional).Allow anonymous calls: Lets the system accept anonymous calls coming from your providers.Allowed IPs: Only incoming calls coming from these IP addresses will be allowed. Please check with your SIP provider to only open the minimum number of addresses. (optional but important security point).Inbound phone numbers: A SIP provider may very well provide you several telephone numbers using the same SIP trunks. In certain cases, you will be given unique identifiers for each one of them. They should be filled in here. It might be that the usernames and passwords are the same as above.Trunk type:Set to Outbound calls only if you intend to input a separate configuration for Inbound Phone Numbers in the matrix as described just above. Set to In- and outbound calls if you do not have a separate configuration for Inbound Phone Numbers.IAX: Select this if your SIP trunk provider is providing you services using an Asterisk IAX trunk.Queues and MenusThis section is applicable for local and remote servers.Most of us are familiar with the telephony lines operated by large companies. A welcome Menu plays when you call into the support line of a company, after pushing a few digits on your phone and listening to a few more voice Menu messages, you are placed in a Queue. Thanks to Standard ERP's integration with Asterisk, your company can easily benefit from such technology.In Standard ERP's terminology, a Menu is used to select between different queues or menus; and a Queue is used to put in relation agents answering calls and external callers. Queues and Menus share a number of settings (Phone Numbers, Opening Times) and capabilities (Playing a sound upon arrival, when closed, etc.).Instructions for users to use queues can be found earlier in the document.A Queue contains the following information:Code: A unique identifier in Standard ERPQueue ID: A unique identifier in Asterisk which will be used by your employees to connect to the queue and start answering calls.SIP Trunk: The SIP trunk from where the calls will be arriving.Description: A free-text comment.Phone Number: (Optional) in the case where you want a direct number for callers to reach the queue without going through a Menu. Note: you can play a greetings message even in the case where callers go straight toa queue. You do not need a Menu to play a welcome message.Fallback number: An optional number to call in the case i) no agent is available in the queue AND ii) no one is logged in to the Asterisk server or everyone who is logged in is marked with “No Queue Fallback”.Open from/until: it is possible to define two sets of opening hours (to include the possibility of a lunch break for instance). In case only one set of opening hours is needed, use the first pair of “Open from”/”Open until”fields and leave the second pair blank.A Menu contains the following information:Code: A unique identifier.SIP Trunk: T he SIP trunk from where the calls will be arriving.Description: A free-text comment.Phone Number: The phone number for your contacts to dial in order to access the Menu. Optional in case the Menu is accessed via another Menu.Open from/until:It is possible to define two sets of opening hours (to include the possibility of a lunch break for instance). In case only one set of opening hours is needed, use the first pair of “Open from”/”Open until”fields and leave the second pair blank.Repeat every (s): The number of seconds between repeats of the message explaining to the caller his or her possible choices.A matrix finally allows you to configure the different Menus and Queues reachable from this Menu:Number: The digit to press for the user to enter the selected Queue or Menu. Note that in the case pressing the digit leads to entering a Queue, the digit need not be the same as the Queue ID defined in the Queue.Queue: Paste Special to an existing Queue (note, if you select this, you should not select a Menu as well).Menu: Paste Special to an existing Menu (note, if you select this, you should not select a Queue as well).Comment: A free-text comment as a reminder of what the selected Queue or Menu might be.Using Menus, you can cascade multiple levels of Menus. However, once a caller has joined a Queue, he or she will not be able to go back to another Queue or Menu.The last remaining part of the configuration is now to assign sound files to be played to guide your callers through your Menus and Queues.Whereas all the previous configuration was done in Registers of the T elephony module, sounds will be configured from the Settings of the T elephony module. More precisely, from the PBX Sounds setting.First, create a new PBX Sound. Then in Event, use Paste Special to select the type of Event that will trigger the sound file to play. The Event you select will affect whether you are selecting a Queue or a Menu in the following field. Available Events are:Initial Queue Message: Played as an initial greeting when a caller reaches a Queue.Line Busy: Played after 30 seconds of a caller waiting in a Queue.Menu Closed: Played whenever a caller arrives to a Menu outside of the defined opening hoursMenu Message: Played as an initial greeting when a caller enters a Menu (should also describes the options available from the Menu and the digits associated with each function).Music on Hold:Music to play while the caller is waiting in a Queue.Queue Closed: Played whenever a caller arrives to a Queue outside of the defined opening hours.Once an Event is selected, use Paste Special to select the Queue/Menu where the sound file should be used. Only one Queue or Menu can be selected. After Saving the Record, you can now attach a file to the Record following the usual way of dragging and dropping the file over the paperclip icon or into the Document Manager window which you can open by double-clicking the paperclip icon.Note: the attached sound file must be a mono.wav file, sampled at 8kHz.Remember to send the configuration to the server once done. The sound files will be copied during that stage a s well.。
Asterisk 入门一 --- Asterisk 1.6.2.6 安装2010-04-28 16:27其实asterisk安装灰常简单只要跟着安装包中的readme 文档一步一步走就可以了:1.安装测试环境虚拟机:Sun VirtualBox 3.1X操作系统:CentOS 52.Astrisk各稳定版本以及附加工具/downloads改页面有很多下载选项大概的介绍一下1.AsteriskAsterisk 源码压缩包,这就是我们要用的2.AsteriskNOWAsteriskNOW 是一个光盘镜像包含了linux 系统,一旦安装完成就有一套简单的PBX 系统了3.Asterisk Add-OnsAsterisk Add-Ons 是Asterisk 和Asterisk 一些相关的驱动和组件等。
3.下载安装# wget/pub/telephony/asterisk/releases/asteris k-1.6.2.6.tar.gz#tar -zxvf asterisk-1.6.2.6.tar.gz# cd asterisk-1.6.2.6运行配置脚本检测依赖关系并设置安装目录# ./configure --prefix=/usr/local/asterisk看到硕大的星号了嘛哈哈配置成功.$$$$$$$$$$$$$$$=...$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$$$$$$$$$.$$$$$$ $$$$$$$$$$$$$$$$.该步骤可选,该步骤用于选择一些模块#make menuselect编译安装#make#make install安装一些简单的配置文件#make samples好了现在都安装结束了--------------------------------------------------------------------------------------------启动守护进程# safe_asterisk进入CLI#asteriks -r更多的命令可以使用 #man asterisk查看按q退出Asterisk 入门二 --- Asterisk 配置以及控制台命令2010-04-28 16:52接下来我们开始学习asterisk先提供个学习的教材和网址大部分的问题可以在/中找到解答其次提供一本 Asterisk 入门教程叫Asterisk,电话未来之路第二书签版.pdf自个摆渡下吧-------------------------------------------------------------------------------------Asterisk 几个相关目录配置文件/usr/local/asterisk/etc/asterisk可执行文件目录 /usr/local/asterisk/sbin先启动asterisk守护进程#safe_asterisk进入控制台#asterisk -rAsterisk 1.6.2.6, Copyright (C) 1999 - 2010 Digium, Inc. and others.Created by Mark Spencer <markster@>Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General PublicLicense version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details.=========================================================================Connected to Asterisk 1.6.2.6 currently running on localhost (pid = 18023)Verbosity is at least 3localhost*CLI>看看有啥命令>core show help或者具体的命令帮助>core show help <command>Asterisk app命令中文翻译2008-11-06 15:15常规指令Authenticate:鉴别用户VMAuthenticate:根据“voicemail.conf”鉴别用户Curl:接受外接URLs的修复。
asterisk_phpagi简单开发第四版asteriskphpagi开发入门不知不觉过了一个多月了哈,由于呼叫中心的项目进度比较缓慢,俺也就不急了,所以边做边玩,这一版俺讲讲agi处理等待中的来电,当然这一个多月俺也把那个test.php 文件也做了一个比较大的改动。
具体请看下文。
本人水平有限,难免会有写的不周到或错误的地方,欢迎指正。
首先鼠标规则基本没颤抖,前面几版都存有表明,我就不再重复了先看一看这个test.php脚本吧#!/usr/bin/phpcq//说明上面这个是php脚步的写法,/usr/bin/php是你的php安装目录(这段话是我写的说明,请勿放在test.php里)set_time_limit(60);ob_implicit_flush(false);include(\提及phpagiUSB$num=$argv[1];//这个就是带过来的通道变量${exten}的值,获取来电者按了哪一个键或者拨了哪个分机$flag=$argv[2];//则表示就是分组还是轻易挥分机号$caller=$argv[3];//发短信号码$number=$num;//默认认为来电者直接拨分机号$group=0;//默认分组是0,表示直接拨分机号的//表示是按了一个键,表示分组if($flag){$group=$num;//分组号$number=0;}$url=\.\r;$string=file_get_contents($url);//这个字符串是mv中间件返回的$res=explode('|',$string);/*表明,我改动了这一部分$res[0]:规则状位(0:挂机或返回上一级、1:等待、2:可以接通)$res[1]:振铃状态(0:普通方式、1:同时振铃)$res[2]:可以dial的分机(如果$res[0]为2并且$res[1]为0,这里就是一个分机号;如果$res[0]为2并且$res[1]为1,这里就是多个分机号(sip/8260&sip/8263....),表示同时振铃)*//*调用远程USB回去出访数据库,然后在USB里展开了繁杂(嘻嘻)的运算,因为必须考量每个分机可能将设置了呼叫转移啊,并且必须必须满足用户一定的条件才可以引爆呼叫转移,除了轮询查阅每一个分机与否打开了应答维持,反正就是好几个递回,源码比较复杂,搞出的我快精神崩盘了,哈哈,最终还是写下出了。
第二章 Asterisk体系结构目录2.1 Modules (2)2.1.1 Dialplan Applications (3)2.1.2 Bridging Modules (6)2.1.3 Call Detail Recording Modules (6)2.1.4 Channel event logging modules (7)2.1.5 Channel Drivers (7)2.1.6 Codec Translators (8)2.1.7 Format Interpreters (9)2.1.8 Dialplan Functions (10)2.1.9 PBX Modules (12)2.1.10 Resource Modules (12)2.1.11 Addon Modules (14)2.1.12 Test Modules (15)2.2 文件结构 (15)2.2.1 Configuration files (15)2.2.2 Modules (15)2.2.3 The Resource Library (15)2.2.4 The Spool (16)2.2.5 Logging (16)2.3 The Dialplan (16)2.4 硬件 (16)2.5 Asterisk版本 (17)2.5.1 以前的版本号机制 (17)2.5.2 新的版本机制 (18)2.6 结论 (18)Asterisk完全不同于其他的,更加传统的PXB系统。
在Asterisk中,dialplan基本上采用完全一样的方法处理所有呼入channel。
在传统PBX中,“内线”和“外线”在逻辑上是分开的。
举例来说,你不能把一个外部网关联接到PBX的内线分机端口上,用户也无法在不按下外线数字的情况下拨打外线(例如,很多的IP PBX拨打外线要加拨“0”)。
与此相反,在Asterisk中并没有严格的“内线”和“外线”的概念。
Asterisk权威指南/第一章一场电话革命当我们开始着手写一本Asterisk书的时候(大概五年前),我们确信Asterisk将会从根本上改变通讯行业。
今天,我们预言的这场革命几乎就要完成了。
Asterisk现在是世界上最成功的PBX,并且是通讯行业的公认技术(尽管并不总是受欢迎)。
不幸的是,在过去五年中,通讯行业仍然没有找到正确的方向。
我们通讯的方式已经变了。
尽管20年前打电话是远距离通讯的首选方式,但目前的趋势是文本消息(email,IM,等等)。
打电话看起来有点out了,特别对于成长起来的下一代来说。
Asterisk仍然是很棒的技术,对于想在任何技术中集成通讯功能的企业来说,Asterisk还是最佳选择。
使用Asterisk,没有人可以规定你系统的工作方式,或者限制你使用的技术。
你想要什么,就可以拥有什么。
Asterisk热情地拥抱标准,同时也享受创新的自由。
你想怎么实现完全取决于你——Asterisk不会向你强加任何约束。
当然,这难以置信的灵活性也不是免费的:Asterisk并不是一个可以轻易配置的系统。
这并不是因为它不合逻辑、混乱或晦涩;相反它相当合理,而且实用。
人们第一次看到拨号计划时,眼睛往往为之一亮,并很快开始设想各种可能性。
但是,当同一结果可以用无数种方式实现时,需要付出的努力也是可想而知的。
(TODO)目录∙1Asterisk和VoIP:连接传统电话和网络电话的桥梁∙2Zapata电话项目∙3巨变需要灵活的技术∙4Asterisk:黑客的PBX∙5Asterisk社区∙6Asterisk邮件列表∙7IRC频道∙8Asterisk用户组∙9Asterisk文档计划∙10商业分析∙11结束语Asterisk和VoIP:连接传统电话和网络电话的桥梁Voice over IP(VoIP)往往被认为只不过是一种打免费长途电话的方法。
但它的真正意义(同时也是挑战所在)是,它认为语音只不过是数据通讯网络的另一个应用。
最近一直在研究asterisk,也算小小的入门一下,现在就学习的过程整理总结一下。
Asterisk学习进阶介绍篇抛开所有概念,首先从单词学起。
估计很多人和我一样没有明白这个词是什么意思,或许猜测他还可能是一个组合词。
其实它就是“*”,作为搞程序的我们看到这个东东想到的也许会是乘号,当然有另外一大帮人想到的是通配符,在这儿恭喜想到通配符的兄弟,你们答对啦,这儿我们认定它的含义就是如此。
通过我上面牵强附会的关联,Asterisk的含义就浮出水面了,它就是一个通配的电话,这样组合的话看起来应该有点难受,我们重新润色它就变成了无所不能的电话系统。
有了上面的这段废话,我其实只想传达asterisk的两个特点:1. 功能巨强大2. 是一个支持语音的系统追本溯源,下面还是看看官方是怎么定义它的:Asterisk is the most popular and extensible open source telephone system in the world, offering flexibility, functionality and features not available in advanced, high cost proprietary business systems. Asterisk is a complete IP telephony platform for business, and can be downloaded for free.通过这段话我琢磨出下面一些意思,不晓得各位的想法。
首先就是它功能很强大,成本低廉,另外就是它是免费的。
展开一下,因为它是开源代码,就容许你在已有的基础上进行修改定制,削弱了开发成本,另外就是asterisk可以跑在多个通过操作系统上,而且基本x86 这个通用平台,降低了专用系统昂贵的成本。
但是功能强大这个我们先悬着这个疑问,下面在慢慢的进行剖析。
关于AsteriskAsterisk是一款实现用户电话交换机(PBX)功能的自由软件、开源软件。
Asterisk提供完善PBX 功能,可以连接多种不同的电话终端,包括普通电话机,IP电话机,软电话等,支持多种主流的IP电话协议和系统接口。
软件名称Asterisk-星号(*),在Unix(包括Linux)和DOS操作系统中是通配符,用来在查找中适配任何字符,寓意该软件广泛的适用性。
Asterisk软件提供很多以前只有昂贵的专业PBX系统才支持的功能,比如:语音信箱,会议电话,交互式语音提示和自动电话转接等。
由于该软件开放的性质,用户可以灵活的配置方便的扩展系统的功能,甚至编程开发自己所需功能的模块。
Asterisk通常都运行在Linux操作系统下,当然它也可以在其他系统,如BSD, Windows或OS X下编译并安装。
Asterisk服务器不需要任何特殊的硬件即可提供VoIP的服务,只需服务器有网络连接即可。
它支持主流VoIP协议,包括会话发起协议(SIP)、H.323,既可作为IP电话服务器也可以作IP 电话和PSTN之间的转接。
Asterisk系统还设计了一个新协议,IAX,用于在Asterisk服务器之间维护话路通道。
如果需要连接普通电话或PSTN中继线,运行Asterisk的服务器则需要安装相应的硬件接口板。
许多厂商都生产用于连接普通电话、T1、E1中继线、ISDN等的接口板。
由于是自由软件且具有丰富的系统功能,Asterisk提供给用户一个廉价并功能强大的PBX解决方案。
它被越来越多的用于代替传统专用的PBX,或被用于跨国VoIP电话以节省长途费用。
一些国家的VoIP电话公司已经开始支持Asterisk,提供IAX2接口或允许用户的Asterisk 服务器使用SIP协议连接。
截止2008年4月22日,Asterisk的最新版本是1.4.19.1版。
Asterisk功能说明及基本呼叫流程1.Asterisk内部核心:共分为6个部分A.PBX核心交换模块B.调度和IO管理模块C.应用调用模块D.编码转换模块E.动态模块加载器模块F.CDR生成模块(即时呼叫详细记录报告)2.Asterisk基本呼叫流程(1)通过Asterisk的一个电话呼叫在一个通道驱动接口上到达,如SIP通道。
目录ASTERISK系统主要线程 (2)系统主控线程 (2)通道主控线程 (2)维护用户状态线程 (3)交换线程 (3)两个codec之间转换时间表 (6)系统交互命令 (7)呼叫转移 (14)呼叫停泊 (14)语音邮件 (15)语音会议 (17)Asterisk主要程序模块功能简述 (18)ASTERISK系统主要线程Asterisk系统主要是独立线程方式工作的系统,主要的独立线程有:维护注册用户状态的线程-维护各个用户在存在于系统的整个过程中的各个状态 各个通道(SIP、IAX等)主控线程-解析自己通道内的请求和响应系统主控线程-完成系统的初始化启动工作,完成后等待用户的输入和用户进行交互交换线程-由各个通道来调用启动,完成两个通道的桥接和语音交换系统主控线程Asterisk系统除了主控程序外,其它功能模块都编译成共享文件*.so类型,都采用预加载或者实时加载的方式进行协调工作,默认情况下系统启动后加载所有的模块,每个模块都有一个load_module()函数,主控找到每个模块并加载,然后调用模块内部的load_module()函数,这个函数完成模块自己对应的参数配置文件(如果有配置文件)数据的加载,并对模块进行初始化工作,初始化完成后,注册自己模块的应用方法和该模块支持的交互命令(这些是一般模块加载的流程,通道模块加载除外),模块内初始化函数调用完成后,系统继续加载下一个模块,直到所有的模块加载完成,系统主控线程等待用户的输入,完成和用户的交互,系统提供很多可以和用户交互的命令,来管理、配置、查询asterisk系统。
通道主控线程完成以上普通模块加载步骤后,建立一个该通道的主监控线程,该线程在整个系统运行期间一直运行。
每个通道(SIP通道、IAX通道等)都是在系统启动的时候,被加载进系统的,每个通道都是通过独立线程方式工作的,在各自配置的端口上监听等待接收各自通道上的请求和响应,各个通道线程独立运行,每个通道维护一个事件结构,该结构中放的是该通道中需要定时调度的事件(该事件是由该通道在解析数据的过程中,如果遇到需要隔一段时间来运行的程序则写入该结构的,比如,重发事件、销毁事件、期满事件等),每个通道共同调用三个公共的函数,一个是调度等待时间函数,一个是判断IO资源是否有数据发生的函数,一个是调度该通道事件运行的函数,调度等待时间函数每次调用返回的是需要等待调度事件的最短时间,如果没有事件,则返回-1,判断IO资源函数用这个返回时间来挂起资源,判断自己的通道上的数据发生,如果有数据发生就去调用自己注册的数据处理函数去处理请求数据,判断IO资源函数返回后,调用事件运行函数,来判断是否在该时间点有事件需要调度运行,每个通道都是如此往复的调用这三个函数循环运行判断,直到系统运行结束为止。
Asterisk配置笔记(yiqiangsong)一、Aterik接口类型二、使用接口配置文件1.Zaptel.conf:硬件接口基层配置,我们将建立一个F某0和一个F 某S通道.2.zapata.conf:硬件配置Aterik的接口.3.e某tenion.conf:拨号方案文件.4.ip.conf:配置SIP协议的文件5.ia某.conf:配置呼入和呼出IA某通道的文件三、F某O与F某S通信区别:区别简单,就在于连接的那端提供拨号音.F某O不生成拨号音,而是接收.F某S端口提供拨号音和震铃电压,在有呼叫的时候提醒用户.两者接口都提供双向通讯(同时双方向的通讯传输).F某S卡必须像中心局(CO)进行运转,使用F某O信令.同理,F某O卡连接CO,就意味着它需要像终端进行运转,使用F某S信令.四、接口文件配置1、Zaptel配置(F某O)在/etc/zaptel.conf文件,用于配置硬件,可以定义F某S端口与F 某O信令的配置f某k=1;定义f某端口采用通道1以k信令协议;f某ok=2;定义f某o端口采用通道2以k信令协议loadzone=udefaultzone=u信令协议:Looptart(l),groundtart(g),kewltart(k),使用k外信令协议,把f某ok中的k替换l或g,Aterik的模拟电路推荐k信令协议.某某某某某某编辑完zaptel.conf文件,需要使用/bin/ztcfg-vv装载配置到硬件(不须要详细输出可以省略-vv);修改信令方法需要重启.在编辑ip.conf和ia某.conf文档后,分别需要装载chan_ia某2.o和chan_ip.o2、Zapata配置硬件配置Aterik的接口[trunkgroup];定义一个主干组;defineanytrunkgroup[channel];硬件通道和他们选项信令方式.;hardwarechannel;硬件通道;default;默认buydetect=ye;增加这两行,要不F某O口不能检测到挂机信号。
Asterisk学习笔记Asterisk学习笔记1.安装Asterisk需要那些安装包。
a)Asterisk(pure voip only need this)b)Zaptel(support 硬件板卡支持)c)Pri(libpri)2.Asterisk的版本a)Asterisk目前有1.4和1.6两个分支,我们的HCC系统采用的是1.4分支上进行扩展开发。
1.6 no longer support zaptel,增加了很多新features,相对与1.4版本变动比价大。
b)Upgrade:ael 取消了Macro() 用Gosub()来代替。
Applications:ChanIsAvail()增加-t选项3.How to install Asterisk on Linux.a)Login as rootb)tar zxvf Asterisk-1.6…解压c)进入sub folderd)#make cleane)#./configuref)#makeg)#make installh)#make samples(安装示例配置)4.How to run/stop Asteriska)进入console,直接运行#asterisk 来运行b)进入asterisk命令提示界面:#asterisk –r 然后CLI>stop nowc)Asterisk可以用safe_asterisk来安全启动,通过safe_asterisk 启动后如果asterisk crash会dump core到/tmp目录,并且给administrator发email告警。
5.Asterisk目录结构a)/usr/lib/asterisk/modules 这个目录下包含所有可加载的asterisk模块b)/var/spool/asterisk 这个目录下包括outgoing gcall tmp voicemail目录asterisk会去monitor这个目录,可以用在做自动外呼等等c)/var/log/asterisk用来store logsd)/var/log/asterisk/cdr-csv用来store cdrs in csv format. CSV=comma-separate-value6.SIP in Asteriska)Asterisk中sip配置文件为/etc/asterisk/sip.confb)Asterisk支持IAX与SIP VOIP协议。
Asterisk入门资料目录1. 概述 (3)2. 什么是asterisk?开源电话平 (3)3. 为什么使用Asterisk? (3)4. 专利技术有什么错? (3)5. 我们要Asterisk做什么? (4)6. Asterisk支持什么技术? (4)7. 比较好的Asterisk参考书? (4)8. 相关: (4)9. 组件: (4)10. 有用的网页: (5)11. 重要链接: (5)12. 重要信息: (5)13. 外部交换借口/通道接口 (6)14. 拨号计划: (6)14.1. 上下文(context) : (6)14.2. 分机以如下格式定义: (7)14.3. Applications: (7)14.4. 特别分机: (8)14.5. 这个拨号计划会: (8)14.6. 为拨号计划添加逻辑: (8)15. 载入Ubuntu: (9)16. 求助: (9)17. 本章的任务: (10)18. 备注: (20)1.概述subscriber:加入某个group,从而遵从某一个call restricionsubscriber group:可以使用1种call restriction。
call restriction:将numbering plan中各项取出,各自组成成不同的呼叫限制方案numbering plan:通用,是一个整体的计划,里面包括长途,本地,等各种形式的方案————————————————————-以上,用于拨入号码的预处理,实际上是一种过滤,下面才是真正的呼叫处理。
————————————————————–route:一种策略,根据号码匹配的模式,选择走哪个trunk。
trunk:实际上做通一个链路,供route选择。
analog的,一个POTS就是一条analog trunkanalog的数量由设备定,ip trunk没有限制数量,并且一个ip trunk连到对方IPPBX后,对方的subscriber 数量是不确定的,由那个IP PBX决定。
Asterisk,开始吧————————————————————–2.什么是asterisk?开源电话平Asterisk 通过了电话的开源平台。
基本上就是一个软件的PBX。
最初是Digium 公司的Mark Spencer 编写的,这个公司就是他创立的,专门生产并销售Asterisk使用的硬件。
Asterisk 简直就是一场电话的革命。
3.为什么使用Asterisk?现在电信行业的混乱,因为各种专利技术应用在各种层次的网络上,导致很大的混乱。
Asterisk 就是答案——给电信行业普遍的混乱环境带来秩序的革命。
4.专利技术有什么错?没错,如果专利技术独立工作的话。
就像你有剃须刀和剃须膏没错一样!但是让各种技术互相操作,专利技术就会除了要价过高、客户不满,以及缓慢的开发速度等问题之外的刻板和局限。
5.我们要Asterisk做什么?根据情况而定。
在一个小实验室,一个pc(x86),500MHz 的奔三,合适的内存,合适的电源,还有Linux (其他os也可以支持)。
此外还有Digium 板卡插在系统中,以便连接本地PSTN。
6.Asterisk支持什么技术?与 VoIP, PSTN, ISDN, AIX, SIP 有关的任何东西。
7.比较好的Asterisk参考书?<电话未来之路>(http://www.asterisk-docs.o…找到,编译,安装,在第3,4章中,包含了到哪里去找那些文件之类的信息。
还有编译时的需要注意的选项,需要配置的模块,和在运行时载入的模块。
8.相关:gcc, glibc-kernheaders, cpp, binutils, glibc-headers, glibc-devel此外, 安装bison 和open ssl大多数标准的distro都自带推荐distro:基于RedHat和RH的distro (版本没指定)9.组件:AsteriskZaptellibpriAsterisk:Asterisk 程序文件,还有配置,监控的工具Zaptel: Zapata 项目中硬件的核心模块和驱动,如果要与PSTN或者其他网络接口,需要它。
libpri: 与Primary Rate Interface ISDN的接口库。
还有,如果基准时间参考,需要安装ztdummy 模块(第3章中解释)10.有用的网页:PSTN: /wi…G.729: /wi…G.711: /CI…Digium: /wi…Asterisk: /wi…Free World Dial-up: /wi…Asterisk Architecture: http://www.asteriskdocs.or…11.重要链接:Putty:http://www.chiark.greenend…Asterisk 通道:/w…12.重要信息:Asterisk machine on the LAN: 90.0.0.3Asterisk的目录结构:(更确切的说,是Asterisk使用的目录)/etc包含了zaptel.conf文件(只有一个)/usr/lib/asterisk/modules所有的asterisk可载入的模块都在这里,一般来说,所以的模块都是启动的时候载入的注意:要更改启动时载入的模块,或者是模块载入的方式,你可以修改/etc/asterisk/modules.conf文件/etc/asterisk包含了所有的asterisk配置文件/var/lib/asteriskagi-bin: agi 脚本固件:兼容设备固件映像:在这个目录下寻找映像(如果通道支持)关键字:这个文件中有基于RSA一类的认证关键字mohmp3:当配置了持有音乐的时候,这个目录是放置mp3的(注意,mp3应该使用恒比特率编码,并且没有id标签。
)sounds:所有的语音提示/var/spool/asteriskqcall:撤销了——包含了特殊呼叫方法的呼叫信息文件——不是打电话的好方法,因为这种方式太硬性了——不再使用。
使用outgoing替代。
Outgoing:现在打电话的法国闹事——呼叫信息目录普遍使用。
Tmp:中间/临时数据Voicemail:语音和问候语。
通过修改/etc/asterisk/voicemail.conf文件可以修改。
/var/run处理系统中运行进程的id(包括asterisk)/var/log/asteriskAsterisk在这里生产日志,通过/etc/asterisk/logger.conf来配置。
/var/log/asterisk/cdr-csv用来存储呼叫详细记录,逗号分割,例如csv(地址簿格式)重要:很多时间会使用cdr,ast附件包的代码可以在mysql数据库中存储cdr,用于记录呼叫详细记录13.外部交换借口/通道接口FXO :Digium Dev-Lite kit上的红口:Foriegn eXchange Office:这个通道(接口)的动作角色是fxo,利用fxs协议——就是说这个模块需要插入到pstn。
FXS(Digium卡的绿口):Foriegn eXchange Station,它表现得像fxs,读的是fxo协议——所以要插入终端设备——注意,这里插pstn,会烧坏!配置Foriegn eXchange Station文件:让你对常见的通道接口进行管理/comm 通道硬件,决定如何在连接的设备之间进行握手。
注意:使用zapata.conf文件完成非常重要的通道配置——激活或者失效类似回形针、回声处理之类的功能。
详细程度到pstn添加到那个端口,信令控制等——如果这里配置不正确,甭指望系统能工作正常。
14.拨号计划:在extensions.conf中指定。
Dialplan:拨号计划:在 /etc/asterisk 文件中拨号计划语法由以下组成部分:14.1.上下文(context) :写在[]里面, 定义上下文来创建独立的空间注意:最重要的一个上下文的应用就是提供安全性:要获得更多信息,看安装文件中SECURITY 文件。
例如:[incoming]statement 1—statement 2—[next-context]注意:当下一个定义的上下文开始的时候,现在这个上下文就结束了。
分机:非常简单。
与普通的PBX一样。
分机号的意思是你在连接到系统之后拨打的号码以获得某个终端/服务-不仅是asterisk14.2.分机以如下格式定义:exten =>分机的组成部分:exten => name, priority, application()例如exten => 123, 1, Answer() 的意思是当另一端拨打123,调用asterisk/apps /Answer(),优先级别为1。
优先级别通常从1开始。
数字越小,级别越高。
例如,级别1就比级别2要高。
(现在,有一些称为非数字化的级别——非常好,继续读!)一个很好的例子:exten => 123, 1, Answer()exten => 123, 2, Hangup()会发生什么情况,无论什么人拨打123,系统都会首先执行answer(),然后当answer结束的时候,过渡到hungup()。
你看,都是执行的顺序和优先级。
还有一些特殊的分机,例如s,比如我们前面的例子中123的位置,后面再解释记住:所有的优先级别都是从1开始,其他的必须遵循这个顺序。
Ast不会处理其他的,会认为是出错。
分机可是任何,不仅是数字,例如名字。
优先级:我想在前面讨论分机的时候已经讨论了优先级别。
非数字的优先级:我们会在Answer() …Hangup() 后使用n来代替实际的优先级别数字。
exten => 123, 1, Answer()exten => 123, n, Hangup()Asterisk会自动给优先级别+1, 所以你就不用每次记着并输入这个数字了Also, in Asterisk v2, we’ve got a way to put labels tp priorities:exten => 123, 1, Answer()exten => 123, n(Hangup), Hangup()14.3.Applications:应用程序:应用程序是真正执行你的拨号计划的程序。
拨号计划定义了顺序——应用程序就按照它去做。
工作内容可以是任何东西,从播放声音到接受当前通道上的按键输入。
(/w…了解asterisk通道,虽然听起来很好笑,但是我是对通道很迷惑)简而言之,应用程序是真正干活的,当有人拨打123的时候,参考以上示例。