VOIP with Asterisk & Perl



Similar documents
Micronet VoIP Solution with Asterisk

Mediatrix 3000 with Asterisk June 22, 2011

VoIP Workshop PacNOG3

Basic configuration of the GXW410x with Asterisk

Guideline for SIP Trunk Setup

Asterisk. Michael Kershaw

Configuration Notes 290

Applications between Asotel VoIP and Asterisk

VOIP, Linux, and Asterisk Making Beautiful Voice Together

How to Configure MTG200 with FreePBX

Unicorn60x0 IP ANALOG GATEWAY ASTERISK CONFIGURATION

Telephony with an Asterisk phone system

Configuring the Cisco SPA8800 IP Telephony Gateway in an Asterisk Environment

Asterisk: The Open Source PBX Solution Adam Olson Systems and network administrators typically deal with

Overview of Asterisk (*) Jeff Gunther

Fig. Setting up of a VoIP call. Fig. Experimental setup

White paper. SIP An introduction

Connecting Your Enterprise With Asterisk: IAX to Carriers. Dayton Turner Voxter Communications

General Guidelines for SIP Trunking Installations

Setup Guide: on the MyNetFone Service. Revision History

Implementation of a Fully Functional VoIP Server Inside of a Campus Network

Test on IX130 Performance

1) How do I setup my SIP trunk for inbound/outbound calling? We authenticate IP-PBX SIP Trunking traffic by:

EarthLink Business SIP Trunking. Asterisk 11.2 IP PBX Customer Configuration Guide

Skype connect and Asterisk

Setup the Asterisk server with the Internet Gate

SIPSTATION User Guide. Schmooze Com Inc.

General Guidelines for SIP Trunking Installations

Atcom MP01 and Elastix Server

ACD: Average Call Duration is the average duration of the calls routed bya a VoIP provider. It is a quality parameter given by the VoIP providers.

Connecting with Vonage

Manual. ABTO Software

ICE 008 IP PBX. 1. Product Information New Mini PBX Features System Features

Application Note Configuring the Synapse SB67070 SIP Gateway for Broadvox GO! SIP Trunking

Quick Provisioning Guide for Third-Party PBX

MyIC setup and configuration (with sample configuration for Alcatel Lucent test environment)

Integrating VoIP Phones and IP PBX s with VidyoGateway

VegaStream Information Note Considerations for a VoIP installation

Network Connection Considerations for Microsoft Response Point 1.0 Service Pack 2

NOC Workshop VoIP in the NOC labs SANOG10

Integrating Asterisk FreePBX with Lync Server 2010

Indepth Voice over IP and SIP Networking Course

MINIMUM NETWORK REQUIREMENTS 1. REQUIREMENTS SUMMARY... 1

IP-PBX Quick Start Guide

IP Telephony with Asterisk. Sunday A. Folayan

ZyXEL V100 Support Notes. ZyXEL V100. (V100 Softphone 1 Runtime License) Support Notes

Connect your Control Desk to the SIP world

Asterisk. Technical Application Notes

Intercommunication between two MyPBX (via VoIP Trunk)

There are a couple of notes about this however: It is best to have the IP subnet that the VoIP device on be on the same subnet as the DXL Exchanges.

Integrate VoIP with your existing network

Building Robust IPTSP Based on Open Source Technology. Anowar Hasan Sabir, BDCOM Online Ltd. Bangladesh

Transbox. User Manual

TALKSWITCH VOIP NETWORK TROUBLESHOOTING GUIDE

ESI SIP Trunking Installation Guide

CVOICE Exam Topics Cisco Voice over IP Exam # /14/2005

nexvortex Setup Guide

An Introduction to VoIP Protocols

Ryan Brown October 9, 2004 The Burgh Live, LLC. Voice over IP using Asterisk (*)

spiderstar VoIP Interface Version 4.0 User manual

nexvortex Setup Guide

VoIP Workshop PacNOG 6

GSM VOIP GATEWAY LEVEL. User Guide. GB with GSM module Two-way converter between VoIP and GSM

IPPBX FAQ. For Firmware Version: V2.0/V

Configuration Notes 0217

SIP Trunk Configuration Guide. using

SIP Configuration Guide

SSVP SIP School VoIP Professional Certification

Using Polycom KIRK Wireless Server 300 or 6000 with Asterisk

PBX Setup Basic setup procedures

Allo PRI Gateway and Elastix Server

Asterisk SIP Settings User Guide. Schmooze Com Inc.

Asterisk Business Edition TM Digium Partner Certification

A Guide to Connecting to FreePBX

Internet telephony Asterisk system.

TEL 500 WRITE UP WEEK 8 FREE PBX SIP LAB SUBMITTED TO: PROF. RONNY BULL BY: ANUSHA ALIGAPALLY

Configuration Guide for connecting the Eircom Advantage 4800/1500/1200 PBXs to the Eircom SIP Voice platform.

To ensure you successfully install Timico VoIP for Business you must follow the steps in sequence:

Asterisk & ENUM. Extending the Open Source PBX. Michael Haberler, IPA Otmar Lendl, nic.at

Intercommunication between two MyPBX (via VoIP Trunking)

Online course syllabus. MAB: Voice over IP

Open Source Telephony Projects as an Application Development Platform. Frederic Dickey Director Product Management

Grandstream Networks, Inc. How to Integrate UCM6100 with Microsoft Lync Server

Quick Start Guide v1.0

nexvortex SIP Trunking Implementation & Planning Guide V1.5

Figure The scenario

Troubleshooting Voice Over IP with WireShark

Configuring the Synapse SB67070 SIP Gateway from AT&T for Clearfly SIP Trunking. January 2013

Project Code: SPBX. Project Advisor : Aftab Alam. Project Team: Umair Ashraf (Team Lead) Imran Bashir Khadija Akram

Version 0.1 June Xerox WorkCentre 7120 Fax over Internet Protocol (FoIP)

Transcoding and Call Centers with OpenSIPS Bogdan-Andrei Iancu Founder OpenSIPS Project OpenSIPS Solutions

NetVanta 7100 Exercise Service Provider SIP Trunk

Level 1 Technical. Networking and Technology Basics. Contents

Lab Introduction software Voice over IP

VOIP (Voice Over Internet Protocol) Hacking-Fake Calling

Setting up a reflector-reflector interconnection using Alkit Reflex RTP reflector/mixer

Voice over IP (VoIP) for Telephony. Advantages of VoIP Migration for SMBs BLACK BOX blackbox.com

Connecting with sipgate

Transcription:

VOIP with Asterisk & Perl By: Mike Frager <mike@dialyourleads.com> 11/2011

The Elements of PSTN - Public Switched Telephone Network, the pre-internet phone system: land-lines & cell-phones. DID - Direct Inward Dial, a phone number on the PSTN. SIP - Session Initiation Protocol, the ringing, answered and hangup signals of VOIP. RTP - Real-time Transport Protocol, the audio (or video) of the VOIP call; also know as: the media stream. UDP - User Datagram Protocol, used for most VOIP packets.

Why UDP? Most VOIP systems use the UDP protocol to initiate calls and transport the media stream. UDP is used for VOIP packets instead of TCP because: TCP packets might be resent if they are not delivered immediately. TCP packets might be re-ordered, or delayed before reaching the application. Most VOIP audio codecs are capable of withstanding some packet loss.

Which audio codec? Audio codecs encode, and optionally compress, audio signals into binary streams that can be sent over the network. There are a few commonly used codecs: G.711 (u-law) - uncompressed, widely supported by carriers. G.729 - compressed, requires a license to use, though widely supported. Speex - an open source codec for speech, low bandwidth. G.722 - wide-band, high bandwidth, HD codec, supported by only by VOIP phones.

So how does it all work? SIP Media Server The PSTN: SIP/RTP calls Perl SIP Phone SIP/RTP calls Receive Calls PSTN -> VOIP: Origination Place Calls VOIP -> PSTN: Termination Flowroute connects calls to/from carriers. Soft-phone Flowroute provides a gateway to the PSTN, charges apply.

Termination: Placing a call to the PSTN using SIP Switchboard operators ain t what they used to be... Then: Now:

Origination: Receiving a call from the PSTN via a DID Hello

Network Address Translation: VOIP & NAT can cause problems External devices cannot send packets directly to devices behind a NAT firewall. For VOIP there is a grab-bag of tricks that are used to overcome this limitation. Asterisk is fairly adept at dealing with the problem. Most modern, consumer-grade routers will work properly with VOIP by default. If problems are encountered: Read documentation at http://voip-info.org/.

Asterisk: an Open Source Media Server Asterisk is a daemon that you run on your system to provide SIP and RTP media streaming for VOIP calls. Asterisk is a Virtual PBX, which means it is configured by default to be a corporate-style, branch phone system where each phone has an extension: 100, 101, 102, etc... Asterisk provides the features to receive inbound SIP calls and route them to either a VOIP phone or a PSTN gateway. Asterisk can also initiate calls programmatically. Asterisk can answer calls internally to play sounds, record messages, and create Interactive Voice Response systems (IVRs), etc...

Asterisk Config: /etc/asterisk/ sip.conf SIP profile to connect to the PSTN through a VOIP service provider (Flowroute): [flowroute] host=sip.flowroute.com username=47346967 secret=w9cslk38w12 type=friend nat=no qualify=yes dtmfmode=rfc2833 context=inbound canreinvite=no disallow=all allow=ulaw allow=g729 insecure=port,invite ; The name of the SIP profile ; SIP host to connect to ; SIP Login ; SIP Password ; Everybody is a friend of Asterisk these days ; Flowroute is not behind a NAT ; Periodically check if Flowroute is reachable ; Which type of dialpad key-press signals to use ; Dialplan context to use by default for this profile ; Able to redirect RTP media stream to a different host ; Limit media codecs ; Allow uncompressed 8Hz U-law codec ; Allow compressed g729 codec ; Accept calls from any registered IP

Asterisk Config: /etc/asterisk/ sip.conf SIP profile for a VOIP desk phone: [100] host=dynamic secret=c83jx73jx type=friend nat=yes canreinvite=no disallow=all allow=ulaw allow=g729 context=localexts insecure=port,invite qualify=yes ; Phone will get its IP address using DHCP ; The phone might be behind a NAT ; Default context localexts for internal phones

Asterisk Config: /etc/asterisk/ extensions.ael (The Dialplan ) Context for outbound calls from internal phones: context localexts { _NXXXXXXXXX => { Set(CALLERID(num)=13104561234); Dial(SIP/1${EXTEN}@flowroute); }; 100 => { Dial(SIP/100,45); Voicemail(100@default); }; 101 => { Dial(SIP/100,45); Voicemail(100@default); }; 102 => { Dial(SIP/100,45); Voicemail(100@default); }; 301 => { Agi(agi://127.0.0.1:7788/fastcgi); }; };

Asterisk Config: /etc/asterisk/ extensions.ael (More Dialplan) Contexts for inbound calls from the PSTN and an IVR prompt for the company: context inbound { 13104561234 => { Answer(); goto voiceprompt,s,begin; }, }; context voiceprompt { begin: s => { Wait(1); Background(main-company-prompt); }; // Play the message WaitExten(15); // Wait for an extension, otherwise Dial(SIP/100&SIP/101/&SIP/102,25); // Ring all these phones at once Voicemail(100); }, _1XX => { Dial(SIP/${EXTEN},25); Voicemail($EXTEN); },

Asterisk Config: /etc/asterisk/ manager.conf Allow your programs to access the Asterisk Manager Event API: [astmgr] secret = v2ovm39clg8 deny=0.0.0.0/0.0.0.0 permit=127.0.0.1/255.255.255.255 read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan write = system,call,agent,user,config,command,reporting,originate Middle Manager Bob

Perl & Asterisk: 2 Interfaces AMI - Asterisk Manager Interface The Manager interface allows external programs to monitor call-related events inside Asterisk. Perl connects to an event socket and listens for events. The AMI interface can also be used to initiate events, like originating a call, transferring a call, and more. Perl will connect a socket, issue a command, then disconnects. AGI - Asterisk Gateway Interface The AGI interface is used to control calls from inside the dialplan. The Agi(...) application will connect to a Perl daemon. Once connected to the daemon, the call progress will be controlled by Perl.

Perl Modules: AMI Modules: Asterisk::AMI - Newest module, OO-interface, recommended. Asterisk::Manager - Reference module, still works. AGI Modules: Asterisk::FastAGI - Based on Net::Server, recommended. Asterisk::AGI - Reference module, same functions as Asterisk::FastAGI.

Show me some code!?

#!/usr/bin/perl use Asterisk::AGI; use Net::Ping::External qw(ping); $AGI = new Asterisk::AGI; my %input = $AGI->ReadParse(); my $finished = 0; $AGI->exec('Festival', '"Enter the eye-p address you wish to ping."'); my $ipaddr = ''; my $x = 0; while (!$finished) { my $input = chr($agi->wait_for_digit('5000')); if ($input =~ /^[0-9\*\#]$/) { # pressed something if ($input =~ /^[\*\#]$/) { # pressed * or # $x++; if ($x > 3) { $finished = 1; } else { $ipaddr.= '.'; } } else { # pressed a digit $ipaddr.= $input; } } else { # must have timed out $finished = 1; } if ( length($ipaddr) > 14) { $finished = 1; } } if ($ipaddr!~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) { $AGI->exec('Festival', "\"Invalid Address: $ipaddr\""); exit 0; } $AGI->exec('Festival', '"Please wait"'); if (ping(host => "$ipaddr", timeout => 2)) { $AGI->exec('Festival', '"Host is up"'); } else { $AGI->exec('Festival', '"Host is down"'); } Written by: James Golovich <james@gnuinter.net>

We re Hiring! If you found this presentation interesting, and you re looking for Perl career in Los Angeles, please contact me! My Company: Dial Your Leads Website: http://www.dyl.com/ Email: mfrager@gmail.com or mike@dialyourleads.com Call Me: 614-886-7347 (Cell) or 888-310-4474 x200 (Desk) Address: 4551 Glencoe Ave., Suite 155, Marina del Rey