asterisk in three beer’s time or less or: how i stopped worrying and learned to love the dialtone...

32
Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 [email protected]

Upload: lea-peardon

Post on 02-Apr-2015

215 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

Asterisk in Three Beer’s Time Or Less

Or: How I Stopped Worrying and Learned to Love The Dialtone

© John Todd 2003-08-20 [email protected]

Page 2: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

What is Asterisk? (generally)

Asterisk is a PBX replacement system, designed to reproduce the features of standard office phone systems. Asterisk is also a Voice over IP toolkit which allows interaction between these PBX features and IP-based networks (local and remote.) Asterisk is hardware independent, and is designed to run on OSS operating systems.

Page 3: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

What is Asterisk? (details)

Telephony gateway (TDM channels - PRI,POTS) VoIP Gateway (IP channels) IVR system (Interactive Voice Response) Voicemail system Scriptable telephony-to-anything (Perl, C, etc.) More than will fit on this slide

Page 4: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

What Asterisk isn’t

A billing system A CRM system A web server or XML server (re: Cisco 79xx) A configuration tool for VoIP devices A voice recognition system A USENET or email client

Page 5: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Goals of Asterisk

Provide Open-Source implementations of basic PBX functionality

Be vendor neutral (despite last point here) Be as all-encompassing as possible for features Be flexible and provide hooks for advanced features Move proprietary hardware features into open

source software Sell TDM hardware cards for Digium

Page 6: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Who is Digium?

Primary supporter of Asterisk development Owner of the CVS server/bug system/mailing list

boxes/etc. Approves all patches and features by community Produces TDM cards (“Wildcard” hardware)

which works particularly well with Asterisk Owner of the disclaimers for all contributions to

Asterisk, holder of copyright

Page 7: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

WHAT?!? NON-GPL!?? JIHAD!!

Asterisk is GPL, but with an important clause Digium can license branches of the source such that

those branches are not GPL Digium gets disclaimers from all contributors saying

that Digium can do so Generally everyone is happy with this system Hold your flames until after I’m finished. :-)

Page 8: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Channel types: VoIP

SIP - Session Initiation Protocol H.323 MGCP - Media Gateway Control Protocol SCCP - Skinny Client Control Protocol (Cisco)

All of these use UDP for setup/transport except for SCCP, which uses a mix of UDP/TCP

Page 9: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Channel Types: VoIP (cont’d)

Phones for VoIP (SIP): Grandstream 102 - ~$85 new Cisco ATA 186 - 2 lines of analog - ~$140 new Cisco 7960/7940 - very nice deskphone - ~$300 used Many others - market is starting to flood with new vendors

from SE Asia Software for VoIP (SIP)

www.xten.com - free SIP client (“Lite”) gnophone.com - Linux SIP client Windows Messenger - don’t ask me, I don’t know how.

Page 10: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Channel types - non-VoIP

TDM POTS cards (Digium, Zapata, Voicetronix, etc.) TDM Digital (AdTran VoFR, Digium E1/T1, etc.) All TDM cards require install of Zaptel driver suite CAPI (ISDN card support for Linux ISDN driver) USB dongle for FXS Modem drivers for certain modems (yuck) Speaker/headphones (don’t try this at home, kids)

Page 11: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

System Requirements

No clear rule of thumb on processor size; at least 400mhz PIII recommended

Almost any version of Linux supported; RH 7.x or 8 is dev platform (9 has tweak issues)

Source + binaries (including sounds) are ~35m Using complex codecs (i.e.: G.729, speex, etc.) will increase

processor load dramatically Best to have a >1.5ghz machine for multi-channel use Linux preferred, though *BSD slowly starting to become

stable for non-hardware channels

Page 12: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Gotchas

Mpg123 needs to actually be mpg123, and not mpg321 (and located in /usr/bin/)

You need to have matching kernel source installed correctly to compile Asterisk/Zaptel

VoIP isn’t simple the first time you do it Asterisk documentation is less than adequate -

mailing list and Google have better data

Page 13: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Call Flow (briefly)

Calls come in on channels and are then handed to the “extensions.conf” file, which is the dialplan

Dialplan contains logical sections of matches called ‘Contexts,’ and each channel sends a call into the dialplan with a context name and a dialed number

The dialplan then matches (with modified regexp’s) the number being dialed, and runs applications accordingly

Each match on the dialed number has an order of steps called ‘Priorities’, and are indicated with an integral incrementing number (argh! Like a horrible BASIC Frankenstein, without the flexibility! )

Page 14: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Regular expressions (briefly)

All regular expressions start with “_” character in dial examinations.

“X” means any number, “N” is any number other than 0 or 1

“.” means any number of characters Brackets represent groups, with standard “-” and “,”

meanings ([1-9] or [0,1,2]) Better regexp in the works Example: _1410985012X is the same as

_1410985012[0-9]

Page 15: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Call Flow (cont’d)

[from-my-pri]exten => 14109850123,1,Answerexten => 14109850123,2,Wait(2)exten => 14109850123,3,Playback(monkeys)exten => 14109850123,4,Goto(more-monkeys,123,1)

[more-monkeys]exten => _12X,1,Playback(sorry-no-more-monkeys)exten => _12X,2,Hangup

Page 16: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Redirection based on ANI

You can match against calling number instead of called number.

This is a.k.a. “The ex-girlfriend filter” by the inventor of the routines

This pattern matches against called number (1410…) and also against calling numer (301…)

exten => 14109850123/3013659999,1,Busy

Page 17: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Redirection of Call Flow

GotoIf - can parse basic Booleans GotoIfTime - handy way to deal with time-based

redirection Some applications will add 101 to the existing

priority when certain errors occur (notably, Dial does this on busy, and DBget/DBput do this on errors reading from the internal database)

Any other type of errors result in channel hangup

Page 18: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Variables

${VARNAME} is how variables are used Variables must be declared before Booleans can

be performed (gah - no null value comparitor) Variables can be nested during setting

Exten => 123,1,SetVar(BAR=blah) Exten => 123,2,SetVar(FOO=3) Exten => 123,3,SetVar(NEWVAR.${FOO} = ${BAR}) This results in ${NEWVAR.3} being set to “blah”

Page 19: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Special Variables

${EXTEN} - always the most important variable. This is the number that is being currently evaluated.

${CALLERIDNUM} - the ANI (if available) of the call leg that is creating the call

Some others, less used: ${EPOCH}, ${ENV(var)}, ${CONTEXT}, ${PRIORITY}, several other descriptors of the call leg we’re processing

Page 20: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Some Applications

Dial - connects an inbound call with some other channel. One specifies the technology (SIP, Zap, H323, etc.) the number to be dialed, the Ring-No-Answer delay, and options (if desired)

exten => 1234,1,Dial(SIP/1234,25)

exten => 1234,2,Voicemail2(u1234)

Page 21: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Some Applications (cont’d)

Playback(filename) Plays a sound file in .gsm format

Background(filename) Plays a sound file while listening for DTMF (touch tone)

input

[test]exten => 123,1,Background(press-a-number)exten => 123,2,Goto(1)exten => _X,1,SayDigits(${EXTEN})

Page 22: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Some Applications (cont’d)

MeetMe(conf#) Adds the caller to a conference room (optionally muted

or unmuted)

Monitor Records channel (in and out) to .wav or .gsm files

PrivacyManager Forces anonymous calls to enter valid ANI

Page 23: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Some Applications (cont’d)

DISA Lets callers from one channel get dialtone on another

channel

SetMusicOnHold You can specify .mp3 files as music on hold selections

(random or sequential)

MP3Player Fairly useless, but fun. You can specify files or streams

of .mp3 to be played to callers.

Page 24: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Some Applications (cont’d)

There are over 80 different applications in the system - no time to talk about them all

Applications are easily created and added if you’re a decent C coder

Channels are generic, so you don’t have to know about any of the ugly VoIP or TDM stuff

Page 25: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Voicemail

Voicemail can be sent as email as well as stored on disk (1 minute = 100kb)

Short pages can be sent to email addresses when VM received

Customizable timezones and time readouts per user - supports multiple languages

.wav, .gsm file storage or email Dial by name directory hinges on VM data

Page 26: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Practical Uses (home)

Ditch your long distance company! SIP long distance (domestic and int) providers starting to crop up at low rates. Use Asterisk to gateway to them.

Prevent phone spam! Callers with no CID get ditched.

Filter your phone lines. Allow or forward callers who are on “priority” lists based on ANI.

Page 27: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Practical Uses (office)

Ditch your LD company (see prior slide) Interconnect office PBXs at zero network cost Get “Unified Messaging” Give ubiquitous access to the PBX for home/travelling

employees Disaster recovery scenarios Move phones into your IT department and away from

your expensive PBX consulting firm Eliminate adds/moves/changes as physical chores

Page 28: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Advanced Topics

Call queues - you can build a call center with Asterisk, with various call weightings and agent logins/hot seating

Multi-ring, cascading ring with different technologies (inbound calls forward to your desk line and your cell phone - first answer gets it)

Multi-language support with same dialplan Festival integration for voice synthesis

Page 29: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Really Advanced Topics

Manager interface: TCP socket based interface for controlling and monitoring the system; meant for automated manager tools (see: gastman)

AGI scripts: built-in scriptable hooks to allow passing of data back and forth between Asterisk and external programs.

Asterisk.pm - Perl module that works with AGI to handle gruntwork of call handling

Page 30: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Really Advanced Topics(cont’d)

Sybase and MySQL modules CDR (call detail record) output can be

customized or put into database instead of flat file

Use IAX2 trunk mode to get up to 200% more calls in the same bandwidth as other VoIP systems

Route your calls to least-cost providers

Page 31: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Crazy Extra Stuff That Didn’t Fit

Can run PPP or HDLC over channels - Asterisk can be a RAS server or a router (masochism)

Can use speaker/microphone as a “phone line” Can do video calls or conferencing ENUM e.164 DNS-based call routing

E.G. 2.1.2.1.2.5.4.3.0.5.1.e164.arpa. TDM over ethernet for front-end processing

Page 32: Asterisk in Three Beer’s Time Or Less Or: How I Stopped Worrying and Learned to Love The Dialtone © John Todd 2003-08-20 jtodd@loligo.com

© 2003 John Todd ([email protected])

Resources and Wrap-Up http://www.asterisk.org/ http://www.digium.com/ http://www.loligo.com/asterisk/ http://www.wwworks-inc.com/asterisk/ http://www.xten.com/ http://www.onlamp.com/pub/a/onlamp/2003/07/03/asterisk.html

John Todd - [email protected]

Asterisk Gun For Hire

PLUG Advanced Topics 2003-08-20