Está en la página 1de 168

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang i

MC LC
Trang Trang ba lt ................................................................................................................ Nhim v n tt nghip .......................................................................................... Lch trnh thc hin n tt nghip .......................................................................... Li cm n .................................................................................................................i Mc lc .................................................................................................................... ii Lit k bng ............................................................................................................ vii Lit k hnh ........................................................................................................... viii Lit k t vit tt .................................................................................................... xii Tm tt ...................................................................................................................xiv Abstract ................................................................................................................... xv Chng 1 GII THIU ............................................... Error! Bookmark not defined. 1.1 M u ............................................................... Error! Bookmark not defined. 1.2 L do thc hin ti ........................................ Error! Bookmark not defined. 1.3 Mc tiu ca ti ............................................ Error! Bookmark not defined. 1.3.1 Xy dng h thng IP PBX ....................... Error! Bookmark not defined. 1.3.1.1 Yu cu ................................................... Error! Bookmark not defined. 1.3.1.2 Cc bc thc hin ................................. Error! Bookmark not defined. 1.3.2 Gii php tnh cc cuc gi .................... Error! Bookmark not defined. 1.3.2.1 Yu cu ................................................... Error! Bookmark not defined. 1.3.2.2 Cc bc thc hin ................................. Error! Bookmark not defined. 1.4 i tng cn tm hiu ...................................... Error! Bookmark not defined. 1.5 Gii hn ca ti ............................................. Error! Bookmark not defined. 1.6 B cc ca n................................................ Error! Bookmark not defined. Chng 2 TNG QUAN V VOIP .......................................................................... 9 2.1 Mng in thoi chuyn mch cng cng ........................................................ 9 2.1.1 PSTN lc ban u ....................................................................................... 9 2.1.2 Nhng kin thc c bn v PSTN ............................................................ 11 2.1.2.1 Tn hiu tng t v tn hiu s ............................................................. 11 2.1.2.2 iu ch xung m PCM ......................................................................... 11 2.1.2.3 Local loop v Trunk ............................................................................... 11 2.1.2.4 Truyn tn hiu trong PSTN ................................................................... 12 2.1.2.5 Nhng dch v v ng dng ca PSTN ................................................. 13 2.1.3 Nhng hn ch ca PSTN ......................................................................... 13 2.2 Voice over Internet Protocol (VoIP) ................................................................. 14 2.2.1 Chuyn mch gi ...................................................................................... 14 2.2.2 CODEC M ha v gii m ................................................................... 15 2.2.3 Cc giao thc iu khin ........................................................................... 16 2.2.4 Nhng u im ca VoIP ......................................................................... 19 2.2.5 Nhng hn ch ca VoIP .......................................................................... 20 2.2.6 Mt s dch v ca VoIP........................................................................... 20 2.2.6.1 Dch v in thoi qua Internet .............................................................. 20 2.2.6.2 Thoi thng minh ................................................................................... 20 2.2.6.3 Dch v tnh cc cho cuc gi ............................................................. 20

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang ii

2.2.6.4 Dch v Callback Web ........................................................................... 20 2.2.6.5 Dch v fax qua IP ................................................................................. 20 2.2.6.6 Dch v Call Center ................................................................................ 21 2.3 Kt lun ............................................................................................................. 21 Chng 3 GIAO THC KHI TO PHIN SIP ................................................ 22 3.1 Gii thiu giao thc SIP .................................................................................... 22 3.2 Cc thnh phn ca SIP ..................................................................................... 23 3.2.1 User Agent ................................................................................................ 23 3.2.1.1 User Agent Client ................................................................................... 23 3.2.1.2 User Agent Server .................................................................................. 23 3.2.2 Cc loi Server trong mng SIP ................................................................ 23 3.2.2.1 Proxy Server ........................................................................................... 23 3.2.2.2 Redirect Server ....................................................................................... 24 3.2.2.3 Registrar Server ...................................................................................... 24 3.2.3 Back to Back User Agent (B2BUA) ......................................................... 25 3.2.4 Cc c ch hot ng ca SIP ................................................................... 26 3.2.4.1 M hnh Peer to Peer .............................................................................. 26 3.2.4.2 M hnh thng qua proxy server ............................................................ 27 3.2.4.3 Cuc gi SIP thng qua m hnh Redirect Server ................................. 28 3.3 SIP v H.323 ...................................................................................................... 31 3.3.1 Mc phc tp ....................................................................................... 31 3.3.2 Kh nng m rng ..................................................................................... 31 3.4 SIP v IAX ........................................................................................................ 32 3.5 Kt lun ............................................................................................................. 33 Chng 4 GII THIU V CI T ASTERISK ............................................. 34 4.1 Tng i IP PBX ............................................................................................... 34 4.1.1 Khi qut v tng i IP PBX ................................................................... 34 4.1.2 Cc u im so vi tng i PBX truyn thng ....................................... 34 4.1.3 So snh gia IP PBX v PBX truyn thng .............................................. 34 4.1.4 Kh nng p dng trong cc doanh nghip va v nh ............................ 35 4.2 Tm hiu v Asterisk ......................................................................................... 35 4.2.2 Kin trc c bn ca Asterisk ................................................................... 38 4.2.3 H thng cng bao gm 4 chc nng API chnh ...................................... 39 4.2.4 Cc m hnh ng dng trin khai .............................................................. 39 4.2.4.1 Tng i VoIP IP PBX ........................................................................... 39 4.2.4.1 Kt ni IP PBX vi PBX........................................................................ 40 4.2.4.2 Kt ni gia cc server Asterisk ............................................................ 41 4.2.4.3 Cc ng dng IVR, VoiceMail, in Thoi Hi Ngh .......................... 42 4.2.4.4 Chc nng phn phi cuc gi t ng ACD ........................................ 43 4.2.5 S ra i ca giao thc IAX Inter Asterisk Exchange........................... 43 4.3 Ci t v cu hnh Asterisk .............................................................................. 44 4.3.1 Yu cu v cu hnh phn cng ................................................................ 44 4.3.2 Kt ni Internet ......................................................................................... 44 4.3.3 Ci t h iu hnh Linux ....................................................................... 44 4.3.3.1 Thit lp a ch IP ................................................................................. 44 4.3.3.2 Update h iu hnh Linux .................................................................... 45

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang iii

4.3.3.3 Download v ci t cc gi ph h tr ci t Linux ........................... 45 4.3.3.4 Ci t Apache 2 .................................................................................... 45 4.3.3.5 Ci t PHP5 .......................................................................................... 45 4.3.3.6 Ci t MySQL ...................................................................................... 46 4.3.4 PUTTY ...................................................................................................... 46 4.3.5 WinSCP ..................................................................................................... 48 4.4 Ci t Asterisk ................................................................................................. 49 4.4.1 Download cc gi ci t ca Asterisk ..................................................... 49 4.4.2 Gii nn v ci t cc gi ca h thng Asterisk .................................... 50 4.4.2.1 Ci t gi DAHDI ................................................................................ 50 4.4.2.2 Ci t gi Lipri ..................................................................................... 50 4.4.2.3 Ci t gi Asterisk ................................................................................ 51 4.4.2.4 Ci t gi Asterisk-addons ................................................................... 51 4.4.2.5 Ci t gi Extra Sound ......................................................................... 51 4.5 Kt lun ............................................................................................................. 51 Chng 5 GII THIU V CI T FREEPBX .............................................. 52 5.1 Gii thiu FreePBX ........................................................................................... 52 5.2 Ci t chng trnh FreePBX .......................................................................... 52 5.3 Cu hnh Card X100P giao tip vi PSTN ........................................................ 56 5.3.1 Gii thiu Card X100P .............................................................................. 56 5.3.2 Khi nim FXO v FXS ............................................................................ 57 5.3.3 Cu hnh Card X100P giao tip vi PSTN ............................................... 58 5.4 Kt lun ............................................................................................................. 61 Chng 6 GII THIU V CI T A2BILLING ........................................... 63 6.1 Gii thiu A2Billing .......................................................................................... 63 6.2 Tm hiu v AGI (Asterisk Gateway Interface) ................................................ 64 6.2.1 Cu trc c bn AGI ................................................................................. 64 6.2.2 Phn loi AGI ............................................................................................ 65 6.2.3 Mt s hm c bn ca AGI ..................................................................... 66 6.3 Cu trc v nguyn tc hot ng ca A2Billing .............................................. 71 6.4 Ci t A2Billing ............................................................................................... 73 6.5 Mt s khi nim trong A2Billing .................................................................... 79 6.6 Kt lun ............................................................................................................. 81 Chng 7 XY DNG H THNG PBX ASTERISK V GII PHP TNH CC A2BILLING ................................................................................................... 82 7.1 M hnh h thng thc t................................................................................... 82 7.2 Cc thit b phn cng v phn mm s dng................................................... 83 7.2.1 Phn cng .................................................................................................. 83 7.2.2 Phn mm .................................................................................................. 83 7.3 Mt s chc nng ca h thng IP PBX ........................................................... 83 7.3.1 Add Extension (To ti khon thu bao) .................................................. 83 7.3.2 Call Waiting (Cuc gi ch) ..................................................................... 89 7.3.3 Music On Hold (Nhc ch khi gi my) .................................................. 89 7.3.4 Blacklist (Danh sch loi tr) ................................................................... 93 7.3.5 Ring Groups ( chung chm) ............................................................... 94 7.3.6 Queues (Hng i) .................................................................................... 96

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang iv

7.3.7 Do Not Disturb (T chi nhn cuc gi) .................................................. 97 7.3.8 Conference (Xy dng h thng hi thoi) ............................................... 97 7.3.9 Follow Me (Chuyn cuc gi khi bn) ..................................................... 99 7.3.10 Callback (T ng gi li) ......................................................................101 7.3.11 Voicemail (Hp th thoi) ......................................................................103 7.3.12 Call Forward (Chuyn hng gi) .......................................................... 104 7.3.13 Call Pickup (Nhn cuc gi t xa trong cng mt nhm) ...................... 105 7.3.14 IVR (ng dng tng tc thoi) ............................................................. 106 7.3.15 Time Conditions (Xc lp thi gian biu)...............................................109 7.3.16 Day/Night Mode Control (Chuyn i ch ngy m) ...................... 112 7.3.17 Speed Dial (Quay s nhanh) ...................................................................114 7.3.18 System Recordings (H thng ghi m) ................................................... 115 7.3.18.2 Ghi m trc tip ..................................................................................116 7.3.18.3 Ti ln cc bn ghi m c sn ............................................................ 117 7.3.19 Calls Recordings (Ghi m cuc gi) ....................................................... 118 7.3.19.1 ng nhp ti khon Voicemail ......................................................... 118 7.3.19.2 Ghi m tt c cuc gi ........................................................................120 7.3.19.3 Ghi m cuc gi khi c yu cu ......................................................... 120 7.3.20 Call Parking and Transfer (Chuyn cuc gi) ........................................121 7.3.20.1 Chuyn cuc gi c qun l ............................................................... 122 7.3.20.2 Chuyn cuc gi khng c qun l .................................................... 123 7.3.20.3 Duy tr cuc gi ..................................................................................123 7.3.21 Remote Extension (Extension ng nhp t xa) .....................................123 7.3.21.1 NAT port (Forwarding Port) .............................................................. 123 7.3.21.2 Gii thiu v No-IP ............................................................................124 7.3.21.3 Cu hnh Remote Extension ............................................................... 126 7.3.22 Thit lp Trunk cho cc cuc gi trong FreePBX ..................................129 7.3.22.1 Trunks .................................................................................................129 7.3.22.1.2 To ZAP Trunk ............................................................................130 7.3.22.1.3 To SIP Trunk ..............................................................................131 7.3.23 Outbound Routes (nh tuyn cuc gi ra) ............................................132 7.3.24 Mt s kt qu thc hin .........................................................................133 7.4 Mt s chc nng ca A2Billing .....................................................................137 7.4.1 Providers and trunks ................................................................................137 7.4.1.1 Providers ............................................................................................... 137 7.4.1.2 Trunks ...................................................................................................138 7.4.2 Rate Cards ............................................................................................... 140 7.4.3 Rates ........................................................................................................142 7.4.4 Call plan ..................................................................................................147 7.4.5 Customers ................................................................................................ 148 7.4.6 Kt hp FreePBX v A2Billing .............................................................. 151 7.4.7 Mt s kt qu thc hin vi A2Billing..................................................153 7.4.8 Mt s chc nng khc ca A2Billing .................................................... 156 7.4.8.1 Call Report ........................................................................................... 156 7.4.8.2 T ng cp nht Card Number cho cc Extension ............................. 157 7.4.8.3 Package offer ( Gi khuyn mi h tr dch v) ..................................159

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang v

7.4.9 Giao din web ngi dng A2Billing ..................................................... 160 7.4.9.1 Gii thiu .............................................................................................. 160 7.4.9.2 Mt s chc nng s dng trn giao din ngi dng ......................... 162 7.4.9.2.1 Call history (Lch s cc cuc gi) ................................................162 7.4.9.2.2 Speed dial (Quay s nhanh) ........................................................... 162 7.4.9.2.3 Ratecard ......................................................................................... 163 7.4.9.2.4 Simulator (M phng cuc gi) ..................................................... 163 7.5 Kt lun ...........................................................................................................163 Chng 8 KT LUN V HNG PHT TRIN ..........................................165 8.1 Kt lun ...........................................................................................................165 8.2 Hng pht trin .............................................................................................. 165 Ti liu tham kho ....................................................................................................168

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang vi

LIT K BNG
Trang Bng 2.1 So snh cc chun CODEC ....................................................................... 16 Bng 3.1 Cc loi Frame trong giao thc IAX ......................................................... 32 Bng 4.1 So snh gia PBX truyn thng v IP-PBX .............................................. 35 Bng 4.2 Yu cu v phn cng i vi tng i Asterisk ...................................... 44 Bng 6.1 Cc hm c bn ca AGI .......................................................................... 71

Gii thiu

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang vii

LIT K T VIT TT
AAA ACD ACK ADSL AGI API ATA B2BUA BRI CDR CGI CLASS CLI CODEC CRM Cseq DAHDI DHCP DID DISA DNID DNS DSL DUC DTMF FXO FXS GPL GSM GUI HTTP IAX ISDN ISP IVR LAN LCD LCR MF MOH MP3 NAT Authentication Authorization - Accounting Automatic Call Distribution Acknowledgement Asymmetric Digital Subcriber Line Asterisk Gateway Interface Application Program Interface Analog Telephone Adapter Back to Back User Agent Basic Rate Interface Call Detail Record Common Gateway Interface Custom Local Area Signaling Service Command Line Interface Compression/Decompression Algorithm Customer Relationship Management Command Sequence Digium Asterisk Hardware Device Interface Dynamic Host Configuration Protocol Direct Inward Dialing Direct Inward System Access Dial Number Identifier Domain Name System Digital Subcriber Line Dynamic Update Client Dual Tone Multi-Frequency Foreign Exchange Office Foreign Exchange Station General Public License Global System For Mobile Communications Graphical User Interface Hyper Text Transport Protocol Inter Asterisk Exchange Integrated Services Digital Network Internet Service Provider Interactive Voice Response Local Area Network Least Cost Dialing Least Cost Routing Multi-Frequency Music On Hold MPEG-1 Audio Layer 3 Network Address Translation

Gii thiu

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing NGN OSS PBX PC PCM PIN PRI PSTN RCTP RPM RTP SDP SER SIP SS7 TCP UA UAC UAS UDP URI URL URL VoIP VSP WAN WAV Next Generation Networks Operations Support System Private Branch Exchange Personal Computer Pulse Code Modulation Personal Identification Number Primary Rate Interface Public Switch Telephone Network RTP Control Protocol Red Hat Package Manager Real Time Protocol Session Description Protocol SIP Express Router Session Initial Protocol Signaling System 7 Transmission Control Protocol User Agents User Agent Client User Agent Server User Datagram Protocol Universal Resource Identifier Universal Resource Location Uniform Resource Locator Voice Over Internet Protocol VoIP Service Provider Wide Area Network Waveform audio format

Trang viii

Gii thiu

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 9

Chng 1

TNG QUAN V VOIP

1.1 Mng in thoi chuyn mch cng cng Mng in thoi chuyn mch cng cng, hay cn gi l PSTN (Public Switch Telephone Network), l m hnh mng in thoi truyn thng c s dng rng ri hin nay. Trong phn ny, chng ta s tm hiu mt cch s lc v nhng vn c bn ca PSTN. 1.1.1 PSTN lc ban u Ban u, vic truyn ging ni c thc hin bng mt mch gi l ringdown, trong khng s dng cc s in thoi gi nh by gi m dng dy ni trc tip gia hai thit b. Thit k n gin ny dn dn c ci tin, t vic ch c mt ngi ni pht trin thnh h thng cho php hai ngi cng trao i trc tip vi nhau. Vic truyn tn hiu thoi trn cc cp dy ng i hi phi c cc thnh phn km theo khc nh micro bng cacbon, pin, nam chm in v mng rung. Ngoi ra phi c dy ni trc tip cc thit b ca ngi ni v ngi nghe vi nhau. Nhng yu cu nh vy lm cho h thng in thoi khng hiu qu, chi ph cao v khng linh hot.

Hnh 1.1 S kt ni 4 my iu ny cng d hiu, v d chng ta c 4 my in thoi cn lin lc vi nhau, cc my phi ni trc tip vi nhau nh hnh 2.1. Khi s lng my cng nhiu th s kt ni cng chn cht. Nu mun kt ni mt h thng c 8 my th s lng cp dy ng l 28 nh hnh 2.2.

Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 10

Hnh 1.2 S kt ni 8 my Mt cch tng qut, khi c N my trong h thng th phi c N(N-1)/2 cp dy ni. R rng, vi cch thc cu hnh v hot ng nh trn, h thng khng nhng i hi mt mt chi ph qu cao, m cch thc t chc qun l cng rt kh khn. Chng hn, khi cn thm mt my vo mt h thng ang c sn N my th phi ni thm vo N cp dy mi. khc phc nhng khuyt im ca h thng trn, mt c ch mi ra i cho php kt ni cc cuc gi mt cch d dng v thun li hn nhiu. C ch ny s dng mt thit b chuyn mch (switch), n gip cho ngi s dng c th thc hin cuc gi vi my in thoi khc thng qua trung tm chuyn mch. Mi my ch cn kt ni vi trung tm chuyn mch m khng cn phi ni trc tip vi cc my khc.

Hnh 1.3 M hnh chuyn mch lc s khai Ban u khi mi pht trin, b phn chuyn mch do con ngi trc tip m nhn. Hnh 2.3 m t mt s c bn ca h thng chuyn mch lc mi hnh thnh. Tri qua hn 100 nm pht trin, cc h thng chuyn mch in thoi ngy nay c thay th bng nhng h thng chuyn mch t ng, s dng cc cng ngh in t mi. PSTN l mng in thoi s dng h thng chuyn mch t ng ang c dng mt cch rng ri hin nay.

Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 1.1.2 Nhng kin thc c bn v PSTN 1.1.2.1 Tn hiu tng t v tn hiu s

Trang 11

Cc tn hiu trong t nhin vn l cc tn hiu tng t. Tn hiu tng t c th hin bng cc i lng vt l bin thin lin tc theo thi gian, v d nh bin dng in, sng m, Tuy nhin, trong thc t, khi s dng tn hiu tng t truyn tin tc i xa thng gy ra nhiu tn tht v nng lng, nht l tin cy ca tn hiu do qu trnh thm nhp ca cc nhiu v mt mt trn ng truyn. Do ngi ta thng chuyn cc tn hiu tng t thnh tn hiu s trong cc h thng vin thng. Tn hiu s v c bn l mt chui cc k hiu ri rc c chn t mt tp hu hn cc k hiu ri rc, v d nh cc chui cc k t ch hay s. H thng thng tin s chng t c nhng u th ca mnh so vi h thng tng t. Chnh v vy, trong h thng in thoi ngi ta s dng cc phng php iu ch s chuyn i gia tng t v s. Phng php iu ch xung m PCM (Pulse Code Modulation) l mt v d c s dng rng ri. 1.1.2.2 iu ch xung m PCM PCM l phng php m ha ph bin c s dng trong cc h thng in thoi truyn thng. N cho php chuyn i cc tn hiu tng t thnh cc chui cc bit 0 v 1. Qu trnh ny phi tun theo nh lut Nyquist, tc l mt tn hiu lin tc theo thi gian c th c phc hi chnh xc nu nh bng thng ca n l hu hn v tn s ly mu ln hn hoc bng hai ln bng thng tn hiu. Trong cc h thng m ha thoi, qu trnh ca PCM nh sau: Tn hiu thoi l tn hiu tng t c cho qua b lc thng thp loi b cc thnh phn c tn s cao hn 4000 Hz. Tn hiu sau c ly mu tn s 8000 Hz. Sau khi c ly mu, tn hiu s c chuyn thnh dng ri rc qua qu trnh lng t ha. Thng thng trong h thng thoi ngi ta s dng 8 bit lng t v dng gii thut nn c th gn nhiu bit hn cho cc tn hiu c bin nh. T cch thc hot ng nh trn, c th thy c tc ca h thng thoi ph bin l 64 kbps. C hai loi PCM 64 kbps c dng nhiu l -law cc nc Bc M v a-law cc nc Chu u. C hai dng ny u kh ging nhau, thay v phi dng n 12 hay 13 bit nh trong PCM tuyn tnh th chng ch dng 8 bit cho t m. Tuy nhin -law t ra hiu qu hn so vi a-law trong nhng trng hp t s tn hiu trn nhiu thp. 1.1.2.3 Local loop v Trunk Local loop dng ch vng lp trong i dy ni t trung tm chuyn mch n my in thoi ca khch hng. Qu trnh giao tip gia cc thu bao vi trung tm c thc hin trong vng lp ny. Trunk l ng giao tip gia cc trung tm chuyn mch vi nhau.

Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 12

M hnh mng in thoi dng cy Cc thu bao khng ni trc tip vi nhau m kt ni vi mt trung tm chuyn mch. Cc trung tm ny li kt ni vi nhau v kt ni vi trung tm chuyn mch cp cao hn. C nh th to ra mt m hnh mng in thoi dng hnh cy nh hnh v 2.4. Vi vic kt ni nh vy, khi c qu nhiu cuc gi xy ra cng mt lc th cc trung tm c th iu khin cc cuc gi i theo cc hng ph hp trnh gy ra nghn mng.

1.1.2.4 Truyn tn hiu trong PSTN


PSTN c hai dng truyn tn hiu (signaling), l user network signaling v network network signaling. Trong kiu th nht, user network signaling, thit b u cui ngi s dng lin lc vi mng in thoi thng qua cp dy xon. Signaling ph bin trong trng hp ny l DTMF (Dual Tone Multi-Frequency). Hnh v 2.5 di dy m t cu trc ca mt bn phm DTMF.

Hnh 1.5 Cu trc bn phm DTMF Bn phm DTMF cu thnh t mt ma trn 4x4, mi hng tng ng vi mt tn s thp v mi ct tng ng vi mt tn s cao. Mi phm bm tng ng vi Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 13

mt tn hiu sin c hai xung cc v tr thp v cao tng ng. V d, khi phm 9 c bm th mt tn hiu sin c hai xung cc tn s 852 Hz v 1477 Hz c gi i. Tn hiu ny c b phn chuyn mch tip nhn, gii m v xc nh phm no c bm. DTMF l phng php in-band signaling. Trong ISDN (Intergrated Services Digital Network), phng php truyn tn hiu l out-of-band signaling. Vi phng php ny, tn hiu c truyn trong nhng knh khc nhau. Knh truyn cc tn hiu voice, data, fax gi l knh bearer hay cn gi l knh B vi tc 64 kbps. Knh truyn cc tn hiu mang gi l knh iu khin hay l knh D. i vi cc vn phng nh th ch cn dng BRI (Basic Rate Interface) vi 2 knh B 64 kbps v mt knh D 16 kpbs. Tuy nhin vi cc cng ty ln hn, lng thng tin cn truyn nhiu hn th phi dng PRI (Primary Rate Interface) vi 23 knh B 64 kbps v 1 knh D 64 kpbs. Vic s dng out-of-band signaling c nhng u im nh dng c mt cch phc hp trong cc knh thng thng, gim nhiu, hn ch tr tn hiu, Kiu th hai l giao tip network network signaling, thng dng cc phng tin truyn dn nh: T1/E1 vi cc cp dy xon i: T1 l ng truyn c tc 1.554 Mbps thng dng Bc M v Nht. E1 cng l ng truyn s nhng tc cao hn 2.048 Mbps dng Chu u. T3/E3, T4 vi cp xon ng trc: T3 cha 28 knh T1, E3 cha 16 knh E1 v T4 cha 168 knh T1. T3 v T4 dng sng vi ba. SONET (Synchronous Optical Network) truyn qua cp quang tc ln n vi Gbps. Network network signaling s dng phng php in-band signaling nh MF (Multi-Frequency) hay RBS (Robbed Bit Signaling). MF kh ging vi DTMF nhng khc ch n dng tp cc gi tr tn s khc v thay v trao i gia ngi dng vi nhau nh DTMF th MF li trao i gia cc b phn chuyn mch vi nhau. Ngoi ra network network signaling cn s dng cc out-of-band signaling nh SS7 (Signaling System 7). SS7 l phng thc trao i thng tin gia cc b phn chuyn mch vi nhau nhm iu khin cc cuc gi v dch v CLASS (Custom Local Area Signaling Services). 1.1.2.5 Nhng dch v v ng dng ca PSTN PSTN cung cp nhiu dch v cho ngi s dng, ngoi nhng chc nng nghe ni thng thng, c th k ra mt vi ng dng ca PSTN nh: cuc gi ch, chuyn hng cuc gi, conference, hin th s ngi gi, t ng gi li, 1.1.3 Nhng hn ch ca PSTN Mng in thoi PSTN p ng c kh tt nhu cu trao i thng tin thng qua m thoi. Tuy nhin, ngy nay vi s pht trin ca h thng mng IP Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 14

cc doanh nghip lun mun tch hp c d liu v ting ni ln mt h tng chung. Cc mng ny s p ng c nhng yu cu mi, dch v mi vi gi thnh thp v cht lng chp nhn c. Qua mt thi gian hnh thnh v pht trin ca PSTN, ngi ta thy rng n c mt s nhc im ni bc nh: PSTN khng th to ra v trin khai cc ng dng mt cch nhanh chng. Khi s cnh tranh ngy cng cao trong th trng, bin php hu hiu nht to nn u th cho mnh chnh l to ra cc dch v mi nht v nhanh nht. PSTN l h thng mng da trn mt h tng khp kn, ngha l ch c nh cung cp dch v c quyn pht trin cc ng dng trn dch v . iu ny gy kh khn cho cc cng ty khi mun p ng y nhu cu ca khch hng. Do ngi ta hng n mt gii php m cho php nhiu nh khai thc pht trin mt cch sng to v hiu qu cc ng dng. Khng th truyn ng thi data, voice v video trn h tng mng PSTN truyn thng vi cc dy in thoi analog nh hin nay. Cn phi s dng h thng truyn dn bng rng tc cao nh DSL, cp, hay wireless c th tch hp ng thi voice, data v video. H tng mng xy dng cho voice khng thch hp cho truyn dn data. S dng bng thng khng hiu qu. PSTN dng kiu chuyn mch circuit switching i hi 64-kpbs cho mt cuc thoi trn i dy.Ngha l khi c ngi ang thc hin mt cuc gi trn i dy no th 64-kpbs s c s dng cho sut c qu trnh thoi m khng c thnh phn th ba no c th chen vo s dng n. Gi thnh cho xy dng v chi ph phi tr cho cc nh cung cp dch v cao.

Xu th tch hp voice v data trn mt mng chung l nhu cu tt yu trong thi i hin nay khi m Internet tr nn ph bin rng ri. VoIP c xem nh l mt bc tin mi gip ci thin ng k nhng nhc im ca PSTN v pht trin c nhiu ng dng mi. 1.2 Voice over Internet Protocol (VoIP) VoIP l cng ngh truyn tn hiu thoi trn ng truyn mng nn tng IP. Cng ngh ny s dng nhng k thut ring m ha tn hiu voice thnh cc gi tin c th truyn ti qua mng IP nh LAN hay Internet. VoIP khng ch gii quyt c vn ni b m cn c th kt ni vi PSTN thng qua cc Gateway. VoIP lm c nhng g m PSTN c th lm c vi chi ph thp hn nhiu. 1.2.1 Chuyn mch gi im khc bit trc ht gia h thng in thoi truyn thng PSTN v h thng VoIP l cch thc truyn tn hiu thoi. Trong PSTN ngi ta s dng phng thc truyn bng circuit switching. iu ny c ngha l khi ai ang thc hin cuc gi th circuit switching to ra mt lin kt i hi cc ti nguyn nh ng dy, cc switch, cc kt ni phi c s dng lin tc cho cuc gi ny v mt ngi khc khng th s dng cc ti Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 15

nguyn . S dng phng php ny cho php thu c cht lng kh tt nhng lm hao ph ti nguyn. VoIP s dng packet switching truyn tn hiu thoi. Phng thc hot ng ca packet switching khc vi phng thc hot ng ca circuit switching. Thay v phi to ra mt kt ni lin tc nh l circuit switching, packet switching chia tn hiu cn truyn ra lm cc phn nh, cc phn ny s c ng gi thnh cc packet truyn i v s c ti hp li thnh tn hiu ban u ni nhn. Cch lm ny cho php tn dng ti nguyn mt cch hiu qu.

Hnh 1.6 Circuit switching v packet switching 1.2.2 CODEC M ha v gii m Tn hiu di bng nm gia 0.3 v 3.4 KHz c xem nh l tn hiu voice. Thng thng tn hiu voice c ly mu tn s 8 KHz. Cc mu ny c lng t ha u hay khng u s dng mt mc lng t cho trc. V d khi dng 8 bit lng t, tc l c 256 mc lng t, th tc tn hiu l 64 Kbps. C ch ny c gi l m ha PCM v c dng rng ri trong h thng PSTN hin nay vi cc lut A v . VoIP i hi tc bit thp hn so vi PSTN nn khng dng phng php m ha v gii m ca PSTN. Cng vi s pht trin ca cc cng ngh vi x l, tn hiu v b nh, nhiu k thut m ha v gii m ra i phc v cho cc ng dng vi tc bit thp nh VoIP, trong c s dng rng ri nht l cc chun G.723.1 v G.729A. G.723.1 c tc t 5.3 n 6.1 Kbps vi 30-ms frame v G.729A c tc bit l 8 Kbps vi 10-ms frame. Frame u ra ca G.723.1 c 159 bit khi hot ng tc 5.3 Kbps v c 192 bit khi hot ng 6.4 Kbps. Trong khi vi G.729A th di frame u ra ch c 80. G.729A c lp t n gin hn v s dng hiu qu hn G.723.1 nn c s dng rng ri hn. C hai thit k ny u s dng cng mt lng b nh l 10K

Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 16

ROM v 2K RAM, nhng G.723.1 cn n 16 MIP (Message Tranfer Parts) ca dung lng x l trong khi G.729.A ch cn dng 10 MIPS. Ngoi ra cn c mt s chun CODEC khc. Bng 2.1 m t so snh cc chun CODEC khc nhau.

Bng 1.1 So snh cc chun CODEC 1.2.3 Cc giao thc iu khin Nn tng ca cng ngh VoIP l hai giao thc c bn H323 v SIP (Session Initiation Protocol). truyn tn hiu voice c hai u dng chung mt chun RTP/UDP/IP. Chun H.323 l chun c pht trin u tin bi ITU (International Telecommunications Union), c s dng kh lu v c tch hp d dng vo cc h thng tng i ni b PBX (Private Branch eXchange) thc hin cc cuc gi qua VoIP thng qua cc knh truyn nh ISDN. Hin nay cc thit b VoIP theo chun H.323 cng c kh nng hot ng tt trn ng truyn bng thng rng ADSL (Asymmetric Digital Subcriber Line). Chun H.323 cho php truyn dn cc tn hiu voice, data, video v cc ng dng chia s trn ng truyn IP vi cc k thut bo mt kh tt. thit lp h thng VoIP da trn nn H.323 cn c mt s thit b nh in thoi (Terminal), MCU (MultiPoint Control Unit), Gateway, GateKeeper. Hnh 2.8 m t cc thnh phn c bn ca H.323.

Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 17

Hnh 1.7 Cc thnh phn c bn ca H.323 Chun SIP c pht trin bi IETF (Internet Engineering Task Force) nh mt giao thc peer-to-peer gn nh v hiu qu trn ng truyn mng internet hay LAN. Da trn nn tng HTTP (Hyper Text Transfer Protocol) v MIME (Multi purpose Internet Mail Extensions), SIP hiu qu hn trong vic tch hp voice v data theo thi gian thc v chim t bng thng trn ng truyn. SIP h tr t tn cc account thng qua DNS (Domain Name System) hay URL (Uniform Resource Locator) v ng dng PC-based phone do linh hot hn khi thit k mng.

Hnh 1.8 Cc thnh phn c bn ca SIP Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Cc vn v SIP s c cp k hn trong chng sau.

Trang 18

Ngoi H.323 v SIP ra, khi ni n VoIP cn phi quan tm n mt s protocol khc nh MGCP (Media Gateway Control Protocol), H.248/MEGACO, RTP, RCTP. MGCP l s kt hp gia giao thc n gin iu khin gateway SGCP (Simple Gateway Control Protocol) pht trin bi Cisco v Telcordia vi giao thc Internet iu khin cc thit b IPDC (Internet Protocol Device Control). MGCP iu khin v qun l cuc gi thng qua cc media gateway. Nhim v ca cc media gateway l to nn s chuyn i tng thch gia cc tin tc c dng trong PSTN v trong mng IP bng cch chuyn cc dng m ha v gii m t G.711 trong PSTN sang G.723 hay G.729 trong VoIP. Bn cnh , media gateway cng h tr loi tr ting vng thng qua phn cng. RTP (Real-time Transport Protocol) v RCTP (RTP Control Protocol) l nhng giao thc iu khin vn chuyn tn hiu thi gian thc. Cc giao thc ny rt quan trng m bo real-time cho cuc gi. Mt cuc gi thng thng chia lm nhiu phin khc nhau bao gm bo hiu cuc gi, iu khin cuc gi, tha thun cc phng thc truyn thng v phin hi thoi. V tr ca RTP chnh l phin hi thoi. Qua vic tha thun phng thc truyn thng, cc bn tham gia hi thoi s tin hnh m hai cng UDP k nhau, cng chn dng truyn ting ni (RTP) v cng l dng truyn thng tin trng thi gim st (RCTP). Thng thng hai cng mc nh c chn l 5004 v 5005. Tn hiu thoi ti pha pht sau khi c s ha, qua b CODEC s c nn thnh cc gi tin. Cc gi tin ny c gn thm cc header tng ng khi n tng UDP/IP. Cc header thng c kch thuc l 40 bytes cha cc thng tin v a ch ngun, a ch ch, cng tng ng, header RTP v mt s thng tin c lin quan khc.

Hnh 1.9 Cu trc gi tin Header RTP cho bit cc thng tin quan trng v gi nh phng php m ha, ch mc gi, nhn thi gian,Cc thng tin ny cho php xc nh s rng buc gia gi tin vi thi gian. Nh , cc gi tin c sp xp theo ng th t thi gian thc trc khi c gii m v pht li. RCTP c nhim v gim st nh gi qu trnh truyn tin da trn vic truyn mt cch nh k cc gi tin iu khin ti cc thnh vin tham gia hi thoi cng vi c ch truyn d liu. C th k ra bn chc nng chnh ca RCTP nh sau:

Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 19

Cung cp c ch phn hi cht lng truyn d liu. Bn gi thng k qu trnh gi qua cc bn tin ngi gi cho cc thnh vin. Bn nhn cng lm nhim v thng k cc tin nhn qua bn tin ngi nhn. T vic gim st cc thng tin t bn gi v bn nhn c th iu khin li cc thng s cn thit tng cht lng cuc gi. y l chc nng quan trong nht ca RCTP. Mi ngun cung cp gi tin RTP c nh dng bi mt tn CNAME. RCTP s cho cc thnh vin bit tn ny. Quan st s thnh vin tham gia hi thoi bng vic thng k cc bn tin. Mang cc thng tin thit lp cuc gi, cc thng tin v ngi dng. y l chc nng ty chn. N c bit hu hiu khi iu khin cc phin lng, cho php thm bt thnh vin mt cch d dng m khng c rng buc no. Thc ra h thng VoIP hot ng hiu qu nht cn phi s dng nhiu giao thc khc. C th tham kho cc chun m ITU hay EITF a ra bit r hn v cc giao thc ny. 1.2.4 Nhng u im ca VoIP VoIP ra i khai thc c mt cch hiu qu nhng tnh nng ca mng truyn s liu, khai thc tnh linh hot trong vic pht trin cc ng dng mi ca mng IP. Nhng u im ni bt ca VoIP c th k ra di y: Gim ng k chi ph cuc gi: y l u im rt ln ca VoIP so vi dch v in thoi truyn thng. VoIP c kh nng cung cp nhng cuc in thoi ng di vi chi ph thp v cht lng dch v chp nhn c. Mt khi VoIP c trin khai, chi ph cc cuc gi ng di tng ng vi chi ph s dng internet. Nguyn nhn l cc tn hiu voice c m ho v truyn trong mng IP nn kh nng s dng knh t hiu qu cao hn. Bn cnh , tn hiu thoi by gi c nn t 64 Kbps trc y xung cn 8 Kbps, kt hp vi tc x l nhanh hin nay m bo cho VoIP c th p ng i hi thi gian thc trong iu kin bng thng hn ch. Khi thc hin cuc gi trong mng PSTN, chi ph b ra l duy tr mt knh truyn 64 Kbps xuyn sut t my ny n my kia thng qua cc tng i. Vi cc cuc gi ng di th ch ph ny r rng l rt ln. Trong khi , khi gi t mng PSTN dng VoIP th chi ph phi b ra ch l duy tr mt knh 64 Kbps t my gi n gateway. Do hiu qu kinh t cao hn nhiu. Tch hp mng thoi, mng s liu v mng bo hiu: trong VoIP, tt c cc tn hiu voice, data hay cc bo hiu u c th i chung trong mng IP. iu ny cho php tit kim c mt chi ph ng k khi u t xy dng c s h tng. Kh nng m rng: cc h thng tng i c thng l h thng kn nn rt kh thm vo nhng tnh nng mi. Trong khi khi dng VoIP vi cc m ngun m cho php t do thm vo cc tnh nng mi, ng thi h thng s linh hot hn v d dng m rng hn. Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 20

Khng cn thng tin iu khin thit lp knh truyn vt l: cc gi thng tin trong mng IP c truyn n ch m khng cn phi thit lp nn mt knh truyn ring no. Qun l bng thng hiu qu: nh ni trn, VoIP nn tn hiu xung cn 8 Kbps nn tit kim c bng thng ng k. Ngoi ra vic qun l bng thng cng linh hot hn do kh nng iu tit bng thng ph hp. Dch v a dng: VoIP cho php to ra nhiu tnh nng dch v mi nh thng tin ngi gi ti, nhiu s cho mt thit b u cui, truyn file, chia s d liu, xem hnh nh ngi gi,

1.2.5 Nhng hn ch ca VoIP


K thut phc tp: m bo thi gian thc trong truyn tn hiu bng cc gi l rt kh do tnh trng mt gi v tr khng c nh Vn bo mt: VoIP s dng mng Internet lm c s h tng nn vn bo mt cn phi c cao v Internet l mi trng ph bin ton cu v rt phc tp ng thi n cng l h tng chung cho rt nhiu cc ng dng khc. 1.2.6 Mt s dch v ca VoIP 1.2.6.1 Dch v in thoi qua Internet Vi VoIP, ngi s dng c th thc hin cc cuc gi khng ch gia cc my tnh vi nhau qua mng internet m cn gia in thoi vi my tnh hay in thoi vi in thoi. Hn na, cc thit b u cui dng cng rt a dng, c th l analoge phone, IP phone hay softphone... 1.2.6.2 Thoi thng minh S kt hp gia Internet v mng PSTN cho php to ra nhng dch v in thoi thng minh. Internet cho php gim st v iu khin cuc gi hiu qu hn. 1.2.6.3 Dch v tnh cc cho cuc gi Thoi qua Internet cho php nh cung cp nhng dch v tnh cc cuc gi cho cc khch hng trong v ngoi nc. Ch cn c PC kt ni Internet v phn mm chuyn i nh Quicknets Technologies Internet PhoneJACK l c th thc hin c iu ny. 1.2.6.4 Dch v Callback Web World Wide Web lm mt cuc cch mang trong cch giao dch vi khch hng ca cc doanh nghip. Vi tt c cc tim nng ca web, in thoi vn l phng tin kinh doanh khng th thiu. in thoi web cho php a cc phm bm ln trn web kt ni cc cuc gi. 1.2.6.5 Dch v fax qua IP Khi s dng fax qua IP s tit kim c chi ph v knh thoi. Lc ny fax c truyn trc tip qua Internet ch khng dng line in thoi nh thng thng. Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 1.2.6.6 Dch v Call Center

Trang 21

Gateway Call Center vi cng ngh thoi qua Internet cho php nh kim duyt trang web vi cc PC trang b multimedia kt ni c vi b phn phi cc cuc gi t ng. Mt u im ca thoi Ip l kh nng kt hp thoi v d liu trn cng mt knh. 1.3 Kt lun Mc d khi mi ra i, dch v VoIP cn c nhiu im hn ch so vi dch v gi in thoi ng di truyn thng nh thi gian kt ni lu, cuc gi c kh nng b t gia chng, ting thoi c tr, kt ni lc c lc khng. Tuy nhin, sau nhng bc tin ln v tc ng truyn Internet, VoIP cho thy nhng u im ni tri ca n so vi h thng PSTN truyn thng. Theo c tnh, dch v VoIP hin ang chim 60% th phn in thoi ng di trong nc v quc t. VoIP s khng mt thi gian qu lu chim mt v tr thng tr tuyt i trong dch v in thoi ng di trong nc v quc t.

Chng 2 Tng quan v VoIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 22

Chng 2

GIAO THC KHI TO PHIN SIP

2.1 Gii thiu giao thc SIP Giao thc khi to phin (Session Initiation Protocol - SIP) l giao thc thuc lp ng dng dng khi to, hiu chnh v kt thc cuc gi. Cc chc nng c bn ca SIP bao gm: nh v ngi s dng: xc nh h thng u cui m ngi dng s dng cho truyn thng. Tnh sn c ca ngi s dng: xem ngi s dng c sn sng giao tip khng. Kh nng ngi s dng: xc nh cc phng tin truyn thng v cc tham s cho cc phng tin s dng. Khi to phin: bo chung, thit lp cc thng s phin. Qun l phin: bao gm vic chuyn i v kt thc mt phin, thay i cc thng s phin v yu cu cc dch v. SIP l mt thnh phn c s dng chung vi cc giao thc khc to thnh h thng a phng tin hon chnh. Hai giao thc thng c s dng chung vi SIP l giao thc vn chuyn thi gian thc RTP (Real-time Transport Protocol) v giao thc c t phin SDP (Session Description Protocol). RTP l giao thc cho php vn chuyn cc tn hiu (gm c audio, video v text) p ng theo thi gian thc. Cc tn hiu ny c m ho v chia thnh cc gi truyn qua Internet. SDP dng c t cc thng s ca phin. Mt mng SIP bao gm nhiu thnh phn, cc thnh phn c th tng tc vi nhau thc hin mt phin no , ng thi c th tng tc vi cc thnh phn ca mt mng SIP khc mt khi user c nhu cu thc hin kt ni ti mt user khc khng cng mng vi n.

Hnh 2.1 Cc thnh phn ca mt mng SIP

Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 2.2 Cc thnh phn ca SIP 2.2.1 User Agent

Trang 23

User Agent bao gm hai loi: User Agent Client v User Agent Server. d hiu, ta c th nh ngha User Agent (UA) l mt ng dng m c th khi to (thit lp), chp nhn v kt thc mt cuc gi trong mt phin kt ni. Khi UA khi to cuc gi bng vic gi bn tin yu cu INVITE th UA s ng vai tr l mt client. Ngc li UA nhn bn tin yu cu th n li c vai tr l mt server. Trong mt phin kt ni ca SIP, UA thng tn ti trn cc my user di dng cc ng dng nh PC ci softphone nhng n cng c th l phn cng c nhng sn phn mm h tr giao thc SIP nh IP phonehoc l cell phone, cc cng PSTN, thit b h tr c nhn PDA 2.2.1.1 User Agent Client User Agent Client (UAC) c nhim v gi bn tin yu cu khi to phin kt ni. Chc nng ny ch tn ti trong qu trnh gi bn tin yu cu ( tm gi l qu trnh giao dch). V sau khi gi xong bn tin, n li c th nhn mt yu cu t mt UA khc. Vo lc ny, n khng cn l UAC na m li l UAS (User Agent Server). Mt UAC c th gi cc bn tin yu cu nh INVITE, ACK, OPTIONS, BYE, CANCEL v REGISTER. 2.2.1.2 User Agent Server User Agent Server (UAS) c nhim v nhn bn tin yu cu, sau x l bn tin yu cu ny v cui cng l gi bn tin phn hi v ni pht bn tin yu cu n cho n. Cng nh UAC, UAS ch c vai tr trong thi gian nhn bn tin yu cu v gi li bn tin phn hi, khi qu trnh ny kt thc th n li c th l mt UAC nu n gi yu cu cho mt Client hoc mt Server khc. Nh vy, mt thit b u cui trong mng SIP va c th l UAC v va c th l UAS. Tuy nhin n ch c th m nhim mt chc nng duy nht trong mt qu trnh giao dch. Ty thuc vo vic nhn hay l gi bn tin yu cu m n c th l UAC hoc UAS. 2.2.2 Cc loi Server trong mng SIP 2.2.2.1 Proxy Server Proxy Server l mt thc th trung gian c nhim v nhn cc bn tin yu cu SIP, gi li bn tin p ng v ni gi bn tin yu cu v cui cng l forward bn tin yu cu ny n UAS hoc mt Server khc. Nh vy, Proxy Server va l mt UAC va l mt UAS. Khi n nhn bn tin yu cu t mt UAC th n ng vai tr nh mt UAS. Ngc li, khi n forward bn tin yu cu m n nhn c th n li l mt UAC. Tuy nhin, Proxy Server khng trc tip to ra bn tin yu cu nh mt UAC m tip nhn bn tin yu cu ri chnh sa bn tin ny cho ph hp ri forward chng i m thi. Hn na, Proxy Server ch c th nhn v forward cc bn tin bo hiu SIP ch khng nhn hoc forward bn tin thoi. Proxy Server c chia lm hai loi: Stateless Proxy v Statefull Proxy. Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 24

Stateless Proxy ch n gin l forward bn tin i. Khi nhn mt bn tin yu cu, Stateless Proxy s x l yu cu ny sau n forward bn tin yu cu c x l m khng c lu li bt k trng thi no ca qu trnh giao dch. iu ny c ngha l Stateless Proxy s khng nh l n tng nhn v x l bn tin yu cu ny. y cng chnh l nhc im ca Stateless Proxy. V Stateless Proxy hon ton khng bit c qu trnh giao dch c thnh cng hay khng v n cng khng th truyn li cc bn tin yu cu hay bn tin phn hi gi trc trong trng hp bn tin b mt hay tht lc. Statefull Proxy phc tp hn Stateless Proxy. Trong lc nhn bn tin yu cu, Stateful Proxy s to ra mt trng thi v gi n cho n khi s giao dch kt thc. V th n c th truyn li cc bn tin m n gi trc . V d nh khi mt bn tin Request c forward i th ng thi b nh thi c bt ln, nu nh trong khong thi gian no m khng nhn c bn tin Response th Proxy Server s tin hnh gi li bn tin Request . Statefull cn c u im l c kh nng fork (r nhnh). C ngha l trong khi nhn mt bn tin yu cu, n cng c th gi i mt hay nhiu bn tin khc. Hu ht cc Proxy Server ngy nay u l Statefull Proxy v chng i hi cu hnh phc tp, cc chc nng gim st, r nhnh, tnh tonv cc chc nng thit yu ca mt Statefull Proxy. 2.2.2.2 Redirect Server Redirect Server l mt thc th c nhim v nhn bn tin yu cu v p ng li bng mt bn tin 3XX. Bn tin ny s cha danh sch cc v tr c th c ca pha b gi. UAC hoc Proxy s cn c vo danh sch a ch ny trc tip lin lc m khng cn phi thng qua Redirect Server. 2.2.2.3 Registrar Server Registrar Server c nhim v nhn bn tin ng k t pha user. Trong bn tin ng k ny s c username, password, IP address hoc SIP URI v cc thng tin ny s c Registrar Server lu li trong mt vng c s d liu. Vng c s d liu ny cn c gi l Location Service - mt vng database tru tng cho Proxy hay Redirect truy xut n n khi cn thit. Thng thng vi cc h thng nh, Registrar server c ci t cng vi Proxy Server/ Redirect Server. Tuy nhin vi cc h thng ln, nu tch hp Registrar Server cng vi Proxy hoc Redirect th s gy ra hin tng qu ti (over load), v mt khi c li xy ra s nh hng n ton b h thng. Do , trong trng hp i hi phi lu tr nhiu c s d liu th Registrar c ci t trn mt my tnh xa. Khi , cc Proxy Server/ Redirect Server mun truy xut ly database th li phi s dng mt giao thc khc (khng phi giao thc SIP) giao thc LDAP.

Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 2.2.3 Back to Back User Agent (B2BUA)

Trang 25

\ Hnh 2.2 M hnh B2BUA B2BUA l mt thc th logic ca mng SIP. N tng t nh mt Proxy Server: va l mt UAC va l mt UAS trong vic nhn v forward bn tin yu cu cng nh gi li bn tin phn hi. Tuy nhin, B2BUA khc vi Proxy Server ch n tham gia vo sut qu trnh hi thoi gia hai u cui. Bn tin bo hiu v bn tin thoi u phi thng qua B2BUA. B2BUA c kh nng ngt kt ni trong khi Proxy Server th khng th. iu c bit ch l B2BUA s n danh tnh (a ch IP hoc SIP URIs) ca bn gi bn tin n n, thm ch cho php sa i cc thng tin trong bn tin nh port, codecs, a ch IP. Tuy nhin, mt s trng hp vn c th cu hnh B2BUA sao cho n hot ng nh mt Proxy. Tc l bn tin bo hiu vn thng qua B2BUA cn bn tin thoi th lc ny s trc tip gi qua li gia cc u cui m khng thng qua B2BUA. Asterisk Server hot ng nh mt B2BUA, ta c th cu hnh trong file sip.conf vi thng s canreinvite=yes/no gi tin thoi c th hoc khng th qua Asterisk Server.

Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 26

Hnh 2.3 Cu hnh Asterisk vi canreinvite 2.2.4 Cc c ch hot ng ca SIP 2.2.4.1 M hnh Peer to Peer

Hnh 2.4 M hnh Peer to Peer Trong m hnh ny, c Tesla v Marconi u bit a ch ca nhau. u tin, Tesla mun thit lp cuc gi vi Marconi nn gi bn tin yu cu INVITE n Marconi. Gi s Marconi khng sn sng thit lp phin kt ni th sau mt khong thi gian khi Marconi khng gi li bn tin p ng no chng t mnh c kh nng thc hin cuc gi th mt bn tin Request Timeout c gi t Marconi n Tesla. Nu Marconi ang rnh, mt tn hiu chung s c gi t Marconi v cho Tesla, lc ny Tesla hiu rng Marconi nhn c bn tin INVITE. Khi Marconi nhc my, mt bn tin 200 OK t Marconi gi v Tesla bo cho Tesla bit rng Marconi chp nhn yu cu thit lp phin kt ni vi Tesla. Khi , Tesla s gi li mt bn tin ACK Marconi bit rng Tesla nhn c bn tin 200 OK. Phin kt ni lc ny chnh thc c thit lp. Dng Media t Tesla ti Marconi v ngc li c truyn theo giao thc RTP.

Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 27

Trong qu trnh m thoi, c hai bn Tesla v Marconi u c quyn yu cu chm dt phin kt ni bng cch gi mt bn tin yu cu BYE. Khi bn cn li s xc nhn vic nhn bn tin BYE bng bn tin 200 OK kt thc phin kt ni. M hnh Peer to Peer l m hnh khng thng dng bi v i hi cc SIP phones phi lu tr li tn v a ch ca cc SIP Phones khc. Vy vi mt s lng ln cc SIP phones th sao? Lc ny cuc gi s thc hin qua mt c ch khc l thng qua Proxy Server hoc Redirect Server. 2.2.4.2 M hnh thng qua proxy server

Hnh 2.5 C ch hot ng ca SIP thng qua Proxy server

Hnh 2.6 M hnh SIP thng qua Proxy u tin, user1 s gi bn tin INVITE yu cu c thit lp phin kt ni vi user2. Tuy nhin user1 khng bit chnh xc a ch ca user1 trong mng IP nn n gi INVITE ny n cho Proxy Server - qun l min ca user1.

Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 28

Proxy Server lc ny s gi mt p ng 100 TRYING v cho user1 thng bo cho user1 rng proxy ang thay mt user1 forward bn tin ny n cho user2. Proxy Server s truy xut ln vng d liu ca n tm kim a ch hin ti ca user2. Nu user2 ng k vi Registrar Server th cc thng tin nh username, password ca n s c lu tr trong vng d liu database Proxy/Redirect c th truy xut bt c lc no. Location Service s gi tr li cho proxy a ch hin ti ca user2. Proxy Server s gi mt bn tin INVITE mi da trn bn tin INVITE m n nhn c t user1 gi n user2. Nhng lc ny, Request URI trong dng Start Line c i thnh user2@alp.sev.com (a ch hin ti ca User2). User2 p ng li bn tin INVITE t Server bng bn tin 100 TRYING. SIP phone ca User2 xut hin tn hiu chung cnh bo vi user2 rng c mt cuc gi ang n. ng thi, mt bn tin 180 RINGING t SIP phone ca user2 gi v cho user1 thng qua Proxy thng bo vi user1 rng user2 nhn c bn tin INVITE ca user1. Khi user2 nhc my, mt bn tin 200 OK c gi t sip phone ca user2 n user1 thng bo vi user1 rng user2 nhn cuc gi. Khi user1 nhn c bn tin 200 OK, user1 hiu rng user2 nhc my v chp nhn kt ni vi user1. Lc ny user1 s gi mt xc nhn ACK v cho user2 thng bo vi user2 rng n nhn c p ng 200 OK v lc ny cuc gi chnh thc c thit lp. 2.2.4.3 Cuc gi SIP thng qua m hnh Redirect Server

Hnh 2.7 Cuc gi SIP thng qua Redirect Server u tin user1 gi mt bn tin INVITE n Redirect Server l host1@seq.com yu cu c thit lp cuc gi vi user2. Redirect Server lc ny s tm kim trong c s d liu ca n (location service) v tr hin ti ca user2. Location sau khi tm c a ch ca user2 s gi a ch ny v user1 thng qua bn tin p ng 302. a ch ca user2 lc ny l 87604309@sev.alp.com. Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 29

Sau khi nhn c p ng 302 t pha redirect server, user1 s xc nhn vic nhn c bn tin ny bng bn tin ACK. Da vo a ch ca user2 trong bn tin p ng 302 t Redirect Server, user1 s trc tip gi bn tin INVITE n cho user2 a ch sev.alp.com User2 nhc my chp nhn cuc gi, ng thi mt bn tin 200 OK c gi t user2 n user1. User1 s gi bn tin ACK n user2 xc nhn vi user2 rng n nhn c p ng 200 OK ca user2. Lc ny cuc gi c thit lp. SIP Registration

Hnh 2.8 Qu trnh ng k ca User Hu ht cc cuc gi SIP thng c s tham gia ca Server. V vy Server c vai tr quan trng trong vic tm kim v tr ca user b gi. Mi user phi c ng k vi Registrar Server v v tr hin ti ca user bng cch gi mt bn tin REGISTER. Bn tin ny s cha cc thng tin v user nh username v password, a ch IPRegistrar Server s lu cc thng tin ny vo vng c s d liu ca n. Proxy v Redirect c th truy xut ln c s d liu ny nh v c user b gi.

Hnh 2.9 Cc bc ng k ln Registrar Server u tin userB s gi mt bn tin REGISTER n Registrar Server ng k. Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 30

Registrar Server s gi mt bn tin phn hi 401 Unauthenticate v cho userB, thng bo vi userB rng Registrar server cha nhn dng c userB. Sau user B s gi li bng tin REGISTER ti Registrar Server km theo cc thng tin v chng thc trong trng Authentication nh Username, password c m ha MD5, a ch SIP URI Registrar Server s gi li cho userB bng tin 200 OK thng bo cho user B rng vic ng k thnh cng. Cuc gi SIP thng qua m hnh B2BUA:

Hnh 2.10 Cuc gi SIP qua B2BUA


V c bn, B2BUA hot ng ging nh mt Proxy Server chc nng bo hiu. Tuy nhin, B2BUA khc mt Proxy ch l bn tin thoi cng phi thng qua B2BUA ch khng trc tip truyn gia hai user. u tin, UserA mun thit lp cuc gi vi userB nhng li khng bit chnh xc v tr ca UserB nn userA gi bn tin INVITE n B2BUA. B2BUA tm kim v tr ca userB trong c s d liu ca n ri forward bn tin INVITE mi n userB. Bn tin INVITE ny c B2BUA thay i trng Via vi a ch ca chnh n. Khi userB nhn c bn tin INVITE t B2BUA, mt tn hiu chung 180 RINGING s c gi t userB n B2BUA bo vi B2BUA rng userB nhn c bn tin yu cu INVITE v ang rung chung cnh bo bn b gi l c cuc gi ang n. B2BUA gi bn tin 180 RINGING v cho userA. Khi userB nhc my, mt bn tin 200 OK s c gi n B2BUA thng bo rng userB chp nhn cuc gi. B2BUA li forward bn tin 200 n cho userA. UserA xc nhn bng bn tin ACK gi n B2BUA, B2BUA li forward bn tin ny n userB. Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Phin cuc gi c thit lp.

Trang 31

Lu : n y userA mun gi tn hiu thoi n userB th trc tin n phi gi bn tin thoi n B2BUA, B2BUA mi chuyn bn tin thoi n userB v ngc li. B2BUA hon ton giu danh tnh ca hai bn cho d cuc gi c thit lp. V th hai bn tham gia cuc gi khng h bit thng tin v nhau. 2.3 SIP v H.323 Nh trnh by trn, SIP v H.323 l hai dng c bn to nn VoIP. Trong phn ny chng ta s so snh cc c im ni bc ca chng. 2.3.1 Mc phc tp H.323 l giao thc phc tp, ring ti liu hng dn ca n thi cng ln n 736 trang, trong khi , SIP l giao thc n gin hn vi 128 trang ch dn. H.323 nh ngha ra hng trm thnh phn, cn SIP ch c 37 header, trong mi phn nh cha t tham s v bin hn nhng li mang nhiu thng tin hn. V c bn, trong in thoi Internet, SIP s dng ch yu 4 header (To, From, Call-ID v Cseq) v 3 dng yu cu (INVITE, ACK v BYE). H.323 dng dng trnh din nh phn cho cc bn tin da trn ASN.1 v PER (Packet Encoding Rules). SIP th s dng mt dng trnh din khc, l dng text, kh ging vi HTTP v RTSP (Real Time Streaming Protocol), lm cho c php cng nh l qu trnh x l n gin hn. Bn cnh , vi dng text, SIP cn tn dng c sc mnh ca cc ngn ng x l nh Perl. S phc tp ca H.323 cn th hin ch n dng nhiu protocol khc nh H.450, H.225.0 v H.245. Vic s dng nh vy lm ny sinh nhiu vn lin quan n firewall. Ngc li, SIP s dng protocol n gin hn, v ch yu cu nhng thng tin cn thit m thi. 2.3.2 Kh nng m rng Kh nng m rng l mt thc o rt quan trng nh gi mt protocol. SIP da trn nn tng ca HTTP v SMTP (Simple Mail Tranfer Protocol), nhng protocol v ang c s dng rng ri, v c thit k vi nhng tnh nng cho php m rng v sau. Theo mc nh, nhng header khng r rng s b loi b. Cc clients s dng header Require yu cu cc tnh nng no t server. Ch rng cc tnh nng ny phi c server lu tr v nhn bit. Khi nhn c yu cu, server s kim tra xem th nhng tnh nng ny c tn ti hay khng v cho cu tr li tng ng. Cc tnh nng mi c th c ng k vi server, iu ny c ngha l ngi s dng c th vit ra nhng tnh nng mi v ng k vi server s dng. tng cng kh nng m rng, cc li trong SIP c chia lm 6 lp, mi lp tng ng vi mt dng li. SIP ging nh HTTP nn c ch m rng ca n cng ging vi HTTP. PEP (Protcol Extension Protocol) l mt cch c s dng ph bin. H.323 cng cung cp c ch m rng kh tt. Tuy nhin vn c mt s gii hn. Th nht, vic m rng ch cho php vi nhng ni c cc tham s nonstandard. Khch hng khng th thm gi tr mi vo cho tham s sn c. Th hai, Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 32

H.323 khng cung cp c ch cc thit b u cui trao i thng tin vi cc m rng m n h tr. Nhng gi tr tham s ny khng t ni ln ngha ca n. l nhng gi tr ca ring cc nh sn xut. 2.4 SIP v IAX Cc thnh phn thng tin trong IAX c m ha theo bit nh phn thay v m ha ASCII. Kch thc ca gi bo hiu IAX nh hn nhiu so vi giao thc SIP, nhng khng phi l vn cn quan tm tr khi c mt s lng ln cc client ng k thng xuyn. Ni chung, IAX2 hiu qu hn trong vic m ha, gii m v xc nh thng tin. Tuy nhin rt kh ng dng IAX vo thc t xem n tng thch nh th no vi nhng cng ngh khc bi v c qu t ti liu ni v chng. Ch s dng duy nht mt ng truyn media v bo hiu nn IAX cho php n c nh hng NAT trong sut v ch s dng mt port duy nht nn d dng trong vic qun l. V vy khng bao gi c tnh hung cuc gi c thit lp m khng th chuyn tn hiu m thanh (ngoi tr vn khng bng thng). SIP tun theo chun IETF, trong khi IAX ch mi c mt vi ti liu mi xut bn nn tiu chun ca n vn cha c cng nhn. IAX cho php mt u cui kim tra tnh hp l ca s in thoi quay bit vic quay s hon tt cha hay vn cn dang d. iu ny khng c h tr trong giao thc SIP. Cc bn tin trong IAX c gi l cc frame v c chia lm 3 loi chnh l full, mini v meta frame. xc nh bn tin thuc loi no th da vo bit F trong bn tin, nu F=1th bn tin thuc loi full frame, cn F=0 th c th l mini hay meta frame. Loi Frame Mini Full c tnh chnh Khng yu cu bn tin ACK t IAX bn kia Yu cu s xc nhn t bn kia Kch thc 4 bytes 12 bytes Mc ch s dng Vn chuyn d liu thoi Vn chuyn d liu i hi tin cy nh bn tin bo hiu

Meta

Video Khng yu cu bn tin frame:6 bytes Vn chuyn video hay nhiu ACK t IAX bn kia miniframe ch vi mt header Trunk frame:8 bytes Bng 2.1 Cc loi Frame trong giao thc IAX

Tm li l IAX l giao thc dnh cho VoIP mi nht cho n thi im ny vi nhiu u im hp dn nh:

Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Ti thiu s dng bng thng. Trong sut vi NAT. Hiu qu vi c ch trung k.

Trang 33

2.5 Kt lun SIP ngy cng tr nn ph bin v tr thnh mt giao thc bo hiu chnh ca VoIP. V vy vic tiu chun ha giao thc bo hiu SIP l cn thit. Giao thc SIP cho php thc hin truyn thng lin doanh nghip a phng tin v cung cp mt cp pht minh v li th cnh tranh mi. Giao thc ny s c s dng hi t rt nhiu ng dng, thit b v cch thc truyn thng to ra nhng tnh nng v kh nng mi.Cc li ch ca SIP s tr thnh mt b phn khng tch ri ca h thng truyn thng v mng thng minh.

Chng 3 Giao thc khi to phin SIP

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 34

Chng 3
3.1 Tng i IP PBX

GII THIU V CI T ASTERISK

3.1.1 Khi qut v tng i IP PBX ng dng ph bin nht v sm nht ca VoIP, nn tng to ra IP-PBX, l vic thit lp gateway VoIP bn pha trung k ca PBX. Gateway ny ng gi lung thoi v nh tuyn n qua mng VoIP. Gii php ny tn dng cc c tnh hin c ca tng i PBX nh thoi hi ngh, chuyn tip cuc gi, Cui cng, cc nh pht trin phn mm pht trin ln PBX mm, hay IPPBX. IP- PBX cung cp kh nng chuyn mch, thc hin cc dch v gia tng qua mng d liu. Cc cuc gi trong mt tng i v cc cuc gi gia cc tng i c nh tuyn qua mng IP, i vng qua ton b mng PSTN. IP-PBX c th giao tip vi mng PSTN thng qua Gateway. 3.1.2 Cc u im so vi tng i PBX truyn thng Cc u im ca IP-PBX xut pht t nhng u im ca mng chuyn mch gi IP so vi mng chuyn mch knh, nh: Qun l v bo dng d dng hn. Kh nng kt ni t xa, kh nng di ng. Kt hp thoi/d liu to ra ng dng mi. D dng pht trin cc dch v mi do cu trc m v cc giao din chun. D s dng do c h tr nhiu bi phn mm v giao din ha GUI. Thng tin hp nht. 3.1.3 So snh gia IP PBX v PBX truyn thng PBX truyn thng IP PBX

PBX khng thc hin c mt chc IP-PBX c y cc chc nng ca mt nng ca IP-PBX: Web, Instant message, PBX truyn thng (CTI, VoiceMail, ACA E-mail v kt ni ISDN ra PSTN). Cho php thc hin lin lc ni b qua PBX i hi phi c mt h thng mng mng LAN ngay c khi cha c h thng in thoi ni b. PBX. PBX truyn tn hiu thoi trn h thng ng in thoi ni b. Nu mun IP-PBX truyn d liu v thoi trn cng truyn d liu, bt buc phi c thm h mt ng dy. thng mng LAN. H tr duy nht mt loi u cui l in IP-PBX c kh nng h tr nhiu u cui

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing thoi tng t.

Trang 35

thoi khc nhau: in thoi tng t, in thoi IP, my tnh c nhn...

C thm nhiu dch v gi tr gia tng Kh nng pht trin cc loi hnh dch v khc: telephone, e-mail, fax, web call gi tr gia tng km. back, web chat, instant messaging,... Tn hiu trc khi chuyn n ng truyn c thng qua cc b nn v gii nn, bng thng cho mi cuc gi c Mi ng dy thoi ch c th thc hin th c nn xung cn 5,3 Kbits/s c mt cuc gi ti mt thi im, do (chun nn thoi G.723.1), thay v 64 khng tit kim bng thng. Kbits/s ca thoi thng. Do tnh cht tit kim bng thng nh vy nn vi mt ng dy thoi (CO line) c th thc hin c nhiu cuc gi hn. Kh m rng, nng cp v bo dng. D dng m rng, nng cp v bo dng.

Bng 3.1 So snh gia PBX truyn thng v IP-PBX 3.1.4 Kh nng p dng trong cc doanh nghip va v nh C th n gin ho qu trnh trin khai tng i IP-PBX cho mt doanh nghip nh sau: Xy dng mng LAN. Thit lp h thng my ch v ci t phn mm iu khin IP-PBX. Thit lp cc Gateway ra mng PSTN hoc Internet. Thit lp cc u cui VoIP.

Bc th nht l phc tp nht v i hi u t ln nht nhng thc ra li n gin nht v a s cc doanh nghip c sn mng LAN. Bc th 2 quan trng nht, nhng thc ra cng ch n gin l ci t phn mm ln mt my ch. My ch ny c th l dnh ring cho IP-PBX hoc cng c th c chia s vi cc ng dng khc ca doanh nghip. Bc th 3 i hi phi mua thit b chuyn dng kt ni vi mng PSTN. Gateway kt ni IP/PSTN thng l card PCI cm trong my ch cng vi phn mm iu khin chuyn dng. Cc u cui VoIP trong bc 4 c th l phn mm chy ngay trn my PC (l cc Softfone nh X-lite) hay l mt thit b chy c lp (nh IP Phone ca Cisco) v cng c th l cc Mobile Fone h tr SIP. 3.2 Tm hiu v Asterisk Asterisk l h thng chuyn mch mm, l phn mm m ngun m c vit bng ngn ng C chy trn h iu hnh linux thc hin tt c cc tnh nng ca Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 36

tng i PBX v hn th na. Asterisk ra i vo nm 1999 bi mt chng trai sinh nm 1977 tn l Mark Spencer. Anh ta vit phn mm ny ban u khng ngoi mc ch h tr cho cng ty ca mnh trong vic lin lc m thoi h tr cng ng ngi s dng v pht trin Linux. Asterisk em n cho ngi s dng tt c cc tnh nng v ng dng ca h thng tng i PBX v cung cp nhiu tnh nng m tng i PBX thng thng khng c c, l s kt hp gia chuyn mch VoIP v chuyn mch TDM, l kh nng m rng p ng nhu cu cho tng ng dng Asterisk l mt phn mm thc hin chc nng tng i in thoi PBX mang tnh cch mng, tin cy, m ngun m v min ph, bin 1 PC thng thng chy h iu hnh Linux thnh 1 h thng in thoi doanh nghip mnh m. Asterisk l mt b cng c m ngun m cho cc ng dng thoi v l 1 server x l cuc gi y chc nng. Asterisk l mt nn tng tch hp in thoi vi tnh ha kin trc m. Nhiu h thng Asterisk c ci t thnh cng trn khp th gii. V hin nay Asterisk vn tip tc c cng ng nhng ngi dng trn th gii pht trin mnh m. Asterisk c th c s dng cho nhiu th v c cc c trng bao gm: Private Branch Exchange (PBX). Voicemail Services with Directory. Conferencing Server. Packet Voice Server. Encryption of Telephone hoc Fax Calls. Heterogeneous Voice over IP gateway (H.323, SIP, MGCP, IAX). Custom Interactive Voice Response (IVR) system. Soft switch. Number Translation. Calling Card Server. Predictive Dialer. Call Queueing vi Remote Agents. Gateway v Aggregation cho cc h thng PBX. Remote Office hay User Telephone Services. PBX long distance Gateway. Telemarketing Block. Standalone Voicemail System.

Hin nay Asterisk ang trn pht trin nhanh c rt nhiu doanh nghip trin khai ng dng cho cng ty ca mnh. y l xu th tt yu ca ngi s dng in thoi, v cc cng ty u cn phi lin lc vi nhau trong cng vic gia cc phng ban hoc chi nhnh v cn mt chi ph thp thm ch khng phi tn chi ph khi

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 37

thc hin cc cuc gi ni b ca cng ty. Khng gi gn thng tin lin lc trong cng ty m cc ng dng giao tip vi mng PSTN hoc mng VoIP (nh voice777) cho php gi ra bt c s in thoi no c trn mng PSTN. Ngoi ra vic tch hp vo cc ng dng nh CRM v h thng Outlook lm cho kh nng ng dng ca Asterisk linh hot hn p ng nhu cu cn thit cho ngi s dng in thoi. Asterisk thot u c pht trin trn GNU/Linux nn x86 (Intel), nhng gi y n cng c th bin dch v chy trn OpenBSD, FreeBSD v Mac OS X v Microsoft Windows.

Hnh 3.1 Asterisk giao tip vi cc h thng, thit b khc Asterisk l h thng chuyn mch tch hp va l cng ngh truyn thng TDM va l chuyn mch VoIP. Hnh trn cng cho thy kh nng giao tip ca h thng. Giao tip vi in thoi analog thng thng, giao tip vi thit b in thoi VoIP, ngoi ra cn c th giao tip vi mng PSTN v cc nh cung cp VoIP khc.

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 3.2.2 Kin trc c bn ca Asterisk

Trang 38

Hnh 3.2 Kin trc c bn ca Asterisk V c bn kin trc ca Asterisk l s kt hp gia nn tng cng ngh in thoi v ng dng in thoi, cng ngh in thoi cho VOIP nh SIP, H323, IAX, MGCP... cc cng ngh in thoi cho h thng chuyn mch mch TDM nh T1, E1, ISDN v cc giao tip ng truyn thoi Analog. Cc ng dng thoi nh chuyn mch cuc gi, tng tc thoi, caller ID, voicemail, chuyn cuc gi Asterisk c mt s chc nng chnh ng vai tr quan trng trong h thng chuyn mch cuc gi. Khi khi ng h thng Asterisk th chc nng Dynamic Module Loader thc hin np driver ca thit b, np cc knh giao tip, cc format, codec v cc ng dng lin quan, ng thi cc hm API cng c lin kt np vo h thng. Sau h thng PBX Switching Core ca Asterisk chuyn sang trng thi sn sng hot ng chuyn mch cuc gi, cc cuc gi c chuyn mch tu vo k hoch quay s (Dialplan) c thc hin cu hnh trong file extension.conf. Chc nng Application Launchar rung chung thu bao, quay s, nh hng cuc gi, kt ni vi hp th thoi Scheduler and I/O Manager m nhim cc ng dng nng cao, cc chc nng c pht trin bi cng ng pht trin asterisk. Codec Translator xc nhn cc knh nn d liu ng vi cc chun khc nhau c th kt hp lin lc c vi nhau.

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 39

Tt c cc cuc gi nh hng qua h thng Asterisk u thng qua cc giao tip nh SIP, Zaptel, IAX. Nn h thng Asterisk phi m trch nhim v lin kt cc giao tip khc nhau x l cuc gi.

3.2.3 H thng cng bao gm 4 chc nng API chnh Codec translator API: cc hm m nhim thc thi v gii nn cc chun khc nhau nh G711, GMS, G729 Asterisk Channel API: Giao tip vi cc knh lin lc khc nhau, y l u mi cho vic kt ni cc cuc gi tng thch vi nhiu chun khc nhau nh SIP, IAX, H323, Zaptel Asterisk file format API: Asterisk tng thch vi vic x l cc loi file c nh dng khc nhau nh mp3, wav, gsm Asterisk Aplication API: Bao gm tt c cc ng dng c thc thi trong h thng Asterisk nh Voicemail, CallerID Ngoi ra, Asterisk cn c th vin Asterisk Gateway Interface (AGI, tng t nh CGI) - c ch kch hot ng dng bn ngoi, cho php vit kch bn phc tp vi mt s ngn ng nh PHP hay Perl. Ni chung, kh nng vit cc ng dng ty bin rt ln. 3.2.4 Cc m hnh ng dng trin khai 3.2.4.1 Tng i VoIP IP PBX

Hnh 3.3 M hnh tng i Asterisk PBX

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 40

y l h thng chuyn mch VoIP c xy dng phc v cc cng ty c nhu cu thc hin trn nn tng mng ni b trin khai. Thay v lp t mt h thng PBX cho nhu cu lin lc ni b th nn lp t h thng VoIP iu ny s lm gim chi ph ng k. H thng c th lin lc vi mng PSTN qua card giao tip TDM hoc cc gateway. Kt ni IP PBX vi PBX

Hnh 3.4 Kt ni IP PBX vi PBX Mt ng cnh t ra y l hin ti cng ty trang b h thng PBX by gi cn trang b thm p ng nhu cu lin lc trong cng ty sao cho vi chi ph thp nht, gii php thc hin l trang b h thng Asterisk v kt ni vi h thng PBX ang tn ti qua lung E1. Ngoi ra tng kh nng lin lc vi mng PSTN v VoIP khc, cng ty c th thc hin kt ni vi nh cung cp dch v VoIP.

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 3.2.4.2 Kt ni gia cc server Asterisk

Trang 41

Hnh 3.5 Kt ni cc server Asterisk Phng php trn ng dng rt hiu qu cho cc cng ty nm ri rc cc v tr a l khc nhau nhm gim chi ph ng di. V d cng ty m c tr s t ti nc M v cc chi nhnh t ti Vit Nam vi cc a im thnh ph H Ch Minh v H Ni. Thng qua mng WAN ca cng ty cc cuc gi ni b gia cc v tr khc nhau s lm gim chi ph ng k.

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 3.2.4.3 Cc ng dng IVR, VoiceMail, in Thoi Hi Ngh

Trang 42

Hnh 3.6 ng dng IVR, Voicemail, Conference ng dng thc hin cc server kt ni vi h thng PSTN hay tng i PBX trin khai cc ng dng nh tng tc thoi IVR. Mt v d cho ng dng tng tc thoi l cho bit kt qu s s hay kim tra cc cuc gi ging dch v 19001260 vy. ng dng VoiceMail thu nhn nhng tin nhn thoi t pha thu bao ging nh chc nng hp th thoi ca bu in thnh ph. Cn chc nng in thoi hi ngh thit lp cho nhiu my in thoi cng ni chuyn vi nhau.

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 3.2.4.4 Chc nng phn phi cuc gi t ng ACD

Trang 43

Hnh 3.7 Chc nng ACD ACD (Automatic Call Distribution): Phn phi cuc gi t ng. y l chc nng ng dng cho nhu cu chm sc khch hng hay nhn phn hi t pha khch hng. Gi s cng ty c kh nng tip nhn cng mt lc 10 cuc gi. Nh th cuc gi th 11 gi n th h thng gii quyt nh th no? Bnh thng th s nghe tn hiu bn nhng vi chc nng phn phi cuc gi s a thu bao vo hng i ch tr li, trong khi ch tr li cuc gi thu bao c th nghe nhng bi ht hay do Asterisk cung cp, trong lc ny nu 1 trong 10 s in thoi tr v trng thi ri th cuc gi ang ch s c tr li. Ging nh chc nng ca dch v 1080 hay 116 ca bu in thnh ph vy. 3.2.5 S ra i ca giao thc IAX Inter Asterisk Exchange IAX l giao thc bo hiu VoIP c pht trin bi tc gi ca phn mm Asterisk khc phc nhng hn ch trong giao thc SIP. Khng ging nh giao thc SIP chuyn ti thoi v bo hiu trn hai knh khc nhau (out of band), IAX chuyn ti thoi v bo hiu trn cng mt knh (in band). IAX gii quyt c vn NAT cp trn phn giao thc SIP. Mc khc IAX l giao thc ti u trong vic s dng bng thng, cho php nhiu gi d liu thoi trn cng mt IP header, c ch chuyn ti nhiu cuc gi trn cng mt gi IP c gi l trung k (Trunk). C th gii thch thm c ch trung k nh sau: gi s Ti cn gi 5 bc th ti ngi bn ca Ti, Ti s c hai hnh thc thc hin, th nht l mi bc th Ti b vo mt phong b vy tng cng ti phi s dng 5 phong b gi i 5 bc th, cch th hai l Ti b 5 bc th vo 1 phong b v gi i vy tng cng Ti ch tn 1 Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 44

phong b. Qua phn tch trn, r rng vic a 5 bc th vo mt phong b gi i s tit kim hn so vi vic gi 5 bc th vi 5 phong b. C ch trn cng ging nh nhiu cuc gi c ng thnh gi v chuyn i trn ng trung k. 3.3 Ci t v cu hnh Asterisk 3.3.1 Yu cu v cu hnh phn cng Ty theo mc ch s dng v s lng cc user trong h thng m thit b phn cng c trang b theo mc khc nhau. Di y l mt s khuyn ngh theo cng ng Asterisk v cu hnh phn cng cho Asterisk Server: Mc ch Th nghim hc tp H thng cho vn phng hoc nh ring H thng nghip nh cho doanh S lng cc knh 1-5 5-10 15 >15 Cu hnh ti thiu 400-MHz x86, 256 MB RAM 1-GHz x86, 512 MB RAM 3-GHz x86, 1 GB RAM Dual CPUs hoc trin khai trn nhiu server

H thng thng mi c va v ln

Bng 3.2 Yu cu v phn cng i vi tng i Asterisk 3.3.2 Kt ni Internet C th ci t Asterisk khng cn kt ni mng nu c sn cc gi ph kin, tuy nhin do cn phi cp nht h iu hnh trc khi ci Asterisk nn tt nht l kt ni vi ng truyn Internet. Vic ci t nhanh hay chm iu ph thuc vo tc mng Internet v cu hnh my tnh. 3.3.3 Ci t h iu hnh Linux ci t Asterisk, trc tin chng ta cn phi ci t h iu hnh Linux trn my tnh ca mnh. C th ci h iu hnh Linux Fedora, CentOS, Redhat, hoc Debian. Trong n tt nghip ny, nhm thc hin ti s dng h iu hnh Ubuntu Server 10.0.4. Qu trnh chun b trc khi tin hnh ci t Asterisk c trnh by nh sau. 3.3.3.1 Thit lp a ch IP Cn thit lp cho server mt a ch IP tnh tin cho vic truy cp vo giao din web ca Server. y h thng Server c a ch IP tnh l: 192.168.1.10

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 3.3.3.2 Update h iu hnh Linux

Trang 45

V Ubuntu l mt h iu hnh m ngun m nn m bo cho h thng chy n nh sau khi ci t ta cn tin hnh cp nht v ci t cc gi h tr cn thit cho vic ci t cc chng trnh sau ny ca chng ta. apt-get update apt-get upgrade 3.3.3.3 Download v ci t cc gi ph h tr ci t Linux apt-get install gcc g++ make libncurses5-dev apt-get install linux-headers-`uname r` bison openssl libssl-dev libeditline0 libeditline-dev libedit-dev gcc make g++ mc php5-cli apt-get install libxml2-dev apt-get install festival apt-get install libmysqlclient15-dev apt-get install mc build-essential linux-headers-`uname -r` apt-get install libncurses5-dev libssl-dev libmysqlclient15-dev libnewt-dev zlib1g-dev apt-get install libxml2-dev libtiff4-dev libaudiofile-dev apt-get install openssh-server curl sox lame mpg123 3.3.3.4 Ci t Apache 2 Apache hay l chng trnh my ch HTTP l mt chng trnh dnh cho my server i thoi thng qua giao thc HTTP ca mng web. apt-get install apache 2 Sau khi ci t ta cn khi ng apache2 bng lnh: /etc/init.d/apache2 restart Nu c thng bo li, Could not reliably determine the servers fully qualified domain name, using 127.0.1.1 for ServerName, bn c th dng trnh son tho nano,vi... sa file httpd.conf nh sau: nano /etc/apache2/httpd.conf Khi nano m, nhp vo ServerName localhost v lu li. Khi ci t hon tt, bit Apache c hot ng hay khng th dng trnh duyt n a ch Ubuntu Server http://192.168.1.10. Nu nhn thy dng ch It works!,c ngha Apache hot ng. 3.3.3.5 Ci t PHP5 apt-get install mysql-server php5 php5-cli php5-gd php5-mysql php-pear php-db Sau khi ci t PHP xong, PHP tng thch v hot ng c cng Apache ta cn khi ng li Apache.

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing /etc/init.d/apache2 restart

Trang 46

kim s hot ng ca PHP ta tin hnh thc hin mt phn Test nh. To mt file testphp.php trong th mc /var/www/ sudo vi /var/www/testphp.php Nhp vo on code nh sau: <?php phpinfo(); ?>, ri Save li. M trnh duyt web, nhp http://192.168.1.10/testphp.php s thy kt qu nh sau:

Hnh 3.8 Giao din cu hnh PHP 3.3.3.6 Ci t MySQL Ta cn ci t MySQL server lu tr cc Database cn thit cho cc chng trnh hot ng sau ny nh FreePBX v A2billing apt-get install mysql-server Ta cn nh tn User v Password s dng cho vic truy cp Database ca SQL sau ny, trong n nhm thc hin ti s dng: MySQL username: root MySQL username: root Trong qu trnh ci t theo hng dn sau y, nu bc no b li khng th thc hin c th nht thit phi khc phc c li trc khi qua bc tip theo. 3.3.4 PUTTY Putty l 1 phn mm gi lp cho Linux rt hay v tin li. Bn khng cn phi ngi trn my server m vn c th thc hin nhng dng lnh ca my server bng Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 47

chng trnh ny. Putty c xem nh 1 remote ca my server m chng ta khng th no b qua c.

Hnh 3.9 Giao din chng trnh PUTTY


Nhp vo a ch IP ca my server, mc Protocol chn SSH sau chn Open ta s thy mn hnh Linux ca my server hin hnh:

Hnh 3.10 Mn hnh Linux thng qua chng trnh PUTTY

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 3.3.5 WinSCP

Trang 48

WinSCP l mt m ngun m cho Windows s dng SSH. Chc nng chnh ca n l sao chp an ton cc tp tin gia my hin ti v my c iu khin t xa. Vic sao chp d liu t my Client sang my Server s c thc hin n gin hn rt nhiu bng vic ko th nh trong win XP. Trong khi nu dng my server th sao chp d liu th chng ta s phi nhp nhng dng lnh mt nhiu thi gian m i khi li khng chnh xc.

Hnh 3.11 Giao din chng trnh WinSCP Nhp vo Host name l a ch IP tnh ca Server ( y l 192.168.1.10) User name: root Password: <your passoword> Sau khi ng nhp s hin th ca s mn hnh nh sau:

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 49

Hnh 3.12 Ca s giao din sau khi ng nhp WinSCP 3.4 Ci t Asterisk 3.4.1 Download cc gi ci t ca Asterisk http://downloads.asterisk.org/pub/telephony/libpri/releases/libpri-1.4.12.tar.gz http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk1.4.42.tar.gz http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons1.4.13.tar.gz http://downloads.asterisk.org/pub/telephony/dahdi-linuxcomplete/releases/dahdi-linux-complete-2.4.0+2.4.0.tar.gz http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-engsm-current.tar.gz Ta c th download cc gi trn trc tip bng my server, nhng y thao tc d dng, ta dng WinSCP copy cc gi t my XP sang th mc /usr/src/asterisk ca my Linux.

Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 50

Hnh 3.13 Sao chp d liu thng qua WinSCP 3.4.2 Gii nn v ci t cc gi ca h thng Asterisk 3.4.2.1 Ci t gi DAHDI Ta cn gn card X100P trc khi ci t gi ny (card X100P s c cp trong ni dung phn sau). cd /usr/src/asterisk tar xzvf dahdi-linux-complete-2.4.0+2.4.0.tar.gz cd dahdi-linux-complete-2.4.0+2.4.0/ make all make && make install && make config DAHDI l tn gi mi ca module Zaptel trn Asterisk 1.4.x iu khin cc card Digium (dnh cho cng FXO, FXS v E1/T1). Gi Dahdi cha cc Driver cho cc phn cng giao tip vi Asterisk v mt s th vin cho vic c thc hin giao tip vi phn cng hay khng. 3.4.2.2 Ci t gi Lipri Th vin libpri cung cp cc driver cho cc card giao tip trung k PRI v mt s phn cng khc. Ngay c Asterisk khng giao tip vi card PCI no chng ta cng nn ci t gi ny bi mt s module ca Asterisk yu cu th vin ny. cd /usr/src/asterisk tar xzvf libpri-1.4.12.tar.gz cd libpri-1.4.12 make clean make install Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 3.4.2.3 Ci t gi Asterisk cd /usr/src/asterisk tar xzvf asterisk-1.4.42.tar.gz cd asterisk-1.4.42 ./configure make clean make install make config make samples 3.4.2.4 Ci t gi Asterisk-addons bin dch v ci t gi asterisk-addons ta thc hin cc lnh sau: cd /usr/src/asterisk/asterisk-addons-1.4.7 ./configure make make install 3.4.2.5 Ci t gi Extra Sound

Trang 51

Gi ny b sung thm cc file m thanh h tr cn thit cho tng i Asterisk. cd /usr/src/asterisk cp -r asterisk-extra-sounds-en-gsm-current.tar.gz /var/lib/asterisk/sounds cd /var/lib/asterisk/sounds tar xzvf asterisk-extra-sounds-en-gsm-current.tar.gz 3.5 Kt lun Ch vi mt s thit b phn cng n gin kt hp vi Asterisk, chng ta hon ton c th t chc thnh mt tng i hon chnh th nghim dch v VoIP cng nh kt ni gia mng IP v PSTN. Hng dn trn y mi ch l cc bc c bn ci t mt h thng tng i Asterisk. L s kt hp gia chuyn mch VOIP v chuyn mch TDM, Asterisk s em n cho ngi s dng tt c cc tnh nng v ng dng ca h thng tng i PBX v cung cp nhiu tnh nng m tng i PBX thng thng khng c c. y l mt phn mm thc hin chc nng tng i in thoi PBX mang tnh cch mng, tin cy, m ngun m v min ph, bin 1 my tnh thng thng chy h iu hnh Linux thnh 1 h thng in thoi doanh nghip mnh m, l mt b cng c m ngun m cho cc ng dng thoi v l 1 tng i x l cuc gi y chc nng. Bn cnh , n cn l mt nn tng tch hp in thoi vi tnh ha kin trc m. Nhiu h thng Asterisk c ci t thnh cng trn khp th gii. V hin nay Asterisk vn tip tc c cng ng nhng ngi dng trn th gii pht trin mnh m. Chng 4 Gii thiu v ci t Asterisk

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 52

Chng 4

GII THIU V CI T FREEPBX

4.1 Gii thiu FreePBX FreePBX l mt ng dng web c y chc nng ca PBX. Nu bn s dng Asterisk, bn s nhn thy rng khi ta mun thm mt Extension hay thit lp cc chc nng, dch v ca tng i th ta phi tc ng lp trnh trc tip trn cc file cu hnh, vit cc hm Dialplans v thit lp thng s cho cc dch v mt cch phc tp, d sai st, kh qun l v tn nhiu thi gian. FreePBX gip ta n gin ha nhng iu trn bng cch thit lp, cu hnh tng i hon ton thng qua giao din Web GUI (Graphical User Interface) iu khin v qun l Asterisk mt cch trc quan v d dng. 4.2 Ci t chng trnh FreePBX Download gi FreePBX ti a ch: http://mirror.freepbx.org/freepbx-2.7.0.tar.gz Sao chp gi va download v b vo th mc /usr/src v bt u thc hin cc lnh ci t tng bc nh sau: To mt user mi vi tn l asterisk adduser asterisk --disabled-password --no-create-home --gecos "asterisk PBX user" Thay i user v group mc nh cho Apache i vi asterisk trong file apache2.conf cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf Vo th mc /etc/apache2/envars ta cn thay i cc dng sau: export APACHE_RUN_USER=www-data export APACHE_RUN_GROUP=www-data thnh: export APACHE_RUN_USER=asterisk export APACHE_RUN_GROUP=asterisk Vo file /etc/php5/apache2/php.ini, thay i cc thng s cho cc dng sau: memory_limit = 16M thnh: memory_limit = 100M v magic_quotes_gpc = On thnh:

Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing magic_quotes_gpc = Off

Trang 53

Ta cn khi ng li Apache2, y l bc quan trng trc khi tin hnh ci t FreePBX /etc/init.d/apache2 restart Sau ta cn phn quyn s hu truy cp cc th mc v tp tin ca Asterisk cho user asterisk m ta to ra ban u. chown asterisk:asterisk /etc/asterisk -R chown asterisk:asterisk /usr/lib/asterisk -R chown asterisk:asterisk /var/lib/asterisk -R chown asterisk:asterisk /var/log/asterisk -R chown asterisk:asterisk /var/spool/asterisk R chown -R asterisk /var/{lib,log,spool}/asterisk Trong file /etc/asterisk/asterisk.conf, tm v thay i nh sau: astrundir => /var/run v thay i thnh astrundir => /var/log/asterisk Vo th mc /usr/sbin/safe_asterisk thay i #!/bin/sh thnh #!/bin/bash Chy h thng asterisk vi user l asterisk v group l asterisk vi lnh sau: asterisk -U asterisk -G asterisk Trc khi tin hnh ci t FreePBX ta cn to cc Database cn thit cho c s d liu ca chng ta. To 1 Database c tn l Asterisk cha cc c s d liu khi cu hnh FreePBX cho Asterisk. V to 1 Database c tn l asteriskcdrdb cha cc c s d liu cho chc nng CDR ca FreePBX. mysqladmin -u root -proot create asterisk mysqladmin -u root -proot create asteriskcdrdb Vo th mc cha file ci t FreePBX cd /usr/src/freepbx-2.7.0 Tin hnh truy nhp cc Table SQL vo trong cc Database thit lp trn phc v cho s hot ng cu hnh ca FreePBX. mysql -u root -p asterisk < SQL/newinstall.sql mysql -u root -p asteriskcdrdb < SQL/cdr_mysql_table.sql Cn m bo rng phi xa b file amporttal.conf trc khi chy file script ci t cho FreePBX.

Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing rm -f /etc/amportal.conf

Trang 54

Bt u tin hnh chy file install_amp trong th mc ci t FreePBX. ./install_amp Trong qu trnh chy tp tin ny ta cn tr li mt s thng s thit lp sau, nhng ci khng c cp n th xem nh mc nh: Q: Enter your USERNAME to connect to the 'asterisk' database: A: root Q: Enter your PASSWORD to connect to the 'asterisk' database: A: root Q: Enter the path to use for your AMP web root: A: /var/www Q: Enter the IP ADDRESS or hostname used to access the AMP web-admin: A: <put your Ubuntu server IP address here> Vo file /etc/amportal.conf, thay i AUTHTYPE=none thnh AUTHTYPE=database Phn quyn s hu thc thi cc file trong th mc /var/www/ cho user asterisk chown -R asterisk. /var/www/ t file script amportal vo th mc init.d ln -s /usr/local/sbin/amportal /etc/init.d/amportal update-rc.d amportal defaults cd../ Sap chp th mc cha cc file MOH ca asterisk cho FreePBX ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3 Khi ng li astersik v apache2 bng cc lnh sau: /etc/init.d/apache2 restart /etc/init.d/asterisk restart Khi nh li amportal m bo cho s hot ng ca FreePBX bng lnh: amportal start Sau khi khi ng nu khng c li xy ra trong qu trnh ci t th ta s nhn c cc thng bo nh sau: SETTING FILE PERMISSIONS Permissions OK Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing STARTING ASTERISK Asterisk is already running STARTING FOP SERVER FOP Server Started

Trang 55

Nh th l cng vic ci t FreePBX hon thnh. Sau khi ci t xong ta vo trnh duyt web Firefox, ng nhp vo a ch http://192.168.1.10/admin s xut hin giao din Login nh sau:

Hnh 4.1 Giao din ng nhp ti khon FreePBX Lc ny ta s ng nhp vo giao din FreePBX vi Username v Password mc nh nh sau: Username: root Password: root

Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing V giao din cu hnh FreePBX nh sau:

Trang 56

Hnh 4.2 Giao din Web ca FreePBX 4.3 Cu hnh Card X100P giao tip vi PSTN 4.3.1 Gii thiu Card X100P Card X100P l thit b dng kt ni gia cc user trong mng ni b Asterisk vi mng PSTN. X100P hin nay khng cn c sn xut, do mc h tr s lng Port FXO, FXS t. Tuy nhin, X100P li rt thch hp cho mc ch nghin cu do gi c rt hp l. X100P l loi card chun cung cp 1 port FXO dng cho h thng Asterisk. Port FXO dng cho vic kt ni Asterisk PBX vi PSTN. N cho php IP PBX khi to/nhn cuc gi thng qua line analog truyn thng. X100P rt thch hp cho vic xy dng h thng IVR (tng tc theo li thoi) v ng dng voice mail. N cng h tr tt c cc chc nng Caller ID, hi thoi Vic kt hp X100P vo Asterisk s h tr kt ni vi h thng c, khng lm lng ph h tng c u t trc y.

Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 57

Hnh 4.3 Card FXO X100P Thng s k thut: Dng khe cm chun PCI. Thch hp vi cc khe PCI cung cp mc in p 3.3/5V. Tng thch vi cc h thng PSTN. Nhn bit tn hiu DTMF(rt quan trng vi IVR). 4.3.2 Khi nim FXO v FXS FXO (Foreign Exchange Office) l thit b nhn tn hiu t tng i gi n nh dng chung, tn hiu nhc v gc my, tn hiu mi quay s, gi v nhn tn hiu thoi. Ni cch khc FXO dng kt ni vi ng dy in thoi. FXS (Foreign Exchange Station) l thit b ti ni cung cp ng dy in thoi, thit b FXS s cung cp tn hiu mi quay s (dialtone), dng chung, hi m chung (ring tone). Trong ng dy Analog, FXS cung cp dng chung v in p cho in thoi hot ng, v d FXS cung cp in p -48VDC n my in thoi Analog trong sut thi gian m thoi v cung cp 90VAC (20hz) pht in p rung chung. Thit b FXS pht cn thit b FXO nhn. Mun cho php cc my in thoi ni b trong h thng IP PBX Asterisk kt ni v thc hin cuc gi vi mng PSTN, chng ta cn phi c thit b phn cng tng thch. Thit b phn cng ny l cc FXO/FXS card cho php h thng IP PBX Asterisk giao tip vi mng PSTN. Thit b phn cng thng k hiu bt u bng cm t TDMxyB trong x l s lng port FXS, y l s lng port FXO gi tr ti a ca x v y l 4, v d card TDM22B c ngha l c 2 fort FXS v 2 port FXO. S line PSTN s tng ng vi s cuc gi vo ng thi, do nu dng X100P (1FXO) th ti 1 thi im ch c duy nht 1 cuc gi vo/ra PSTN. Cc kiu bo hiu ng dy t thit b u cui (FXO, inthoi, PBX) n tng i in thoi trong mng PSTN, bao gm:

Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Loop start (ls). Ground start (gs). Kewlstart (ks).

Trang 58

Bo hiu ls v gs l phng php pht hin thay i tn hiu ng dy thc hin bo hiu gia thit b u cui v tng i. i vi kiu bo hiu Loop start th h thng s pht hin thay i ng dy bng in tr vng, ngha l khi thu bao trong trng thi gc my th in p cung cp cho thit b u cui l -48V(dc) nhng khi thu bao nhc my th in p qua in tr vng ca my in thoi cn khong -10V(dc), nh in p st gim ny m tng i pht hin thu bao nhc my v cung cp m hiu mi quay s cho thu bao (dial-tone). i vi kiu bo hiu Ground start th da vo s thay i ng dy nh vo in p ni t (kiu ny hin nay khng cn s dng). i vi kiu Kewlstart th phng thc bo hiu ging vi kiu Loop start nhng c phn khc i cht p ng cho cc ng dng ca h thng Asteisk, im khc bit ch yu l d trng thi nhc gc my pha u cui. in hnh nh ng dng voicemail, khi mt cuc gi vo h thng voicemail th lm sao h thng nhn bit c lc no l pha u cui kt thc pht tin nhn, nn qua kiu bo hiu Kewl start th h thng Asterisk s d trng thi khong lng kt thc nhn tin nhn. 4.3.3 Cu hnh Card X100P giao tip vi PSTN Sau khi ci t Driver DAHDI cho card X100P ta tin hnh thc hin mt s lnh cu hnh cc file card ny c th giao tip c vi PSTN. Load driver cho Card X100P: modprobe wcfxo Thc hin lnh sau to ra file /etc/dahdi/system.conf cho vic cu hnh sau ny cho Card: dahdi_genconf vvvv Thc hin lnh sau xem thng tin v gi ci t Dahdi v thng tin cc knh m Dahdi ang h tr: dahdi_cfg -vvv Mn hnh s hin cc thng tin nh sau:

Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 59

Hnh 4.4 Lnh dahdi_cfg vvv m bo Asterisk nhn dng c Card giao tip X100P ta cn tin hnh thc hin cc lnh kim tra sau: root@ubuntu:~# dahdi_scan

Hnh 4.5 Lnh Dahdi_scan root@ubuntu:~# dahdi_tool

Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 60

Hnh 4.6 H iu hnh nhn c Card X100P ubuntu*CLI> dahdi show status

Hnh 4.7 Trng thi hin ti ca Card X100P Nu Alarms = OK cho bit bn gn line PSTN vo Card ri. Nu Alarms = RED cho bit bn cha gn line PSTN. Nu Alarms = UNCONFIG cho bit bn cha chy lnh "dahdi_genconf", "dahdi_cfg". ubuntu*CLI> dahdi show channels

Hnh 4.8 Cc knh h tr khi gn Card

Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 61

Sau khi Card c nhn dng th ta cn tin hnh cu hnh mt s thng s trong cc file config sau gip cho Card hot ng (cc thng s khng c cp n c xem nh l mc nh). Trong file /etc/dahdi/system.conf # Span 1: WCFXO/0 "Wildcard X100P Board 1" (MASTER) RED Fxsks = 1 Echocanceller = mg2,1 # Global data Loadzone = us Defaultzone = us Trong file /etc/asterisk/chan_dahdi.conf language=en usecallerid=yes echocancel=yes echocancelwhenbridged=no echotraining=800 #include dahdi-channels.conf

Trong file /etc/asterisk/dahdi-channels.conf ; Span 1: WCFXO/0 "Wildcard X100P Board 1" (MASTER) RED ;;; line="1 WCFXO/0/0" signalling=fxs_ks callerid=asreceived group=0 context=from-pstn channel => 1 callerid= group= context=default 4.4 Kt lun FreePBX ra i gip chng ta trnh c vic cu hnh Asterisk bng tay rt tn km thi gian v d sai st. y thc s l mt ngi dng thn thin vi ha cu hnh cho Asterisk. Thng qua giao din ny, ta c th xc nh v thc hin bt k

Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 62

thay i h thng no m khng phi vo chnh sa cc tp tin cu hnh. Vi giao din Web d dng, t ng sinh m code, min ph, FreePBX c n nhn nng nhit v tr thnh giao din chun cu hnh Asterisk.

Chng 5 Gii thiu v ci t FreePBX

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 63

Chng 5

GII THIU V CI T A2BILLING

5.1 Gii thiu A2Billing T cc chng trc chng ta lm quen vi Linux, Asterisk v Trixbox. Trong chng ny nhm thc hin ti s tp trung vo vic ci t cu hnh, v trin khai gi A2Billing thc hin vic tnh tin cho cc cuc gi. A2Billing cho ra nhiu phin bn khc nhau vi nhiu ci tin v sa li. Tuy nhin A2Billing vn l m ngun m, cha c thng mi ha v do vn cn tn ti mt s li v mt s chc nng cha hon thin. Cc ti liu hng dn s dng v cu hnh l rt thiu. Trong chng ny, nhm thc hin ti s hng dn ngi dng ci t v tm hiu A2Billing 1.9.3. T thy c nhng tnh nng ca A2Billing v p dng vo thc t. Trong phm vi n ny, nhm thc hin ti chn A2Billing ci t v nghin cu v 3 l do chnh: Mt l A2Billing hon ton min ph v ang c cng ng Asterisk nh gi cao. Hai l vic ci t v s dng A2Billing i hi phi c kin thc tng hp v Asterisk, kt ni vi c s d liu Mysql v nhiu k nng khc. A2Billing cho ta ci nhn rt tng qut v cch qun l v tnh tin cuc gi v A2Billing c m hnh rt ging cc h thng tnh tin ang c s dng hin nay ca cc nh cung cp dch v. Khi ci t thnh cng A2Billing cho chng ta nhng tnh nng c bn sau y: Cc dch v gi in bng Card truyn thng: A2Billing c th c cu hnh cung cp cc dch v gi in bng card chun thng qua vic quay s v xc nhn s Number v Password. Cc dch v VoIP: Cc khch hng c th c cung cp soft-phone hoc hard-phone v tr tin cho cc cuc gi thit lp qua VoIP. Nh cung cp dch v VoIP u cui: A2Billing kt hp vi Asterisk c th c s dng nh mt chuyn mch mm kt ni v tnh tin cho s lng ln cc cuc gi. Khi A2Billing ng vai tr nh nh kinh doanh v phn phi dch v cho ngi dng. Nh th A2Billing kt hp vi Asterisk cung cp mt nn tng cng ngh y tnh nng v chuyn mch mm cung cp cc dch v kt hp. Trong A2Billing bao gm cc hnh thc tr trc v tr sau, bo co, thng k, kim sot cc cuc gi. N c th c cu hnh cung cp nhiu dng dch v: gi in tnh tin, chuyn cuc gi, hp th thoi, tr tin qua mng (Visa card, Paypal,...). Gii php s dng A2Billing cho doanh nghip bao gm nhng thnh phn nh sau: Server: l mt my tnh c cu hnh tt.

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 64

Line Interface Cards: Cc loi phn cng kt ni vi mng TDM (PRI, BRI, Analogue). Linux: H iu hnh chy nn. Apache: Chy web server. MySQL/ Postgresql: Qun l c s d liu. A2Billing: B my tnh tin v qun l cuc gi. A2Billing c trin khai trong mt s mi trng thng mi khng nhng cho cc cng ty c mc ch kt hp hnh thc TDM truyn thng vi h thng VoIP mi, m cn phc v cho cc cng ty cung cp dch v gi in tr tin bng card. A2Billing c ng k bn quyn bi GPL. iu ny ngha l bn c quyn chnh sa h thng ca bn nhng trong phm vi qui nh ca GPL. 5.2 Tm hiu v AGI (Asterisk Gateway Interface) Trong kin trc Asterisk, Asterisk h tr knh giao tip vi chng trnh ngoi l AGI (Asterisk Gateway Interface), cho php ta vit cc ng dng bn ngoi tng tc vi Asterisk. AGI cho php Astersik gi thc thi mt chng trnh ngoi m rng nhiu chc nng ca Astersik nh iu khin cc knh thoi, pht m thanh, c s DTMF, lin kt vi c s d liu, Cc chng trnh ngoi c gi l AGI Script, ta c th lp trnh ra cc AGI Script bng nhiu ngn ng lp trnh khc nhau nh Perl, PHP, C, C#, Java

5.2.1 Cu trc c bn AGI


AGI Script lin lc vi Asterisk bng cc knh thng tin STDOUT, STDIN v STDERR. STDOUT: AGI script gi thng tin n Asterisk. STDIN: Asterisk gi thng tin v AGI script. STDERR: Thng tin li.

Hnh 5.1 S giao tip gia Asterisk v AGI script Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 65

Trong s trn cho chng ta thy AGI giao tip vi rt nhiu cc thnh phn khc nhau. Giao tip vi database lu tr thng tin nh chi tit cuc gi, h thng tnh cc Giao tip vi web cho chng ta pht trin cc ng dng trn nn web nh kim tra mail. Coffee Maker thc hin rt nhiu cng vic cn li trong h thng Asterisk nh kim tra cu hnh h thng, lit k cc extension, kim tra password, cu hnh h thng AsteriskNhn chung AGI cho php chng ta thc hin nhiu cng vic gip khai thc v qun l Asterisk mt cch hiu qu nht. 5.2.2 Phn loi AGI AGI gm mt s loi nh sau: AGI: y l loi AGI bnh thng. AGI Script c th c lp trnh bi nhiu loi ngn ng khc nhau, c kh nng iu khin Dialplan, v phi t trn my ch Asterisk. EAGI (enhanced AGI): y l loi AGI nng cp c cc chc nng ging nh AGI, ngoi ra EAGI cn c kh nng c knh m thanh vo trn knh STDERR+1. DeadAGI: c chc nng tng t nh AGI nhng DeadAGI cn c kh nng lm vic trn cc knh cht ( knh cht l knh thoi c kt thc), y l kh nng m AGI bnh thng khng c. FastAGI: cho php Asterisk gi AGI Script qua mng TCP/IP, AGI Script khng cn phi t ngay trn my ch Asterisk.

Hnh 5.2 AGI giao tip vi Asterisk

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 5.2.3 Mt s hm c bn ca AGI Cc hm AGI ANSWER Tr li cc knh truyn. ANSWER Tr v cc gi tr: -1 nu khng thnh cng. 0 nu thnh cng. CHANNEL STATUS [channel name] C php v tnh cht

Trang 66

Yu cu trng thi ca knh uc ch nh bi channel name hoc nu khng ch nh knh no th mc nh l knh hin ti. CHANNEL STATUS Tr v gi tr: 0 nu knh b nghn v tn ti. 1 nu knh b nghn nhng c duy tr. 2 nu knh b ngt. 6 nu ng dy bn. DATABASE DEL family key DATABASE DEL Xa mt mc trong c s d liu ca Asterisk mt kha c ch nh. Tr v gi tr: 0 nu khng thnh cng. 1 nu thnh cng. DATABASE GET family key Ly li gi tr t c s d liu ca Asterisk mt kha c ch nh. DATABASE GET Tr v gi tr: 0 nu khng c. 1 (gi tr) gi tr c lp bao gm c du ngoc n. DATABASE PUT family key value DATABASE PUT Thm vo hoc update mt mc trong c s d liu ca Asterisk vi mt kha ch nh v gi tr ch nh Tr v gi tr:

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 0 nu khng thnh cng. 1 nu thnh cng. EXEC application options. EXEC

Trang 67

Thc thi ng dng quay s c th gm c cc ty chn. Tr v gi tr: -2 nu khng tm thy ng dng Gi tr nu ng dng tr v gi tr GET DATA filename [timeout] [max_digits]

GET DATA

Chy file m thanh c tn filename v cho php nhp cc s, di ti a l max_digits. Ging nh hm Background() trong ng dng quay s. GET FULL VARIABLE variablename [channelname] Nu bin c ch nh bi variablename c lp, s tr v gi tr ca n trong du ngoc n. Lnh ny hiu c cc tn bin phc tp khng ging nh GET VARIABLE. Tr v cc gi tr: 0 nu khng c knh no hoc bin khng c thit lp. 1 (gi tr) nu gi tr c ly bao gm c du.

GET FULL VARIABLE

GET OPTION

GET OPTION filename escape_digits [timeout] ging nh stream file nhng c ty chn timeout. HANGUP [channelname] Gc my mt knh thoi, nu khng ch nh knh no th mc nh l knh hin ti.

HANGUP

Tr v gi tr: -1 Knh ch nh khng tn ti. 1 Gc my thnh cng. NoOp [text]

NoOp

Thng dng mc ch debug, lnh ny s in ra mn hnh Asterisk text. RECEIVE CHAR timeout

RECEIVE CHAR

Nhn mt k t text trn knh. Ch nh mt timeout mili giy l thi gian ti a ch i vic nhp k t, hoc thit lp 0 khng gii hn thi gian ch. Tuy nhin

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing phn ln cc knh l khng h tr nhn text.

Trang 68

RECORD FILE filename format escape_digits timeout Ghi m knh gi vo mt tp tin ch nh cho n khi nhn s escape. nh dng file c qui nh l format c th gsm, mp3 hay wav Timeout thit lp bng -1 nu mun khng gii hn. Tr v gi tr: -1 nu khng thnh cng. 0 nu thnh cng. SAY ALPHA number escape_digits c chui s c ch nh, kt thc khi ngi dng nhn s escape. SAY ALPHA Tr v gi tr: -1 nu li hoc gc my. 0 nu c thnh cng m khng nhn s escape. gi tr ca s c nhp, dng thp phn. SAY DATE date escape_digits c ngy c ch nh, kt thc c khi ngi dng nhn s escape, date l s giy v sau tnh t thi im 00:00:00 ngy 1 thng 1 nm 1970. Tr v gi tr: -1 nu li hoc gc my. 0 nu c thnh cng m khng nhn s escape. gi tr ca s c nhn, dng thp phn. SAY DATETIME datetime escape_digits c ngy gi tng t nh say date. Tr v cc gi tr: SAY DATETIME -1 nu li hoc gc my. 0 nu c thnh cng. gi tr ca s c nhp. SAY DIGITS number escape_digits SAY DIGITS c chui cc s ch nh, kt thc nu ngi dng nhn s escape. Tr v cc gi tr:

RECORD FILE

SAY DATE

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing -1 nu li hoc gc my.

Trang 69

0 nu c thnh cng m khng nhn s escape. gi tr cc s c nhn. SAY NUMBER number escape_digits Ging vi say digits nhng c gi tr ca mt s ch khng c tng ch s. SAY NUMBER Tr v cc gi tr: -1 nu li hoc gc my. 0 nu c thnh cng m khng nhn s escape. gi tr nhn c t ngi dng. SAY TIME time escape_digits c thi gian c ch nh, ging nh say datetime. SAY TIME Tr v cc gi tr: -1 nu li hoc gc my. 0 nu c thnh cng m khng nhn s escape. SEND IMAGE image Gi bc nh c ch nh trn knh hin ti. Tuy nhin phn ln cc knh khng h tr gi hnh. SEND IMAGE Tr v cc gi tr: -1 nu li hoc gc my. 0 nu bc hnh c gi thnh cng hoc knh khng h tr gi hnh. SEND TEXT text_to_send Gi vn bn c ch nh trn knh hin ti. Tuy nhin phn ln cc knh khng h tr truyn vn bn. Nhng vn bn nhiu hn 1 t th nn trong du ngoc kp v mi lnh ch chp nhn mt dng n. Tr v cc gi tr: -1 nu li hoc gc my. 0 nu vn bn c gi i hoc knh khng h tr gi vn bn. SET AUTOHANGUP SET AUTOHANGUP time C tc dng lm cho knh t ng ngt khi thi gian time

SEND TEXT

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 70

tri qua. Tt nhin n c th ngt trc . time bng 0 nu khng mun t ng ngt knh. Tr v gi tr 0 nu t ng ngt c thit lp SET CALLERID number SET CALLERID Thay i Caller ID ca knh hin ti. Tr v gi tr 1 nu Caller ID c thit lp. SET CONTEXT context SET CONTEXT Thit lp context tip tc cc ng dng AGI tn ti. Tr v gi tr 0 nu context c thit lp. SET EXTENSION extension SET EXTENSION Thay i extension tip tc ng dng AGI tn ti. Tr v gi tr 0 nu Extension c thit lp. SET MUSIC ON [on|off] [class] SET MUSIC ON Thit lp hoc hy b chc nng pht nhc ch music-onhold. Lun lun tr v gi tr 0. SET PRIORITY priority SET PRIORITY Thay i quyn u tin cho cc ng dng AGI k tip. Tr v gi tr 0 nu thit lp c. SET VARIABLE variablename value SET VARIABLE Thit lp hoc cp nht cho cc tn bin c ch nh bi variablename. Nu bin khng tn ti, n s c to ra. Tr v gi tr 1 bin c thit lp. STREAM FILE filename escape_digits Chi cc tp tin m thanh ch nh bi filename, ngt khi nhn s escape. Ch nh dng ca tp tin phi bao gm trong filename. STREAM FILE Tr v cc gi tr: 0 nu chi thnh cng m khng nhn s escape. -1 nu li hoc gc my. gi tr ca s c nhn, dng thp phn. WAIT FOR DIGIT WAIT FOR DIGIT timeout

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 71

Ch cho ti timeout knh nhn c cc s nhn t ngi dng. Nu timeout bng -1 nu mun khng gii hn. Tr v cc gi tr: -1 li hoc knh khng tn ti. 0 ht timeout. gi tr ca s c nhn. Bng 5.1 Cc hm c bn ca AGI 5.3 Cu trc v nguyn tc hot ng ca A2Billing Asterisk xut ra mt CDR (Call Detail Record) cho mi cuc gi. Thng th tp tin lu tr ny s c Asterisk xut ra trong th mc /var/log/asterisk/cdr-csv. CDR s cha ng nhng thng tin chi tit v cc cuc gi trong asterisk. V thc hin chc nng tnh tin, chng ta s phi tm hiu v CDR. Trong mi file CDR s bao gm nhng thnh phn chnh sau: accountcode: account number c s dng (l dy gm 20 k t). src: CallerID number (l dy gm 80 k t). dst: Destination extension (l dy gm 80 k t). dcontext: Destination context (l dy gm 80 k t). clid: CallerID (dy gm 80 k t). channel: Knh s dng (80 k t). dstchannel: Destination channel (80 k t). lastapp: ng dng cui cng s dng (80 k t). lastdata: D liu ra ca ng dng cui cng (80 k t). start: Thi gian bt u cuc gi (date/time). answer: Thi gian tr li cuc gi (date/time). end: Thi gian kt thc cuc gi (date/time). duration: Thi gian cuc gi t lc quay s (giy). billsec: Tng thi gian gi t lc c tn hiu tr li (giy). disposition: Trng thi cuc gi: ANSWERED, NO ANSWER, BUSY, FAILED. amaflags: AMA = Automated Message Accounting. omit: Khng record calls. billing: nh du thc hin billing. documentation: nh du cho documentation. user field: Ngi dng t nh ngha (ti a 255 k t). Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 72

Trong mt mng li in thoi thng thng, h thng to ra CDR t cc thnh phn ca mng. Cn nhng ng dng m thc thi trn c s d liu CDR s s dng c s d liu dng khc. V OSS (operations support systems) l mt qu trnh c bit nh chuyn c s d liu ca CDR sang mt dng c s d liu khc m ta c th thc thi c d dng. Vi trng hp ca A2Billing th c s d liu m ta s s dng thc thi chc nng tnh tin, qun l cuc gi l MySQL v PostgreSQL.

Hnh 5.3 Chc nng ca OSS Trong Asterisk th CDR c sinh ra trong cng h thng my ch vi Asterisk. Khi CDR c sinh ra, mt qu trnh tnh ton cho mi cuc gi s c thc hin da trn c s d liu ca mt hoc nhiu file CDR. Qu trnh ny c gi l nh gi v c th c thc thi trn mt b my khc. iu ny cho php chng ta thc thi ng dng mt my ch khc khng phi l my ch Asterisk. H thng nh gi ny l mt phn ca h thng tnh tin. V h thng tnh tin ca chng ta s quyt nh thi gian cuc gi, tnh ton s d ti khon v cho php cuc gi c thit lp hay khng. T s tng tc tr li h thng my ch Asterisk thng qua cc cc hm AGI.

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 73

Hnh 5.4 S A2Billing tng tc vi Asterisk 5.4 Ci t A2Billing Download gi A2Billing ti a ch: https://nodeload.github.com/Star2Billing/a2billing/tarball/v1-current Sau khi download v ta thay i tn thnh a2billing.tar.gz v copy vo th mc /usr/src ca Server. Trc khi tin hnh download v ci t, ta phi m bo h thng Asterisk hot ng tt. V d nh cc cuc gi ni b, cuc gi ra ngoi PSTN, cuc gi thng qua nh cung cp dch v VoIP, c thit lp ng hay cha. iu ny l ht sc quan trng, v bt c li no xy ra v khi ci t thm gi A2Billing th s tr nn kh hn cho ta trong vic tm li cng nh sa cha. V c bit chng ta s s dng li mt s thit lp trong FreePBX m ta thc hin chng trc. Cng nh vic ci t FreePBX, ta cn m bo Apache2, PHP, MySQL u hot ng tt trc khi tin hnh ci t A2billing. Cc bc tin hnh ci t A2billing vi lnh nh sau: Chun b Database cho a2billing cd /usr/src/a2billing/DataBase/mysql-5.x/ mysql -u root -proot <a2billing-createdb-user.sql Tin hnh ci t c s d liu cho A2billing bng cch chy file script installdb.sh ./install-db.sh Trong qu trnh ci t ta cn khai bo cc thng tin sau: Enter Database Name: mya2billing Enter Hostname: localhost Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Enter UserName: a2billinguser Enter Password: a2billing

Trang 74

Sau khi ci t xong ta cn truy nhp vo c s d liu va to kim tra li mysql mya2billing -u a2billinguser -pa2billing Kim tra cc table trong database a2billing ci t y cha, nu ci t hon thnh ta s thy kt qu nh sau: mysql> show tables; +---------------------------+ | Tables_in_mya2billing | +---------------------------+ | cc_agent | | cc_agent_commission | | cc_agent_signup | | cc_agent_tariffgroup | | cc_version | | cc_voucher | +---------------------------+ 97 rows in set (0.00 sec) Tip theo ta tin hnh ci t giao din web A2billing v phn quyn thc thi cho cc th mc cp -rf /usr/src/a2billing/customer /var/www/ chmod 777 /var/www/customer/templates_c cp -rf /usr/src/a2billing/agent /var/www/ chmod 777 /var/www/agent/templates_c cp -rf /usr/src/a2billing/admin /var/www/a2billing chmod 777 /var/www/a2billing/templates_c cp -Rf /usr/src/a2billing/common /var/www/ Ci t v thc thi cc file AGI cho s hot ng ca A2billing cp /usr/src/a2billing/AGI/a2billing.php /var/lib/asterisk/agi-bin/ cp /usr/src/a2billing/AGI/a2billing_monitoring.php /var/lib/asterisk/agi-bin/ cp -rf /usr/src/a2billing/common/lib /var/lib/asterisk/agi-bin/ chmod +x /var/lib/asterisk/agi-bin/a2billing.php chmod +x /var/lib/asterisk/agi-bin/a2billing_monitoring.php chown -R asterisk:asterisk /var/lib/asterisk/agi-bin Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Thay i cc file cu hnh ca A2billing bng cc lnh sau: llllcp /usr/src/a2billing/a2billing.conf /etc/asterisk chown asterisk:asterisk /etc/asterisk/a2billing.conf ln -sf /etc/asterisk/a2billing.conf /etc/a2billing.conf sed -i s/\(port *= *\)\(.*\)/\13306/ /etc/asterisk/a2billing.conf

Trang 75

sed -i s/\(user *= *\)\(.*\)/\1a2billinguser/ /etc/asterisk/a2billing.conf sed -i s/\(password *= *\)\(.*\)/\1a2billing/ /etc/asterisk/a2billing.conf sed -i s/\(dbname *= *\)\(.*\)/\1mya2billing/ /etc/asterisk/a2billing.conf To vi ng dn cha tp tin MOH mp3 cho A2billing mkdir -p /var/lib/asterisk/mohmp3/acc_1 mkdir -p /var/lib/asterisk/mohmp3/acc_2 mkdir -p /var/lib/asterisk/mohmp3/acc_3 mkdir -p /var/lib/asterisk/mohmp3/acc_4 mkdir -p /var/lib/asterisk/mohmp3/acc_5 mkdir -p /var/lib/asterisk/mohmp3/acc_6 mkdir -p /var/lib/asterisk/mohmp3/acc_7 mkdir -p /var/lib/asterisk/mohmp3/acc_8 mkdir -p /var/lib/asterisk/mohmp3/acc_9 mkdir -p /var/lib/asterisk/mohmp3/acc_10 chmod 777 /var/lib/asterisk/mohmp3/acc_* chown -R asterisk:asterisk /var/lib/asterisk/mohmp3/ Ci t cc tp tin m thanh h tr cho A2billing cd /usr/src/a2billing/addons/sounds chmod +x install_a2b_sounds.sh ./install_a2b_sounds.sh mkdir -p /var/lib/asterisk/sounds/a2billing chmod +x /var/lib/asterisk/sounds/* To cc tp tin m rng lin kt gia A2billing v Asterisk cd /etc/asterisk/ touch additional_a2billing_iax.conf touch additional_a2billing_sip.conf touch extensions_a2billing.conf echo #include additional_a2billing_sip.conf >> /etc/asterisk/sip_custom.conf

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing echo #include additional_a2billing_iax.conf >> /etc/asterisk/iax_custom.conf echo -e >> /etc/asterisk/extensions_custom.conf echo #include extensions_a2billing.conf >> /etc/asterisk/extensions_custom.conf

Trang 76

Phn quyn truy cp, thc thi cho cc tp tin, th mc lin quan cho s truy nhp vo A2billing ca user chmod 777 /etc/asterisk/additional_a2billing_iax.conf chmod 777 /etc/asterisk/additional_a2billing_sip.conf chown -R asterisk:asterisk /etc/asterisk/additional_a2billing_iax.conf chown -R asterisk:asterisk /etc/asterisk/additional_a2billing_sip.conf chown -R asterisk:asterisk /var/lib/asterisk/agi-bin chown -R asterisk:asterisk /etc/asterisk/ chown -R asterisk:asterisk /var/www/common chown -R asterisk:asterisk /var/www/a2billing chown -R asterisk:asterisk /var/www/customer chown -R asterisk:asterisk /var/www/agent chown -R asterisk:asterisk /var/lib/asterisk/ Thay i v thm vo tp tin manager.conf cc thng tin cn thit bng cc lnh sau: sed -i s/\(enabled *= *\)\(.*\)/\1yes/ /etc/asterisk/manager.conf echo [myasterisk] secret = mycode deny=0.0.0.0/0.0.0.0 permit=127.0.0.1/255.255.255.0 read = system,call,log,verbose,command,agent,user write = system,call,log,verbose,command,agent,user >> /etc/asterisk/manager.conf Nu mun cho php khi ng A2billing t FreePBX, ta cn to mt Custom Trunk mi bng lnh sau: echo [macro-dialout-trunk-predial-hook] exten => s,1,GotoIf($[${OUT_${DIAL_TRUNK}:4:4} = A2B/]?customfreepbx-a2billing,${OUTNUM},1:2) exten => s,2,MacroExit Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing [custom-freepbx-a2billing] exten => _X.,1,DeadAGI(a2billing.php|${OUT_${DIAL_TRUNK}:8}) exten => _X.,n,Hangup() >> /etc/asterisk/extensions_custom.conf

Trang 77

B sung thm mt s Context cn thit cho A2billing c th hot ng c cng vi Asterisk echo [a2billing] exten => _X.,1,Answer exten => _X.,n,Wait(1) exten => _X.,n,AGI(a2billing.php|1) exten => _X.,n,Hangup [a2billing-callback] exten => _X.,1,deadAGI(a2billing.php|1|callback) exten => _X.,n,Hangup [a2billing-cid-callback] exten => _X.,1,deadAGI(a2billing.php|1|cid-callback|34);last #parameter is the callback area code exten => _X.,n,Hangup [a2billing-all-callback] exten => _X.,1,deadAGI(a2billing.php|1|all-callback|34);last #parameter is the callback area code exten => _X.,n,Hangup [a2billing-did] exten => _X.,1,deadAGI(a2billing.php|1|did) exten => _X.,2,Hangup [a2billing-voucher] exten => _X.,1,deadAGI(a2billing.php|1|voucher) exten => _X.,n,Hangup [custom-a2billing-did] exten => _X.,1,deadAGI(a2billing.php|1|did) exten => _X.,2,Hangup [custom-a2billing] exten => _X.,1,deadAGI(a2billing.php|1) exten => _X.,n,Hangup >> /etc/asterisk/extensions_a2billing.conf Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing To cc tp tin Log cn thit trong th mc /var/log/a2billing mkdir -p /var/log/a2billing touch /var/log/asterisk/a2billing-daemon-callback.log touch /var/log/a2billing/a2billing-daemon-callback.log touch /var/log/a2billing/cront_a2b_alarm.log touch /var/log/a2billing/cront_a2b_autorefill.log touch /var/log/a2billing/cront_a2b_batch_process.log touch /var/log/a2billing/cront_a2b_bill_diduse.log touch /var/log/a2billing/cront_a2b_subscription_fee.log touch /var/log/a2billing/cront_a2b_currency_update.log touch /var/log/a2billing/cront_a2b_invoice.log touch /var/log/a2billing/cront_a2b_check_account.log touch /var/log/a2billing/a2billing_paypal.log touch /var/log/a2billing/a2billing_epayment.log touch /var/log/a2billing/api_ecommerce_request.log touch /var/log/a2billing/api_callback_request.log touch /var/log/a2billing/a2billing_agi.log

Trang 78

chown asterisk:asterisk /var/log/asterisk/a2billing-daemon-callback.log chown -R asterisk:asterisk /var/log/a2billing Nh th l cng vic ci tA2billing hon thnh. Sau khi ci t xong ta vo trnh duyt web Firefox, ng nhp vo a ch http://192.168.1.10/a2billing s xut hin giao din Login nh sau:

Hnh 5.5 Giao din ng nhp ti khon A2Billing

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 79

Lc ny ta s ng nhp vo giao din A2billing vi Username v Password mc inh nh sau: Username: root Password: changepassword V giao din cu hnh A2Billing nh sau:

Hnh 5.6 Giao din Web cu hnh ca A2Billing 5.5 Mt s khi nim trong A2Billing Trong chng trc, nhm thc hin ti thc hin thnh cng vic thit lp h thng tng i PBX Asterisk cho nhu cu thc hin cuc gi ni b, trong nc v quc t ca doanh nghip nh v va. chng ny, nhm thc hin ti tip tc pht trin h thng p ng thm mt s yu cu ca doanh nghip. A2Billing kt hp vi Asterisk c th c ci t, thit lp v chnh sa p ng nhiu nhu cu khc nhau. Trong doanh nghip th cc nhu cu c th l: Tnh tin cuc gi quc t cho cc phng ban, chi nhnh khc nhau. Kim tra cc cuc gi ra bn ngoi ca nhn vin cng ty. Bo co, thng k cc cuc gi ra ngoi cng ty. T ng la chn cc kt ni vi nh cung cp dch v ti u, tit kim chi ph cc cuc gi ra bn ngoi ca cng ty. Thc hin cuc gi qua web. Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 80

Ta tip tc s dng m hnh cng ty s dng trong chng trc. y, chng ta cn phi m bo l cc cuc gi v cc kt ni c thc hin thnh cng. A2Billing ch b sung thm mt s tnh nng v nhu cu c th ch khng tham gia vo cc qu trnh thit lp cuc gi hay cc cu hnh Context, Extension, Sip Friend ca Asterisk. y nhm thc hin ti s tip tc thit lp trong trng hp cng ty c mt ng dy PSTN v hai nh cung cp dch v VoIP nh trong chng trc.

Hnh 5.7 M hnh kt ni trong cng ty Trc khi chng ta lm vic vi A2Billing, ta cn phi c mt s khi nim v A2Billing v cc tnh nng trong . A2Billing thc s nhiu tnh nng hn l mt ng dng gi in bng card thng thng. Trong c mt s khi nim m chng ta cn phi gii thch qua l: Customers, Rates, Rate cards, Call plan, Trunks Chng ta s tm hiu thit lp chi tit sau khi ni qua khi nim tng mc. Customers Customers l ngi dng, ng thi cng l card ngi dng thc hin cuc gi. y hon ton ging nh cc card VoIP ang c bn trn th trng Vit Nam. Mt Customer s c xc nhn vi mt s PIN number hoc s Card number. Rates Rates l chi ph thc hin cuc gi n mt a im c th no . Ta qui nh rate l qui nh ph thc hin cuc gi n mt a im. Rate cards Rate cards c th hiu l mt nhm cc Rates. Ta c nhiu Rates khc nhau cho nhng a im gi in khc nhau. V d ta c 3 nh cung cp dch v PSTN, mi ngi tnh ph khc nhau. Ta s gom chung 3 rate vo 1 rate card l PSTN.

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 81

Call plan Call plan th li l mt nhm cc Rate cards. Dng v d trn, nu ta c mt Rate card cho mc ch gi ni ht, mt Rate card khc cho gi lin tnh. Ta s gom hai Rate card thnh mt Call plan c tn l trong nc. V khi , chng ta s to ra cc loi Card c th thc hin cuc gi n cc Call plan m ta qui nh. Ta c th bn cc loi card gi in trong nc khc cc loi card gi in quc t. Trunks Trunks l cc kt ni t A2Billing n th gii bn ngoi (cc nh cung cp dch v). Trunk c th l cc ng dy PSTN truyn thng (gi l Zap trunk) hoc ng kt ni Internet n cc nh cung cp dch v VoIP (gi l SIP/IAX trunk). Vit Nam hin thi cc nh cung cp dch v VoIP cha cung cp hnh thc dch v Trunk m ch l cc Card Number phc v mc ch gi in quc t qua softphone hoc IP-phone. 5.6 Kt lun A2Billing kt hp vi Asterisk cung cp cho cc doanh nghip mt gii php hu hiu cho vic qun l cuc gi v tnh tin cuc gi trong phm vi cng ty nh v va. V quan trng nht l A2Billing hin thi ang l gi ci t c cung cp hon ton min ph nn n ang c cng ng Asterisk nh gi cao. A2Billing cng cho ta thy c ci nhn rt tng qut v cch qun l v tnh tin cuc gi v phn mm ny c cc chc nng rt ging cc h thng tnh tin ang c s dng hin nay ca cc nh cung cp dch v.

Chng 6 Gii thiu v ci t A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 82

Chng 6 XY DNG H THNG PBX ASTERISK V GII PHP TNH CC A2BILLING


6.1 M hnh h thng thc t

Hnh 6.1 M hnh h thng thc t Gii thch m hnh: My ch Asterisk c kt ni mng LAN vi cc thit b u cui VoIP nh Analog Phone, IP Phone, Softfone thng qua thit b ATA(Analog Telephone Adapter). Do , cc thit b u cui VoIP c th ng nhp vo mng LAN ni b tng i v thng thoi lin lc vi nhau m khng phi tn bt k cc ph no. Ngoi ra, cc thit b u cui VoIP c th ng nhp vo ni b tng i bt c ni no c kt ni Internet nu my ch Asterisk c ng k mt Domain ring.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 83

H thng tng i giao tip vi mi trng PSTN thng qua Card giao tip X100P gip cc thu bao ni b tng i c th thc hin c cuc gi bnh thng ra bn ngoi thng qua PSTN. gii quyt vn cc ph cho cc cuc gi quc t ng di t ni b trong cng ty sang cc quc gia khc, ta c th ng k cho tng i ca chng ta thm mt IP Trunk ca cc nh cung cp dch v VoIP nhm gip chng ta thc hin c cc cuc gi ny thng qua mi trng Internet, nh th s gim bt chi ph cho nhng cuc gi quc t ca cng ty. Do hn ch v iu kin vt cht, trang thit b nn nhm thc hin ti ch s dng phn mm Softfone X-Lite lm thit b u cui VoIP duy nht trong n ny. 6.2 Cc thit b phn cng v phn mm s dng 6.2.1 Phn cng Cc thit b phn cng c s dng trong m hnh trn l: My ch Asterisk c cu hnh tng i mnh. Card giao tip X100P. in thoi analog. Tng i FX106. 6.2.2 Phn mm y l cc phn mm ci t cn thit cho my ch Asterisk: H iu hnh Linux Ubuntu 10.04 . Phn mm m ngun m Asterisk: o asterisk: version 1.4.42. o asterisk-addons: version 1.4.13. o dahdi: version 2.4. o libpri: version 1.4.12. Phn mm m ngun m FreePBX phin bn 2.7. Phn mm m ngun m A2Billing phin bn 1.9.3. Phn mm SoftPhone X-Lite version 3.0 ci trn my o VMWare. 6.3 Mt s chc nng ca h thng IP PBX 6.3.1 Add Extension (To ti khon thu bao) Trc tin ta khi ng trnh duyt Web, nhp http://192.168.1.10/admin s xut hin giao din ng nhp nh sau: vo a ch

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 84

Hnh 6.1 Giao din ng nhp ti khon FreePBX Lc ny ta s ng nhp vo giao din FreePBX vi Username v Password mc nh nh sau: Username: root. Password: root. V y l giao din FreePBX sau khi ng nhp:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 85

Hnh 6.2 Giao din Web ca FreePBX Vo mc Extensions bn tri mn hnh s hin ra ca s dch v. Chn Generic SIP Device.

Hnh 6.3 To cc ti khon SIP Nhn Submit bt u cu hnh ti khon thu bao. Sau s hin ra ca s giao din nh sau:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 86

Hnh 6.4 Cu hnh cc thng s ti khon SIP y l cc thng s chnh ta cn quan tm: User Extension: s in thoi ca thu bao. Display Name: tn ca thu bao. secret: mt khu ca thu bao. Thit lp xong nhn Submit cui phn ng k thu bao lu li thit lp bt c khi no to mt ti khon thu bao mi.. Ln u trang, click Apply Configuration Changes (mu cam) vo bt u p dng cu hnh.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 87

Hnh 6.5 p dng cu hnh Ta c th ng nhp vo cc ti khon thu bao va to trn thng qua phn mm Soft Phone X-Lite 3.0. Softphone l mt phn mm c ci trn my tnh thc hin tt c cc chc nng ging nh thit b in thoi VoIP, cn lu khi s dng softphone l my tnh phi c card m thanh, headphone v khng b chn bi firewall. ng nhp ti khon thu bao dinh101trn PC th nht: Khi ng phn mm X-Lite, chn SIP Account Settings nh hnh di:

Hnh 6.6 Giao din softphone X-Lite

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 88

Sau s hin ra giao din cu hnh v ta nhp cc thng s nh hnh di:

Hnh 6.7 Cu hnh ng nhp ti khon thu bao trn X-Lite Nhp Apply sau nhn OK lu li thit lp. Softphone X-Lite s bt u ng nhp ti khon thu bao. y l giao din X-Lite sau khi ng nhp thnh cng:

Hnh 6.8 ng nhp thnh cng trn softphone Cu hnh user viet102 trn PC th hai vi s thu bao 102 (tng t). Sau khi ng nhp thnh cng ti khon thu bao viet102 trn X-Lite, ta quay s 101 s gi ti user dinh101. Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Call Waiting (Cuc gi ch)

Trang 89

Call Waiting l dch v cho php thu bao vn c th nhn c tn hiu bo c cuc gi n trong khi ang m thoi vi thu bao khc. Thu bao c th kt thc cuc gi hin hnh tr li cuc gi mi, hoc c th tm thi ngng cuc gi hin hnh chuyn sang nhn cuc gi mi. Ta c th kch hot dch v ny trc tip qua in thoi. kch hot dch v, thu bao quay s *70. hy dch v, thu bao quay s *71. 6.3.3 Music On Hold (Nhc ch khi gi my) Tnh nng Music On Hold ca Asterisk c nhiu ng dng thc t rt thit thc. Mt s ng dng tiu biu nh trong khi ch gi my c gp ngi khc chng hn, thu bao c th nghe m nhc gii tr qun i thi gian ch i, khi ch tr li cuc gi thu bao s nghe m nhc thay v hi m chung nh in thoi truyn thng hoc pht ra mt thng ip thng bo cho mt tc v no . FreePBX c sn mt s lng nhc ch, tuy nhin ta c th chn la nhc ch theo mun ca ring mnh thay th cho cc nhc ch c sn. FreePBX ch h tr nh dng tp tin MP3 hoc WAV. to ra th vin nhc ch ca ring mnh, ta ch cn ti ln tt c cc tp tin MP3 hoc WAV. Chng ta cn chuyn i cc tp tin MP3 v WAV thnh nh dng chun ph hp vi FreePBX: Tc Bit: 128. n sc. c c b nhc ch theo mun, ta cn phi to ra th vic nhc ch lu tr cc bi ht. Chn mc Music on Hold bn tri ca s mn hnh s hin ra giao din nh sau:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 90

Hnh 6.9 Giao din cu hnh dch v Music on Hold to mt th vin nhc ch mi, click chn Add Music Category. Ta nhp tn th vin nhc ch trong khung Category Nam:

Hnh 6.10 To th vin nhc ch Nhac-Viet-Nam


Chn Submit Changes lu li th vin. Trong ca s tip theo, nhp chn Browse chn tp tin nh dng WAV hoc MP3 mun a vo th vin Nhac-Viet-Nam. Nhn Upload bt u ti ln.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 91

Hnh 6.11 Ti ln cc tp tin nhc ch Sau khi qu trnh ti ln hon tt, nhn Apply Configuration Changes lu li cu hnh.

Hnh 6.12 p dng cu hnh dch v Music On Hold


Tip theo chn th Outbound Routes bn tri ca s mn hnh, trong mc Music On Hold chn th vin nhc ch mun s dng.

Hnh 6.13 Cu hnh MOH trong Outbound Routes

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Chn Submit lu li thit lp nh hnh di:

Trang 92

Hnh 6.14 Lu li thit lp nhc ch cho cc cuc gi n Tng t, chn th Inbound Routes, trong mc Music On Hold chn th vin nhc ch mun s dng.

Hnh 6.15 Cu hnh MOH trong Inbound Routes

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Click Submit ri Apply Configuration Changes lu li cu hnh.

Trang 93

Hnh 6.16 p dng cu hnh By gi ta c th nghe c nhc ch trong khi i tn hiu bt my. 6.3.4 Blacklist (Danh sch loi tr) Mc ch ca tnh nng ny l gip thu bao loi tr cc cuc gi n ca mt thu bao no , lm c iu ny ta a s in thoi ca thu bao m ta khng mun tr li cuc gi vo trong danh sch Blacklist. Mt v d c th nh khi c mt s in thoi gi in vi mc ch xu, chng ta mun cc s in thoi ny khng c thc hin cuc gi n in thoi ca ta na, lc ny ta s a cc s in thoi vo danh sch Blacklist. Chng ta c th qun l danh sch loi tr Blacklist thng qua giao din FreePBX. u tin chng ta nhp chn th Blacklist bn tri ca s mn hnh s hin ra giao din cu hnh. Trong mc Number, ta nhp s thu bao m ta khng mun nhn cuc gi.

Hnh 6.17 Giao din cu hnh dch v Blacklist Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Sau nhn Submit Changes lu li thit lp.

Trang 94

S thu bao 101 sau khi b a vo danh sch loi tr s khng th gi c n tng i. Thu bao s nhn c thng bo The number you have reached is not is service. Ngoi ra ta c th iu chnh danh sch Blacklist trc tip qua in thoi: a mt s thu bao vo danh sch loi tr: trn in thoi ta quay s *30 s nhn c thng bo nhp s thu bao mun loi tr ri nhn #. Sau khi nhn xong, ta s nhn c yu cu xc nhn thu bao mun loi tr. xc nhn ta nhn phm 1. Cui cng ta nhn c thng bo xc nhn a thu bao trn vo danh sch loi tr. a s thu bao gi n cui cng vo danh sch loi tr: trn in thoi ta quay s *32 s nhn c thng bo yu cu xc nhn a s thu bao gi n cui cng vo danh sch loi tr. xc nhn ta nhn phm 1. Cui cng ta s nhn c thng bo xc nhn a thu bao trn vo danh sch loi tr. Xa mt s thu bao khi danh sch loi tr: trn in thoi ta quay s *31 s nhn c thng bo nhp s thu bao mun xa khi danh sch ri nhn #. Sau khi nhn xong, ta s nghe c yu cu xc nhn. xc nhn ta nhn phm 1. Cui cng ta nghe thy thng bo xa thu bao trn khi danh sch loi tr.

6.3.5 Ring Groups ( chung chm)


Ring Groups l dch v thit lp cc s thu bao thnh mt nhm v khi c cuc gi t bn ngoi n tng i th cc thu bao trong nhm s cng chung. Mt v d c th nh khi c thu bao gi n s 600 l s in thoi phng chm sc khch hng ca mt cng ty, th tt c cc in thoi ca nhn vin trong phng chm sc khch hng s chung ng lot, cho n khi c mt thu bao trong nhm nhc my nhn cuc gi ny. tin hnh cu hnh dch v, ta chn mc Ring Groups bn tri mn hnh, s hin ra ca s giao din:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 95

Hnh 6.18 Giao din cu hnh dch v Ring Groups y l cc thng s c bn chng ra cn quan tm: Ring-Group Number: y l s in thoi i din ca nhm. Group Description: tn ca nhm. Ring Strategy: cch thc chung. C 2 ch thng s dng: o Ring All: chung ng lot cho tt c cc thu bao trong nhm. o Hunt: chung cho thu bao u tin trong nhm, nu thu bao ny khng nhc my th n s chuyn qua thu bao k tip v tip tc nh vy. Ring Max: thi gian chung. Extension list: Danh sch cc s in thoi c a vo nhm. Ngoi ra, trong trng hp khng c ai trong nhm nhc my tr li cuc gi, ta c th ci t h thng Voicemail thng bo yu cu li li nhn thoi trong mc Destination if no answer nh hnh di:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 96

Hnh 6.19 Cu hnh mc Destination if no answer cho dch v Ring Groups 6.3.6 Queues (Hng i) Dch v hng i cho php bn qun l mt s lng ln cc cuc gi n. y l ng dng rt linh hot, c rt nhiu la chn iu chnh cho ph hp vi cc tnh hung khc nhau. cu hnh dch v ny ta chn mc Queues bn tri mn hnh s hin ra ca s giao din:

Hnh 6.20 Giao din cu hnh dch v Queue Nhp chn Add Queue to hng i. y l cc thng s c bn ta cn quan tm: Queue Number: y l s in thoi i din cho hng i. Nhng thu bao ni b trong danh sch Dynamic Members s dng s in thoi ny Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 97

thm * ng nhp hoc thot khi hng i (v d nh 700* ng nhp hng i, 700** thot khi hng i nu Queue Number l 700). Queue Name: tn ca hng i. Tn hng i ch s dng giao din Web d dng xc nh. Queue Password: Mt khu ca hng i. Nu chng ta ch trng n vn bo mt, chng ta c th ci mt khu cho hng i trnh nhiu thu bao cha c cho php ng nhp vo hng i. Khi mt thu bao no mun ng nhp vo hng i, thu bao s c nhn c thng bo yu cu nhp mt khu ny. Nu ta trng mc ny th cc thu bo s khng cn phi nhp mt khu. Static Agents: y l danh sch s in thoi ca cc thu bao lun ng nhp sn vo hng i. Nhng thu bao ny khng cn phi ng nhp vo hng i nhng cng khng th thot khi hng i. Dynamic Members: y l danh sch cc s thu bao c th ng nhp v thot khi hng i. Cc thu bao ny khng t ng ng nhp vo hng i. Restrict Dynamic Agents: c 2 la chn: o Yes: khng cho php cc thu bao khng nm trong danh sch Dynamic Members ng nhp vo hng i. o No: cho php cc thu bao khng nm trong danh sch Dynamic Members ng nhp vo hng i. 6.3.7 Do Not Disturb (T chi nhn cuc gi) Khi kch hot dch v ny, tt c cc cuc gi n thu bao s c yu cu li li nhn thoi. kch hot dch v, thu bao quay s *78. hy dch v, thu bao quay s *79. chuyn trng thi dch v (t hot ng sang ngng hot ng hoc t ngng hot ng sang hot ng), thu bao quay s *76. 6.3.8 Conference (Xy dng h thng hi thoi) Chc nng ny nhm mc ch xy dng h thng hi thoi cho php nhiu ngi c th cng nhau trao i ni chuyn vi nhau, ni m mi ngi cng gi n trao i ni chuyn gi l phng hi thoi, Asterisk cho php ta to ra mt hoc nhiu phng hi thoi tu vo nhu cu ngi s dng. Trong h thng in thoi truyn thng PSTN c th s dng c tnh nng ny chng ta phi tr tin cn i vi Asterisk l min ph. Trn giao din Web FreePBX, ta c th to ra cc phng hi thoi bng cch vo mc Conference bn tri mn hnh. ng nhin bn c th iu chnh cc thng s theo ca bn. y l giao din cu hnh dch v: Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 98

Hnh 6.21 Cu hnh dch v Conference y l cc thng s c bn ta cn quan tm: Conference Number: s in thoi i din ca phng hi thoi, thu bao gi n s ny vo phng hi thoi. Conference Name: tn ca phng hi thoi. User PIN: mt khu nhn dng ng nhp, thu bao mun vo phng hi thoi phi nhp ng mt khu ny. Admin PIN: mt khu ca thu bao ch tr cuc hi thoi. Khi thu bao ng nhp vi mt khu ny th c th qun tr c h thng phng hi thoi nh kha phng chng hn. Mt khu ny khng cn thit i vi nhng cuc hi thoi khng cn ngi ch tr.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 99

Join Message: chn la thng bo cho mng thu bao ng nhp vo cuc hi thoi. Mc nh ca mc ny l none ngha l khng c thng bo cho mng no. Leader Wait: ty chnh ny c 2 la chn: o Yes: i thu bao ch tr trc khi bt u cuc hi thoi. o No: cuc hi thoi s bt u khng cn i thu bao ch tr. User Count: thng bo s thu bao c trong cuc hi thoi. User join/leave: thng bo thu bao va ng nhp hoc thot khi phng hi thoi. Music on Hold: kch hot chc nng nhc ch trong khi phng hi thoi ch c mt thu bao. Sau khi cu hnh xong, ta quay s 8000 v nhp mt khu ng nhp vo phng hi thoi va khi to. By gi ta trong phng hi thoi v bt c khi no c thu bao ng nhp hoc thot khi phng hi thoi th cc thu bao cn khc s c thng bo. kim tra chc nng ny, ta c th ly mt in thoi khc v quay s 8000 ri nhp mt khu. Ta s nghe c thng bo mt thu bao no ng nhp vo phng hi thoi. Nu c 2 thu bao tr ln trong phng hi thoi, cc thu bao s c th m thoi vi nhau. 6.3.9 Follow Me (Chuyn cuc gi khi bn) Sau khi ci t ti khon cc thu bao, ta c th ch nh trc cc thu bao khc tr li nu thu bao c gi khng tr li. y l cch chng ta ci t chc nng . Chn mc Follow Me bn tri ca s mn hnh s hin ra ca s giao din nh sau:

Hnh 6.22 Ca s giao din cu hnh dch v Follow Me Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 100

Chn la thu bao m ta mun ci t dch v (la chn cc thu bao nm bn phi mn hnh. Trong trng hp ny, chng ta s chn thu bao dinh101 s hin ra giao din:

Hnh 6.23 Cu hnh dch v Follow Me y l cc thng s chnh: Ring strategy: chn la ch gi. Extension List: danh sch cc thu bao s chuyn cuc gi khi thu bao c gi khng tr li. Ring time: thi gian chung. Trong trng hp tt c cc s thu bao trong danh sch Extension List khng tr li cuc gi th ta s ch nh hng n tip theo ca cuc gi ti trong mc Destination if no answer. Trong trng hp ny l yu cu li li nhn thoi nh hnh di:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 101

Hnh 6.24 Cu hnh ty chn Destination if no answer Bt k khi no thu bao dinh101 c gi, Asterisk s c gng kt ni vi thu bao ny v nu khng c tn hiu tr li, n s chuyn sang gi thu bao viet102. Nu vn khng c tn hiu tr li, n s tip tc chuyn cuc gi n thu bao phuc103. Nu vn khng c tn hiu tr li th s c thng bo cho ngi gi li li nhn trong hp th thoi Voicemail (ta khai bo iu ny trong mc Destination if no answer). Nhp chut chn Submit Changes. Sau chn Apply Configuration Changes lu li cu hnh.

Hnh 6.25 Lu li thit lp 6.3.10 Callback (T ng gi li) Sau khi ci t dch v Callback, khi thu bao thc hin cuc gi n tng i, tng i s ngt cuc gi v gi li cho thu bao .Cuc gi li ny s chuyn thu bao gi n mt thu bao ni b hoc truy cp mt dch v no . Dch v Callback s gip thu bao gi gim c chi ph cuc gi. cu hnh dch v, ta chn mc Callback bn tri ca s mn hnh s hin ra ca s giao din ca dch v.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 102

Hnh 6.26 Giao din cu hnh dch v Callback y l thng s c bn ta cn quan tm: Callback Description: nhp tn ca nhm Callback. Callback Number: nhp s in thoi ca thu bao m tng i s thc hin dch v Callback. Nu trng mc ny th tng i s thc hin dch v Callback i vi bt k cuc gi n no. Delay Before Callback: thi gian tng i tr hon trc khi gi li. Trong mc Destination after Callback ta s cu hnh cuc gi li ca tng i hng n mt thu bao c th hoc mt dch v no . Trong trng hp ny l chuyn cuc gi li n h thng IVR nh hnh trn. Nhp Submit Changes lu li cu hnh. Cui cng nhn Apply Configuration Changes nh hnh di bt u p dng dch v.

Hnh 6.27 p dng dch v

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 6.3.11 Voicemail (Hp th thoi)

Trang 103

y l tnh nng cho php h thng nhn cc thng ip tin nhn thoi, mi my in thoi c khai bo trong h thng Asterisk cho php khai bo thm chc nng hp th thoi. Mi khi s in thoi bn hay ngoi vng ph sng th h thng Asterisk nh hng trc tip cc cuc gi n hp th thoi tng ng khai bo trc. Voicemail cung cp cho ngi s dng nhiu tnh nng la chn nh mt khu xc nhn khi truy cp vo hp th thoi, gi mail bo khi c thng ip mi. Asterisk cung cp kh nng xy dng ng dng Voicemail, vi kh nng ny gip cho ngi s dng in thoi khng b l bt c cuc gi in thoi no. y l mt s tnh nng ca h thng Voicemail: Khi ngi gi khng c tr li, my khng c kt ni mng hay my in thoi ang bn, h thng u c thng ip ring thng bo tnh trng ca my thu bao c gi v pht thng ip mi li tin nhn. Mi hp th u c qun l bng mt khu v th mc ring. Khi thng ip c nhn, h thng Voicemail c th gi qua mail thng bo, tt nhin c km theo file thng ip. Nhng thng ip li cho trong h thng hon ton c th thay i ph hp vi ng cnh s dng. Khng nht thit phi s dng thng ip mc nh. Chn mc Extensions bn tri ca s mn hnh

Hnh 6.28 Cu hnh Voicemail cho tng Extension

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Trong mc Voicemail & Directory: Status: c 2 la chn. o Enabled: kch hot hp th thoi. o Disabled: v hiu ha hp th thoi. Voicemail Password: mt khu ca hp th thoi.

Trang 104

Hnh 6.29 Thit lp cc ty chn ca Voicemail


Ngoi ra, c th kim tra Voicemail trc tip trn my in thoi theo 2 cch: Quay s *97 ng nhp vo hp mail ca thu bao ang s dng (ch yu cu nhp mt khu ca ti khon mail). Quay s *98 ng nhp vo hp mail ca thu bao bt k (yu cu nhp tn ng nhp v mt khu ca ti khon mail). 6.3.12 Call Forward (Chuyn hng gi) Khi khng nh, hoc i cng tc m ngi s dng khng mun b l tt c cc cuc gi n vn phng hay nh ring th hy ngh ngay n tnh nng chuyn cuc gi Call Forward. Call Forward l dch v cho php thu bao chuyn cc cuc gi n s my ca mnh sang mt s my khc, s my c th l s di ng, s c nh hoc s ca hp th thoi. y l tnh nng thng c s dng trong h thng Asterisk, thu bao c th t ci t s dng khi cn thit. Chc nng cho php chuyn mt cuc gi n mt hay nhiu s my in thoi c nh trc. Mt s trng hp cn chuyn cuc gi nh chuyn cuc gi khi bn, chuyn cuc gi khi khng tr li, chuyn cuc gi tc thi, chuyn cuc gi vi thi gian nh trc. Tt nhin trc tin ta phi kch hot dch v chuyn cuc gi th mi c th thc hin c. Ta c th kch hot dch v ny trc tip trn in thoi.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 105

Hnh 6.30 Chuyn cuc gi qua giao din X-Lite kch hot dch v chuyn cuc gi cho thu bao 101, thu bao thc hin cc bc nh sau: Quay s *72, s c thng bo yu cu nhp s thu bao mun chuyn cuc gi ri nhn #. Tip theo s c thng bo yu cu nhp s thu bao m cc cuc gi s c chuyn ti ri nhn #. Cui cng s c thng bo xc nhn kch hot thnh cng dch v. hy b dch v Call Forward ca tt c cc thu bao ni b, thu bao quay s *73. Sau s c thng bo xc nhn hy dch v. hy b dch v Call Forward ca mt thu bao c th, thu bao quay s *74, s c thng bo yu cu nhp s thu bao mun hy dch v ri nhn #. Sau khi nhp xong, s c thng bo xc nhn hy dch v Call Forward ca thu bao .

6.3.13 Call Pickup (Nhn cuc gi t xa trong cng mt nhm)


Call Pickup l tnh nng rt hu dng, y l tnh nng cho php chng ta t my in thoi ny c th nhn cuc gi ca my in thoi khc cng nhm ang rung chung. Mt v d c th nh khi ta i qua phng ban khc c cng vic th my in thoi ca ta rung chung, c ai ang gi cho ta m khng c ai nhc my, lc ny thay v chy v phng mnh nghe in thoi th ta mn my in thoi ca ng nghip v quay s *8 ri n s in thoi ca ta (*8SoDienThoai#), th l ta tr li c cuc gi in thoi . y chnh l tnh nng Call Pickup. Lu l Call Pickup ch c thc hin khi c 2 my c cng callgroup v pickupgroup. cu hnh cc my c cng callgroup v pickupgroup, ta chn mc Extension bn tri ca s mn hnh s hin ra giao din nh sau: Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 106

Hnh 6.31 Chn la thu bao cu hnh dch v Call Pickup Trong mc Device Options, chnh callgroup = 1 v pickupgroup = 1 cho cc thu bao.

Hnh 6.32 Cu hnh Callgroup v Pickup Group 6.3.14 IVR (ng dng tng tc thoi) ng dng tng tc thoi IVR c rt nhiu ng dng trong thc t, khi gi in thoi n mt c quan hay cng ty no , ta thng nghe thy cc thng ip nh Xin cho qu khch gi n cng ty chng ti, vui lng nhn phm 1 nghe gii thiu v cng ty, nhn phm 2 c h tr k thut, sau ty vo s tng tc ca thu bao gi n, h thng Asteisk s nh hng cuc gi theo mong mun. Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 107

Khi mun xem im thi, mun bit tin cc in thoi ca thu bao, mun bit t gi USD hin nay nh th no, hay kt qu s s tt cc nhng yu cu trn u c th thc hin qua ng dng tng tc thoi IVR. Chn mc IVR bn tri ca s mn hnh s hin ra giao din nh sau:

Hnh 6.33 Giao din cu hnh IVR y l cc thng s chnh: Change Name: tn ca h thng IVR s dng. Timeout: y l thi gian h thng IVR tr hon trc khi chuyn cuc gi n mt thu bao ni b hay dch v no trong trng hp thu bao gi khng nhn phm la chn no. Announcement: chn tp tin ghi m dng lm thng bo cho thu bao gi n. Sau tin hnh nhp cc ty chn m bn yu cu cho IVR ny khi ngi gi nhn ty chn thch hp.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 108

Hnh 6.34 Thit lp cc ty chn IVR Nu bn cn c nhiu la chn hn trong IVR th nhn nt Increase Options. Trong IVR ny, chng ta s thc hin vi yu cu nh sau: T s 1 n s 3, chng ta chn Extension: Phm 1: chn Extension 100 (user Dinh) Phm 2: chn Extension 101 (user Toan) Phm 3: chn Extension 102 (user Quang) Phm 4: (chng ta s thay i thnh k t t) chn Extension 100. Vi Extension cui cng (m chng ta thay i thnh ch "t"), nu ngi gi khng nhn bt k ty chn no, cuc gi s c gi n Extension tng ng vi phm t.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 109

Hnh 6.35 Thit lp ty chn cho Extension cui Sau khi hon tt nhn Save v Apply Configuration Changesed pha trn ca mn hnh.
,

Kim tra bng cch quay s 7777, Asterisk s m phng mt cuc gi n v bn s nghe c thng bo ca h thng IVR. 6.3.15 Time Conditions (Xc lp thi gian biu) Vi dch v ny, chng ta c th to ra nhiu ch thi gian khc nhau v s dng cc ch ny kt hp vi Inbound Route x l cc cuc gi n trn ng trung k mt cch linh hot. Trc ht ta cn to Time Groups. Chn mc Time Groups bn tri ca s mn hnh s hin ra giao din nh sau:

Hnh 6.36 To Time Group Ngay Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing To mt Time Group c tn l Ngay nh hnh trn. Nhp chut chn Submit lu li cu hnh

Trang 110

Sau chn Apply Configuration Changes bt u p dng dch v nh hnh di:

Hnh 6.37 p dng cu hnh Tip theo ta s cu hnh dch v Time Conditions. Chn mc Time Conditions bn tri ca s mn hnh s hin ra giao din nh sau:

Hnh 6.38 Ca s giao din dch v Time Conditions

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 111

To mt Time Condition c tn l Day v c Time Groups l Ngay.

Hnh 6.39 To Time Condition Day Trong mc Destination if time matches ta cu hnh cc cuc gi ti tng i s c chuyn tip ti h thng tng tc thoi IVR nu cuc gi n nm khong thi gian ca Time Group Ngay.

Hnh 6.40 Cu hnh cc cuc gi thuc Time Group Ngay Trong mc Destination if time does not match ta s cu hnh cc cuc gi n khng nm trong khong thi gian ca Time Group Ngay. Cc cuc gi s c chuyn n hp th thoi ca thu bao dinh101.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 112

Hnh 6.41 Cu hnh cc cuc gi khng thuc Time Group Ngay Nhp chn Submit lu li thit lp. Sau chn Apply Configuration Changes bt u p dng dch v.

6.3.16 Day/Night Mode Control (Chuyn i ch ngy m)


Dch v ny cho php chng ta chuyn hng cc cuc gi n tng i m khng cn truy cp vo giao din Web FreePBX iu chnh. Chc nng ny rt hu dng khi cn phi chuyn hng cuc gi mt cch nhanh chng. Mt v c th nh trng hp cng ty phi ng ca sm v thi tit xu. Trong trng hp ny thu bao ni b ch cn quay mt con s ngn th tt c cuc gi n tng i s c chuyn sang ch night (yu cu thu bao gi n li tin nhn Voicemail hoc chuyn n mt dch v no ,). Chn mc Day/Night Control bn tri ca s mn hnh s hin ra giao din cu hnh dch v nh sau:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 113

Hnh 6.42 Giao din cu hnh dch v Day/Night Mode Control y l cc thng s chnh chng ta cn quan tm: Day/Night Feature Code Index: l mt m s nm trong khong t 0 n 9, th thu bao ni b s quay s *28< m s> chuyn i gia 2 ch Day v Night. Description: tn m t cho ch chuyn i ny. Current Mode: ch hin ti (l Day hoc Night). Optional Password: mt khu c th chuyn i ch . Tnh nng ny nhm mc ch bo v ch hin ti khng b thay i bi cc thu bao cha c cho php. Trong ch Day ta ci t hng n ca cc cuc gi ti tng i. Trong trng hp ny l Time Conditions nh hnh di:

Hnh 6.43 Chn hng n trong ch Day

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 114

Trong ch Night ta ci t hng n ca cc cuc gi ti tng i. Trong trng hp ny l Terminate Call nh hnh di:

Hnh 6.44 Chn hng n trong ch Night Vy l ta cu hnh xong dch v, ch Day cc cuc gi s nh hng ti dch v Time Conditions, ch Night cc cuc gi s b ngt. Thu bao ni b quay *280 chuyn ch Day/Night. 6.3.17 Speed Dial (Quay s nhanh) Nu chng ta cn gi cho ai mt cch nhanh chng m khng mun mt thi gian tm s in thoi ca h trong danh b th chng ta c th s dng chc nng quay s nhanh. y l tnh nng cng thng c s dng gi nhanh nhng con s kh nh, thay v gi mt con s di th ch cn gi mt con s ngn gn d nh. Chc nng Asterisk Phonebook s gip chng ta thc hin c iu ny. Chn mc Asterisk Phonebook bn tri ca s mn hnh s hin ra giao din nh sau:

Hnh 6.45 Giao din cu hnh Speed Dial Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing y l cc thng s ta cn quan tm: Name: tn thu bao. Number: s in thoi ca thu bao. Speed dial code: s quay nhanh. Set Speed Dial?: xc nhn s dng s quay nhanh trn.

Trang 115

Sau khi nhp xong cc thng s nhn Submit change lu li thit lp. Khi thc hin cuc gi quay s nhanh th nhn *0<Speed dial code> Ngoi ra, ta c th gn cc s quay nhanh ny trc tip qua in thoi. Cc bc thc hin nh sau: Quay s *75, ta s nhn c thng bo yu cu nhp s quay nhanh v nhn phm #. Sau , ta s tip tc nhn c thng bo yu cu: o Nhn phm 1 nghe thng bo s quay nhanh trn c gn cho s in thoi no. o Nhn phm 2 gn s quay nhanh mi. o Nhn phm 3 thay i s thu bao ca s quay nhanh trn. Sau khi nhp xong v nhn phm #, ta s nghe c thng bo xc nhn s quay nhanh c gn cho s thu bao . 6.3.18 System Recordings (H thng ghi m) H thng ghi m l mt chng trnh c sn trong FreePBX cho php ghi m, ci t thng bo, nhc nh,... c c cc tp tin ghi m, ta chn mc System recordings bn tri ca s mn hnh bt u cu hnh dch v. y l giao din cu hnh:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 116

Hnh 6.46 Giao din cu hnh dch v System recording C hai phng php a cc tp tin ghi m vo s dng: Ghi m trc tip qua in thoi. Ti ln cc bn ghi m c sn. 6.3.18.2 Ghi m trc tip T giao din chnh ca dch v System recording. Ta chn s in thoi ca thu bao dng ghi m sau chn Go nh hnh di:

Hnh 6.47 Chn thu bao mun ghi m Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 117

Trong trng hp ny ta s dng in thoi ca thu bao 100 quay s *77 bt u ghi m.

Hnh 6.48 Quay s *77 ghi m Sau khi ghi m, quay s *99 nghe li on ghi m. Nu ta mun ghi m li th quay s *77.

Hnh 6.49 Quay s *99 nghe li on ghi m Nu hi lng vi on ghi m th t tn cho on ghi m ri chn Save lu li. ( y ta lu vi tn l Main Menu)

Hnh 6.50 t tn on ghi m 6.3.18.3 Ti ln cc bn ghi m c sn Nu c mt tp tin ghi m chun b nh dng WAV, ta c th ti ln bng cch nhp ng dn th mc ca tp tin trong my tnh v ti n ln FreePBX.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 118

Hnh 6.51 Ti ln on ghi m Vic ghi m trc tip hoc ti ln cc bn ghi m c sn s c lu tr trong /var/lib/asterisk/sounds/custom. 6.3.19 Calls Recordings (Ghi m cuc gi) c nhiu cuc tho lun v tnh hp php ca vic ghi m li cc cuc hi thoi. Mt s ngi coi khng phi l mt vn nghim trng trong khi mt s khc coi l hnh ng bt hp php. Nu chng ta ghi m cuc hi thoi m khng c s ng ca tt c cc bn, chng c th ang vi phm php lut v vy iu ny cn c cnh bo. i vi nhng ngi mun ghi m cc cuc hi thoi, cc tp tin ghi m c lu gi trong th mc /var/spool/asterisk/monitor hoc chng ta c th ng nhp ti khon Voicemail xem cc tp tin ghi m cuc hi thoi. 6.3.19.1 ng nhp ti khon Voicemail Chng ta c th ng nhp ti khon Voicemail thng qua ca s giao din FreePBX GUI.

Hnh 6.52 Ca s giao din FreePBX GUI Chn mc Recordings s hin ra ca s giao din nh sau:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 119

Hnh 6.53 Giao din ng nhp ti khon Voicemail xem li cc cuc hi thoi c ghi m, ta ng nhp vi tn ng nhp l s in thoi thu bao v mt khu Voicemail ca thu bao . Nhp vo biu tng loa ca ct Monitor tng ng vi thu bao m ta mun nghe li cc cuc hi thoi ca thu bao (ta phi ci t chng trnh Quicktime v phn h tr Adobe Flash Player trn my tnh c th nghe c cc cuc hi thoi). y l ca s giao din sau khi ng nhp:

Hnh 6.54 Cc cuc hi thoi c ghi m ng dn tp tin cu hnh l /var/www/html/recordings/includes/main.conf.php Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 120

C 2 cch thc ghi m cuc gi: ghi m tt c cuc gi v ghi m khi c yu cu. 6.3.19.2 Ghi m tt c cuc gi c th s dng c chc nng ny ta cn phi kch hot n. Chn thu bao m ta mun ghi m trong mc Extension nh hnh di:

Hnh 6.55 Giao din cu hnh thu bao Trong mc Recording Options ta chn Always ghi m li tt c cc cuc gi n v i ca thu bao ny.

Hnh 6.56 Cu hnh ghi m tt c cc cuc gi n v i 6.3.19.3 Ghi m cuc gi khi c yu cu Tng t nh chc nng ghi m tt c cc cuc gi c trnh by phn trn, ta cn phi kch hot chc nng ghi m cuc gi theo yu cu c th s dng n. Chn mc General Settings bn tri ca s mn hnh s hin ra giao din nh sau:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 121

Hnh 6.57 Cu hnh ghi m cc cuc gi theo yu cu Ta kch hot chc nng ny bng cch nhp thng s vo mc Asterisk Dial command options v Asterisk Outbound Dial command options nh hnh trn. w: cho php ngi c gi c th ghi m bng cch nhn *1. W: cho php ngi gi c th ghi m bng cch nhn *1. Mt s ngi nhn xt rng cn phi nhn nhanh *1 mi kch hot c chc nng ny. 6.3.20 Call Parking and Transfer (Chuyn cuc gi) y l chc nng chuyn cuc gi rt hu ch m Asterisk h tr cho chng ta. C mt s in thoi trung gian lm nhim v chuyn cuc gi v hai thu bao c th gp nhau khi thu bao c gi nhn vo s in thoi m thu bao ch gi ang ch trn v t y c th gp nhau v m thoi. cu hnh dch v, ta chn mc Parking Lot bn tri ca s mn hnh s hin ra giao din nh sau:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 122

Hnh 6.58 Giao din cu hnh chuyn cuc gi C 2 cch chuyn cuc gi: c qun l v khng c qun l. 6.3.20.1 Chuyn cuc gi c qun l Mi cuc gi c gn tng ng vi s khai bo ti parket l 70 cng thm 1. V d nh ta c 3 cuc gi cn qun l, cuc gi u tin s c gn s in thoi l 71, cuc gi th 2 s t ng c gn s in thoi l 72, cuc gi th 3 s c gn s in thoi l 73 v c tip tc nh th. Khi ta tip nhn cuc gi v mun chuyn cuc gi , ta thc hin cc bc nh sau: Nhn ##70, sau cuc gi s c gn s v s gn s c thng bo cho ta. Trong trng hp ny s gn l 71. Sau khi nghe thng bo, ta c th gc my v gi n thu bao ca ngi m ta mun chuyn cuc gi n v bo vi ngi nhn 71 nhn cuc gi. Trong khi ch i, thu bao gi s c nghe nhc ch trong khi ang gi my. Nu thu bao c gi t chi nhn cuc gi, ta s nhc my v nhn 71 thng bo vi thu bao gi l thu bao c gi ang bn, khng th nhn cuc gi. Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 6.3.20.2 Chuyn cuc gi khng c qun l

Trang 123

thc hin chuyn cuc gi khng c qun l (ch n gin l ta chuyn cuc gi m khng quan tm ngi c gi c mun tr li hay khng), ta nhn ## thu bao c gi. Chng hn khi bn mun chuyn cuc gi n thu bao 2001, n gin bn nhn ##2001 v gc my. 6.3.20.3 Duy tr cuc gi Cng ging nh vic qun l chuyn cuc gi trn, ta nhn ##70 v nghe thng bo s c gn ri gc my. y l mt cng vic n gin nn khng cn chc nng gi my trn c in thoi. Lc ny ta s duy tr cuc gi n khi ta sn sng nhn cuc gi, nhn 71 (hoc mt s no ) gn cuc gi. Sau khi cuc gi c gn s, thu bao gi n s nghe nhc ch trong khi ch tin hiu t ngi c gi. 6.3.21 Remote Extension (Extension ng nhp t xa) 6.3.21.1 NAT port (Forwarding Port) Ti sao cn phi NAT port? ch mc nh Router s chn hu ht cc port, trong c cc port dng cho giao thc SIP (5060), IAX2 (4569), RTP (10001-20000). Gi s rng c mt nhn vin ang i cng tc ngoi mun gi in thoi v cng ty bng Remote Extension. Vic anh ta cn lm s l kt ni vo h thng VoIP ca cng ty. Vy nu khng m Port th anh ta s khng kt ni c vo trong h thng v gi tin ng k SIP b chn router. Ta s tin hnh NAT port nh sau: M trnh duyt vo a ch cu hnh ca Modem, y nhm thc hin ti s dng Modem Bluecom 5370 ca VNPT nn a ch cu hnh s l: http://192.168.1.1/, ng nhp vi User v Passpword mc nh l admin. h tr cho chc nng Remote Extension ta cn tin hnh m Port 5060 (h tr cho giao thc SIP) v Port 10001-20000 (h tr cho vic truyn d liu thoi thi gian thc).

Hnh 6.59 NAT port Router Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 124

Kim tra vic NAT port: Khi cu hnh NAT port th vic rt cn thit l kim tra xem cc port m c thnh cng hay khng, vic ny rt quan trng v n h tr cho vic chn on li nu cc dch v sau ny khng chy c. C mt cng c kim tra port rt nhanh v chnh xc l PFPort Checker. Ta c th ti v t ng dn http://portforward.com/store/PFPortChecker.exe

Hnh 6.60 Check port 5060 thnh cng 6.3.21.2 Gii thiu v No-IP No-IP l dch v c cung cp cho nhng ai c nhu cu lm web server hoc cc dch v chy trn nn IP m khng c IP tnh, hin No-IP cung cp dch v min ph cho ngi dng c nhn, sau khi ng k thnh cng trn trang Web https://www.no-ip.com/ bn s s hu c 3 host min ph. Cch thc hot ng: Khi bt router, ISP cung cp cho ta 1 a ch IP ng, IP ny s thay i sau 24h t khi c cung cp, do cc dch v nh remote extension ca VoIP s cn phi cp nht li IP sau mi ngy lm vic, cng vic ny s rt nhm chn v lm mt thi gian ca admin. No-IP l mt trong cc gii php gii quyt vn ny. Mi khi IP thay i, No-IP s t ng cp nht li IP mi tng ng vi host m chng ta ng k vi h. V d nh ta dng Host mypbx.no-ip.info l a ch web ca server Asterisk, khi IP ca Router thay i th dch v No-ip s cp nht IP mi vo host ny, ta khng cn quan tm n IP ny na, tt c by gi ch l khai bo host l xong. cp nht mi IP thay i ca Router, No-ip cung cp cho ta mt cng c l Dynamic Update Client (DUC), ta ci t chng trnh ny vo PC cng mng LAN vi Server, c th Download ti a ch: http://www.no-ip.com/client/ducsetup.exe.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 125

Hnh 6.61 Ca s giao din chng trnh DUC

Hnh 6.62 Cc Host c ng k trn No-IP


Nh vy sau ny, bt c ni u ch cn c mng Internet l ta vn c th truy cp vo giao din Web FreePBX Server ca chng ta vi a ch nh sau:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 126

Hnh 6.63 ng nhp FreePBX thng qua Host

Hnh 6.64 Truy cp giao din FreePBX thng qua Host 6.3.21.3 Cu hnh Remote Extension Remote Extension cho php cc thu bao c th truy cp vo PBX Server bt c ni no trn mng Internet ging nh vic ng nhp trong mng Local ni b cng ty. Chc nng ny mang tnh linh hot v hu dng cho nhng nhn vin c cng vic hot ng bn ngoi cng ty v thng xuyn lin lc vi cc nhn vin khc trong cng ty.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 127

Vic thit lp Remote Extension ging nh vic thit lp cho mt Extension bnh thng trong ni b nhng cn lu vic thng s quan trng, l nat = yes cho php cc Extension bn ngoi c th truy cp v PBX Server ca mnh.

Hnh 6.65 Thit lp NAT cho Remote Extension ng thi ta cn khai /ect/asterisk/sip_nat.conf nh sau: nat = yes externhost = mypbx.no-ip.info localnet = 192.168.1.0/255.255.255.0 externrefresh = 10 Cc bc thit lp thng s trn X-Lite ging nh trc nhng ch khc ch Domain ca Server: bo mt s thng s khc trong file

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 128

Hnh 6.66 Thng tin ng nhp ca X-Lite thng qua Host

Hnh 6.67 Remote Extension ng nhp thnh cng Sau khi cu hnh th Extension 103 vn c th kt ni gi v cho cc in thoi khc trong cng ty bnh thng nh ang trong ni b.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 6.3.22 Thit lp Trunk cho cc cuc gi trong FreePBX 6.3.22.1 Trunks

Trang 129

kt ni vi nhng h thng bn ngoi nh PSTN th chng ta cn phi c nhng ng Trunk. y l nhng ng kt ni trc tip vi nhng nh cung cp dch v nh PSTN hay VSP (VoIP Service Provider) m chng ta phi tr ph cho h hoc l nhng ng kt ni trc tip hai Server Asterisk vi nhau. Nhng ng Trunk ny s nh tuyn cho nhng s ng k t trong h thng kt ni vi nhng thu bao ca th gii bn ngoi. Nu cng ty c nhiu chi nhnh cc vng khc nhau th chng ta nn mua Trunk ca cc nh cung cp dch v gn nht, nh th s tit kim chi ph cho cc cuc gi qua VoIP.

Hnh 6.68 M hnh kt ni cc Trunk ca cng ty Trong phm vi n ny, nhm thc hin ti s dng 2 Trunk kt ni ra bn ngoi: ng dy PSTN Vit Nam vi s in thoi bn l (061)3855659. Nh cung cp dch v VoIP Flowroute (www.flowroute.com) vi user name: 85594878, password: 6gdeYFtbMadP, v khng mua s DID Number. Lu : v ti mang tnh cht th nghim nn nhm thc hin ti khng mua trc tip VoIP Trunk m ch s dng Account dng th dch v VoIP ca nh cung cp Flowroute. V mi khi ta ng k 1 Account trn www.flowroute.com th nh cung cp cho php ta s dng min ph SIP Trunk vi ti khon l $0.25 c th c dng gi th n bt c thu bao no trn th gii vi cc ph mi cuc gi l $0.05/pht (tng ng vi khong thi gian cho php l 5 pht vi mc ch l kim tra th cht lng cuc gi). Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 130

Hnh 6.69 To Trunk trong FreePBX 6.3.22.1.2 To ZAP Trunk Chn Trunks > Add ZAP Trunk v in cc thng s nh sau:

Hnh 6.70 To ZAP Trunk Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Trunk Discription: ZAP Trunk (Tn ca ZAP Trunk). Dial Rules: quy tc bm s c th s dng ng trunk.

Trang 131

Zap Identifier: mc nh l g0, c hiu l cng ni vi line PSTN. y ta t tn l 1 (cng vi s knh ca Card X100P). Vi mi ng trunk to xong, chng ta phi nh tuyn nhng cuc gi cho cc s trong tng i c th gi ra bn ngoi qua nhng ng trunk ny. 6.3.22.1.3 To SIP Trunk y ta s to ng Trunk vi nh cung cp dch v VoIP Flowroute. Thng tin chi tit v cch cu hnh FreePBX c th ng k Trunk c vi nh cung cp dch v c hng dn trn trang web ca Flowroute https://www.flowroute.com/accounts/interconnection/configurator/. Chn Trunks ri chn Add SIP Trunk v in cc thng s nh sau:

Hnh 6.71 To SIP Trunk Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 132

Sau khi chn Submit changes v Reload ta dng lnh sip show registry kim tra SIP Trunk c ng k cha.

Hnh 6.72 ng k SIP Trunk thnh cng 6.3.23 Outbound Routes (nh tuyn cuc gi ra) y l ni chng ta nh tuyn nhng cuc gi ra th gii bn ngoi cho cc s ng k trong tng i PBX ca chng ta. Nh cp trn, vi mi ng Trunk th ta s to mt quy tc nh tuyn cuc gi ra bn ngoi cho chng mc Outbound Routes. Chng ta s to mt ng Route tn PSTN thng qua ZAP Trunk gi cho cc thu bao trong nc Vit Nam bng ng line PSTN v mt ng Route tn via_flowroute thng qua SIP Trunk thc hin cho cc cuc gi quc t. u tin to Route cho ng line PSTN. Chn Outbound Routes ri chn Add Route v in cc thng s nh hnh di:

Hnh 6.73 Cu hnh OutBound Route cho ZAP Trunk Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Route Name: PSTN.

Trang 133

Dial Pattern: 0Z. (l Pattern gi cc s lin tnh cng nh cc s di ng trong nc) v NXXXXXX (l Pattern thc hin cho cc cuc gi ni ht). Trunk Sequence: ZAP/1 (tn ca ZAP Trunk). Sau ta to tip ng Outbound kt ni vi ng Trunk ca nh cung cp dch v VoIP. Chn Outbound Routes ri chn Add Route v in cc thng s nh sau:

Hnh 6.74 Cu hnh OutBound Route cho SIP Trunk Route Name: via_flowroute. Dial Pattern: 00|. (l Pattern thc hin cc cuc gi quc t). Trunk Sequence: SIP/flowroute (tn ca SIP Trunk). 6.3.24 Mt s kt qu thc hin a. Kt qu thc hin cuc gi t bn ngoi vo ni b (t mt s in thoi di ng 01685078238 n Softfone Extension 100) qua ng Line PSTN Vit Nam nh sau: Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 134

Hnh 6.75 Cuc gi bn ngoi vo ni b Ta c th quan st tin trnh thit lp cuc gi ca tng i thng qua lnh set verbose 15

Hnh 6.76 Tin trnh cuc gi vo ni b trn CLI


Ta c th thy cc dng lnh nh: o Executing Dial(DAHDI/1-1, SIP/100|20|W): ang thit lp cuc gi t bn ngoi qua DAHDI Trunk n ti khon SIP/100. o Called 100: kt ni n Extension 100. o SIP/100 is ringing: Softfone 100 ang rung chung. o SIP/100 answered DAHDI/1-1: Softfone 100 tr li, cuc gi kt ni thnh cng. b. Kt qu thc hin cuc gi t Softfone trong ni b tng i gi s thu bao di ng 01685078238 thng qua ng Line PSTN Vit Nam nh sau: Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 135

Hnh 6.77 Cuc gi t ni b ra bn ngoi thng qua ZAP Trunk

Hnh 6.78 Tin trnh cuc gi ra bn ngoi thng qua ZAP Trunk trn CLI Ta c th thy cc dng lnh nh: o Executing Dial(SIP/100, DAHDI/1/01685078238|300|W): ang thit lp cuc gi t ti khon SIP/100 n thu bao s 01685078238 qua DAHDI Trunk c tn l 1. o Called 1/01685078238: kt ni n thu bao s 01685078238. o DAHDI/1-1 answered SIP/100: cuc gi kt ni thnh cng. c. Kt qu thc hin cuc gi t Softfone trong ni b gi s thu bao quc t 1.562.6846327 nc M thng qua mng VoIP ca nh cung cp dch v Flowroute (USA). Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 136

Hnh 6.79 Cuc gi t ni b ra bn ngoi thng qua SIP Trunk

Hnh 6.80 Tin trnh cuc gi ra bn ngoi thng qua SIP Trunk trn CLI Ta c th thy cc dng lnh nh: o Executing Dial(SIP/100, SIP/flowroute/15626846327|300|W): ang thit lp cuc gi t ti khon SIP/100 n thu bao s 15626846327 (bn USA) qua SIP Trunk c tn l flowroute. o Called flowroute/15626846327: kt ni n thu bao s 15626846327. o SIP/flowroute answered SIP/100: cuc gi kt ni thnh cng.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 6.4 Mt s chc nng ca A2Billing 6.4.1 Providers and trunks

Trang 137

Sau y chng ta s thc hin cc thit lp c th to ra cc s Card Number thc hin cuc gi. Chng ta cn phi lm kh nhiu cc thit lp trc khi c s Card Number c th gi in c. Trc tin l qui nh cc ng gi ra bn ngoi gi l cc Trunks. Chng ta thit lp mt trunk gi in ra ngoi PSTN trong FreePBX vi tn l ZAP/1. Ta s thit lp n cho A2Billing. 6.4.1.1 Providers Providers l cc nh cung cp dch v thoi gip cho cng ty c th lin lc ra bn ngoi. Hin ti ta c hai nh cung cp dch v ph bin l PSTN Provider vi ng Line in thoi truyn thng, v VoIP Provider lin lc thng qua ng truyn Internet. menu bn tay tri, chn Providers. u tin ta chn Add Provider, ta s t tn l PSTN Provider. Provider name: PSTN Provider. Description: ty .

Hnh 6.81 Thit lp Provider Chn Confirm Data, v ta c PSTN Provider c lit k trong Provider List. Ta c th Edit hoc Delete nu cn thit. Thc hin tng t vi Provider c tn l VoIP Provider

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 138

Hnh 6.82 List Provider c thit lp


6.4.1.2 Trunks Sau khi to hai Providers xong ta tin hnh to Trunk trong mc Add Trunk. u tin ta s to mt ZAP Trunk vi nh cung cp dch v PSTN, in vo nhng thng tin sau: VoIP-Provider: PSTN Provider (tn nh cung cp dch v PSTN to trn). Label: PSTN Trunk (tn ca Trunk). Provider Tech: DAHDI (do ta ci gi Dahdi h tr cho Card giao tip PSTN). Provider IP: 1 (tn ca ng ra PSTN ta t trong FreePBX). Additional Parameter: trng. Status: Active (kch hot Trunk). Cc mc Add Prefix v Remove Prefix s cho ta cc cch gi in ph hp vi nhu cu. Tuy nhin khi ta trng th s thun tin nht.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 139

Hnh 6.83 Thit lp ZAP Trunk Chn Confirm Data. By gi trong Trunk List s c 2 trunk hin ra l Zap label v default. Ta s delete trunk default i v n khng c cng dng g.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Tng t nh vy, ta thit lp trunk cho nh cung cp dch v VoIP.

Trang 140

Hnh 6.84 Thit lp SIP Trunk Ch : Mc d l Provider IP nhng nu ta ch in domain IP ca nh cung cp dch v th A2Billing khng th ng k (register) c vi nh cung cp dch v v s khng thc hin cuc gi c. y cng l mt trong nhng li nh m A2Billing cha hon thin. Chn List Trunk ta s thy 2 ng Trunk ra ngoi c thit lp nh sau:

Hnh 6.85 Danh sch Trunk thit lp 6.4.2 Rate Cards By gi n lc ta thit lp mt s Ratecards. Nh trn ta ni Ratecards c dng ta qui nh chi ph thc hin cuc gi n mt a im c th no . Ta s to 2 Ratecards, mt Ratecards Domestic cho cc cuc gi trong nc s dng PSTN Trunk, v mt Ratecards International cho cc cuc gi ra nc ngoi thng qua VoIP Trunk, ti v cc ph khi thc hin mt cuc gi quc t thng qua VoIP Trunk s r hn rt nhiu so vi khi ta thc hin gi trc tip t PSTN Trunk. Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 141

u tin ta s thit lp chi ph cho cc cuc gi qua ng dy PSTN cho tt c cc cuc gi trong nc. M mc RATES bn tri v chn RateCards.

Hnh 6.86 To RateCard in vo nhng thng tin sau: Tariffname: Domestic. Start date: default. Expiry date: default. Trunk: Zap label. DNID Prefix: all. CallerID Prefix: all.

Hnh 6.87 To RateCard cho cc cuc gi trong nc

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 142

Chn Confirm Data. Ta s c kt qu local hin trong List RateCard. Ta cng c th edit hoc delete cc Rate Card nu cn thit. V ta cng to RateCard International thng qua VoIP Trunk.

Hnh 6.88 To RateCard cho cc cuc gi quc t Sau khi chn Confirm Data ta s thy RateCards List nh sau:

Hnh 6.89 Danh sch cc RateCard c thit lp 6.4.3 Rates Rate l chi ph thc hin cuc gi n mt ni no v cch tnh cc cuc gi do ta s quy nh da theo Dial Prefix ca mi quc gia khc nhau cng nh khu vc ca quc gia . V d nc Anh c Prefix l 44, nhng trong s phn bit: 441, 442, 443 l Prefix gi cho in thoi bn nc Anh v 4477, 4478, 4479 l Prefix gi cho s di ng nc Anh.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 143

Ta c th tm hiu v tham kho cc Prefix ny mc PROVIDERS:

Hnh 6.90 Danh sch Prefix ca cc quc gia trn th gii Ta c th xa v b sung cc Prefix nu cn thit. Chn Rates v chn Add Rate bn tri to Rate cho cc cuc gi quc t. in vo cc thng s sau:

Hnh 6.91 To Rate cho cc cuc gi quc t Ratecard: International (dng SIP Trunk cho cuc gi quc t). Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Dial Prefix: 1562 (Prefix ca United States).

Trang 144

Buying Rate: 1 (s tin ta tr cho nh cung cp dch v, 1USD/pht). Buyrate Min Duration: trng (thi gian ngn nht cho 1 cuc gi n v: giy). Buyrate Billing Block: trng (Block s giy cho 1 cuc gi n v: giy).

Hnh 6.92 Thit lp thng s cho Rate cc cuc gi quc t Selling Rate: 2 (s tin ta bn li cho ngi dng, 2USD/pht). Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 145

Sellrate Min Duration: trng (thi gian ngn nht cho 1 cuc gi n v: giy). Sellrate Billing Block: trng (Block s giy cho 1 cuc gi n v: giy). Connect Charge: trng (ph tnh khi mt cuc gi c kt ni). Disconnect Charge: trng (ph tnh khi mt cuc gi khng c kt ni). Minimum Call Cost: trng (mc ph thp nht cho mt cuc gi). Start Date: default. Stop Date: default. Start Time: default. End Time: default. Trunk: NOT DEFINED (tn ng Trunk dng cho im m ca cuc gi ny, hoc Not Defined dng Trunk ca RateCard). Thc hin tng t cho Rate thc hin cuc gi n nc Anh, Canada

Hnh 6.93 Danh sch cc Rate cc nc quc t Ta to Rate cho cuc gi quc t n M v Anh s dng ZAP Trunk vi tn l flowroute m ta ng k vi nh cung cp dch v v thit lp trong FreePBX. Vn tip theo l cc cuc gi trong nc th sao? Ta s to thm mt Rate na cho mc ch thc hin cuc gi trong nc thng qua SIP Trunk ng line in thoi truyn thng ca nh cung cp dch v PSTN trong nc.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Chn Add Rate v in cc thng tin nh sau:

Trang 146

Hnh 6.94 To Rate cho cc cuc gi trong nc Cc thit lp thc hin ging nh i vi cuc gi quc t ch cn thay i mt s thng s sau: RateCard: Domestic (dng ZAP Trunk cho cuc gi trong nc). Dial Prefix: defaultprefix (s s dng Trunk ny nu cuc gi c thc hin vi nhng Prefix cha c thit lp trong Rates List).

Hnh 6.95 Danh sch cc Rate cc cuc gi trong nc v quc t Ch : vi VoIP ta thng s dng cng lc nhiu nh cung cp dch v. Vi mt prefix chng ta c th to nhiu Rate khc nhau ng vi cc Trunk khc nhau . Khi A2Billing s la chn ng ra cho cc cuc gi theo tiu ch LCR (least cost routing) hoc LCD (least cost dialing) m chng ta s cp sau. Chn Confirm Data. By gi chng ta c 2 Rate. Chng ta c th thit lp thm nhiu Rate khc nhau. Ty thuc vo ng ra ca cuc gi hoc do cch ta tnh tin ngi dng customer Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 6.4.4 Call plan

Trang 147

Call plan l mt nhm cc RateCards. Ti sao chng ta cn phi to nhm cc RateCards. l v mc ch tit kim tin bng cch hng cc cuc gi theo cc trunk hp l t c mt trong 2 tiu ch: LCR (least cost routing) hay LCD (least cost dialing). Hu ht cc chng trnh c chc nng tnh tin cuc gi u tch hp hai thut ton LCR v LCD. Nht l khi chng ta c nhiu ng ra thc hin mt cuc gi. LCR (Least Cost Routing): LCR s s dng trunk m ta mua vo r nht. V th s tit kim chi ph cho ta. LCD (Least Cost Dialing): LCD th s s dng trunk m customer ca ta gi n n r nht. V th s tit kim chi ph cho customer. Callplan s hu ch khi ta thu nhiu ng SIP Trunk nhng nc khc nhau. VD: nu ta thu ba SIP Trunk ba quc gia khc nhau nh: USA, Php, c. V mi nh cung cp dch v VoIP mi quc gia s c gi cc khc nhau cho cng mt ch gi nn khi thut ton LCD v LCR mi c th pht huy tc dng ca n. V chng ta cng khng c s dng nhiu nh cung cp dch v nn y nhm thc hin ti s ch to mt Call Plan n gin. Chn mc RateCard bn tri v chn Create Call Plan. in vo nhng thng tin sau: Name: CALL. LC Type: LCD (ta s tit kim chi ph cho customer). Package: No Package Offer (nu khng ci t dch v khuyn mi cho Callplan ny, nu c ta chn Offer). Remove Inter Prefix: No (khng loi b Prefix gi quc t (00 hoc 011) trc khi thc hin s cn gi. Chng hn nh t Vit nam gi qua Anh, ta phi nhn 0044 vi 00 l Prefix gi quc t t Vi nam, 44 l m nc ca Anh, nu ta chn Yes th ch c 44 c truyn i khi ta thc hin cuc gi). i vi cc nh cung cp dch v VoIP th hu nh chng ta khng cn nhn Inter Prefix khi thc hin cuc gi quc t, do khi tnh cc cuc gi h ch quan tm n Prefix Country Code ca quc gia cn gi m thi.

Hnh 6.96 To Call Plan Sau ta Add c 2 Rate Card ca ta l International v Domestic vo Call Plan Call. Nh vy Customer ca ta s thc hin c c in thoi trong nc qua ng dy PSTN v in thoi quc t qua nh cung cp dch v VoIP. Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 148

Hnh 6.97 Add cc RateCard vo CallPlan 6.4.5 Customers n y chng ta thit lp hon tt nhng nn tng cn thit thc hin cuc gi qua A2Billing. By gi chng ta bt u s dng nhng thit lp cho vic to ra cc Customers. Mt Customer thc cht l mt s Card Number cho ngi dng s dng gi ging nh nhng th VoIP ang c bn rng ri trn th trng Vit Nam. Trc tin, chn Customers bn tay tri, chn Add::Search. V in vo nhng thng tin sau:

Hnh 6.98 To Customer (1) Account Number: default (thng l 10 s c pht mt cch ngu nhin) WebUI Login: c th default hoc thay i, y l Username khch hng Login vo trang web ngi dng. WebUI Password: c th default hoc thay i, y l password ca khch hng Login vo trang web ngi dng. Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Balance: 100.00 (s tin ta to ra cho Card n v: USD)

Trang 149

Hnh 6.99 To Customer (2) in thng tin c nhn ca ngi dng. C th khai bo y hoc ngi dng c th khai bo hoc thay i trn web Customer khi Login vo ti khon ca h.

Hnh 6.100 To Customer (3) Payment Type: Prepaid Card (dng loi Card ti khon tr trc). Callplan: CALL. Status: ACTIVE. Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 150

Simultaneous Access: Simultaneous Access (cho php card ny c s dng cng lc bi nhiu ngi).

Hnh 6.101 To Customer (4) Enable Expiry: No Expiry (khng c hn s dng). Expity Date: ngy ht hn s dng Card, mc ny c tc dng khi Enable Expiry: Expire Date. Expiry Days: s ngy s dng Card, mc ny c tc dng khi Enable Expiry: Expire Days Since First Use/ Expire Days Since Creation. Create SIP Config: Yes (cho php t ng to SIP config). Create IAX Config: No. Chn Confirm Data thm customer ny vo list customer. Ta c th to thm bao nhiu Customer ty . Chn List Customers xem nhng Customers ta c, ta c th edit hoc delete nu cn thit.

Hnh 6.102 Danh sch customer thit lp Mt cch khc to mt lng ln Customers cng mt lc l s dng chc nngGenerate Customers. Ta c th to ra 10,50,100, cards cng 1 lc. in vo nhng thng tin nh hnh sau v chn Generate Cards.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 151

Hnh 6.103 To nhiu Customer cng lc Lu : trong A2Billing cc khi nim nh Customer, Account Code, Account Number, PIN Number, Card Number c coi l nh nhau. 6.4.6 Kt hp FreePBX v A2Billing Chng ta to ra cc Cards thnh cng. thc hin c cuc gi ra bn ngoi ta cn phi kt ni Asterisk vi A2Billing. By gi ta s quy nh bt k cuc gi no trong ni b ra ngoi u phi bm s 777 c thng qua A2Billing qun l vic tnh cc cho tng nhn vin trong cng ty. Ta phi thay i Pattern trong mc Outbound Route ca FreePBX cho c 2 Trunk. i vi ZAP Trunk:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 152

Hnh 6.104 Lin kt FreePBX v A2Billing (1) i vi SIP Trunk:

Hnh 6.105 Lin kt FreePBX v A2Billing (1)

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 153

Chng ta cn to mt extension cho A2Billing. Vi Asterisk chng ta cn edit li file extensions.conf. V cc thu bao trong tng i ni b c Context l frominternal nn ta cn thm mt s dng lnh nh sau: nano /etc/asterisk/extensions.conf Trong context [from-internal-custom], thm vo nhng dng sau: exten => 777,1,Answer exten => 777,n,Wait exten => 777,n,AGI(a2billing.php|1) exten => 777,n,Hangup Sau khi chnh sa li file Extensions.conf ta save v reload li Asterisk. Nh vy by gi, tt c cc Extension trong cng ty chng ta mun thc hin cuc gi ra ngoi phm vi cng ty s phi gi n s 777 (ngoi s 777 ra s khng th thc hin c cuc gi ra ngoi vi bt k s no khc). Ch 1 giy v sau s i qua h thng A2Billing. Ta c th thay i s 777 bng bt c s no khc ta mun. By gi t mt extension 100 mun gi ra ngoi s bm s 777. Ta s nghe yu cu nhp s PIN number. PIN number chnh l s Card Number. nh vo 10 ch s, chng trnh s thng bo s tin cn li ca Card v yu cu ta quay s mun gi vi kt thc l du thng # (pound key). Da vo Prefix ca s in thoi chng trnh s ra thng bo thi gian ta c php gi. V d, ta thc hin mt cuc gi cho s in thoi di ng Vit Nam vi cu trc cuc gi nh sau: 777 (gi n A2Billing) <Please enter your complete PIN number> 7837063549# (PIN number) <You have 100 dolars> <Please enter the number you wish to call, then press the pound key> 01685078238# (s in thoi bn trng H.BK) <You have 500 minutes to call> 6.4.7 Mt s kt qu thc hin vi A2Billing. y nhm thc hin ti s thc hin 2 cuc gi: mt cho s in thoi di ng Vit Nam qua ng PSTN v hai l cho mt s USA qua nh cung cp dch v VoIP flowroute. a/ T Softfone Extension 100 nhn 777 thc hin cuc gi cho s di ng 01685078238 Vit Nam qua ng dy PSTN, ta s nghe yu cu nhp s PIN Number, thng bo s tin cn li trong ti khon v thi gian ti a m ta c th thc hin cuc gi, theo cc bc sau: Nhn: 777. Nghe: Please enter your complete PIN number Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Nhn: 7837063549#.

Trang 154

Nghe: You have 87 dolars and 80 cents, Please enter the number you wish to call, then press the pound key Nhn: 01685078238#. Nghe: You have 439 minutes to call

Hnh 6.106 Cuc gi t ni b cho s in thoi trong nc

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 155

Hnh 6.107 Tin trnh cuc gi t ni b cho s in thoi trong nc ta c th theo di chi tit qu trnh thc hin cuc gi ca A2Billing. Ta set lnh sau: set verbose 15. Trn command line s hin ra: o Playing prepaid-enter-pin-number: yu cu nhp s PIN Number. o Playing prepaid-you-have: s tin c trong ti khon. o Playing prepaid-enter-dest: yu cu nhp s in thoi cn gi. o Playing prepaid-minutes: thi gian cuc gi ti a. o Called 1/01685078238: cuc gi c kt ni qua ng PSTN vi Trunk DAHDI/1. o DAHDI/1-1 answered SIP/100: cuc gi kt ni thnh cng. b/ T Softfone Extension 100 nhn 777 thc hin cuc gi cho s 15626846327 USA qua nh cung cp dch v VoIP, ta s nghe yu cu nhp s PIN Number, thng bo s tin cn li trong ti khon v thi gian ti a m ta c th thc hin cuc gi.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 156

Hnh 6.108 Tin trnh cuc gi t ni b cho s in thoi quc t


Ta c th theo di qu trnh thc hin cuc gi thng qua Command Line nh hnh trn. o Playing prepaid-enter-pin-number: yu cu nhp s PIN Number. o Playing prepaid-you-have: s tin c trong ti khon. o Playing prepaid-enter-dest: yu cu nhp s in thoi cn gi. o Playing prepaid-minutes: thi gian cuc gi ti a. o Called flowroute/15626846327: cuc gi c kt ni qua ng SIP Trunk vi tn l flowroute. o SIP/flowroute answered SIP/100: cuc gi kt ni thnh cng. 6.4.8 Mt s chc nng khc ca A2Billing 6.4.8.1 Call Report Trong Cal Report c mt chc nng quan trng khng th thiu trong bt k dch v tng i no l CDRs (Call Detail Record) h tr cho vic lu tr cc thng tin cuc gi trong c s d liu tin cho vic qun l, tra cu v thng k.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 157

Hnh 6.109 Thng tin chi tit cc cuc gi trong A2Billing Trong A2Billing ta c th theo di, thng k cc thng tin cuc gi theo cc tiu ch nh: Theo ID ca Customer. Theo Customer number. Theo Callplan, Trunk, Provider, Rate. Theo khong thi gian. Theo s in thoi gi hoc c gi, CallerID, 6.4.8.2 T ng cp nht Card Number cho cc Extension Trong qu trnh thc hin cc cuc gi t bn trong cng ty ra bn ngoi, th nhn vin cng ty s cm thy phin phc khi c phi nhp i nhp li s PIN Number cho mi cuc gi ra ngoi trn my in thoi hoc Softfone trn my tnh ca mnh. gii quyt vn trn th FreePBX v A2Billing cho php ta cu hnh c th ghi nh li s PIN Number cho cc Extension trong ni b cng ty. Ta c 2 cch thit lp. Cch th nht: Thit lp trong FreePBX Trong FreePBX ta chn Extension thit lp mun b sung chc nng b qua vic nhp m s PIN Number, sau nhp s Card Number ca Customer vo AccountCode nh hnh sau:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 158

Hnh 6.110 Thit lp Accountcode cho Extension Cch th hai: Thit lp trong A2Billing T ng cp nht CallerID ca Extension vo trong Card Number ca Customer sau ln gi th nht. Khi , trong nhng ln gi k tip ta thc hin cuc gi t in thoi ca mnh, thng qua Caller ID th h thng s t nhn bit my ca bn v kt ni m khng cn phi nhp m PIN Number. Vo SYSTEM SETTING, chn Global List v thay i cc thng s nh sau:

Hnh 6.111 T ng pht Caller ID cho Customer

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 159

Vo CUSTOMERS, chn Caller-ID kim tra xem CallerID c Add vo Account Number hay cha.

Hnh 6.112 Danh sch Caller ID ca Customer Nh vy, t y v sau mi khi nhn vin thc hin cuc gi ra ngoi cho khch hng s khng cn tri qua vic nhp m s PIN Number di dng v mt thi gian nh trc. Tuy nhin, vic ny khng mang tnh bo mt ti khon cao bi v khi bn i vng khng c mt bn lm vic ca mnh, th ngi khc c th dng in thoi ca mnh gi ra ngoi lm nh hng n s tin trong ti khon hin c ca bn. 6.4.8.3 Package offer ( Gi khuyn mi h tr dch v) Trong A2Billing cn c cc gi khuyn mi h tr dch v cho ngi dng nh sau: Vo PACKAGE OFFER, chn Add v nhp cc thng s:

Hnh 6.113 To gi h tr dch v Label: tn gi khuyn mi. Number of Free Calls (S cuc gi c min ph). Free Second (S giy c min ph trong tun hoc thng). Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Package Type: Unlimited calls (Cuc gi khng gii hn).

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing Billing Type: Starting Day: 7). Free Units: Monthly (Min ph tnh theo thng). Weekly (Min ph tnh theo tun).

Trang 160

Ngy bt u p dng gi khuyn mi: Monthly (1-31), Weekly (1S giy c min ph hoc s cuc gi c min ph.

Sau khi thit lp xong ta cn Add tn RATE cn c p dng cc gi khuyn mi ny.

Hnh 6.114 Add cc gi khuyn mi cho cc Rate Khi Rate gi n nc Anh s c p dng cc gi khuyn mi m ta thit lp. 6.4.9 Giao din web ngi dng A2Billing 6.4.9.1 Gii thiu Ging nh hu ht cc nh cung cp dch v VoIP. A2Billing cho php ngi dng kim tra ti khon ca mnh, coi s d tin trong ti khon, cc cuc gi thc hin hoc thay i thng tin c nhn, mt khu Vic ny c thc hin kh d dng v trc quan qua giao din web. Kt ni n giao din web ngi dng bng a ch sau: http://192.168.1.10/customer/ Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 161

Ta s c yu cu nhp User v password. User y l s WebUI Login (khng phi s Card Number) v Password l WebUI Password to ra trong qu trnh to Customer (hoc do qun tr vin t qui nh).

Hnh 6.115 Giao din ng nhp ca ngi dng A2Billing Sau khi ng nhp thnh cng. Ta s vo trang Account information. y ta c th chnh sa li thng tin c nhn nu cn thit.

Hnh 6.116 Giao din ngi dng Trn y ch l nhng chc nng c bn nht ca A2Billing. A2Billing cn nhiu chc nng khc na nh: thng k cuc gi, bo co, kha cuc gi, to CID Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 162

Khi kt hp y chng ta s c mt h thng p ng tt nhng nhu cu ca doanh nghip hoc s dng nh mt nh cung cp dch v VoIP u cui. 6.4.9.2 Mt s chc nng s dng trn giao din ngi dng 6.4.9.2.1 Call history (Lch s cc cuc gi) Ngi dng c th xem li thng tin chi tit tt c cc cuc gi mnh thc hin.

Hnh 6.117 Lch s cc cuc gi trong A2Billing 6.4.9.2.2 Speed dial (Quay s nhanh) Ngi dng c th thit lp chc nng quay s nhanh cho Card Number ca mnh. Sau khi thit lp chc nng, sau ny khi thc hin cuc gi ta ch cn quay s ngn gn (0-9) i din cho nhng s mnh thng xuyn lin lc.

Hnh 6.118 Thit lp chc nng quay s nhanh Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing 6.4.9.2.3 Ratecard

Trang 163

Ngi dng c th xem cc ph thc hin cuc gi n cc quc gia khc nhau do cng ty cung cp.

Hnh 6.119 Xem gi bn RateCard


6.4.9.2.4 Simulator (M phng cuc gi) A2Billing cn h tr chc nng m phng cuc gi, gip cho ngi dng bit trc c ti khon ca mnh s thc hin vi s cn gi l bao nhiu pht, cc ph bao nhiu.

Hnh 6.120 M phng cuc gi 6.5 Kt lun Chng ny trnh by mt cch chi tit cc dch v ca tng i ni b Asterisk v phn mm tnh cc A2Billing. Ngoi cc chc nng c bn nh mt tng i ni b, Asterisk cn cung cp thm rt nhiu tnh nng, tin ch trong cc gi phn mm s dng m ngun m, min ph, cho php ngi s dng c th ch ng khai bo, ci t theo nhu cu nh Voicemail, in thoi hi ngh, cc dch v tng tc hoc phn phi cuc gi t ng, nhc chung linh ng v phong ph vi nhiu dng khc nhau, trong khi , cc tng i PBX thng thng ch cung cp cc dch v c bn cho vic chuyn mch, kt ni cc thu bao hoc nu mun c thm dch v th phi trang b thm cc thit b phn cng hoc phn mm bn quyn. Cc tnh nng ny p ng hu ht cc nhu cu lin lc ca doanh nghip. Thng qua giao din Web, ta c th gim st, vn hnh, cu hnh t bt k u v bt c khi no. Vi cc u im vn hnh n nh trn h tng vin thng sn c ca doanh nghip, linh hot trong vic ci t cc dch v cho ph hp vi nhu cu, ct Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 164

gim chi ph cuc gi n mc thp nht gia cc chi nhnh, vn phng v cuc gi quc t khi kt hp vi cc nh cung cp dch v in thoi quc t, Asterisk c trin khai ph bin cc nc c nn kinh t pht trin. y chnh l minh chng r rng nht v u im ca h thng m ngun m min ph m mnh m ny.

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 165

Chng 7
7.1 Kt lun

KT LUN V HNG PHT TRIN

n trnh by c khi qut cng ngh VoIP v a ra m hnh ng dng rt thc t bi v n xut pht t nhu cu ca cc doanh nghip. l vic xy dng tng i in thoi IP PBX da trn phn mm m ngun m Asterisk c cu hnh thng qua giao din Web FreePBX v thc hin gii php tnh tin in thoi cho tng i ny da trn phn mm m ngun m A2Billing. Hin nay, cc quc gia pht trin, cng ngh m nhm thc hin ti ang nghin cu c ng dng kh rng ri trong cc cng ty va v nh. Hn th na, VoIP , ang s tr thnh mt thnh phn khng th thiu c ca cng ngh mng tin tin Next Generation Network (NGN). Nhn chung, vic thit lp, cu hnh h thng IP PBX thng qua giao din FreePBX p ng mt cch tinh t nhu cu cho ngi s dng: giao din cu hnh n gin d s dng, d dng qun l, kim sot thng tin chi tit h thng, mang tnh linh hot cao cho vic cp nht trc tuyn, ci tin h thng vi nhiu Module ty theo nhu cu ca ngi s dng. Bn cnh , gii php tnh tin cuc gi VoIP gii quyt c cc nhu cu chnh ca mt cng ty chng hn nh: theo di v tnh cc cc cuc gi ra bn ngoi cho cc phng ban v chi nhnh, qun l cuc gi ca cc nhn vin ra bn ngoi cng ty, bo co v thng k cc cuc gi hng ngy, hng thng, t ng ti u la chn kt ni vi nh cung cp VoIP tit kim chi ph, gi in thoi qua web 7.2 Hng pht trin Do thi gian thc hin ti c hn, nn ni dung lun vn ch cp n cc vn nh: thit lp h thng IP PBX Asterisk trn giao din GUI FreePBX vi cc chc nng c bn ca mt tng i ni b, v kt hp phn mm A2Billing cung cp gii php tnh cc trong doanh nghip, ch yu kim sot cc cuc gi bn trong ni b ra bn ngoi cng ty. Nu c thi gian nghin cu th nhm thc hin ti s pht trin h thng theo cc hng sau y: - V phn cng: ngoi vic giao tip vi FX106 s dng card X100P ca hng Digium hoc cc gateway c cng FXO, chng ta c th cu hnh tng thch vi cc Card giao tip cc lung s nh E1, T1, to nn mt tng i ln vi dung lng ln ti hng chc, thm ch hng trm knh thoi. - Nghin cu v chc nng CRM, c th vi phn mm SugarCRM qun l ton b thng tin khch hng i vi vic ng dng trong quy m doanh nghip: T nhng thng tin c nhn, s thch khch hng cho n ton b hot ng lin quan khch hng. Bn cn bit khch hng ny giao dch vi cty bao nhiu ln, ni dung ca tng ln giao dch l g? Ri bao nhiu cuc gi, cuc hn gp vi khch hng trc y, ni dung l g? Bao nhiu mail c gi, ni dung nh th no? Tt c SugarCRM u p ng tt. - Kt ni nhiu server Asterisk vi chung mt c s d liu c th p ng nhu cu cho cc cng ty ln a quc gia. Ta s kt hp nhiu Server cch xa nhau v Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 166

mt a l trn th gii nhng ch dng chung mt h c s d liu thng nht. Trong qu trnh pht trin ny, chng ta s phi gii quyt rt nhiu vn pht sinh chng hn nh cht lng cuc gi ( tr, trt, mt gi), bo mt cc cuc gi quan trng, sao lu dliu,...Di y l m hnh tham kho vi 3 server Asterisk s dng mt Database:

Hnh 7.1 3 server Asterisk s dng chung 1 Database. - S dng mt SIP proxy: Asterisk khng phi l mt SIP proxy, Asterisk ch h tr giao thc SIP. Trong SIP, cc thit b s ng k vi SIP server, v server ny s cho php cc thit b thc hin giao tip vi nhau. Khi mt lng ln cc thit b SIP c dng, mt SIP Proxy s c dng qun l vic ng k v kt ni sao cho hiu qu nht. Asterisk th li khng ng vai tr nh mt SIP Proxy, cc thit b SIP c th ng k vi Asterisk nhng khi s lng ng k tng ln, Asterisk s khng th qun l tt. Asterisk ch kim sot tt trong phm vi 100 thit b. Do mt hng pht trin khc ca ti l s dng mt SIP Express Router (SER) gip Asterisk qun l mt lng ln cc thit b SIP. y l m hnh tham kho:

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 167

Hnh 7.2 M hnh SER

Chng 7 Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Xy dng h thng PBX Asterisk v gii php tnh cc A2Billing

Trang 168

Ti liu tham kho


Ti liu nc ngoi [1]. [2]. [3]. [4]. [5]. [6]. Ben Sharif, Elastix without Tears, 2008. Ben Sharif, Trixbox-2 without Tears, 2007. Colman Carpenter, David Duffett, Nik Middleton, Asterisk 1.4, PACKT Publishing, Birmingham Mumbai, 2009. David Gomillion & Barrie Dempster, Building Telephony Systems with Asterisk, PACKT Publishing, 2006. Flavio E. Goncalves, Configure Guide for Asterisk PBX, 2007. Jared Smith, Jim Van Meggelen & Leif Madsen, Asterisk The Future of Telephony, OReilly, 2007. L Quc Ton, Sch Asterisk Ting Vit. Nguyn Th Qunh Trang, Tng i Asterisk v Cng Ngh VoIP, Trng i hc Bch Khoa Nng, 2009. Phan Quc Khanh & Nguyn M Ngn, Xy Dng H Thng IP Call Center Da Trn M Ngun M Asterisk, Trng i hc S Phm K Thut HCM, 2011.

Ti liu ting Vit [7]. [8]. [9].

[10]. Phm Thanh Phong & Nguyn L Linh, Gii Php Tnh Cc Cho H Thng PBX Asterisk, Trng i hc Bch Khoa TP H Ch Minh, 2008. Cc a ch Web http://www.asterisk.org/downloads http://www.asterisk2billing.org/ http://www.baonguyen.vn http://www.data4ict.com/tutorials/a2billing/a2billing.asp http://www.forum.asterisk2billing.org/ http://www.freepbx.org/book/export/html/1855 http://www.my.opera.com/asteriskvn/blog http://www.sysadminman.net/documentation.html http://www.sysadminman.net/livedemo.html http://www.trixbox.org/ http://www.voip.com.vn/forum/ http://www.voip-info.org/

Ti liu tham kho