asterisk 使用教程
What is Asterisk?
Asterisk is an open source framework for building communications applications. Asterisk turns an ordinary computer into a communications server. Asterisk powers IP PBX systems, VoIP gateways, conference servers and other custom solutions. It is used by small businesses, large businesses, call centers, carriers and government agencies, worldwide. Asterisk is free and open source. Asterisk is sponsored by Digium.
Asterisk 是用于构建通信应用程序的开放源码框架。可以将普通计算机转换为通信服务器,实现IP PBX系统、VoIP网关、会议服务器和其他定制解决方案。它被全世界的小企业、大企业、呼叫中心、运营商和政府机构使用。Asterisk 是Digium公司赞助的免费和开源的软件。
-
2.asterisk 安装
apt-get install asterisk
-
2.2 源码编译安装方式
- 1.下载源码:http://downloads.asterisk.org/pub/telephony/asterisk/
- 2.解压源码
- 3.# ./configure
- 4.# make && make install
-
-
3.asterisk 简单使用
asterisk 的配置文件在/etc/asterisk/目录下,修改/etc/asterisk/sip.conf 内容如下可以创建sip账号
[general]
context=default
[6001]
type=friend
username=6001
context=from-internal
host=dynamic
secret=pbx6001
disallow=all
allow=ulaw
[6002]
type=friend
username=6002
context=from-internal
host=dynamic
secret=pbx6002
disallow=all
allow=ulaw上面我创建了两个sip用户,6001,6002 密码分别是pbx6001,pbx6002
下载SIP客户端,如eyeBeam,zoiper
修改/etc/asterisk/sip.conf 内容如下:
[from-internal]
exten=>6001,1,Dial(SIP/6001,20)
same=>n,Hangup()
exten=>6002,1,Dial(SIP/6002,20)
same=>n,Hangup()重启asterisk,这样才能使配置生效。
在另一台电脑上登录6002 sip账号,用软电话拨号呼叫6001,呼叫成功。
或者是同一台电脑上安装多个SIP客户端,不同客户端登录不同的账号,进行测试。
如上说明建立呼叫成功! -
4.Asterisk 框架图
Asterisk 按模块划分为以下几类:
Channel Drivers
Channel drivers communicate with devices outside of Asterisk, and translate that particular signaling or protocol to the core.
Dialplan Applications
Applications provide call functionality to the system. An application might answer a call, play a sound prompt, hang up a call or provide more complex behavior such as queuing, voicemail or conferencing feature sets.
Dialplan Functions
Functions are used to retrieve, set or manipulate various settings on a call. A function might be used to set the Caller ID on an outbound call, for example.
Resources
As the name suggests, resources provide resources to Asterisk and its modules. Common examples of resources include music on hold and call parking.
CODECs
A CODEC (which is an acronym for COder/DECoder) is a module for encoding or decoding audio or video. Typically codecs are used to encode media so that it takes less bandwidth. These are essential to translating audio between the audio codecs and payload types used by different devices.
File Format Drivers
File format drivers are used to save media to disk in a particular file format, and to convert those files back to media streams on the network.
Call Detail Record (CDR) Drivers
CDR drivers write call logs to a disk or to a database.
Call Event Log (CEL) Drivers
Call event logs are similar to call detail records, but record more detail about what happened inside of Asterisk during a particular call.
Bridge Drivers
Bridge drivers are used by the bridging architecture in Asterisk, and provide various methods of bridging call media between participants in a call.
前面之所以可以使用sip客户端相互呼叫,依赖于Asterisk里的Channel Drivers 里的chan_sip实现,除了chan_sip,Asterisk还支持其它类型的通道。以后会慢慢接触。