26
Wireless Africa November 2008 VoIP, Laboratory C: Billing in a Village Telco  Version 1.0 Author: IT46 VoIP Laboratory C VoIP Billling in a Village Telco (cc) Creative Commons Share Alike Non-Commercial Attribution 3 The Village Telco is composed by four major components: (1) a mesh potato, that acts as a wireless meshed VoIP client, (2) a billing platform, (3) a monitoring system and a (4) IP/VoIP gateway that provides access to voice and IP services via one of multiple trunk technologies. This laboratory focuses on the installation of a billing system for the Asterisk open source PBX. The document covers the installation and basic configuration of a2billing A2billing is an open source implementation of a telecommunication billing and added value services platform. 1 A2billing is a LAMP (Linux Apache Mysql(Postgresql) PHP) application that interfaces with Asterisk using both the AMI and AGI interfaces.  This laboratory has been tested using Debian etch, Debian etch and half, Ubuntu 8.04 and Ubuntu 8.10. This laboratory has been tested using a2billing v1.3.4 1 http://www.asterisk2billing.org 1 (26)

VoIP Laboratory C

  • Upload
    buinhi

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    VoIPLaboratoryCVoIPBilllinginaVillageTelco

    (cc)CreativeCommonsShareAlikeNonCommercialAttribution3

    TheVillageTelcoiscomposedbyfourmajorcomponents:(1)ameshpotato,thatactsasawirelessmeshedVoIPclient,(2)abillingplatform,(3)amonitoringsystemanda(4)IP/VoIPgatewaythatprovidesaccesstovoiceandIPservicesviaoneofmultipletrunktechnologies.

    ThislaboratoryfocusesontheinstallationofabillingsystemfortheAsteriskopensourcePBX.Thedocumentcoverstheinstallationandbasicconfigurationofa2billing.A2billingisanopensourceimplementationofatelecommunicationbillingandaddedvalueservicesplatform.1

    A2billingisaLAMP(LinuxApacheMysql(Postgresql)PHP)applicationthatinterfaceswithAsteriskusingboththeAMIandAGIinterfaces.

    ThislaboratoryhasbeentestedusingDebianetch,Debianetchandhalf,Ubuntu8.04andUbuntu8.10.Thislaboratoryhasbeentestedusinga2billingv1.3.4

    1 http://www.asterisk2billing.org

    1(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    TableofContentsPART1.HWandSWRequirements....................................................................................3PART2.Installationofa2billing............................................................................................4

    STEP1.GetA2Billingsourcecode...................................................................................4STEP2.PreparetheDatabase..........................................................................................5STEP3.Edita2billingconfigurationfile...........................................................................5STEP4.Fixpermissions,filesandfolders.......................................................................6

    1.SIPandIAX..............................................................................................................62.Musiconhold(notmandatory).................................................................................73.Soundfiles..................................................................................................................84.ConfigureAsteriskManager......................................................................................85.InstallTheAGIcomponents....................................................................................9

    STEP5.InstallwebbasedGraphicalinterfaces...............................................................9PART3.ConfigureA2Billing...............................................................................................10

    STEP1.Createdialplan..................................................................................................10STEP2.Providersandtrunks.........................................................................................11

    1.CreateproviderforoutgoingVoIPcalls...................................................................112.Createproviderforlocalcalls..................................................................................12

    STEP3.Ratecardsandcallplans.....................................................................................131.Definecallplan..........................................................................................................14

    STEP4.Createratecards................................................................................................141.Createrates..............................................................................................................142.Addratedtocallplans..............................................................................................15

    STEP5.Createcustomers...............................................................................................16PART4.ConfigureVOIPClients.........................................................................................17

    STEP1.Retrievesipparameters.....................................................................................17STEP2.ConfigurationofSIPparameters.......................................................................17

    1.Dialplan....................................................................................................................172.Createfourusers(Port14).....................................................................................183.Createaserviceprovider..........................................................................................184.CallingRule.............................................................................................................205.Configuresecondclient............................................................................................20

    PART5.ConfigureIncomingcalls.......................................................................................21STEP1.AddDID............................................................................................................21STEP2.Adddestinations................................................................................................22

    PART6.ConfigureexternalSIPclient................................................................................22STEP1.CreateaSIPUSERinAsterisk.........................................................................22STEP2.ConfiguretheATA............................................................................................23STEP3.ConfigureASoftphone......................................................................................25

    2(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    1.Installsoftphone.......................................................................................................252.Configuresoftphone.................................................................................................25

    PART7.Practicalexercises..................................................................................................26PART8.DefaultpasswordsandURL..................................................................................26

    PART1. HWANDSWREQUIREMENTS(Minimum)Hardwarerequirements:

    2IP04 1PAP2 2Analoguephones 1PC 4Ethernetcables

    LinuxRequirements:1. ApachewithMysql,PHP5andGDsupport2. PHP5CLIwithPCNTsupport(phpm)2

    3. Mysql phpagi2.14includedhttp://phpagi.sourceforge.net

    /A2Billing_AGI/libs_a2billing/phpagi_2_14 jpgraph_lib(includedina2billing)A2Billing_UI/Public/jpgraph_lib

    PrerequiredPackagesA2billingrequiresthepackagesofaLAMP(PHP5)installation.

    Toinstallthenecessarypackages,runthefollowingcommands:

    #aptgetinstalllibapache2modphp5php5php5common#aptgetinstallphp5cliphp5mysqlmysqlserverapache2php5gd#aptgetinstallopensshserver

    Asteriskisofcoursealsoneeded.

    #aptgetinstallasterisk

    SetupupthehardwareaccordingtoImage1(leavethePAP2ATAforlater).

    2 Checkyourphp.inifor:magic_quotes_gpc=Offregister_globals=Off

    3(26)

    http://phpagi.sourceforge.net/

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    PART2. INSTALLATIONOFA2BILLING

    Inanutshellinstallinga2billingrequiressevensteps:

    1. Downloadandunpacksourcecode

    2. Setupthedatabase

    3. Edita2billing.conffile.Settingupthedatabaseparameters

    4. Fixpermissionsandfolders

    5. Installingthewebbasedgraphicaluserinterfaces(CustomerandAdmin)

    6. PlacetheAGIfiles

    7. Prepareyourdialplan

    STEP1. GETA2BILLINGSOURCECODE

    Wewillnowcreateadirectory(mkdir)forthesoftware(/usr/local/src/a2billing),downloadthesourcecode(wget)andunpackit(tar).3

    #mkdirusr/local/src/a2billing

    3 IfyouareadeveloperconsiderusingtheSVNversionsvncousernameguestpasswordguesthttp://svn.a2billing.net/svn/asterisk2billing/trunk

    4(26)

    Image1:HardwaresetupforLabC.

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    #cd/usr/local/src/a2billing#wgethttp://www.asterisk2billing.org/downloads/A2Billing_1.3.4.tar.gz#tarzxvfA2Billing_1.3.4.tar.gz

    STEP2. PREPARETHEDATABASE

    WewillnowcreateaMySQLdatabase(mya2billing)forthebillingsoftware.Thefilea2billingMYSQLcreatedbuser.sqlincludesascriptthatcreatesthedatabasewiththecorrectaccesscontrolusersandpermissions.

    #cd/usr/local/src/a2billing#mysqlurootpexit

    STEP3. EDITA2BILLINGCONFIGURATIONFILE

    WeneedtoedittheA2Billingconfigurationfile(a2billing.conffile).ThefilecontainsalltheconfigurationinformationfortheAsterisk2Billingplatform,suchasdatabaseconnectionparameters,AGIbehaviorandWebInterfacecustomization.

    First,weneedtocopythedefaultconfigurationfilefromthesourcecode(/usr/local/src)toAsterisk(/etc/asterisk).

    #cp/usr/local/src/a2billing/a2billing.conf/etc/asterisk/

    Openthefilewithyourfavoritetexteditor(viisusedinthisexample).IfyouarenewtoLinux,werecommendyoutousethetexteditorGedit4.

    #vi/etc/asterisk/a2billing.conf

    4 Geditisagraphicaltexteditorandcannotberunfromaconsole.Inthatcase,werecommendvi.

    5(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    Thisfilecontainsdifferentsectionstoconfigureseveralpartsoftheapplication:

    section[database]:Toconfigurethedatabaseconnection

    section[webui]:Tocustomizethewebuserinterface

    section[recprocess]:ConfigurationfortheRecurringprocess(crontjob)

    section[agiconfX]:ConfigurationfortheAGI,severalconfigurationscanbedefined,ie"agiconf1","agiconf2",etc...thegroupidparameterwilldefinewhichconfigurationtouse.Usage:DeadAGI(a2billing.php|%groupid%)bydefaultagiconf1isused

    Let'shavealookatthedatabaseparametersinthesection[database].Thefollowingexampleshowsthedefaultdatabaseconfigurations.Ifyoudecidetochangethedatabaseparameters(youshoulddefinitelychangethepassword),thissectionneedstobeupdated.Makesurethattheportnumberiscorrectandthatyouhavetherighttypeofdatabaseenabled(mysql).

    [database]hostname=localhostport=3308user=a2billinguserpassword=a2billingdbname=mya2billing;dbtype=postgresdbtype=mysql

    STEP4. FIXPERMISSIONS,FILESANDFOLDERS

    Inthisstep,wewilltweakthefilepermissionsofAsterisktofittheA2Billingsoftware.WewillalsocreateanumberofadditionalfilesandfoldersthatA2Billingneeds,whichdoesnotcomewiththedefaultinstallation.

    1. SIPandIAX

    Firstwewillsetafewfilepermissions(chmod,chown)andcreate(touch)theSIPandIAXconfigurationfilesforAsterisk.

    chmod777/etc/asterisktouch/etc/asterisk/additional_a2billing_iax.conf

    6(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    touch/etc/asterisk/additional_a2billing_sip.confecho\#includeadditional_a2billing_sip.conf>>/etc/asterisk/sip.confecho\#includeadditional_a2billing_iax.conf>>/etc/asterisk/iax.confchownRfwwwdata/etc/asterisk/additional_a2billing_iax.confchownRfwwwdata/etc/asterisk/additional_a2billing_sip.conf

    2. Musiconhold(notmandatory)

    NowwewillcreatetenmusiconholdfoldersforAsterisk.Thefolderswilllooklikethefollowing:

    /var/lib/asterisk/mohmp3/acc_1;

    /var/lib/asterisk/mohmp3/acc_2;

    /var/lib/asterisk/mohmp3/acc_3;

    Tosaveyouthetroubleofcreatingallthefolderswiththerightpermissions,wehavecreatedascriptthatdoesthejobforyou.Tocreatethefolders,dothefollowing:Openatexteditandcreateafilecalledcreate_mohmp3.sh.Pasteinthecodefoundbelow,savethefileandquit.

    #!/bin/bashmkdir/var/lib/asterisk/mohmp3/acc_1mkdir/var/lib/asterisk/mohmp3/acc_2mkdir/var/lib/asterisk/mohmp3/acc_3mkdir/var/lib/asterisk/mohmp3/acc_4mkdir/var/lib/asterisk/mohmp3/acc_5mkdir/var/lib/asterisk/mohmp3/acc_6mkdir/var/lib/asterisk/mohmp3/acc_7mkdir/var/lib/asterisk/mohmp3/acc_8mkdir/var/lib/asterisk/mohmp3/acc_9mkdir/var/lib/asterisk/mohmp3/acc_10chmod777/var/lib/asterisk/mohmp3/acc_*

    Now,runthescriptfromthecommandline:

    #/bin/bashcreate_mohmp3.sh

    Nowweneedtoaddmusiconholdclassestothemusiconholdconfigurationfile(musiconhold.conf).Again,wehavecreatedascriptthatmakestheworkforyou.Justcreateafile(add_mohmp3.sh)withthecodebelowandrunthescriptfromthecommandline.

    7(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    echoacc_1=\>mp3:/var/lib/asterisk/mohmp3/acc_1>>/etc/asterisk/musiconhold.confechoacc_2=\>mp3:/var/lib/asterisk/mohmp3/acc_2>>/etc/asterisk/musiconhold.confechoacc_3=\>mp3:/var/lib/asterisk/mohmp3/acc_3>>/etc/asterisk/musiconhold.confechoacc_4=\>mp3:/var/lib/asterisk/mohmp3/acc_4>>/etc/asterisk/musiconhold.confechoacc_5=\>mp3:/var/lib/asterisk/mohmp3/acc_5>>/etc/asterisk/musiconhold.confechoacc_6=\>mp3:/var/lib/asterisk/mohmp3/acc_6>>/etc/asterisk/musiconhold.confechoacc_7=\>mp3:/var/lib/asterisk/mohmp3/acc_7>>/etc/asterisk/musiconhold.confechoacc_8=\>mp3:/var/lib/asterisk/mohmp3/acc_8>>/etc/asterisk/musiconhold.confechoacc_9=\>mp3:/var/lib/asterisk/mohmp3/acc_9>>/etc/asterisk/musiconhold.confechoacc_10=\>mp3:/var/lib/asterisk/mohmp3/acc_10>>/etc/asterisk/musiconhold.conf

    Makesurethattheresultaretenlinesasbelow(wherei=110)inthemusiconhold.conffile.

    acc_i=>mp3:/var/lib/asterisk/mohmp3/acc_i

    3. Soundfiles

    Weneedtocopy(cp)afewfilesfromA2BillingpackagetoAsterisksoundsfolder.

    cd/usr/local/src/a2billing/addons/cpsounds/*/usr/share/asterisk/sounds/cpsounds/en/*/usr/share/asterisk/sounds/

    4. ConfigureAsteriskManager

    ConfiguretheAsteriskManagerbyeditingthemanager.conffile.

    #vi/etc/asterisk/manager.conf[general]enabled=yesport=5038bindaddr=0.0.0.0

    [myasterisk]secret=mycoderead=system,call,log,verbose,command,agent,userwrite=system,call,log,verbose,command,agent,user

    8(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    5. InstallTheAGIcomponents

    PlacetheentirecontentofthedirectoryA2Billing_AGIintoyouragibindirectory.

    mkdir/usr/share/asterisk/agibincd/usr/local/src/a2billing/A2Billing_AGIcpa2billing.php/usr/share/asterisk/agibin/cpRflibs_a2billing/usr/share/asterisk/agibin/

    Makesurethescriptisexecutablechmod+x/usr/share/asterisk/agibin/a2billing.php

    STEP5. INSTALLWEBBASEDGRAPHICALINTERFACES

    Inthisstep,wewillinstallthetwographicalinterfacesofA2Billing,theAdministrationinterface(A2Billing_UI)andtheCustomerinterface(A2BCustomer_UI).

    PlacethedirectoriesA2Billing_UIandA2BCustomer_UIintoyourwebserverdocumentroot.

    cprf/usr/local/src/a2billing/A2Billing_UI/var/www/cd/var/www/A2Billing_UIchmod777templates_c

    cprf/usr/local/src/a2billing/A2BCustomer_UI/var/www/cd/var/www/A2BCustomer_UIchmod777templates_c

    Restartyourwebserver(Apache).

    /etc/init.d/apache2restart

    Checkpoint2:Directabrowsertotheadministrativewebinterface(http:///A2Billing_UI)andlogin(checkforalldefaultpasswordsattheendofthisdocument).

    Congratulations,youhavenowcompletedthesoftwareinstallationpart.Let'smoveontotheconfiguration!

    9(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    PART3. CONFIGUREA2BILLINGPart3focusesonconfiguringtheA2Billingsoftware.WhenwehavecompletedPart3,wewillbeabletoperformthefollowingoperations:

    1. Alocalusercancallanyotherlocaluserandbebilledforthephonecall

    2. Differentratescanbeappliedtodifferentusers(GoldandSilvermembers).

    3. Alocalusercandialout(viatheVoIPprovider)andbebilledforthephonecall

    4. People(outsideofthenetwork)cancallintoanylocaluser.

    STEP1. CREATEDIALPLAN

    Theextensions.confistheAsteriskdialplan.Callsthatinteractwiththebillingsoftwareneedtobehandledinsideofoneormanya2billingrelatedcontexts.

    Thecallsthatreachthecontextareprocessedusingthea2billing.phpAGIscript.Thea2billing.phpscriptcanbeinvokedinmanydifferentmodes(standard,did,voucher,callback,etc).Intheexample,wecreatetwodifferentcontexts,thefirstcontext[a2billing]handlesallthecallsfromourVoIPclients.Whenacallarrives,anyextensionnumber_X.

    10(26)

    Image2:Theredlinesrepresentsvoicecommunicationchannelsbetweenusers/peers.

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    (2digitsormore)reachesthescripta2billing.php

    Thesecondcontext[did],willbeusedtoroutecallsbacktotheusers.Callstotheclients(DID)arehandledinsideofthe[did]context.Thescripta2billing.phpindidmodeisresponsibleofroutingthecallbacktooneofourusers.5

    Editextension.conf(/etc/asterisk)andaddthefollowingtwoextension.

    [a2billing];CallingCardapplicationexten=>_X.,1,Answerexten=>_X.,2,Wait,2exten=>_X.,3,DeadAGI,a2billing.phpexten=>_X.,4,Wait,2exten=>_X.,5,Hangup

    [did];CallingCardapplicationexten=>_X.,1,Answerexten=>_X.,2,Wait,2exten=>_X.,3,DeadAGI(a2billing.php|1|did)exten=>_X.,4,Wait,2exten=>_X.,5,Hangup

    STEP2. PROVIDERSANDTRUNKS

    WewillnowconfigureA2Billingthroughitswebinterface.Inourscenariowewillcreatethefollowingproviders:

    1. ThePBXwillhaveoneVoIPprovider(WA_OUT)toreachtheoutsideworld.

    WA_OUTwilluseSIPastrunktechnology

    2. ThePBXwillhaveonelocalprovider(WA_LOCAL)toreachlocalclients.Theroutingoflocalcallsisconsideredasanotherprovider.

    LogintotheA2Billing_UI(username/passwordattheendofthisdocument).

    1. CreateproviderforoutgoingVoIPcalls

    Asystemcanhaveaccesstooneormoreproviderstoreachthevoiceworld.Eachprovidercanimplementoneormorevoiceroutingtechnologies(trunks).Wewillcreateoneprovider/withonetrunkthatusestheSIPprotocol.

    5 DeadAGIisavariantofAGIthatyouusewhenthechannelishungup.

    11(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    1. CreateaproviderandnameitWA_OUT(Trunk>CreateProvider)2. CreateatrunktotheWA_OUTProvider(Trunk>Addtrunk)

    Thetrunkshouldhavethefollowingparameters:

    VoIPProvider: WA_OUTLabel: VoIPupstreamsProvidertech: SIPProviderIP: ipaddressofyourVoIPprovider

    Notethatifthereareanytrunksavailablebydefault,youcansimplydeletethem.6

    2. Createproviderforlocalcalls

    Bydefault,A2Billingdoesnotprovideasimplemechanismtoroute(nortobill!)clientswithinthesamenetwork,asthedefaultbusinessmodelbehindthesoftwareistoprovidemeanstopeopletoreachotherproviders,nottointerconnectpeopleonthesamenetwork.

    Sinceourmainaimistoroutephonecallsbetweenlocalclients,andprobablyalsochargeforthosephonecalls,weneedtofindaworkaroundinA2Billing.

    Toaddthefunctionalityoflocalrouting/billingweneedtomakesurethatallcallstolocalclientsareprocessedinsideoftheDIDcontext.7

    1. CreateaprovidercalledWA_LOCAL.2. CreateatrunktoWA_LOCALwiththefollowingparameters:

    VoIPProvider: WA_LOCALLabel: VoIPlocalProvidertech: localProviderIP: %dialingnumber%@did

    6 Iftheproviderrequiresauthenticationorspecialparameters,wewillreplacetheproviderIPfieldfortheprovider[name].Wewilleditmanuallythefilesip.confandcreateanentryfortheprovider[name]wheretoincludethenecessaryparameters.

    7 Acalltoaninternalusersisgoingtobeforwardedtothe[did]localcontextinsteadoftheVoIPupstreamprovider.

    12(26)

    mailto:%dialingnumber%@did

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    STEP3. RATECARDSANDCALLPLANS

    Thisstepshandlestariffsandratesforthebillingsystem.Theconceptsinvolved,whichareimportanttounderstandarethefollowing:

    Eachclientisassociatedtoonecallplan(aservicelevel).

    AcallplanisacollectionofratecardsconnectedtoaLCtype.

    LCTypereferstoanalgorithmforrouteselection.A2Billingsupportstwodifferentalgorithms:

    LCR(LeastCostRouting):Selectthetrunkwiththecheapestcarriercost.(buyingrate)LCD(LeastCostDialing):Selectthetrunkwiththecheapestretailrate(sellingrate)

    Aratecardisacollectionofcallratesforcertaindestinations.Theratecardhasafallbacktrunk/providerdefined.

    Arateincludesbuyingandsellingcosts(rate/min,connectionfeeetc.)foracertaintrunk/provider.

    Image3providesanoverviewonhowthedifferentconceptsinteractwitheachother.

    13(26)

    Image3:LogicaloverviewofA2Billingconcepts.

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    1. Definecallplan

    Wewanttobeabletochargeclientsdifferentratesdependingontheirmemberstatus.Inthisexample,wewillusethemembertypesGoldandSilver.

    GoldmembersenjoysbetterratesthatSilvermembers.

    CreateonecallplanfortheGoldmembers(WA_GOLD)andonecallplanfortheSilvermembers(WA_SILVER).BothcallplansshouldbebasedontheLCR.

    STEP4. CREATERATECARDS

    Then,createthreeratecards,oneforoutgoingcalls(bothGoldandSilvermembers),andtwoforlocalcalls(oneforSilverandoneforGold).

    Tariffname Trunk

    WA_out_default VoIPupstreams

    WA_local_gold DID_local_provider

    WA_local_silver DID_local_provider

    1. Createrates

    Willwillnowcreatethreedifferentrates,oneratepartofeachoftheratecard.Let'sstartwiththerateforoutgoingcallstotheVoIPprovider.

    Inthiscase,wepretendthatourVoIPproviderroutesonlycallstoSpain,hencetheprefix34.

    WehavealsoassumedthatthebuyingratefromtheVoIPproviderinSpainis1USD/minute.Furthermore,weassumethattheminimumtimetheVoIPproviderchargesforis30sec(0.5USD),anditchargesusinblocksof30seconds(hence,aphonecallof35secondsandoneof59secondscostthesame).Naturally,thesefiguresneedstobeadoptedtoyourspecificVoIPprovider.

    Inthisexample,wehavedecidedtoselltheoutgoingVoipcallsforthedoublerate(2USD/minute).Theminimumtimetobillaswellasthebillingblockissetto60seconds.

    Localphonecallswithinournetworkareinfactfreeofchargefortheadministratorofthenetwork8.Whenwecreateratesforlocalcalls,wecanstillchoosetochargeforthosephonecallsornot.

    8 Excludingoperationandmanagementofthenetwork.

    14(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    Inthisexample,wewillcreatetworatesforlocalcalls,onerateforGoldmembers,andoneforSilvermembers.Inthisway,youcanchargeclientsdifferentrates,dependingontheirmemberstatus.

    Parameter Rate1 Rate2 Rate3

    Ratecard WA_out_default WA_local_gold WA_local_silver

    Dialprefix 34 46 46

    Destination Outgoing Localgold Localsilver

    Buyingrate 1 0 0

    Buyrateminduration

    30 30 30

    Buyratebillingblock

    30 30 30

    Sellingrate 2 1 1.5

    Sellrateminduration

    60 30 60

    Sellrateminblock

    60 30 60

    Connectcharge 0 0 0

    Disconnectcharge

    0 0 0

    Trunk VoIPupstreams VoIPlocal VoIPlocal

    2. Addratedtocallplans

    Gobacktothetwocallplansyoupreviouslycreatedandaddsuitableratecardstoeachone.

    Callplan Ratecard(s)

    WA_SILVER WA_out_defaultWA_local_silver

    WA_GOLD WA_out_defaultWA_local_gold

    15(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    STEP5. CREATECUSTOMERS

    Customeraccountscanbepredefinedinadvance,soonceanewclientjoins,oneoftheidleaccountsishandedouttohimorher.

    Wewillgenerateasetof10customeraccountswiththefollowingparameters:

    Parameter Value

    Lengthofcardnumber 10

    Numberofcards 10

    Tariff WA_SILVER

    Credit 100USD

    Access Simultaneously

    Currency USD

    Runservice Yes

    Youhavenowcreated10customeraccounts.Inthisexample,wewillonlyusethefirsttwoaccounts.

    Openthefirstaccountandview(ListCustomer,Edit)itscontents.Asyoucansee,eachcustomeraccountisidentifiedwiththefollowinguniqueparameters:

    Cardnumber IdentifiestheuserwhenregisteringtoAsterisk.

    Cardalias UsedasusernamefortheA2Billingweblogin.

    WebUIpasswordPasswordforA2Billingweblogin.

    ChangethecardaliasandwebUIpasswordtosomethingeasytoremember,asyouwillusetheseparametersanumberoftimes.

    Forexample,use1234(ascardaliasandwebpassword)forthefirstcustomer,and5678forthesecondcustomer.Whatevernumbersyouchoose,writethemdownonapieceofpaper.

    Bydefault,allcustomerswerecreatedasSilvermembers.UpgradethefirstcustomertoGoldmember,butkeepthesecondcustomerasSilverMember.

    Pleasenotthatinthisview,youcanalsoeditthecustomerspersonaldata,suchasname,address,emailandmobilephonenumber.

    16(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    PART4. CONFIGUREVOIPCLIENTSWewillnowconfigurethetwoclientsofyourVoIPnetworkwiththeuseraccountswejustcreatedinA2Billing.

    STEP1. RETRIEVESIPPARAMETERS

    LogintotheA2BillingcustomerUI9withtheusername/passwordofthefirstcustomersyoucreated(theparametersyouwrotedown).GototheSIP/IAXinfotabinthemainmenu.ThemainwindowwillnowdisplaytheSIPconfigurationdetailsforthiscustomer.

    Theparametersyoushouldpayattentiontoarethefollowing:

    username sameascardnumberfromA2BillingadministrationUI

    secret passwordforSIPregistrationtoAsterisk.

    STEP2. CONFIGURATIONOFSIPPARAMETERS

    LogintotheVoiptelGUI10ofyourclientdevice.

    1. Dialplan

    Createadefaultdialplan(Dialplan1)underCallingrules.

    9 http://ipaddrofa2billing/A2BCustomer_UI10 Http://ipaddrofclientdevice/

    17(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    2. Createfourusers(Port14)

    Parameter User1 User2 User3 User4

    Extension 1000 2000 3000 4000

    Name 1000 2000 3000 4000

    Analogueport 1 2 3 4

    Dialplan Dialplan1

    Extensionoptions: Voicemail,Callwaiting,3waycalling

    3. Createaserviceprovider

    AllcallsfromanyVoIPclient(IP04orATA)inthenetworkwillgothroughtheVoIPgateway(andA2Billing)beforeitisroutedtoitsfinaldestination.Alsolocalphonecalls(betweenlocalclients)willgothroughthegateway.Dependingonthedestinationofthecall,A2Billingwillapplydifferentroutingandbillingrulestoeachcall.

    Forthatpurpose,weneedtocreateaserviceproviderthatconnectsyourVoIPclient(IP04)withtheVoIPgateway.

    Whenwecreatetheserviceproviderwewillusethecustomerdetails11(username,password)createdbyA2Billingtoidentifytheuserhttp://www.voipinfo.org/wiki/index.php?page=Asterisk+cmd+DeadAGI.

    AshostparameterwewillstatetheIPaddressoftheVoIPgateway.

    Parameter Value

    Providertype Customervoip

    Comment WA_OUT

    Protocol SIP

    Register Yes

    Host

    Username

    Password

    Ifyoueditordeleteaprovider,theAsteriskconfigurationfileusers.confsometimesgetscorrupted12.Therefore,aftermakingchangestoaprovider,itcanbeagoodideatoverify

    11 Theusername/passwordweretrievedfromtheA2BCustomerUIforthisspecificcustomer.12 Weknow,itshouldnot!Butbettercheckitjustincase:)

    18(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    thattheusers.conffilecontainthedatayouwish.

    #vi/etc/asterisk/users.conf

    Theendoftheusers.conffile(intheIP04)shouldincludethefollowingdata:

    [trunk_1]disallow=allallow=alaw,ulawcallerid=contact=qualify=yescontext=DID_trunk_1dialformat=${EXTEN:1}fromdomain=fromuser=group=hasexten=nohasiax=nohassip=yeshost=insecure=veryport=5060provider=registeriax=noregistersip=yessecret=trunkname=CustomWA_OUTtrunkstyle=customvoipusername=

    IfyoueditanyAsteriskconfigurationfilesmanually,donotforgettoreloadAsteriskwiththefollowingcommand:

    #asteriskr#CLI>reload

    19(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    4. CallingRule

    Weneedtocreateacallingrulethatroutesallouroutgoingrulestotheprovideryoujustcreated(WA_OUT).Wewillusetheprefix00toreachtheVoIPgateway.

    Parameter Value

    Rulename WA_OUT

    Placethiscallthrough

    CustomWA_OUT

    Beginswith 00

    Followsby 0

    Strip 0

    Prepend 0

    5. Configuresecondclient

    Repeatstep14toconfigurethesecondVoIPclient.Remembertousetheusername/passwordfromanotherclientaccount.

    Checkpoint3:NowyoushouldbeabletoseeinyourVoIPgateway(thatrunsAsteriskandA2Billing)thatyouhavetwopeersregistered.Logintothegateway(ssh)andrunthefollowingcommand:

    #asteriskr#CLI>sipshowpeers

    Ifyoudonotseetwopeersregistered,youneedtoreviewyourconfigurations.

    FromtheAsteriskcommandlineintheIP04,youcanverifythattheyareregisteredintheVoIPgatewaywiththefollowingcommand:

    #CLI>sipshowregistry

    Checkpoint4:YoushouldnowbeabletoreachtheVoIPgatewaybycalling00fromanyofyourIP04extensions.Toreachanylocalextension,westillneedtoaddsomemoreconfigurations.

    20(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    PART5. CONFIGUREINCOMINGCALLSWewillnowconfigureroutingandbillingrulesforincomingcallstoanyofourlocalextensions.

    STEP1. ADDDID

    IntheA2Bwebmenu,setupbillingrulesforincomingcallstoextension1000and2000foreachIP04.[i]and[j]representstheuniqueidofyourIP04s.

    Herewecanselectifaclientshouldbechargedforincomingcalls,orifthatserviceshouldbefreeofcharge.Inthisscenario,incomingcallswillnotbechanged.

    DID Billing Monthlyrate

    46[i]1000 Free 0

    46[i]2000 Free 0

    46[j]1000 Free 0

    46[j]2000 Free 0

    Ofcourse,DIDscanbesetupforextension3000and4000aswell,butwewillonlyusethefirsttwoextensionsinthisexample.

    21(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    STEP2. ADDDESTINATIONS

    Now,weneedtomatcheachDIDcreatedwithanexistingcustomerandextension.

    Createfourdestinations,oneforeachextensionandcustomer.

    Destination IDCard DID

    SIP//1000 IDofcardnumber1 46[i]1000

    SIP//2000 IDofcardnumber1 46[i]2000

    SIP//1000 IDofcardnumber2 46[j]1000

    SIP//2000 IDofcardnumber2 46[j]2000

    Checkpoint5:YoushouldnowbeabletoplacephonecallsbetweenthetwoIP04s.Makesurethatyoucanplacephonecallsinbothdirections.Tocallfrom[i]to[j],dothefollowing:

    Call00Call46+[j]+extensionnumber

    Ifyoucannotplacephonecallsinbothdirections,youneedtoreviewyourconfigurations.

    Checkpoint6:YoushouldnotbeabletocalltheVoIPupstreamsprovider.Call00Call34+anynumber

    Theupstreamproviderinourlaboratorywillprovideyouanechotest()nomatterwhich34numberyoudial.

    PART6. CONFIGUREEXTERNALSIPCLIENTAssumethatapersoninanothercity,wantstoreachoneoftheclientsofthelocalVoIPnetwork.Therearemanydifferentwaystodothat,throughtheInternet(IP),thefixtelephonynetwork(PSTN)orthroughGSM.Inthisexample,wewillassumethatthispersonisconnectedtotheInternetandiscallingyouovertheIPprotocol.

    Thepersoncallingin,needseithertohaveasoftphoneinstalledinhiscomputer,orandATA(andananaloguephone)Wewillsetupbothalternatives.

    STEP1. CREATEASIPUSERINASTERISK

    CreateaSIPuser,byaddingthefollowingcodetotheendofthefilesip.conf.

    22(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    [666]type=friendusername=666secret=666disallow=allallow=ulawhost=dynamicqualify=yescontext=fromoutside

    Then,addthefollowinglinestoextensions.conf.

    [fromoutside]include=>did

    Byincludingdidinthecontext[fromotuside]weareforcingthatallcallsarrivingfromtheoutsideviathe666usercanberoutedtoaDID.

    ReloadAsterisk

    #asteriskr#CLI>reload

    STEP2. CONFIGURETHEATA

    ConnecttheATAtotheswitchandconnectananaloguephonetoit.

    EnabledhcponyourATAandfindoutwhichIPaddressthatwasgiventoit.DirectyourbrowsertothewebserveroftheATA.

    Action Command Choices

    Enterconfigurationmenu

    ****

    CheckDHCP 100

    Enable/DisableDHCP 101 Enable:1Disable:0

    CheckIPaddress 110

    23(26)

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    ConfiguretheATAtoregistertotheSIPuserpreviouslydefined(username=666,password=666).

    Hint:TheconfigurationmenuisfoundunderAdminLogin,Line1.

    Checkpoint7:ConfirmthattheATAhasbeenregisteredtotheVoIPgateway(thereshouldbethreeusersonlinenow).

    Checkpoint8:PlaceacallfromtheATAtooneofthelocalextensions.

    24(26)

    Image4:ConfigurationmenuofLinksysPAP2T.

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    STEP3. CONFIGUREASOFTPHONE

    Pleasenotethatthisexampleisvoluntarily,andrequiresaccesstoonemorecomputer.

    1. Installsoftphone

    Installthesoftphoneekigainoneofyourpersonalcomputers.

    #aptgetinstallekiga

    2. Configuresoftphone

    Launchtheapplicationandfollowtheinstallationwizard.Donotforgettodotheaudiotest!

    Createanewaccount,withthesameparametersasweusedfortheATAsetup.

    Checkpoint9:CallintoanyofyourIP04s.Doestheaudioworkbothways?

    25(26)

    Image5:UIforthesoftphoneEkiga.

  • WirelessAfrica November2008VoIP,LaboratoryC:BillinginaVillageTelco Version1.0Author:IT46

    PART7. PRACTICALEXERCISESThebestwaytolearnmoreaboutyourVoIPbillingsystemistoplayaroundwithit.Modifyrates,billingschemes,creditandotherbillingrelatedparameters,andseehowthesystembehaves.

    Selectacoupleoftheexercisesbelowthatyoufindinteresting.

    1. Makesurethatacustomerrunsoutofcreditduringaphonecall.Whathappens?

    2. UpgradeacustomerfromSilvertoGoldmember.Verifythatherrateschanges.

    3. Considerwhatratesyouwouldchargeforlocalphonecalls.Whatbillingparameterswouldyouuse?

    4. CalltoyourselfusingyourownDID.Whathappens?

    5. PlacetwocallssimultaneouslyfromthesameIP04.Whathappenstoyourcredit?

    PART8. DEFAULTPASSWORDSANDURLType Username Password Database URL

    A2Billing_UI root myroot A2Billing_UI

    A2BCustomer_UI admin mypassword A2BCustomer_UI

    Manager myasterisk mycode

    MySQLdatabase a2billinguser a2billing mya2billing

    IP04(ssh) root uClinux

    VoIPtelGUI admin mysecret

    Note!Thefirstcharacterinallusernamesandpasswordsisasmallletter(notcapital).

    26(26)

    PART 1. HW and SW Requirements PART 2. Installation of a2billingSTEP 1. Get A2Billing source codeSTEP 2. Prepare the DatabaseSTEP 3. Edit a2billing configuration fileSTEP 4. Fix permissions, files and folders 1. SIP and IAX2. Music-on-hold (not mandatory)3. Sound files4. Configure Asterisk Manager5. Install The AGI components

    STEP 5. Install web-based Graphical interfaces

    PART 3. Configure A2BillingSTEP 1. Create dialplanSTEP 2. Providers and trunks1. Create provider for outgoing VoIP calls2. Create provider for local calls

    STEP 3. Ratecards and callplans1. Define callplan

    STEP 4. Create ratecards1. Create rates2. Add rated to callplans

    STEP 5. Create customers

    PART 4. Configure VOIP ClientsSTEP 1. Retrieve sip parametersSTEP 2. Configuration of SIP parameters1. Dialplan2. Create four users (Port 1-4)3. Create a service provider4. Calling Rule5. Configure second client

    PART 5. Configure Incoming callsSTEP 1. Add DIDSTEP 2. Add destinations

    PART 6. Configure external SIP clientSTEP 1. Create a SIP USER in AsteriskSTEP 2. Configure the ATASTEP 3. Configure A Softphone1. Install softphone2. Configure softphone

    PART 7. Practical exercisesPART 8. Default passwords and URL