java.ociweb.com
Download
Report
Transcript java.ociweb.com
VoIP, Asterisk, and Java
Michael P. Plezbert
Agilis Systems, Inc
St. Louis Java Users Group
April 13, 2006
Overview
VoIP Basics
Asterisk PBX
Asterisk Gateway Interface
Manager Interface
Asterisk-Java Library
Example
Security
Resources
About Us
VoIP, Asterisk, and
St. Louis JUG April 13,
VoIP
Two-way (pseudo-) real-time
audio communication over IP
network
Allows “free” computer-tocomputer calls (disregarding
broadband connection fees),
e.g. Skype
Calls to “regular” phone
network requires specialized
hardware or service provider,
e.g. Vonage
VoIP, Asterisk, and
St. Louis JUG April 13,
VoIP
Pros
Cons
Allows use of single
network for voice and
data
Reliability of data
network becomes
paramount
Cost savings over
traditional PBX
Can leverage IT support
staff
Latency and jitter are
problems, requiring
overallocation of
bandwidth and/or QoS
Easier interaction with
computer/data systems
VoIP, Asterisk, and
St. Louis JUG
Requires VoIP phones
or other specialized
hardware to emulate
traditional phone
April 13,experience
Asterisk PBX
Open source software PBX system
Runs on commodity computer hardware (x86) and software
(linux/BSD)
Supports standard VoIP protocols
Hardware available for connection to POTS network
Many features built in, e.g. voicemail, call queues, conference
calls
VoIP, Asterisk, and
St. Louis JUG April 13,
Asterisk Interaction
Asterisk can communicate with external programs in several
ways
Call a local script
Connect via socket to an “AGI server”
Simple text messages back and forth
Server can be written in any language that supports socket comm
Cannot be used to originate calls
Accept socket (telnet) connections to a manager interface
More suitable for scripting languages than Java
Can be used to originate calls and receive other events
Read local “call files”
VoIP, Asterisk, and
Simple way to originate
calls
St. Louis JUG
April 13,
Asterisk Gateway Interface
1: a call comes into the asterisk
server
2: the asterisk server makes a
socket connection to an AGI
server
3: the AGI server sends
commands and receives results
over the socket, controlling the
flow of the call
Note that the AGI server cannot
originate a call using this
St. Louis JUG April 13,
VoIP, Asterisk, and
interface
1
Asterisk
Server
2
3
AGI
Server
AGI Commands
The AGI contains many commands for controlling a call,
including
answer
hangup
stream file
Limited to streaming local sound files on the asterisk
server, NOT over the socket interface
wait for digit
record file
VoIP, Asterisk, and
Records to local file on the asterisk server
St. Louis JUG April 13,
Manager Interface
1: client connects via socket
to the asterisk manager
interface and initiates a call
2
2: asterisk server places the
call
Asterisk
Server
3: when call connects,
asterisk server connects via
socket to the AGI server
4: the AGI server can send
commands and receive
results and events over
both the AGI socket
connection and the
VoIP, Asterisk, and
manager interface St. Louis JUG
1
4 3
AGI
Server
April 13,
4
The Asterisk-Java Library
Implements both the AGI server interface and
the manager client interface
Contains classes and methods for sending
commands and receiving events
Eliminates the need to manually build or
parse command strings
VoIP, Asterisk, and
St. Louis JUG April 13,
An Example
Simple example will
Originate a call
Play a sound file
Wait up to 5 seconds for a response
If 1, 2, or 3 is pressed then
Play sound files indicating digit pressed
Else
Play sound file indicating invalid choice
Hangup
VoIP, Asterisk, and
St. Louis JUG April 13,
Security
VPN or ssl-tunnel suggested
Socket comm is plain text (including authentication to
manager interface)
AGI connection is not authenticated
Asterisk configuration
Limit accessibility of external calls
VoIP, Asterisk, and
St. Louis JUG April 13,
Resources
Asterisk:
Asterisk@Home:
http://www.asterisk.org
http://asteriskathome.sourceforge.net
Asterisk-Java Library:
http://www.asteriskjava.org
http://sourceforge.net/projects/asterisk-java
VoIP, Asterisk, and
St. Louis JUG April 13,