Documente Academic
Documente Profesional
Documente Cultură
The Asterisk PBX Switching Core accepts telephone calls from the
interfaces. The Switching Core handles calls according to the
instructions found in a dial plan. The PBX Switching Core uses the
Application Launcher to ring phones, to connect to voicemail, or to dial
out on outbound trunks
Architecture
The PBX Switching Core includes a Scheduler and I/O Manager that is
available to drivers and applications. handles low-level task scheduling
and system management for optimal performance under all load
conditions
H.323
SIP
IAX
H.323
H.323 is an International Telecommunications Union Telecommunications
Standardization Sector (ITU-T) specification for transmitting
multimedia traffic, including video and voice, over an IP network
H.323 Protocols
Feature Protocol
Terminals
Also known as endpoints, terminals provide point-to-point and multipoint
conferencing for audio, video and data
Gateways
Gateways are used to connect between Switched Circuit Network (SCN)
endpoints and H.323 endpoints. Gateways are only needed when an
H.323 endpoint needs to interconnect to a different network
Gatekeeper
Gatekeepers provides pre-call and call-level control services to H.323
endpoints.
H.323 elements
There are five general steps in the H.323 signaling process: setup/teardown,
capabilities negotiation, open media channel, perform call, and release.
Setup/Teardown
To initiate an H.323 call, H.225 is required for the setup process.
The following are the most commonly used signaling messages :
Setup: A forward message sent by a calling entity in an attempt to establish
a connection with the called entity
Proceeding: A backward message sent from the called entity to the calling
entity to inform that call establishment procedures were initiated
The H.323 Call-Signaling Process
Alerting: A backward message sent from the called entity to inform that called
party ringing was initiated
Connect: A backward message sent from the called entity to the calling entity
that the called party answered the call. The connect message can contain the
transport UDP/IP address for H.245 control signaling
Release: sent by endpoint initiating disconnect
Capabilities Negotiation
After setup, H.245 is enlisted to negotiate the call’s application requirements
H.245 determines:
-Which kind of application media each terminal can support: audio, video.
-Which codecs each terminal is capable of and which it may prefer
-How the media channel will be structured, and which packet interval will be
used
-Which terminal will be the master and which will be the slave for the duration
of the call. Master and slave roles distinguish the client/server role
assumptions for future signals during the call and are a protocol formality
The H.323 Call-Signaling Process
Open Media Channel
Once capabilities negotiation has succeeded, RTP Control Protocol (RTCP)
establishes a UDP socket for the media channel
Perform Call
As the call progresses, RTCP, which runs alongside RTP (usually on
separate, consecutive UDP ports that are selected during call setup), can
keep tabs on the media channel
Release
When the call concludes, H.225 enters its release state, signaling an end to
the media channel, an end to the H.245 application capabilities session,
and an end to the call-accounting transaction on the gatekeeper
Session Initiation Protocol (SIP)
The two components in a SIP system are user agents and network servers.
Calling and called parties are identified by SIP addresses
User Agents
A SIP user agent is a client-end application continuing a User-Agent Client
(UAC) and a User-Agent Server (UAS.) These are known as a SIP client
and a SIP server. The client initiates SIP requests as a user's agent. A
server gets requests. A SIP server acts as a user's agent
SIP Overview
Network Servers
Two types of SIP servers proxy servers and redirect servers.
Proxy Servers
Act on behalf of other clients and contains both client and server functions.
a proxy server interprets and can rewrite request headers before passing
them on other servers. Rewriting ensures that the replies follow the same
path back to proxy instead of the client
Redirect Servers
Accepts SIP requests and sends a redirect response back to the client
containing the address of the next server
SIP Overview
Addressing
SIP Uniform Resource Locators (URLs) provide addressing similar to e-mail
addressing. A SIP URL can have various forms and can include a
telephone number, for example:
sip:someone@somewhere.com
sip:1-415-555-1212@somewhere.com
SIP Overview
- Via: shows the transport protocol used and the request route, each
proxy adds a line to this field
- From: shows the address of the caller.
- To: show the called user address of the request.
- Call-Id: Unique identifier for each call and contains the host
address. It must be the same for all the messages within a transaction.
- Cseq: begins with a random number and it identifies in a sequential
way each message.
- Contact : shows one (or more) address than can be used to contact
the user
- User Agent: The client agent who deals the communication.
SIP header
Message Header
Via: SIP/2.0/UDP
192.168.0.100:5060;rport;branch=z9hG4bK646464100000007343c526790
00020a600000e45
Content-Length: 0
Call-ID: 911D32E5-EEDF-4572-B0B2-61B294636E88@192.168.0.100
CSeq: 1 ACK
From: "Prueba"<sip:20000@miasterisk.com>;tag=8922404614682
Max-Forwards: 70
Route: <sip:20001@192.168.0.1>
To: <sip:20001@miasterisk.com>;tag=as0a27b928
User-Agent: SJphone/1.60.289a (SJ Labs)
Contact: <sip:20100@192.168.0.100:5060>;expires=3600
Inter-Asterisk Exchange (IAX) Protocol
IAX is much more compact because it has been developed only for telephony
applications
While a complete cycle of registration, call signaling, voice transmission, and tear-
down can use several TCP and UDP ports and connections with SIP or H.323,
IAX handles all of these functions using a single UDP port. When the IAX client
(endpoint) registers with the IAX server or proxy, this UDP port is utilized. This
same port is also utilized to place a call
Inter-Asterisk Exchange (IAX) Protocol
Requirements
Kernel source
bison
bison-devel
ncurses
ncurses-devel
zlib
zlib-devel
openssl
openssl-devel
gnutls-devel
gcc
gcc-c++
Installation
Check the required packages: Install the packages if they are not
installed:
rpm -q kernel-devel
rpm -q bison
rpm -q bison-devel yum install kernel-devel
rpm -q ncurses yum install bison
rpm -q ncurses-devel yum install bison-devel
rpm -q zlib
rpm -q zlib-devel yum install ncurses
rpm -q openssl yum install ncurses-devel
rpm -q openssl-devel yum install zlib
rpm -q gnutls-devel
yum install zlib-devel
rpm -q gcc
rpm -q gcc-c++ yum install openssl
yum install openssl-devel
yum install gnutls-devel
yum install gcc
yum install gcc-c++
Installation
asterisk-1.4.x.tar.gz
asterisk-addon-1.4.x.tar.gz
asterisk-sounds-1.4.x.tar.gz
Installing a Pure VoIP Server
Download required packages
wget http://downloads.digium.com/pub/asterisk/old-releases/asterisk-
1.4.14.tar.gz
wget http://downloads.digium.com/pub/asterisk/old-releases/asterisk-
addons-1.4.6.tar.gz
wget http://downloads.digium.com/pub/asterisk/old-releases/asterisk-
sounds-1.2.1.tar.gz
Installation
Install mpg123 to play mp3 files for music-on-hold before Asterisk’s
installation
wget http://mpg123.orgis.org/download/mpg123-1.2.0.tar.gz
tar -zxvf mpg123-1.2.0.tar.gz
Installation
cd mpg123-1.2.0
./configure
make
make install
ln -s /usr/local/bin/mpg123 /usr/bin/mpg123
Installing Asterisk
tar -zxvf asterisk-1.4.14.tar.gz
cd asterisk-1.4.14
make clean
./configure
make
make install
make samples
make config
Installation
Installing Asterisk’s Add-ons
tar -zxvf asterisk-addon-1.4.6.tar.gz
cd asterisk-addon-1.4.6
make clean
make
make install
Installing Asterisk’s Sounds
tar -zxvf asterisk-sounds-1.2.6.tar.gz
cd asterisk-sounds-1.2.6
make
make install
Connecting Asterisk to PSTN
Installation
Files needed
libpri-1.4.x.tar.gz
zaptel-1.4.x.tar.gz
asterisk-1.4.x.tar.gz
asterisk-addon-1.4.x.tar.gz
asterisk-sounds-1.4.x.tar.gz
Installation
Download required packages
wget http://downloads.digium.com/pub/asterisk/old-releases/ asterisk-
1.4.14.tar.gz
wget http://downloads.digium.com/pub/zaptel/releases/ zaptel-1.4.8.tar.gz
wget http://downloads.digium.com/pub/libpri/releases/libpri-1.4.3.tar.gz
wget http://downloads.digium.com/pub/asterisk/old-releases/asterisk-addons-
1.4.6.tar.gz
wget http://downloads.digium.com/pub/asterisk/old-releases/asterisk-sounds-
1.2.1.tar.gz
Installation
Installing libpri
tar -zxvf libpri-1.4.3.tar.gz
cd libpri-1.4.3
make
make install
Installing zaptel
tar -zxvf zaptel-1.4.8.tar.gz
cd zaptel-1.4.8
./install_prereq test ;Check for dependencies
./install_prereq install ;Install dependencies if not installed
./configure
make
make install
make config
The remaining installation is similar to that of a pure VoIP Asterisk System
Starting and Managing Asterisk
Asterisk 1.4.14, Copyright (C) 1999 - 2007 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 1.4.14 currently running on localhost (pid = 3960)
Verbosity is at least 3
localhost*CLI>
Asterisk’s Console Commands
Type the following commands on Asterisk’s console:
Asterisk.conf defines the locations for the configuration files, the spool directory, and
the modules, as well as a location to write log files to.
[directories]
astetcdir => /etc/asterisk ; location where Asterisk configuration
files are stored
[general]
enabled = no
port = 5038
bindaddr = 0.0.0.0
[magma]
secret = welcome
deny=0.0.0.0/0.0.0.0
permit= 192.168.1.0/255.255.255.0
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user
cdr_custom.conf
Asterisk will generate a CDR for every finished call by default; this file
defines exactly what gets logged in this CDR line.
[mappings]
Master.csv =>
"${CDR(clid)}","${CDR(src)}","${CDR(dst)}","${CDR(dcontext)}","${CDR(c
hannel)}","${CDR(dstchannel)}","${CDR(lastapp)}","${CDR(lastdata)}",
"${CDR(start)}","${CDR(answer)}","${CDR(end)}","${CDR(duration)}","
${CDR(billsec)}","${CDR(disposition)}","${CDR(amaflags)}","${CDR(ac
countcode)}","${CDR(uniqueid)}","${CDR(userfield)}”
rtp.conf
The rtp.conf file controls the Real-time Transport Protocol (RTP) ports
that Asterisk uses to generate and receive RTP traffic.
[general]
rtpstart=10000
rtpend=20000
rtpchecksums=no
Sip.conf
[general} section
Implements settings on all SIP clients
Port
The port Asterisk should listen for SIP incoming clients. The default is
5060
Bindaddr
If the Asterisk machine has multiple IPs, this option tells Asterisk to
listen on a particular IP. Asterisk listens on all interfaces and aliases by
default
Context
The default context for SIP clients
Sip.conf
Maxexpirey
The maximum amount of time until a peer’s registration expires
Defaultexpirey
This sets the default SIP registration expiration time, in seconds, for
incoming and outgoing registrations
Register
Register this Asterisk with another host
Sip.conf
Client Options
Type
The type option sets the connection class for the client. The options
are:
peer: A device which receives calls from an Asterisk server
user: A device that makes calls through an Asterisk server
friend: A device that can both send and receive calls through
an Asterisk server
Secret
Set a password for the client
Host
A client’s IP address. Can also be set to dynamic if a client comes
from any IP
Sip.conf
Defaultip
Asterisk will send a call on this IP if a host is set to dynamic and the
SIP client is not registered yet
Username
A client’s username
Context
The context to start in extensions.conf
Canreinvite
Connects end-points directly
Nat
Can be set to yes, no, or never. If set to yes, Asterisk ignores the IP
address in the SIP and SDP headers and responds to the address and
port in the IP header. The never option is for devices that cannot
handle rport in the SIP header, such as the Uniden UIP200.
Sip.conf
Qualify
Sets qualify to yes, no, or a time in milliseconds. If you set qualify=yes,
NOTIFY messages will be sent periodically to the remote peers to
determine whether they are available and what the latency between
replies is. A peer is determined unreachable if no reply is received
within 2,000 ms (to change this default, set qualify to the number of
milliseconds to wait for the reply). Use this option in conjunction with
nat=yes to keep the path through the NAT device alive.
Iax.conf
[general] section
Bandwidth
Instead of allowing or disallowing codecs, use low or high bandwidth
options to automatically select the low bandwidth consumption codec
or high bandwidth consumption codec
jitterbuffer
Turn the jitterbuffer on or off. The jitterbuffer is used to maximize audio
quality by balancing latency against the number of dropped packets
dropcount
Sets the maximum number of packets per memory size to be dropped in
order to reduce latency
maxjitterbuffer
Sets the maximum size of the jitterbuffer
Iax.conf
maxexcessjitterbuffer:
Sets the maximum excess jitterbuffer, which, if exceeded, causes the
jitterbuffer to slowly shrink in order to improve latency.
Simple Example
sip.conf extensions.conf
[internal]
[101] exten = > 101,1,Dial(SIP/101)
username=101 exten = > 102,1,Dial(SIP/102)
type = friend
secret = mypassword
qualify = yes
nat = no
host = dynamic
context = internal
[102]
username=102
type = friend
secret = mypassword
qualify = yes
nat = no
host = dynamic
context = internal
Configuring Soft Phone
select
Menu -> System Settings -> Sip Proxy -
> default
Configuring Hard Phone
Open a web browser and type the IP
address of IP phone
Click admin login -> Ext1
sip.conf
extensions.conf
[103]
[internal]
username=101
exten = > 103,1,Dial(SIP/103)
type = friend
exten = > 104,1,Dial(IAX2/104)
secret = mypassword
qualify = yes
nat = no
host = dynamic
context = internal
iax.conf
[104]
username=102
type = friend
secret = mypassword
qualify = yes
nat = no
host = dynamic
context = internal
Introduction To Dial Plan
Introduction To Dial Plan
Actual Asterisk Call Switching is performed by Dial Plan
extensions.conf
Based on priority model
extensions.ael
Based on asterisk extension language
The dial plan consists of four main parts: contexts, extensions, priorities, and
applications.
extensions.conf layout
Contents of extensions.conf is organized in three sections
general
global
contents
They are defined here so that they might be changed easily in the future.
Application - an instruction which tells Asterisk what it should do with the call
Literal
Pattern
Predefined
Literal
Literal extensions can contain numbers (0-9), letters A,B,C,D (some hard phones have
these letters) or all letters (a-z)
An example
[my-phones]
'700' => 1. Park() [res_features]
exten => 23,1,Answer()
-= 2 extensions (4 priorities) in 3 contexts. =-
exten => 23,2,Playback(hello-world) *CLI>
[my-phones]
exten => _2X,1,Answer()
exten => _2X,2,Playback(hello-world)
exten => _2X,3,Hangup()
Testing a Pattern
Test with the following CLI commands.
[my-phones]
exten => _2X.,1,Answer()
exten => _2X.,2,Playback(hello-world)
exten => _2X.,3,Hangup()
Testing a Pattern
Test with following CLI commands.
Example:
[sales]
exten => _12X.,1,NoOp(12X)
exten => 12345,1,NoOp(12345)
exten => _1234.,1,NoOp(1234.)
Pattern matching
Testing
Digium has changed the behaviour of “_.” as it was in Asterisk 1.2. it should have
lowest priority but in Asterisk 1.2 its behaviour is opposite to the expected
behaviour
Pattern matching
Example
[sales]
exten => _12X.,1,NoOp(12X)
exten => 12345,1,NoOp(12345)
exten => _1234.,1,NoOp(1234.)
exten => _.,1,NoOp(testing _.)
Testing:
dialplan show 12345@sales
In Asterisk 1.2:
show dialplan 12346@sales
Predefined
There are several predefined extension names:
- i - Invalid
- s - Start
- h - Hangup
- t - Timeout
- T - AbsoluteTimeout
- o – Operator
[test]
exten => 555,4,Hangup
exten => 555,1,Answer
exten => 555,3,Voicemail(44)
exten => 555,2,Playback(tt-weasels)
n priority
n priority automatically increases a priority's value
using n priority its easy to insert new command without disturbing the original
priorities
Labels can be set using n priority, so that it can be targeted with goto
exten => s,n(start),Answer
Sends control of the current channel to the ; same as above, but using a named priority
specified priority, optionally setting the exten => 124,1,Answer( )
destination’s extension and context
exten => 124,2,Set(COUNT=1)
exten => 123,1,Answer( )
exten =>
exten => 123,2,Set(COUNT=1)
124,3(repeat),SayNumber(${COUNT})
exten => 23,3,SayNumber(${COUNT})
exten => 124,4,Set(COUNT=$[${COUNT} + 1
exten => 123,4,Set(COUNT=$[${COUNT}
])
+ 1 ])
exten => 124,5,Goto(repeat)
exten => 123,5,Goto(3)
Applications(cont.)
GotoIf(condition?label1:label2) ; same thing as above, but this time we'll specify an extension and a
priority for each label
Sends the call to label1 if the condition is exten => 124,1,GotoIf($[ ${TEST} = 101]?123,10:123,20)
true, or to label2 if the condition is ; same thing as above, but these labels have a context, extension, and
priority
false.
exten => 125,1,GotoIf($[ ${TEST} = 101
]?incoming,123,10:incoming,123,20)
Either label1 or label2 may be omitted but
not both.
[globals]
TEST=101
[incoming]
jumps to the specified label if current time matched with the specified time
[countrywide]
include => local1
exten => _0N.,1,NoOp(Country Wide Call)
[international1]
include => local1
include => countrywide
exten => _00Z.,1,NoOp(International Call)
Variables
Variable is a placeholder for a value
A variable preceded by two '_' characters that is '__' will be inherited indefinitely
Inheritance of Channel
Variables
[variable-inheritance-test]
[test1]
exten => 105,1,NoOp(${FEE})
exten => 105,2,NoOp(${FIE})
exten => 105,3,NoOp(${FUM})
exten => 105,4,Dial(Local/106@test2)
[test2]
exten => 106,1,NoOp(${FEE})
exten => 106,2,NoOp(${FIE})
Some Predefined Channel Variables
[nationwide]
include => localcalls
exten => _0N.,1,Macro(test,${EXTEN})
[intercalls]
include => localcalls
include => nationwide
exten => _00Z.,1,Macro(test,${EXTEN}
[macro-test]
exten => s,1,GoToIf($["${MACRO_CONTEXT}":"localcalls"] ?local)
exten => s,n,GoToIf($["${MACRO_CONTEXT}":"nationwide]" ?nation)
exten => s,n,NoOp(interntional call)
exten => s,n,hangup()
exten => s,n(local),NoOp(local calls)
Include
For simplifying and organising larger dial plans.
With include, we use other contexts in current context
The following is syntax of include statement
include => context ;where context is name of contex
first asterisk will look in the current context for match. If finds no match, then asterisk
looks in first included context then second and so on.
Include statement can be made conditional to the time of the day. This make it easier to
implement different day and night behaviors.
Example
[time-based]
include => open|09:00-17:00|mon-fri|*|*
include => open|09:00-14:00|sat|*|*
include => closed
[open]
exten => _X.,1,NoOp(Ofice Open)
[closed]
exten => _X.,1,NoOp(Office Closed)
Dial Command
Dial command sends call on one or more channels
if priorityjumping=yes, the the dial plan jumps to priority+101 on busy, congested and on
channel unavailable.
Syntax is
Dial(type1/identifier [&type2/identifier2 [&type3/identifier3...]],timeout,options,URL
type specifies channel type such as ZAP, SIP, IAX2 and so on
identifierspecifies “phone number” to dial on that channel
specify more than one channel for dial command using & sign.
Timeout optional parameter, defines timeout
Dial Command
Options
t: allow called user to transfer call
T: allow the calling user to transfer
r: generate ringing tone
m: provide music on hold to calling party until called channel answers
h: allow the called person to hangup by dialing *
H: allow the caller to hangup by dialing *
o: send the caller's ID
j: Asterisk v.1.2 jump to priority n+101 if all of the requested channels are busy
M(x): executes the macro(x) once call connects
Dial Command
g: when the called party hangs up, exit to execute more commands in the current
context
G(context^exten^pri) if call is answered, transfer both parties to the specified context
and extension
S(n): hang up the call after n seconds of answer call
Return Codes of Dial Command
Dial sets DIALSTATUS to indicate its success or failure
DIALSTATUS contains the following text string
O and a extension
Call will be directed to operater if caller presses 0 and if operater=yes in voicemail.conf
• Will direct call to a extension (abort)
Special Extensions
T and t extension
t
If there is no input in an IVR menu within a certain timeframe, the t extension is
called
T
The T extension is called after the absolute timeout has been exceeded. You can set
this timeout value with Set(TIMEOUT(absolute)=<seconds>)
Special Extensions
The timer starts whenever the timeout value is set (it does not automatically start with
the connection, it must be started explicitly with the Set() command).
Example:
exten => 20,1,Answer()
exten => 20,2,Set(TIMEOUT(absolute)=120)
exten => 20,3,Playback(hello-world)
exten => 20,4,Wait(1)
exten => 20,5,Goto(3)
In Asterisk, expressions always begin with a dollar sign and an opening square bracket and
end with a closing square bracket, as shown below:
$[expression]
When Asterisk encounters an expression in a dial plan, it replaces the entire expression
with the resulting value.
Example
Boolean operators
expr1 | expr2
expr1 & expr2
expr1 {=, >, >=, <, <=, !=} expr2
Asterisk Features
Asterisk Database (AstDB)
Database data are grouped in families and identified with a key that is
unique within the family. AstDB’s structure is similar to the following:
Family1
Key1 => value
Key2 => value
:
:
Keyn => value
Family2
Key1 => value
Key2 => value
Asterisk Database’s Applications
Applications:
DBput
DBget
DBdel
DBdeltree
Dbput
Stores value in the database
Dbput(family/key=${foo}) (deprecated)
Set(DB(family/key)=${foo}) (new syntax)
CLI Command
CLI*>database put family key
Asterisk Database’s Applications
Dbget
Retrieve a value from the database
Dbget(foo=family/key) (deprecated)
Set(foo=${DB(family/key)})
CLI Command
CLI*>database get family key
Dbdel
Delete a key from the database
Dbdel(family/key)
CLI Command
CLI*>database del
Asterisk Database’s Applications
Dbdeltree
Delete a family or key tree from the database
Dbdeltree(family/keytree)
Call Forwarding
Forward the incoming call to some other number, or forward the
incoming call to some other number in case of busy or unavailable
Taps into a phone call between a caller and a callee. This is possible
with:
ChanSpy()
ZapBarge()
ExtenSpy()
ChanSpy()
Example
While spying
Dialing # cycles the volume
Dialing * will stop spying and look for another channel to spy on
Call Monitoring
ZapBarge()
Listens in on a conversation on a zap channel. If a channel is not
specified, it will prompt for one
Example
Exten => 8159,1,ZapBarge()
Exten => 8159,2,Hangup()
If you dial 8159, you are asked which line you want to listen on; for zap/1-
1 you will press 1# and for zap/25-1 you will press 25#
Call Monitoring
ExtenSpy()
Listen in on a channel, and also whisper into it if necessary
Example
[snoop]
exten => _555/705,1,ExtenSpy(|v(4))
[705]
exten => 705,1, dail(IAX2/trunk_3)
include => snoop
Call Monitoring
Add the following lines in extensions.conf
[spy]
Features.conf settings:
blindxfer => #1
disconnect => *0
atxfer => *2
Call Parking
Places a call on-hold onto a specific parking location so that it can be
picked up by another extension
Features.conf
Parkext => 700
Parkpos => 701-720
Context => parkedcall
Parkingtime => 45
Route by Caller ID
exten => 123/100,1,Answer()
exten => 123/100,2,Playback(tt-weasels)
exten => 123/100,3,Voicemail(123)
exten => 123/100,4,Hangup()
MeetMe Conferencing
Example:
Conf => 2222,1821, 191871
where
2222 is a room number
1821 is a password
19187 is an administrative password
MeetMe() Application
If a PIN argument is specified, the caller must enter that PIN in order to
enter the conference
An Example
[globals]
CONFMAX => 10 ; maximum persons in conference
[macro-stdmeetme]
; with limit to maximum number of persons in conference
• Configure voicemail.conf
• Call the mailbox configured in voicemail.conf from extensions.conf
• Define the mailbox for the user in sip/iax/zapata.conf
voicemail.conf
[general]
Setting=value
[zonemessages]
Newzonename=country/city|options
[context_section]
User-defined contexts here
voicemail.conf
Examples:
Record the audio file in the given box number which may be specified in
voicemail.conf. The flags can be any of the following:
VoiceMailMain()
Enter the main voicemail system to check voicemail. The format is:
VoicemailMain([[s]mailbox]@context)
Mailbox=1234
or
Mailbox=1234@context
Flite
Flite (festival-lite) is a small, fast run-time synthesis engine
asterisk-flite is a Flite text-to-speech module for the Asterisk open-
source PBX.
Flite
cd /tmp
wget http://asterisk-flite.sourceforge.net/extras/flite-1.3-sharedlibs.patch
wget http://asterisk-flite.sourceforge.net/extras/flite-1.3-alsa_support.patch
wget http://www.speech.cs.cmu.edu/flite/packed/flite-1.3/flite-1.3-release.tar.gz
wget http://kent.dl.sourceforge.net/sourceforge/asterisk-flite/asterisk-flite-
0.5.tar.gz
tar -zxvf flite-1.3-release.tar.gz
rm -f flite-1.3-release.tar.gz
cd flite-1.3-release
patch -p1 < ../flite-1.3-sharedlibs.patch
patch -p1 < ../flite-1.3-alsa_support.patch
./configure --enable-shared
make
make install
Flite
cd ../
tar -xzvf asterisk-flite-0.5.tar.gz
rm -f asterisk-flite-0.5.tar.gz
mv asterisk-flite-0.5 flite-1.3-release/
cd flite-1.3-release/asterisk-flite-0.5
make
make install
Verify that there is now a app_flite.so file in /usr/lib/asterisk/modules/
nano /etc/ld.so.conf
make sure that /usr/local/lib is in there. Add it if need be and save file.
ldconfig
asterisk -rx 'restart now'
asterisk -r
show application Flite
Flite
to test it, I simply put it in your extensions.conf file:
Periodicannounce
Periodicannounce and periodic-announce-frequency plays messages
such as “Thank you for holding ….” at regular intervals
Weight
Assign a rank to the queue. If calls are waiting in multiple queues, then
the queue with the highest weight values will be presented to agents
first.
Leavewhenempty
To remove callers from a queue when no agent is present, set this option
to yes
Wrapuptime
Allow a few seconds’ break to an agent after completing a call
Memberdelay
Delay between the time when a queue identifies a free agent and when
the call is connected to that agent
Timeoutrestart
If set to yes, then the timeout for an agent is reset if a BUSY or
CONGESTION is received
Queue()
Format is
Queue(queuename[|options[|URL][|announceoverride][|timeout]])
queuename name of the context in queue.conf
Options:
t Allow the called user to transfer the call
T Allow the calling user to transfer the call
h Allow the called person to hangup by pressing *
H Allow the calling person to hangup by pressing *
n Forbid retries if there is a timeout. Exit and move to next
extension
r Ring instead of music-on-hold
URL Send a URL to the called user if a channel supports this facility
Announceoverride
Set a sound file to override the one set in queues.conf
Timeout
Maximum time to wait in queue. The next extension will be executed
after the timeout
agents.conf
Creation of agent
Format is
Agent => agentnumber, agent_password, name
Agent_number is an agent’s number
Agent_password is an agent’s password
Name is an agent’s actual name
Extensions.conf application
AgentLogin()
Logs an agent to receive calls. An agent can hang-up a call by pressing
the * key
Format is
AgentLogin([AgentNo][,options])
The Option argument contains s, which causes the login to be silent
Example
Exten => 123,1,AgentLogin(42,s)
AgentCallbackLogin()
Format is
AgentCallbackLogin([AgentNo|][exten]@context)
This application asks the agent to login to the system with call back
[ivr-test]
• Analogue Connections
• Digital Connections
Analogue Connections
FXO cards are used to connect Asterisk with PSTN using analogue
phone lines and FXS cards are used to connect analogue phones to
Asterisk
Sangoma:
fxsks=2
loadzone=us
defaultzone=us
The card is FXO, therefore FXS with kewlstart signaling is defined for
channel 2. There can be any of the following three signals:
Loading Drivers
Use the modprobe command. For example, the wctdm is the driver for
Digium TDM400P
modprobe wctdm
rmmod wctdm
Verify the configuration:
#/sbin/ztcfg –vv
An error message indicates that the channel has been configured for the
wrong signaling
channel => 16
channel => 2,3
channel => 1-8
[trunkgroups]
; define any trunk groups
[channels]
; hardware channels
; default
usecallerid=yes
hidecallerid=no
callwaiting=no
threewaycalling=yes
transfer=yes
echocancel=yes
echotraining=yes
; define channels
context=incoming ; Incoming calls go to [incoming] in extensions.conf
signalling=fxs_ks ; Use FXS signalling for an FXO channel
channel => 2 ; PSTN attached to port 2
Digital Connections
T1 Services
T1 service can be provided as channelized or unchannelized. There
are 24 channels in the channelized T1 version. Each channel can be a
telephone call. T1 gives you 24 phone lines in place of the 23 that can
be accommodated with PRI. However, since there is no separate
signaling channel, the signaling information which indicates when a
phone is on the hook or off the hook is carried within each channel
by using or "robbing" the least significant bit. Unfortunately,
channelized T1 does not provide any capability for ANI or caller ID
data. PRI service is required for that purpose.
TE411P - 4 span T1/E1/J1 Card with Hardware Echo Cancellation for 3.3v
PCI
TE410P - 4 span T1/E1/J1 Card for 3.3v PCI
TE406P - 4 span T1/E1/J1 Card with Hardware Echo Cancellation for 5v
PCI
TE405P - 4 span T1/E1/J1 Card for 5v PCI
TE210P - 2 span T1/E1/J1 Card for 3.3v PCI
TE205P - 2 span T1/E1/J1 Card for 5v PCI
TE110P - 1 span T1/E1/J1 Card for 3.3v or 5v PCI
Sangoma
A104
A104
Configuring Digium’s Digital Hardware
Span
Span format is
Span = (spannum),(timing),(LBO),(framing),(coding)
spannum Number of span. Begins with 1 and goes up in integers.
No two spans can have the same span number
Timing How to synchronize the timing device
0: Use as sync source. Send timing synchronization to
other end
1: To use as primary sync source
2: To set as secondary sync source and so forth
Line Build Out (LBO) A cable’s length between a zap card and a
smartjack/telecom-provided modem. In case
of a long cable, use 0
span=2,2,0,ccs,hdb3,crc4
This is the second span on the system, has second priority to receive
timing from the other end, cable is less than 133 feet, uses ccs framing
and hdb3 line encoding.crc-4 is error checking
Zaptel.conf
span=1,1,0,esf,b8zs
bchan=1-23
dchan=24
Zapata.conf
switchtype=national
context=blah
signalling=pri_cpe
group=1
channel => 1-23
Asterisk Real time
Asterisk Real time
If want to use MySQL with Asterisk then install the MySQL database,
client libraries and header.
Install Asterisk Real Time driver, which can be found in the Asterisk
distribution’s add-ons section.
Installing MySQL
cd /usr/src
wget http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.33.tar.gz
tar -zxvf mysql-5.0.33.tar.gz
cd mysql-5.0.33
groupadd mysql
useradd -g mysql mysql
./configure –prefix = /usr/local/mysql
make
make install
Scripts/mysql_install_db
chown -R root /usr/local/mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql
cp Support-files/my-medium.cnf /etc/my.cnf
Installing MySQL
Start MySQL:
/usr/local/mysql/bin/mysql_safe &
mkdir /var/lib/mysql
cd /var/lib/mysql
ln -s /tmp/mysql.sock
To enable the unique ID in Asterisk’s cdrs, add the following line in Makefile:
vi Makefile
CFLAGS += -DMYSQL_LOGUNIQUEID
#define MYSQL_LOGUNIQUEID
Installing Asterisk Real Time driver
Compile and install:
make clean
make
make install
cp cdr_mysql.conf.sample /etc/asterisk/cdr_mysql.conf
cp res_mysql.conf.sample /etc/asterisk/res_mysql.conf
Configuring Database
mysql --user=root –password=password
GRANT ALL
ON asetriskcdrdb.*
TO asteriskuser@localhost
IDENTIFIED BY 'yourpassword';
Configuring Database
Create table cdr
USE asteriskcdrdb;
CREATE TABLE `cdr` (
`calldate` datetime NOT NULL default '0000-00-00 00:00:00',
`clid` varchar(80) NOT NULL default '',
`src` varchar(80) NOT NULL default '',
`dst` varchar(80) NOT NULL default '',
`dcontext` varchar(80) NOT NULL default '',
`channel` varchar(80) NOT NULL default '',
`dstchannel` varchar(80) NOT NULL default '',
`lastapp` varchar(80) NOT NULL default '',
`lastdata` varchar(80) NOT NULL default '',
`duration` int(11) NOT NULL default '0',
`billsec` int(11) NOT NULL default '0',
`disposition` varchar(45) NOT NULL default '',
`amaflags` int(11) NOT NULL default '0',
`accountcode` varchar(20) NOT NULL default '',
`userfield` varchar(255) NOT NULL default ''
);
ALTER TABLE `cdr` ADD INDEX ( `calldate` );
ALTER TABLE `cdr` ADD INDEX ( `dst` );
ALTER TABLE `cdr` ADD INDEX ( `accountcode` );
GRANT ALL
ON asetriskrealtime.*
TO asteriskuser@localhost
IDENTIFIED BY 'yourpassword';
[global]
hostname=127.0.0.1
dbname=asteriskcdrdb
table=cdr
password='your password'
user=asteriskuser
Connecting Asterisk With Database
Edit res_mysql.conf
[general]
dbhost = 127.0.0.1
dbname = asteriskrealtime
dbuser = asteriskuser
dbpass = yourpassword
dbport = 3306
dbsock = /var/lib/mysql/mysql.sock
Connecting Asterisk With Database
Edit the /etc/asterisk/extconfig.conf as given below:
[settings]
sipusers => mysql,asterisk,sip_buddies
sippeers => mysql,asterisk,sip_buddies
extensions => mysql,asterisk,extensions