Está en la página 1de 79

http://my.opera.com/asteriskvn MC LC MC LC CC HNH.. iii CC T VIT TT...

iv

CHNG I: TNG QUAN V ASTERISK 1 1.1 Gii thiu v m ngun m Asterisk.... 1 1.2 Kin trc Asterisk. 4 1.3 Mt s tnh nng c bn... 6 1.3.1 Asterisk l mt PBX. 6 1.3.2 Asterisk l mt h thng IVR... 8 1.3.3 Asterisk l mt h thng Voicemail. 8 1.3.4 Asterisk l mt h thng VoIP (Voice over IP)... 9 1.3.5 Asterisk khng l mt Sip Proxy. 11 CHNG II: CC KHI NIM TRONG H THNG ASTERISK .. 12 2.1 Gii thiu.. 12 2.2 VoIP-Voice over Internet Protocal 12 2.3 Cc phng thc bo hiu giao tip TDM 12 2.3.1 FXO v FXS. 12 2.3.2 Bo hiu Analog gia u cui v tng i.. 13 2.3.3 Bo hiu gia cc tng i... 14 2.4 Bo hiu trn mng VoIP.. 14 2.4.1 H.323 14 2.4.2 SIP-Session Initiation Protocal. 14 2.4.3 Proxy Server. 15 2.4.4 RTP v NAT. 15 2.4.5 IAX-Inter Asterisk eXchange... 16 2.5 Asterisk server... 17 2.6 Thit b VoIP. 17 2.6.1 VoIP phone... 17 2.6.2 Softphone.. 18 2.7 Card giao tip vi PSTN... 19 2.8 ATA.. 20 2.9 Codecs... 20 2.10 QoS-Quality of Service... 20 2.10.1 tr.. 21 2.10.2 trt.. 21 CHNG III: CC M HNH NG DNG M NGUN M 23 3.1 Tng i VoIP PBX 23 3.2 Kt ni IP-PBX vi PBX.. 24
i

http://my.opera.com/asteriskvn

3.3 Kt ni gia cc server Asterisk... 25 3.4 Cc ng dng IVR, Voice Mail, in thoi hi ngh... 26 3.5 Chc nng phn phi cuc gi t ng 27 CHNG IV: CC DCH V C BN CA ASTERSIK 28 4.1 Conference 28 4.2 Voicemail.. 28 4.3 Call Forwarding 28 4.4 Call ID.. 29 4.5 Automated Attendant 29 4.6 Time and Day 29 4.7 Call Pickup 29 4.8 Call Parking.. 29 4.9 Privacy Manager... 30 4.10 Call Detail Records. 30 4.11 Call Recoding. 30 4.12 Blacklist.. 30 4.13 User permission to/international call.. 30 CHNG V: THIT K CU HNH IP-PBX. 31 5.1 Ci t Asterisk. 31 5.1.1 Ci t Zaptel... 32 5.1.2 Ci t libpri. 33 5.1.3 Ci t Asterisk 33 5.1.4 Ci t Asterisk-Addons.. 36 5.2 Cu hnh h thng 38 5.2.1 Cu hnh giao tip vi PSTN 38 5.2.1.a. zaptel.conf... 39 5.2.1.b. zapata.conf.. 41 5.2.2 Giao din SIP... 44 5.2.3 Giao tip IAX... 47 5.2.4 Hp th thoi Voicemail.. 48 5.2.4.a. Gii thiu 48 5.2.4.b. Cu hnh chc nng Voicemail.. 49 5.2.5 Nhc ch (Music On Hold).. 50 5.2.5.a. Gii thiu 50 5.2.5.b. Cu hnh tnh nng MOH 50 5.2.6 Hng i... 51 5.2.6.a. Gii thiu 51 5.2.6.b. Cu hnh.. 51 5.2.7 Xy dng h thng hi thoi 52 5.2.7.a. Gii thiu 52 5.2.7.b. Cu hnh. 53
ii

http://my.opera.com/asteriskvn

5.3 To k hoch quay s cho h thng.. 55 5.3.1 Gii thiu. 55 5.3.2 To mt ng cnh 55 5.3.3 To mt extension 56 5.3.4 To cc Extension gi ra.. 58 5.3.5 H thng tr li tng tc thoi (Automated Attendant). 59 CHNG VI: THI CNG H THNG IP-PBX C BN. 61 6.1 Cc thit b v phn mm s dng trong m hnh 61 6.2K hoch quay s. 64 6.3 Mt s chc nng c bn. 65 6.4 Cu hnh ... 65 6.5 Mt s kt qu thc hin.. 71 KT LUN 72 PH LC... 74 Th vin c php lnh v bin trong asterisk 1.Cc lnh tng qut 74 2.C php lnh tng tc vi Database... 74 3.C php dng lnh lin quan n knh IAX 75 4.C php dng lnh lin quan n knh SIP. 75 5.C php dng lnh lin quan n qun tr h thng. 75 6.Cc bin nh ngha trong Astersik.. 76 TI LIU THAM KHO.. 77 MC LC CC HNH Hnh 1-1: S tng qut.. 3 Hnh 1-2: Kin trc Asterisk . 4 Hnh 1-3: Lin lc gia cc Extension .. 7 Hnh 1-4: Lin lc gia cc vn phng qua Internet . 10 Hnh 2-1: FXO v FXS.. 13 Hnh 2-2: ng k t Client n SIP proxy... 15 Hnh 2-3: Minh ha hot ng ca NAT 16 Hnh 2-4: in thoi VoIP.. 18 Hnh 2-5: in thoi Softphne ... 19 Hnh 2-6: Card TDM22B 19 Hnh 2-7: Thit b ATA.. 20 Hnh 2-8: Nguyn nhn xy ra trt.. 22 Hnh 3-1: IP-PBX... 23 Hnh 3-2: Kt ni IP-PBX vi PBX 24 Hnh 3-3: Kt ni gia cc server Asterisk. 25 Hnh 3-4:Trin khai server IVR, VoiceMail, Hi Thoi 26 Hnh 3-5: Phn phi cuc gi vi hng i.... 27 Hnh 6-1: M hnh IP-PBX c bn 61
iii

http://my.opera.com/asteriskvn

CC T VIT TT ACD ADPCM AGI AMP API ATA CDR CGI CODEC CRM FTP FXO FXS HTTP IAX IETF ITU IVR MAN MGCP NAT POTS PRI QoS RADIUS RTP SCCP SER SIP SMTP WAV Automatic Call Distribution Adaptive Differential Pulse code Modulation Asterisk Gateway Interface Asterisk Management Platform Application Programming Interface Analog Terminal Adaptor Call Detail Record Control Gate Interface COder/DECoder Customer Relationship Management File Transfer Protocol Foreign Exchange Office Foreign Exchange Station Hypertext Transfer Protocol Inter Asterisk eXchange Internet Engineering Task Force International Telecommunication Union Interactive Voice Response Metropolitan Area Network Media Gateway Control Protocol Network Address Translator Plain Old Telephone Service Primary Rate ISDN Quality of Service Remote Authentication Dial In User Service Real Time Transport Protocol Cisco Sking SIP Express Route Session Initiation Protocol Simple Mail Transfer Protocol Waveform Audio
iv

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

CHNG I: TNG QUAN V ASTERISK


1.1 Gii thiu v m ngun m Asterisk Asterisk l phn mm thc hin chc nng tng i in thoi ni b (PBX), cho php cc my in thoi nhnh (extension) thc hin cuc gi vi nhau v kt ni vi cc h thng in thoi khc bao gm c mng in thoi analog thng thng (PSTN) v VoIP. Asterisk c y tnh nng ca tng i PBX thng mi: hp th thoi, hi m, tng tc thoi (menu thoi)c bit, Asterisk cn h tr nhiu giao thc VoIP nh SIP v H.323, hot ng nh trm kt ni gia cc in thoi IP v mng PSTN. Tn Asterisk c ngun gc t k t * c dng trong Unix v Linux, th hin cho ty chn bt k. Asterisk l h thng chuyn mch mm, l phn mm ngun m c vit bng ngn ng C chy trn h iu hnh Linux. Cng nh nhiu d n ngun m, Asterisk thot u c xy dng nhm p ng nhu cu c nhn .Khi cn l sinh vin khoa k thut my tnh ti i hc Auburn Alabama(M), Mark Spencer thnh lp cng ty cung cp dch v h tr ngi dng Linux qua in thoi . tit kim chi ph, thay v mua tng i PBX c sn, Mark quyt nh t xy dng phn mm thc hin chc nng tng i chy trn PC dng h iu hnh Linux v kt qu l Asterisk ra i . Asterisk l mt PBX v hn th na .Asterisk l mt phn mm mang tnh cch mng, tin cy, m ngun m v min ph , bin mt PC r tin thng thng chy Linux thnh mt h thng in thoi doanh nghip mnh m .Astreisk l mt b cng c m ngun m cho cc ng dng thoi v l mt 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 .Cng ngh Asterisk ang phc v cho nhiu doanh nghip . Asterisk l m ngun m, n thc hin truyn thng trong phn mm thay v phn cng. iu ny cho php cc tnh nng mi c thm vo mt cch nhanh chng vi n lc ti thiu.Chng ta c th thc hin cc thay i hay thm vo ca ring mnh mt cch d dng.Vi s h tr bao gm trong n c quc t ha, mt tp hp di do cc file cu hnh, v m ngun m, mi kha cnh ca Asterisk c th c ty bin p ng nhu cu ca chng ta. Phn mm Asterisk c thit k dng module .Cc thnh phn chc nng c thit k thnh tng module ring bit v tch ri vi phn chuyn mch li .Mt trong nhng im sonca Asterisk l qun l extension .Tng bc ca cuc gi c nh ngha nh l mt n g dng .Quay s l mt ng dng, tr li, pht li, hp th thoi l nhng v d ng dng khc .Ta c th to kch bn thc hin gi ng dng bt k
-1-

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

trn knh bt k .V d, c th thit lp mt s extension c chung cng lc 2 knh (c th ni n 2 my in thoi : 1 analog v 1 digital) trc khi chuyn cuc gi n in thoi di ng ,v sau chuyn qua h thng th thoi. Hin nay Asterisk 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 c mng my tnh v cn 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 thc hin cc cng vic trn mng 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 voice 777) 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(Customer Relationship Management) 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 OSX v Microsoft Windows.

-2-

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

Hnh 1-1: S tng qut

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. Asterisk cho php ngay c cng ty hay t chc nh cng c th thit lp h thng in thoi a nng, h tr ng thi in thoi thng thng (analog) v in thoi IP (VoIP).Theo M.Spencer, Asterisk l gii php vin thng cho i chng - ngoi chi ph r v d dng thit lp, kh nng VoIP ca Asterisk cho php kt ni nhng vng xa xi, nhng ni cha c mng cp in thoi truyn thng .

-3-

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

1.2 Kin trc Asterisk

Hnh 1-2: Kin trc 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 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 .

-4-

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

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 ty vo k hoch quay s (Dialplan) c thc hin cu hnh trong tp tin cu hnh extensions.conf . Chc nng Application Launcher 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 . 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 . Mi cuc gi c xut pht hoc c nhn qua mt giao tip trn knh ring bit ca chnh n .Mt knh c th c kt ni n mt knh vt l -v d nh mt ng dy POTS, hoc n mt knh logic-v d nh mt knh IAX hoc SIP. Phn bit s xut hin ca mt cuc gi trn mt knh vi ci g s xy ra vi cuc gi vo , l rt quan trng .Khi mt cuc gi n Asterisk qua mt knh, mt k hoch nh s (Dial plan) quyt nh ci g s thc hin vi cuc gi . V d mt cuc gi c th n qua mt knh SIP: cuc gi c th c n t mt SIP-Telephone hoc t mt SIP- Softphone hot ng trn mt my tnh. K hoch nh s quyt nh cuc gi nn c tr li, c kt ni vi in thoi khc, c chuyn cuc gi hay c nh hng ti Voicemail . Asterisk cung cp nhiu ng dng khc nhau .Cc ng dng ny sn sng cho k hoch nh s khi x l cuc gi vo.K hoch nh s v cc ng dng c la chn s dng trong k hoch nh s quyt nh Asterisk thi hnh nhng hnh ng no. 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 G723, GSM, MP3, ADPCM

-5-

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

Asterisk Chanel 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 foramt API: Asterisk tng thch vi vic x l cc loi file c nh dng khc nhau nh MP3, WAV, GSM, em n s linh hot cho cc ng dng trn nn Asterisk trong vic x l m chung, DTMF Asterisk Aplication API: bao gm tt c cc ng dng c thc thi trong h thng Asterisk nh voicemail, conference, callerID, cho php vit cc ng dng mi c th tng tc trc tip vi phn li PBX. 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. 1.3 Mt s tnh nng c bn 1.3.1 Asterisk l mt PBX Asterisk l mt PBX (Private Branch Exchange).Mt PBX c th c xem nh l mt tng i in thoi ring, kt ni mt hay nhiu in thoi ni b bn trong, v thng kt ni ra bn ngoi bng mt hay nhiu ng dy in thoi .iu ny thng c hiu qu v mt chi ph hn so vi vic thu mt ng dy in thoi cho mi in thoi c nhu cu trong mt doanh nghip. -Station-To-Station Calls: Th nht, nh mt PBX, Asterisk cung cp cc cuc gi Station-To-Station .iu ny c ngha ngi s dng c th quay s t in thoi ny n in thoi khc .

-6-

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

Hnh 1-3: Lin lc gia cc Extension Trong hnh v, mi extension c th kt ni n bt k extension khc bng cch quay s mt cch trc tip . iu ny c ngha rng nu mt modem gi mt bn fax n mt my fax ni b, n thc thi bng cch to mt kt ni trc tip gia hai thit b xuyn qua PBX. -Line Trunking: Th hai, Asterisk cung cp ng trung k.Trong hnh thc n gin nht, ng trung k chia s truy cp ca nhiu ng dy in thoi . Cc ng dy in thoi ny thng c s dng kt ni n mng in thoi ton cu, nh PSTN, nhng cng c th l cc ng dy ring n cc h thng in thoi khc . Cc kt ni ny c th l mt trung k Analog n, nhiu trung k Analog, hay cc kt ni s dung lng cao cho php nhiu cuc gi ng thi c mang trn mt kt ni n. -Telco Features Asterisk h tr tt c cc tnh nng tiu chun m chng ta mong i t bt k cng ty in thoi (telco) no, Asterisk h tr gi v nhn Caller ID, v ngay c cho php chng ta nh tuyn cc cuc gi da trn c s Caller ID.S dng Caller ID vi PSTN chng ta yu cu cc kt ni PSTN ca chng ta phi cung cp tnh nng ny. Asterisk cng h tr cc tnh nng khc nh l: call waiting, call return (*69), distinctive ring, transfering calls, call forwarding Cc tnh nng c bn ny v nhiu hn na c cung cp bi Asterisk. -Phn phi cuc gi tin tin:
-7-

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

Asterisk c th nhn mt cuc thoi, xem xt c tnh ca cuc gi, v thc hin nh tuyn da trn c s . Nu thng tin y khng c cung cp bi nh cung cp kt ni PSTN, th chng ta yu cu ngi gi a vo thng tin bng cch dng in thoi n phm ch tone. Mi khi chng ta thc thi mt quyt nh cch nh tuyn cuc gi, chng ta c th gi n n mt extension n, mt nhm extension, mt recording, mt voicemail box, hoc ngay c mt nhm agent telephone m c th chuyn t in thoi n in thoi. Chn g ta c th s dng cc hng i cuc gi phc v khch hng mt cch hiu qu hn na . S linh hot ny a n cho chng ta kh nng t ch c mt h thng in thoi to ra mt gii php mnh m cho cc doanh nghip tit kim chi ph in thoi . Phn phi cuc gi tin tin trao quyn cho chng ta phc v khch hng theo cch tt nht c th. Mt nhn t lm nn s khc bit chnh gia Asterisk v cc h thng PBX khc l Asterisk khng yu cu mua bn quyn cho bt c tnh nng g . V d s gii hn c bao nhiu cuc gi trong hng i cuc gi (call queue) c quyt nh ch bi phn cng chng ta s dng . 1.3.2 Asterisk l mt h thng IVR IVR (Interactive Voice Response) l tnh nng p ng thoi tng tc. Kh nng v s linh hot ca mt h thng in thoi da vo chng trnh a n cho chng ta kh nng p ng khch hng theo cc cch y ngha . Chng ta c th d ng Asterisk cung cp dch v trong sut 24 gi. Asterisk cho php chng ta pht li cc file, c vn bn, v ngay c truy lc thng tin t c s d liu. y l k thut m chng ta tip cn trong vic tr tin cc in thoi qua h thng ngn hng . Khi chng ta gi n ngn hng, chng ta s nghe mt s loi bn tin c thu v a ra lnh, thng l s dng in thoi n phm ch tone.V d chng ta c th nghe mt li cho v bn tin trng thi, chng ta g vo s ti khon v thng tin c nhn hoc giy y quyn chng thc. Chng ta cng thng nghe thng tin ring, thng tin ring ny c truy lc t c s d liu ,nh l mt vi phin giao dch mi nht hoc s d ti khon .Cc h thng vi tnh nng nh vy c thc thi bng cch s dng Astrisk. 1.3.3 Asterisk l mt h thng Voicemail Aterisk l mt h thng Voicemail bao gm cc chc nng y .H thng Voicemail c sc mnh y kinh ngc .N h tr nhiu ng cnh Voicemail nhiu t chc c th c truy cp vo t cng server .N h tr cc vng thi gian khc nhau v vy cc user c th kim tra khi in thoi ca h c cuc gi vo. N cung cp s la chn thng bo nhn cc bn tin mi qua mail: thc t chng ta c th nh km bn tin audio.

-8-

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

1.3.4 Asterisk l mt h thng VoIP (Voice over IP) Asterisk a n cho chng ta kh nng s dng IP (Internet Protocal) cho cc cu c gi in thoi, c bit cc cuc gi ng di dng IP th chi ph th p hn so vi cc cng ngh in thoi truyn thng . S chn la s dng Asterisk khng c ngha l chng ta ch c th s dng VoIP cho cc cuc gi .Trong thc t nhiu thit lp cho Asterisk khng phi s dng ht tt c, nhng vi mi thit lp h thng c kh nng thm vo VoIP mt cch d dng v bt c lc no m khng cn chi ph cng thm. Hu ht cc cng ty c hai mng: mt cho in thoi v mt cho my tnh .Vn g s xy ra nu chng ta hp nht hai mng ny?Tit kim c nhng g? Tit kim ln nht thu c l gim gnh nng qun l cho cc nhn vin IT (Information Technology) .By gi chng ta c mt vi chuyn gia v my tnh v mng, v t khi in thoi s hot ng trong tm iu khin ca my tnh v qua mng IP ca chng ta, kin thc nn tng tng t s cho php cc nhn vin ca chng ta c quyn qun l h thng in thoi. Chng ta cng s thu c li ch t vic mua thit b c gim xung trong thi gian di. Thit b my tnh ngy cng r hn trong khi cc h thng in thoi c quyn dng nh gi nguyn gi c.V vy chng ta c l mong i gi ca Switch, Router v cc thit b mng d liu khc tip tc gim gi. Hu ht cc h thng in thoi hin ti, cc ng dy in thoi ko xa ti a theo chiu di cp c cho php bi nh sn xut h thng in thoi. Khi dng VoIP chng ta c th c nhiu user s dng cng dch v ca Asterisk t nhiu v tr khc nhau. Chng ta c th c cc user ti vn phng dng in thoi PSTN hoc in thoi IP, chng ta c th c cc user VoIP xa, ngay c khi chng ta c ton b h thng Asterisk c vn hnh v hot ng hon ton tch bit nhng vi nh tuyn c tch hp . Mt phng php gim bt tng ph l gim s lng khng gian vn phng c yu cu .Nhiu doanh nghip s dng lin lc t xa cho mc ch ny .iu ny thng to ra mt vn : chng ta dng s no lin lc mt ngi i li xa. Tng tng rng ngi lao ng lin lc t xa c th n gin ch s dng cng my in thoi khi nh cng nh khi vn phng hoc ngay c khi dng mobile ca h. VoIP cho php chng ta c mt s m rng n bt c ni u khi chng ta c mt kt ni Internet nhanh hp l .iu ny c ngha ngi lm vic c th c mt in thoi nh nu h c mt kt ni bng rng .V vy, h s truy nhp n tt c cc dch v c cung cp vn phng lm vic , v d nh voicemail, gi ng di v quay s n ngi khc. Chng ta chuyn cc ngi lm vic vo trong PBX t nh ca h, chng ta c th lm iu tng t i vi cc vn phng xa .Bng cch ny, ngi lm vic nhiu v tr c th c cc tnh nng ph hp, c truy cp cng phng php mt cch chnh xc, gip gim bt gnh nng hun luyn ngi lao ng .
-9-

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

Nhng iu ny khng phi l tt c m VoIP c th em n cho chng ta.Chng ta c th s dng mt Asterisk server mi vn phng v ni kt li .iu ny c ngha l mi vn phng c th c cc ng dy ni ht ca chnh h, nhng lin lc vn phng n vn phng th c gi (tunnel) qua Internet.S tit kim c c bi trnh cc cuc gi ng di c th ng k.

Hnh 1-4: Lin lc gia cc vn phng qua Internet

Mt khi chng ta c cc Office c ni kt theo phng php nh th, chng ta c th qun l cc cuc gi khng cn ng ni, bt k nhn vin Office no. .V d, nu mt khch hng gi n Office A yu cu v ti khon ca h v phng thanh ton ti khon th Office B, chng ta chuyn cuc gi mt cch d dng n ngi thch hp vn phng khc. Chng ta khng phi quan tm vn phng khc th u .Ch cn h c mt kt ni Internet tin cy, ngay c khi h khng phi trong cng quc gia. Tin li khc khi kt ni cc h thng in thoi vi nhau l chng ta c th nh tuyn cc cuc gi d a trn c s thi gian .Tng tng rng chng ta c hai vn phng, mi vn phng trong mi vng thi gian khc nhau .Mi vn phng chc chn s m ca hot ng nhng thi im khc nhau . qun l khch hng ca chng ta mt cch hiu qu, chng ta c th chuyn cc cuc gi t vn phng cha m ca sang vn phng m .Hn na ,v chng ta ang dng kt ni Internet lin kt cc vn phng , nn khng c ph tn cng thm khi thc hin. Bng cch lin kt cc vn phng ca chng ta li vi nhau s dng VoIP, chng ta c th gia tng dch v cho khch hng trong khi vn gim c chi ph .
- 10 -

http://my.opera.com/asteriskvn - CHNG I: TNG QUAN V ASTERISK

1.3.5 Asterisk khng l mt SIP Proxy Asterisk h tr SIP (Session Initiation Protocal) i vi VoIP .Cc cuc gi c th c thc hin v c nhn vi SIP s dng Asterisk. Trong SIP, cc thit b ng k vi mt SIP server. Server ny cho php cc thit b xc nh v tr vi nhau thit lp lin lc.Khi mt s lng ln ca cc thit b SIP c s dng ,mt SIP Proxy th thng c tn dng qun l s ng k v kt ni theo cch c hiu qu . Tuy nhin, Asterisk khng th hot ng nh mt SIP Proxy .Cc thit b SIP c th ng k vi Asterisk nhng khi s thit b SIP gia tng, Asterisk khng th p ng tt. V vy, nu chng ta d nh dng khong trn 100 thit b SIP, Asterisk c l khng thch hp. Trong khi Asterisk khng l mt SIP proxy, Asterisk c th c cu hnh s dng cho cc s ng k.Mt proxy c s dng ph bin l SER (SIP Express Router).SER l mt SIP proxy ngun m , n gip Asterisk p ng nhu cu cho s thit lp rt ln.

- 11 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

CHNG II: CC KHI NIM TRONG H THNG ASTERISK


2.1 Gii thiu Trong chng ny s gii thch r cc khi nim c bn lin quan n h thng Asterisk, cung cp nhng kin thc nn tng, nhng khi nim cn thit thit k trin khai xy dng h thng in thoi vi Asterisk . 2.2 VoIP Voice Over Internet Protocol VoIP l mt cng ngh cho php truyn thoi s dng giao thc mng IP, trn c s h tng ca mng Internet .VoIP l mt trong nhng cng ngh vin thng ang c quan tm nht hin nay khng ch i vi nh khai thc, cc nh sn xut m cn c vi ngi s dng dch v . VoIP c th va thc hin mi loi cuc gi nh trn mng in thoi knh truyn thng (PSTN) ng thi truyn d liu trn c s mng truyn d liu .Do cc u im v gi thnh dch v v s tch hp nhiu loi hnh dch v nn VoIP hin nay c trin khai mt cch rng ri. Dch v in thoi VoIP l dch v ng dng giao thc IP, nguyn tc ca VoIP bao gm vic s ha tn hiu ting ni, thc hin vic nn tn hiu s, chia nh cc gi nu cn v truyn gi tin ny qua mng, ti ni nhn cc gi tin ny c rp li theo ng th t ca bn tin, gii m tn hiu tng t phc hi li ting ni ban u . Cc cuc gi trong VoIP da trn c s s dng kt hp c chuyn mch knh v chuyn mch gi.Trong mi loi chuyn mch u c u v nhc im ring ca n. Trong k thut chuyn mch knh dnh ring cho mt knh truyn gia hai thit b u cui thng qua cc node chuyn mch trung gian .Trong chuyn mch knh tc truyn dn lun lun c nh (ngha l bng thng khng i), vi mng in thoi PSTN tc ny l 64 kbps, truyn dn trong chuyn mch knh c tr nh . Trong chuyn mch gi cc bn tin c chia thnh cc gi nh gi l cc packet, nguyn tc hot ng ca n l s dng h thng lu tr v chuyn tip cc gi tin trong node mng .i vi chuyn mch gi khng tn ti khi nim knh ring, bng thng khng c nh c ngha l c th thay i tc truyn, k thut chuyn mch gi phi chu tr ln v trong chuyn mch gi khng qui nh thi gian cho mi gi d liu ti ch, mi gi c th i bng nhiu con ng khc nhau ti ch, chuyn mch gi thch hp cho vic truyn d liu v trong mng truyn d liu khng i hi v thi gian thc nh thoi, s dng u im ca mi loi chuyn mch trn th trong VoIP kt hp s dng c hai loi chuyn mch knh v chuyn mch gi . 2.3 Cc phng thc bo hiu giao tip TDM 2.3.1 FXO v FXS FXO (Foreign Exchange Office) l thit b nhn tn hiu t tng i gi n nh dng chung ,tn hiu nhc gc my, tn hiu mi quay s, gi v nhn tn hiu thoi ,

- 12 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

FXO ging nh my Fax hay modem dial- up 56 k , 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 -48V DC n my in thoi Analog trong sut thi gian m thoi v cung cp 90V DC (20Hz) pht in p rung chung .Thit b FXS pht cn thit b FXO nhn. Card TDM s dng trong h thng Asterisk thng tch hp va l thit b FXO, va l thit b FXS (ging b ATA), FXO kt ni vi ng dy in thoi, cn FXS dng kt ni vi my in thoi Analog thng thng dng chuyn mch cuc gi TDM qua h thng Astesisk (s c phn tch thm trong phn cu hnh cho knh TDM) Vi card giao tip Digium FXS, mt Asterisk server c th iu khin cc my in thoi Analog ni b . FXO v cc board mch giao tip T-carrier t Digium c th kt ni mt Asterisk server n mng PSTN . Tm li cn nm: FXS c kt ni vi FXO ging vi ng dy in thoi ni vi my in thoi FXS cung cp ngun cho in thoi FXO (in thoi Analog)

Hnh 2-1: a) My in thoi vai tr FXO kt ni vi FXS (PSTN), hnh b) PBX kt ni vi FXO v FXS, hnh c) ATA ng vai tr nh FXS kt ni vi cc my in thoi vai tr FXO . 2.3.2 Bo hiu Analog gia u cui v tng i Khi chng ta nhc my in thoi gi th nghe tn hiu mi quay s, u bn kia b bn th chng ta nghe tn hiu bn (busy tone), cc loi tn hiu nh vy gi l cc tn

- 13 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

hiu bo hiu analog .Cc tn hiu nh : mi quay s, tn hiu bn, rung chung, trng thi nhc gc my l cc tn hiu c trao i gia thit b FXO v FXS. C nhiu phng thc bo hiu khc nhau ng vi tng ni s dng, v th ti ni kt ni vi ng dy in thoi cn xem xt h ang s dng phng thc bo hiu g, t chng ta khai thc loi tn hiu bo hiu cho thch hp, cc phng thc bo hiu nh Koolstart, Loop Start, Ground Start. Mt minh ha cho vic s dng sai phng thc bo hiu l khi chng ta khai bo phng thc bo hiu gia h thng Asterisk v ng dy in thoi khc nhau th dn n Asterisk s khng nhn bit c tn hiu gc my, iu ny s lm cho Asterisk khng bao gi gii ta c cuc gi thc hin cuc gi mi . 2.3.3 Bo hiu gia cc tng i SS7 h thng bo hiu s 7 c pht trin bi AT&T v ITU l h thng bo hiu s dng cho cc cuc gi gia cc tng i trong mng PSTN .Trong h thng bo hiu s 7 tn hiu chuyn ti trn ng trung k kt ni gia hai tng i gm c hai mch ring, mt cho thoi v mt cho bo hiu, nh vy thoi v bo hiu c th chuyn trn hai knh vt l khc nhau. 2.4 Bo hiu trn mng in thoi VoIP 2.4.1 H.323 H.323 l cng ngh nn tng trong truyn dn m thanh thi gian thc, hnh nh v trao i d liu trn mng c s-mng gi .Trong , ch ra cc b phn, giao th c v cc th tc cung cp cc dch v giao tip a phng tin trn mng c s-mng gi. Mng c s-mng gi bao gm cc mng IP (nh mng Internet) , cc tng i chuyn mch gi (IPX-Internet Packet Exchange), cc mng LAN, cc mng MAN v cc mng WAN. H.323 c th c ng dng mt cch a dng - ch gm thoi(IP Telephony), hay thoi v hnh nh (Video Telephony), hay thoi v d liu, hay bao gm c thoi, d liu v hnh nh. H.323 cng c th ng dng trong truyn thng a phng tin-a im (Multipoint - Multimedia) . H.323 cung cp cc dch v gia tng v do c th ng dng trong cc vng c s bin ng ln v kch c mng v dch v cung cp. 2.4.2 SIP- Session Initiation Protocol SIP l giao thc Internet dnh cho bo hiu VoIP c pht trin bi IETF, cung cp vi chc nng ging h thng bo hiu s 7 nhng da trn nn IP.Mt chc nng ging bo hiu s 7 l bo hiu v thoi chuyn ti trn hai knh ring .Giao thc SIP thc hin chc nng thit lp v bo hiu cuc gi, khi ni n bo hiu cuc gi l ch nh cc tn hiu bo hiu nh: tn hiu mi quay s, tn hiu bn SIP l phn thit lp mc nh ca Astersik (SIP c h tr trong Asterisk vi module chan_sip.so) . Hu ht thit b VoIP mi u c h tr giao thc SIP.N c mt s u im, nh: code th nh hn. L do l SIP ch h tr cc tnh nng rt c bn. Cc tnh nng tin tin c h tr qua cc chun Internet ring bit .

- 14 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

C php iu khin SIP ging nh SMTP, HTTP, FTP v cc giao thc IETF khc .SIP l mt tiu chun ni bt trong VoIP v n n gin so vi giao thc khc v d nh H.323 . Chng ta cu hnh giao thc SIP bng cch son tho trong tp tin /etc/asterisk/sip.conf. Tp tin ny c mt s thit lp trong mt session [general], tip theo l cc nh ngha ca chng ta cho ngi s dng (s phn tch k hn trong phn cu hnh Asterisk) . 2.4.3 Proxy server Mc d hai thit b SIP c th lin lc trc tip vi nhau khi to cuc gi nhng trong giao thc SIP cn c chc nng Proxy linh hot hn trong thip lp cuc gi .Proxy Server s lm nhim v ghi nhn tt c cc s in thoi c pha clien ng k n qua bn tin Registration.Khi mt client khc thc hin cuc gi th thc s Client khng bit s in thoi cn gi ang u nn thng qua Proxy server tm kim thit lp cuc gi.

Hnh 2-2: ng k t Client n SIP proxy, vi giao thc SIP ng bo hiu v thoi ring . 2.4.4 RTP v NAT Cc cuc gi trn Internet vi giao thc SIP c chia thnh cc gi thoi v c chuyn qua giao thc RTP (Real Time Transport Protocol).RTP l giao thc khng ch thc hin chuyn cc gi thoi qua Internet m cn c c Video na .Mt cuc gi thng thng c hai hng thng tin l nhn v pht, RTP lm vic chuyn cc gi d liu thoi cng trn hai hng . RTP c gng m bo d liu s c truyn v nhn trong mt chu k thi gian ngn. R rng tr trong lin lc thoi c th l mt vn . V vy RTP ngn nga tr ny mc ti a c th . NAT (Network Address Translator) l mt tr ngi ln trong giao thc RTP .Mng s dng NAT l mt mng chia s nhiu a ch IP ni b vi mt a ch IP cng cng kt ni vi th gii bn ngoi .NAT dng chia s nhiu my tnh trong mng LAN ni b s dng c Internet, nhng cng chnh v th m cc my tnh ni b
- 15 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

gp kh khn trong vic thc hin cuc gi VoIP qua Inetrnet. chnh l vn tr ngi khi truyn thoi qua giao thc RTP.

Hnh 2-3: Minh ha hot ng ca NAT Trong giao thc RTP nh chng ta bit l thoi c chuyn trn hai ng khc nhau l ng pht v ng thu, vn NAT nm ch tn hiu thoi t bn ngoi vo bn trong qua giao th c RTP khng thc hin c cn chiu ngc li th thc hin tt. Hay ni cch khc vn NAT lm cho cc cuc gi t Inetrnet m thoi vo cc my ni b qua NAT th khng nghe c, cn trong trng hp cc cuc gi t cc my ni b ra cc my Inetrnet th nghe tt . Vn NAT trn c gii quyt trong Asterisk bng vic khai bo thng s nat=yes trong cu hnh knh giao thc SIP. 2.4.5 IAX-Inter Asterisk eXchange IAX l mt giao thc c to bi cc tc gi ca phn mm Asterisk . Bi v s hn ch ca SIP v H.323.H chn to ra mt chun mi cho php Asterisk server lm c rt nhiu th m khng th lm c vi cc chun khc . IAX xuyn qua NAT mt cch d dng . Hu ht cc tng la (firewall) v cc Gateway Internet ti nh u s dng NAT, cng nh cc nh cung cp dch v . SIP v H.323 phi lm vic gian kh pht trin cc chun cho php chng i qua cc dng khc nhau ca NAT. Trong khi , IAX c th lm vic qua hu ht cc thit b NAT ra ngoi .

- 16 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

IAX c kh nng cu hnh hn l cc giao thc khc khi giao tip vi Asterisk (trong Asterisk, IAX c h tr bi module chan_iax2.so) .K t khi m ngun (source code) c bit n, chng ta c th sa n nu mun, v sau trnh nhng thay i ny c nh gi vi mc ch l bao gm trong cc version tng lai ca Asterisk . IAX h tr trung k cho cc cuc gi (trunking of call) . iu ny c ngha l nhiu cuc gi c th c kt hp trong mt lung n .Thng qua kh nng ca trung k, mt s lng bng thng ng k c th c tit kim bi khng c cc overhead ca nhiu lung . IAX kt ni gia cc server h tr chc nng switch command , cc cuc gi c nh tuyn mt cch hiu qu gia cc Asterisk server. Hin c hai phin bn ca IAX l IAX version 1 (IAX) v IAX version 2 (IAX2) . IAX2 ra i c k vng s l mt s thay i hon ho cho nguyn bn IAX version1 . 2.5 Asterisk server Asterisk server l mt PC chy h iu hnh Linux, yu cu cu hnh nh bng 2.1 v m bo chc chn c khe cm m rng gn cc board lin lc .V d Digium T1, adaptor FXO hoc FXS . Bng 2.1: Yu cu ca cu hnh my Asterisk server Mc ch Th nghim, hc tp H thng cho vn phng hoc nh ring H thng cho doanh nghip nh H thng thng mi c va v ln S lng cc knh 1- 5 5-10 Ti 15 Hn 15 Cu hnh ti thiu 400-MHz x86, 256 MB RAM 1-GHz x86, 512MB RAM 3-GHz x86, 1GB RAM Dual CPUs, hay cng c th l nhiu server trong mt cu trc phn tn.

2.6 Thit b VoIP 2.6.1 VoIP phone y l thit b phn cng kt ni vi mng VoIP ging nh my in thoi bn thng thng nhng dnh cho VoIP, cn phi thc hin cu hnh trc khi s dng . Lu mt s tnh nng khi thc hin mua thit b in thoi VoIP: +Low bandwidth: h tr Code no, G729 l tt nht hin nay . +Web Interface: phi c giao tip thit lp cu hnh thn thin d s dng .
- 17 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

+Audio Interface: c speaker phone hay khng . Gi thnh ca in thoi VoIP t hn in thoi thng thng, gi khong trn di 100$/mt ci .

Hnh 2-4: My in thoi VoIP 2.6.2 Softphone in thoi d nht thit lp vi Asterisk l Softphone.L mt phn mm c ci trn my tnh, m phng mt in thoi trn PC, thc hin tt c cc chc nng ging nh thit b in thoi VoIP.Softphone d thit lp v c th c cu hnh khong vi pht.Cn lu khi s dng Softphone l my tnh phi c card m thanh, headphone v firewall khng b kha . Softphone dng card m thanh ca my tnh truyn v nhn tn hiu audio, hoc mt chn la l USB phone, ging nh thit b thoi gn vo cng USB ca my tnh. Softphone th khng t (thng l free) v cc USB phone thng c gi thp hn 50$ S dng Softphone vi h thng Asterisk nn dng Softphone vi cng ngh giao thc mi dnh cho Asterisk l IAX .

- 18 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

Hnh 2-5: in thoi Softphone 2.7 Card giao tip vi PSTN Mun cho php cc my in thoi ni b trong h thng 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 s dng cho h thng Asterisk do chnh tc gi lp cng ty Digium phn phi, y cng chnh l tng ln trong vic phn phi phn mm Asterisk l h thng ngun m s dng min ph. 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, B:Bundle(sn phm c dng sn), gi tr ti a ca x v y l 4 ,v d card TDM22B c ngha l c 2 port FXS v 2 port FXO.

Hnh 2-6 Card TDM22B gm 4 port: 2 FXS v 2 FXO

- 19 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

2.8 ATA- Analog Telephone Adaptors ATA l thit b kt ni vi in thoi analog thng thng n mng VoIP, mt thit b ATA gm c hai loi port: RJ-11 kt ni vi my in thoi Analog thng thng, cn RJ-45 kt ni vi mng VoIP. ATA th c s l thit b FXS chuyn i tn hiu Analog sang tn hiu s s dng cho mng VoIP, tn dng my in thoi Analog nn trang b thit b ATA thay v phi trang b in thoi VoIP. Thit b ATA s dng vi giao thc IAX c Digium phn phi l thit b ATA c s dng rng ri vi Asterisk c tn gi l IAXy .

Hnh 2-7: Thit b ATA 2.9 Codecs Codecs c hiu mt cch tng qut l cc m hnh ton hc c s dng m ha (v nn ) tn hiu thoi dng Analog sang tn hiu Digital v ngc li . C nhiu thut ton codec thc hin chuyn i tn hiu Analog sang tn hiu Digital dng nh phn (0,1) nh G711, GSM, G729. ng vi mi thut ton c nhng u im ring, c bit l vic ti u s dng bng thng trn ng truyn. Mc tiu cui cng l cc thut ton a ra phi m bo cht lng cuc gi tt nht v tit kim bng thng nht G729 l codec tt nht hin nay trong h thng VoIP.Vi h thng Asterisk s dng thut ton ny cn phi mua bn quyn s dng v y l codec khng min ph s dng . 2.10 QoS-Quality of Service Cc yu t nh hng n cht lng dch v-QoS:

- 20 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

2.10.1 tr Thoi l dch v mang tnh thi gian thc rt cao v th tr l yu t nh hng rt ln n cht lng dch v .Tr c nh ngha l khong thi gian tnh t lc tn hiu thoi i t ngi ni ti ngi nghe .Tr l yu t khng th trnh khi, tr i vi mng in thoi truyn thng (mng PSTN) khong t 50 ms n 70 ms.Theo khuyn ngh ca ITU-T, m bo cht lng thoi cho h thng VoIP th tr t u pht ti u thu hoc ngc li khng c vt qu 150 ms, khi m tr vt qu 400 ms n 500 ms th khng th chp nhn c . Cc nguyn nhn gy ra tr bao gm: tr trn mng li, tr trn b m ha gii m, tr trong qu trnh ng gi, tr b m, tr x l ting ni 2.10.2 trt Nguyn nhn gy ra trt l gi tn hiu thoi trong qu trnh truyn t ngun n ch s gp phi nhng iu kin khc nhau trn mng li do thng n ch vi nhng khong tr khc nhau. y l tnh khng ng nht ca tr .Mt nguyn nhn khc ca trt i vi ng dng PC to PC l do vic s dng h iu hnh phi thi gian thc, cc gi tin thoi phi i h iu hnh x l trong nh ng khong thi gian khc nhau khi m h iu hnh phi x l i vi cc ng dng khc nhau .

- 21 -

http://my.opera.com/asteriskvn - CHNG II: CC KHI NIM TRONG H THNG ASTERISK

Hnh 2-8: Nguyn nhn xy ra trt loi b tnh khng ng nht ca tr, ngi ta thit k cc b m tr (Jitter Buffer) ti ni n ca cc gi tin, cc gi tin n vi cc khong cch khc nhau v thi gian c lu ti b m ri ra khi b m vi khong tr nh nhau . Khi b m c kch thc cng ln th kh nng loi b tnh khng ng nht cng ln, tuy nhin vic s dng b m s gy ra hin tng tr trong ng dng thoi, do cn c bi ton cn i gia tr v trt . Ngoi hai nguyn nhn trn cn c mt s nguyn nhn na nh hng n cht lng thoi nh mt gi, gii hn bng thng, ting vng .

- 22 -

http://my.opera.com/asteriskvn CHNG III: CC M HNH NG DNG M NGUN M ASTERISK

CHNG III: CC M HNH NG DNG M NGUN M ASTERISK


Asterisk thc hin rt nhiu ng cnh ng dng khc nhau ty vo nhu cu s dng, di y l nhng ng cnh ng dng thng c s dng trong thc t trin khai h thng Asterisk. 3.1. Tng i VoIP PBX

Hnh 3-1: IP- PBX

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 IP-PBX, iu ny s lm gim chi ph ng k. H thng c th lin lc vi mng PSTN qua giao tip TDM .

- 23 -

http://my.opera.com/asteriskvn CHNG III: CC M HNH NG DNG M NGUN M ASTERISK

3.2. Kt ni IP- PBX vi PBX

Hnh 3-2: 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.

- 24 -

http://my.opera.com/asteriskvn CHNG III: CC M HNH NG DNG M NGUN M ASTERISK

3.3. Kt ni gia cc server Asterisk

Hnh 3-3: Kt ni gia 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 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 .

- 25 -

http://my.opera.com/asteriskvn CHNG III: CC M HNH NG DNG M NGUN M ASTERISK

3.4. Cc ng dng IVR, VoiceMail, in thoi hi ngh

Hnh 3-4: Trin khai server IVR, VoiceMail, Hi Thoi

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.ng dng VoiceMail thu nhn nhng tin nhn thoi t pha thu bao ging nh chc nng hp th thoi ca Vin thng thnh ph trin khai .Cn chc nng in thoi hi ngh thit lp cho nhiu my in thoi cng ni chuyn vi nhau .

- 26 -

http://my.opera.com/asteriskvn CHNG III: CC M HNH NG DNG M NGUN M ASTERISK

3.5. Chc nng phn phi cuc gi t ng

Hnh 3-5: Phn phi cuc gi vi hng i 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. 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 mt trong mi 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 Vin thng thnh ph .

- 27 -

http://my.opera.com/asteriskvn - CHNG IV: CC DCH V C BN CA ASTERISK

CHNG IV: CC DCH V C BN CA ASTERISK


Asterisk c mt s tnh nng c bn c gii thiu chng mt. Trong phn ny s gii thiu mt s tnh nng vi cc ng dng c th hiu r hn v cc tnh nng ca h thng Asterisk . 4.1. Conference call (m thoi nhiu ngi) Nu chng ta cn gi in ti nhiu ngi nhng ch thng bo cho h cng mt ni dung .Tht l mt thi gian v bt tin khi phi ln lt bm s ca tng ngi gi.Chc nng Conference call, s gip chng ta gii quyt iu ny . Cc cuc m thoi nhiu ngi c thit lp cho php ngi nhn cuc gi tham gia m thoi xuyn sut cuc gi hoc c th c thit lp ngi nhn cuc gi ch c php nghe m khng c ni . Chng ta c th cho php ngi gi, gi ti nhng ngi khc v thm h vo tham d cuc m thoi . 4.2. Voicemail (hp th thoi) 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 th h thng Astreisk 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: password xc nhn khi truy cp vo hp th thoi, gi mail bo khi c thng ip mi. - Voicemail transfer: Tnh nng cho php bn chuyn cuc gi vo hp th thoi khi bn khng rnh nghe. -Voicemail dial: Nu bn khng mun in thoi ca ngi nhn chung (trnh lm phin khng cn thit), bn c th ni trc tip vo Voicemail ca ngi nhn .Ngi nhn sau s nghe li thng tin ca bn t Voicemail . 4.3. Call Forwarding (chuyn cuc gi) Khi khng c nh, hoc i cng tc m ngi s dng khng mun b l tt c cc cuc gi n th hy ngh ngay n tnh nng chuyn cuc gi . y l tnh nng thng c s dng trong h thng Asterisk .Chc nng ny cho php chuyn mt cuc gi n mt hay nhiu s my in thoi c nh trc .
- 28 -

http://my.opera.com/asteriskvn - CHNG IV: CC DCH V C BN CA ASTERISK

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 . 4.4. Caller ID (hin th s ch gi) Chc nng ny rt hu dng khi mt ai gi n v ta mun bit chnh xc l gi t u v trong mt s trng hp bit chc h l ai . Ngoi ra Caller ID cn l chc nng cho php chng ta xc nhn s thu bao gi n c ngha l da vo caller ID chng ta c tip nhn hay khng tip nhn cuc gi t pha h thng Asterisk.Ngn mt s cuc gi ngoi mun . 4.5. Automated Attendant (tng tc thoi) Chc nng tng tc thoi c rt nhiu ng dng trong thc t, khi gi in thoi n mt c quan hay x nghip, thu bao thng nghe thng ip nh Xin cho mng bn gi n cng ty chng ti, hy nhn phm 1 gp phng kinh doanh, phm 2 gp phng k thut sau ty vo s tng tc ca thu bao gi n, h thng Astreisk s nh hng cuc gi theo mong mun. Khi mun xem im thi, mun bit tin cc in thoi ca thu bao, mun bit t gi la hin nay nh th no, hay kt qu s s tt c nhng mong mun trn u c th thc hin qua chc nng tng tc thoi. 4.6.Time and Date Vo tng thi gian c th cuc gi s nh hng n mt s in thoi hay mt chc nng c th khc. V d trong cng ty gim c mun ch cho php nhn vin s dng my in thoi trong gi hnh chnh, cn ngoi gi th s hn ch hay khng cho php gi ra bn ngoi . 4.7.Call pickup y l tnh nng cho php chng ta t my in thoi ny c th nhn cuc gi t my in thoi khc ang rung chung . Bn nghe my in thoi ca ngi khc trong phng ang chung.Ngi khng c mt trong phng nhn cuc gi .V bn cng khng mun ri khi b n lm vic ca mnh tr li cuc gi.Bn hy dng in thoi ca bn tr li cuc gi . 4.8.Call Parking Bn ang tr li mt cuc gi .Bn mun chuyn cuc gi ny sang mt ng nghip khc, nhng ngi ny ch c th nhn in thoi sau khong 1 pht na (v ngi ny ang ni chuyn in thoi, hoc va bc ra ngoi ) V bn khng mun cm in
- 29 -

http://my.opera.com/asteriskvn - CHNG IV: CC DCH V C BN CA ASTERISK

thoi na . Bn s park-chuyn, cuc gi ny vo mt Park place (mt s in thoi trung gian) . ng nghip ca bn sau s pickup-nh n, cuc gi t Park place . 4.9.Privacy Manager Khi mt ngi ch doanh nghip trin khai Asterisk cho h thng in thoi ca cng ty mnh nhng li khng mun nhn vin trong cng ty gi i ra ngoi tr chuy n vi bn b, khi Asterisk cung cp mt tnh nng tin dng l ch cho php s in thoi c lp trnh, c php gi n nhng s my c nh no thi, cn nhng s khng c trong danh sch nh sn s khng thc hin cuc gi c. 4.10.Call Detail Records Asterisk gi li cc d liu chi tit cuc gi y .Chng ta c th cha thng tin ny trong mt tp phng (flat file), hoc tt hn l mt database lu tr v tra cu hiu qu. S dng thng tin ny chng ta c th gim st s s dng ca h thng Asterisk. Chng ta c th so snh cc d liu ny vi ha n m cng ty in thoi gi n, cho php chng ta phn tch lu lng cuc gi. 4.11.Call Recording Asterisk a n cho chng ta kh nng ghi m cc cuc gi. Tnh nng ny c s dng chng minh ni dung cuc gi lm tha mn mt yu cu no ca khch hng khi cn thit cng nh kh nng gip trong cc trng hp c lin quan n php lut. 4.12.Blacklist Blacklist cng ging nh Privacy Manager nhng c mt s khc bit l nhng my in thoi nm trong danh sch s khng gi c n my ca bn (s dng trong tnh trng hay b quy ri in thoi) 4.13.User permission to/international call Chng ta c th c cp quyn bng mt m hoc theo s ni b. V cn rt nhiu tnh nng na m h thng Asterisk c th cung cp cho ngi s dng , trn y ch l mt s tnh nng thng c s dng . bit thm cc tnh nng cn li, chng ta c th tham kho website www.asterisk.org.

- 30 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

CHNG V : THIT K CU HNH IP-PBX


Trong chng ny s m t vic ci t phn mm Asterisk vo my server, tm hiu cc file cu hnh h thng quan trng, k hoch quay s(dialplan) 5.1. Ci t Asterisk ci t Asterisk, u tin chng ta phi ci t h iu hnh Linux vo my server . C th ci cc bn phn phi sau ca Linux: Fedora, CentOS, Redhat, Debian Cc gi phn mm ph thuc phi c trong h iu hnh Linux trc khi ci t Asterisk l: bison gcc kernel-source libtermcap-devel ncurses-devel openssl096b openssl-devel

i vi cc phin bn Asterisk trc 1.2, chng ta phi ci t thm gi mpg123 . ci t gi mpg123, chng ta download bng lnh : #wget http://www.mpg123.de/mpg123-0.59.tar.gz Tip theo chng ta bung nn vo mt th mc ch nh, bin dch (compile) v ci t (install) bng cc lnh: #tar zxvf mpg123-0.59.tar.gz #make #make install Sau khi hon tt cc bc trn, chng ta tin hnh download phn mm Asterisk vi phin bn mi nht .Tt c cc gi phn mm ca Asterisk c cung cp y t website cung cp m ngun m : http://www.asterisk.org Download cc gi phn mm Asterisk bng cc lnh : #cd /usr/src #wget http://ftp.digium.com/pub/asterisk/asterisk-1.x.x.tar.gz #wget http://ftp.digium.com/pub/asterisk/asterisk-addons-1.x.x.tar.gz #wget http://ftp.digium.com/pub/asterisk/asterisk-sounds-1.x.x.tar.gz #wget http://ftp.digium.com/pub/zaptel/zaptel-1.x.x.tar.gz #wget http://ftp.digium.com/pub/libpri/libpri-1.x.x.tar.gz ( x :i din cho version)

- 31 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

Vic download nhanh hay chm ty vo tc ng truyn internet, sau khi download hon thnh chng ta tin hnh bung nn cc gi : #tar xzvf asterisk-1.x.x.tar.gz #tar xzvf asterisk-addons-1.x.x.tar.gz #tar xzvf asterisk-sounds-1.x.x.tar.gz #tar xzvf zaptel-1.x.x.tar.gz #tar xzvf libpri-1.x.x.tar.gz Chng ta cng nn to mt lin kt bng cch g lnh : #ln s /usr/src/asterisk-1.x.x /usr/src/asterisk .Lnh ny m bo gi addons c bin dch ng . Tip theo chng ta bin dch cc gi gii nn.Trc tin l gi zaptel, k n l gi libpri, sau cng l gi asterisk. 5.1.1. Ci t Zaptel Gi zaptel c cha th mc /usr/src/zaptel-1.x.x . nh lnh nh di y ci t: #cd /usr/src/zaptel-1.x.x #make clean #./configure #make #make install Cc lnh ny thc hin khong vi pht, ty thuc vo tc ca my tnh ci t . Sau khi ci t xong s tr li du nhc lnh v hin th mt lot cc thng bo, trong c mt s bn tin li m ch yu l yu cu ci t cc gi ph thuc lit k trn, nu cc gi cha c ci t. Gi Zaptel, cha cc driver Zapata c to cho Asterisk, cn thit cho vic s dng phn cng in thoi ca hng Digium, v cng bao gm mt s th vin m Asterisk ph thuc vo, bt k l chng ta c s dng phn cng ca hng Digium hay khng. Nu chng ta mun Asterisk khi ng khi boot my tnh, chng ta dng lnh: #make config Lnh ny to ra mt script chn module Zaptel vo kernel v chy ztconfig khi boot my tnh.

- 32 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

5.1.2. Ci t libpri K n chng ta bin dch v ci t gi libpri c cha ti th mc /usr/src/libpri1.x.x bng cc lnh sau: #cd /usr/src/libpri-1.x.x #make clean #make #make install Qu trnh bin dch ny khong mt pht, sau khi thc hin xong s tr v du nhc lnh . Libpri cung cp cc th vin c yu cu cho vic s dng trung k PRI, cng nh mt s giao tip in thoi khc. Ngay c khi Asterisk khng giao tip vi PRI, chng ta cng nn ci t n. 5.1.3. Ci t Asterisk By gi n lc chng ta thc s ci t Asterisk, c cha ti th mc /usr/src/asterisk-1.x.x . Chng ta ci t nh sau ; #cd /usr/src/asterisk-1.x.x #make clean #./configure #make #make install Sau khi ci t thnh cng, chng ta s c mt h thng PBX vi cc tnh nng c bn. Ti thi im ny chng ta s tin hnh cu hnh h thng theo nhu cu s dng. hiu r hn v cch cu hnh h thng, chng ta s xem cc tp tin cu hnh mu bng cch g lnh: #make samples Asterisk khi ng mi khi boot my tnh chng ta dng lnh: #make config Lnh make samples to ra mt tp tin zaptel.conf th mc /etc v cc tp tin cu hnh mu th mc /etc/asterisk Cc tp tin cu hnh mu bao gm: adsi.conf: tp tin ny cha ng cu hnh cho giao din cc dch v hin th Analog hay vit tt l ADSI (Analog Display Services Interface). adtranvofr.conf: tp tin ny cha cu hnh cho vic s dng Voice over Frame Relay.

- 33 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

agents.conf: tp tin ny ch a cu hnh cho vic s dng cc agent (in thoi vin), thng c ng dng trong cc trung tm cuc gi (call center).Tp tin ny cho php chng ta nh ngha cc agent v gn cho h cc ID v mt khu. alarmreceiver.conf: tp tin ny cu hnh ng dng nhn cnh bo. Chng ta s khng thay i cc gi tr t s thit lp mc nh ca n . alsa.conf: tp tin ny cha cc tham s cu hnh cho card m thanh ca h thng. asterisk.adsi: bao gm script ADSI mc nh ca Asterisk. Script ny s c thc thi t in thoi nu chng ta dng phn cng ADSI. asterisk.conf: tp tin ny thit lp cc bin tng qut cho vic s dng Asterisk. Hu ht nhng tham s ny chng ta s khng cn phi chnh sa . N thng bo cho Asterisk mt cch cn bn ni tm cc tp tin tng qut v cc chng trnh c kh nng thc thi. cdr_manager.conf: tp tin ny cu hnh CDR cho qun l cuc gi. cdr_odbc.conf: y l tp tin cu hnh cho vic s dng mt kt ni c s d liu ODBC lu tr cc CDR ca chng ta. cdr_pgsql.conf:tp tin cu hnh ny cho php chng ta s dng c s d liu PostgreSQL lu tr cc bn ghi CDR ca chng ta. cdr_tds.conf: y l tp tin cu hnh cho vic s dng FreeTDS, cho php cc kt ni n Microsoft SQL v Sybase. enum.conf: tp tin ny cu hnh s dng ENUM, cho php chng ta phn gii cc s in thoi da trn cc DNS, qua cho php chng ta nh tuyn cuc gi n mt s IP thay v i trn mng PSTN. extconfig.conf: vi tp tin ny, chng ta c th ty chn lu cc thng tin hot ng ca queue v mt c s d liu no . extensions.conf: tp tin ny cu hnh hot ng ca Asterisk.Chng ta s tim hiu su v tp tin ny. features.conf: tp tin ny bao gm cc ty chn cho cc chc nng c bn ca h thng nh : call parking, call pickup festival.conf: tp tin ny tit lp cc tham s cho Festival, l mt chng trnh ngun m m cho php server ca chng ta c cc tp tin vn bn. iax.conf: tp tin ny cu hnh cc ti khon s dng giao thc IAX m thoi indications.conf: y l ni cho php chng ta cu hnh cc thuc tnh tng qut ca h thng in thoi nh: nhp chung v cc tone, cho php chng ta cung cp m
- 34 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

thanh ngi dng s dng cc m thanh ca mng in thoi ca mt quc gia no . logger.conf: tp tin ny thit lp cc dng logging m chng ta s s dng. manager.conf: tp tin ny cu hnh cc quyn truy cp t xa n h thng qun l cuc gi Asterisk. meetme.conf: tp tin cu hnh ny thit lp cc phng hi thai n gin .Chng ta cng c th ty chn nh ngha cc mt khu cho tng phng. modem.conf: tp tin ny thit lp cc bin tng qut cho php chng ta s dng cc modem la chn vi Astersik. Ch rng khng nhiu cc modem c h tr bi Asterisk, v hu ht cc modem ch l half-duplex, chng khng c hiu nng tt . modules.conf: tp tin cu hnh ny la chn cc module Astersik no s c khi ng. Chng ta c th kch hot hoc tt cc tnh nng ca PBX thng qua vic thay i cc tham s y . musiconhold.conf: tp tin cu hnh ny to cc tp tin nhc ch v nh ngha th t tp tin no s c pht. oss.conf: cu hnh ny ging nh alsa.conf, chng ta s khng dng n n. phone.conf: tp tin ny cho php chng ta s dng cc giao tip in thoi Linux, nh linejack ca Quicknet privacy.conf:tp tin ny cho php chng ta cu hnh cc ty chn ring. queues.conf: tp tin cu hnh ny cho php chng ta to cc hng i (queue) cho ngi gi, cho php chng ta tip nhn mt s lng ln cc cuc gi c ng mt lc bng gii php thng minh. res_config_odbc.conf: tp tin ny thit lp cu hnh lu tr cc thng tin cu hnh h thng vo mt c s d liu dng ODBC. rpt.conf: tp tin ny cho php chng ta s dng cc b lp v tuyn (radio repeater). rtp.conf: tp tin cu hnh ny thit lp cc cng s dng giao thc thi gian thc ( Real -Time Protocal ). sip.conf: tp tin cu hnh ny nh ngha cc ti khon dng giao thc khi to phin (Session Initiation Protocal) v cc ty chn cho chng .Chng ta cng c th thit lp cc bin tng qut cho SIP, nh dng cng no v thi gian timeout l bao nhiu. skinny.conf: tp tin ny cu hnh giao th c VoIP skinny, vn c s dng rt nhiu trong cc in thoi ca Cisco.

- 35 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

telecordia-1.adsi: y l mt script ADSI mu. voicemail.conf: tp tin cu hnh ny to cc ngi dng h p th thoi(voicemail) v mt vi tham s tng qut cho cc kch bn Mail, h thng voicemail ca Astersik. vpb.conf: tp tin ny cu hnh phn cng Voice Tronix. zapata.conf: tp tin ny thit lp cc thng s cu hnh giao tip in thoi Zapata.Chng ta s s dng tp tin ny cu hnh phn cng ca Digium. Phn cng ca Digium cho php chng ta lin lc vi PSTN . 5.1.4. Ci t Asterisk-addons Ta dng cc lnh sau ci t Asterisk-Addons: #cd /usr/src/asterisk-addons-1.x.x #./configure #make #make install Sau khi bin dch v ci t thnh cng, chng ta c th khi ng v s dng Asterisk vi cc tham s mc nh. C nhiu cch khi ng Asterisk, nhng cch n gin nht l thc hin lnh sau: # /usr/sbin/asterisk rvvvv thot khi ch dng lnh, ta dng lnh sau: CLI>exit Cu trc th mc ca Asterisk : Asterisk s dng nhiu th mc trn h thng Linux qun l cc kha cnh khc nhau ca h thng, nh cc bn ghi hp th thoi, cc bn tin nhc thoi, v cc tp tin cu hnh.Phn ny s trnh by cc th mc chnh yu, c to ra trong qu trnh ci t v c cu hnh trong tp tin asterisk.conf /etc/asterisk/ Th mc /etc/asterisk/ cha cc tp tin cu hnh ca h thng Asterisk, ngoi tr tp tin zaptel.conf c t ti th mc /etc/ .Phn cng Zaptel u tin c pht trin bi Jim Dixon thuc nhm in thoi Zapata( Zapata Telephony Group) giao tip gia my tnh vi mng in thoi , m Asterisk li s dng phn cng ny , vi l do m file cu hnh zaptel.conf khng nm trong th mc /etc/asterisk/ /usr/lib/asterisk/modules/ Th mc /usr/lib/asterisk/modules/ cha tt c cc modules cn thit Asterisk hot ng .Bn trong th mc l cc ng dng khc nhau, cc codec, cc nh dng(format) v cc knh(channel) c s dng bi Asterisk. Theo mc nh Asterisk s np tt c cc module vo lc khi ng . Chng ta c th khng cho np mt module bt k bng cch khng khai bo s dng trong tp tin modules.conf. Lu khi khng cho
- 36 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

np module th phi bit chc module khng nh hng n hot ng ca Asterisk, nu khng li s xut hin khi khi ng . /var/lib/asterisk/ Th mc /var/lib/asterisk/ cha tp tin astdb v mt s th mc con.Tp tin astdb cha ng thng tin c s d liu ca Astersik, ging nh Microsoft Windows Registry. Cc th mc con ca th mc /var/lib/asterisk/ bao gm: . agi-bin/ Th mc agi-bin/ cha cc script ca ngi dng, cc script ny c th giao tip vi Asterisk qua cc ng dng AGI(Asterisk Gate Interface) khc nhau c ci t sn.AGI l phn giao tip vi ngn ng lp trnh script thc hin mt s cng vic ca Asterisk t bn ngoi. . firmware/ Th mc firmware/ cha mt s firmware cho cc thit b khc nhau tng thch vi Asterisk.N hin ti ch cha th mc con /iax cha cc firmware cho thit b IAXy ca Digium.IAXy l thit b ATA s dng giao thc IAX. . images/ Cc ng dng thng tin vi cc knh h tr cc nh ha th s dng th mc ny. Nhng hin ti cc knh thng tin th hu nh khng h tr truyn nh nn th mc ny cng him khi c s dng.Tuy nhin nu cc thit b c h tr th th mc ny tr nn hiu dng. . keys/ Asterisk c th s dng mt h thng kha public/private xc minh cc kt ni gia cc server Asterisk thng qua ch k in t RSA.Nu t mt kha public vo th mc /keys th kt ni ca server u bn kia c th c xc minh bng knh thng tin c h tr, i vi Asterisk th knh giao thc IAX h tr loi xc minh ny. Mt kha private th khng bao gi c phn pht n public, chng ta ch cng b kha public n vi server cn kt ni, sau s xc minh vi kha private ny.C hai kha public v private c lu vi ui .pub v .key t ti th mc keys/ . mohmp3/ Khi chng ta cu hnh Asterisk vi tnh nng Music on Hold, tnh nng ny hot ng s ly cc tp tin MP3 ti th mc mohmp3/. Tp tin nh dng theo chun ca Asterisk nn khi s dng cc file MP3 thng thng cn c s chuyn i thch hp trc khi chp vo th mc trn s dng. . sounds/ Tt c cc tp tin m thanh lin quan n nhc thoi ca Asterisk c t ti th mc sounds/.Ni dung ca cc tp tin cha trong th mc c lit k qua tp tin sounds.txt t ti th mc m ngun ca Asterisk. Cn ni dung ca cc tp tin m thanh c m rng thm c lit k trong tp tin sounds-extra.txt t trong th mc c trch ra khi bung gi asterisk-sounds.

- 37 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

/var/spool/asterisk/ Th mc /var/spool/asterisk/ cha nhiu th mc con bao gm outgoing/, qcall/,tmp/, voicemail/ . Astersik lun kim tra th mc outgoing v qcall v y l hai th mc cha cc tp tin dng text, cha thng tin yu cu cuc gi . Cc tp tin cho php chng ta to ra mt cuc gi n gin bng cch sao chp hoc di chuyn tp tin c cu trc qui nh vo th mc outgoing/. Th mc tmp/ s dng lu tr nhng thng tin tm, lun m bo khng xy ra tnh trng c v vit tp tin cng mt lc, khi yu cu x l tp tin chng ta thao tc trn th mc tmp/ trc khi lu vo tp tin ch . Tt c li nhc thoi t pha ngi s dng v cc li nhc thoi s dng cho thao tc voicemail u c cha trong th mc voicemail/. Mt hp th thoi c to ra ng vi mt my ni b trong tp tin voicemail.conf, s c to ra mt th mc con tng ng cho my ni b ti th mc voicemail/. /var/run/ Th mc /var/run/ cha thng tin process ID (pid) cho tt c cc tin trnh ang hot ng trong h thng, bao gm c Asterisk . Lu l ng vi mi h iu hnh th mc var/run/ c th khc. /var/log/asterisk/ Th mc /var/log/asterisk/ l ni Asterisk cha tt c cc tp tin nht k hay cn gi l tp tin log. Chng ta c th ty bin cc loi thng tin c lu trong cc tp tin log khc nhau qua tp tin cu hnh logger.conf t ti th mc /etc/astersik /var/log/asterisk/cdr-csv: Th mc /var/log/asterisk/cdr-csv c s dng lu chi tit cuc gi CDR , thng tin mc nh v chi tit thng tin cuc gi c lu tr trong tp tin Master.csv, nhng thng th ng vi mi m accountcode s to mt th mc ring lu chi tit cuc gi cho my . 5.2. Cu hnh h thng Sau khi hon tt phn ci t Asterisk, mt bc quan trng tip theo l cu hnh h thng, c th ni y l bc quan trng nht ca vic trin khai h thng n vi tng ng dng c th. 5.2.1. Cu hnh giao tip vi PSTN kt ni vi mng PSTN chng ta cn phi c mt card TDM vi cng FXO v mt ng dy in thoi hoc c th l mt tng i ni b PBX .C nhiu nh sn xut phn cng khc nhau, nhng trong phm vi lun vn s trnh by cu hnh mu dng card zapata TDM04B ca Digium. (Thng tin v card, c th tham kho ti http://www.digium.com ). Trc khi lp t card TDM04B hy tt ngun my tnh v kim tra khe cm PCI c tng thch gn vo hay khng, ch yu l kim tra s tng thch v mt vt l . Sau khi hon tt hy bt my tnh tr li v chun b cu hnh cho card hot ng .

- 38 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

Cu hnh cho card hot ng thng qua hai tp tin cu hnh l tp tin zaptel.conf th mc /etc v tp tin zapata.conf th mc /etc/asterisk 5.2.1.a. zaptel.conf Nh bit tp tin zaptel.conf nm th mc /etc. Chng ta c th chnh sa tp tin ny bng bt c cng c chnh sa text no u thch. Khi thay i ni dung ca tp tin ny, chng ta phi buc cc driver Zaptel c tp tin cu hnh pht hin s thay i. Nu h thng ca chng ta c cu hnh bt u phn cng Zaptel khi boot my, chng ta c th thc hin iu ny bng lnh sau : $/etc/init.d/zaptel stop $/etc/init.d/zaptel start Hoc nu chng ta khng bt u cc giao tip Zaptel khi boot my, chng ta c th thc thi cc s thay i bng cch chy lnh sau: #ztcfg xem cc thng tin xut ra trong qu trnh reload knh Zap, ta thm cc tham s v vo cu lnh trn: #ztcfg vvv C hai ty chn tng qut c thit lp trong tp tin ny . u tin l loadzone, s nh ngha u tin ring bit cho chun ca mt quc gia no , nh cng ca chung nn c l bao nhiu .Cng vy tham s th hai defaultzone s bo cho Zaptel bit vng no c dng mc nh, nu nh khng c ch nh c th. Gi tr cho mi ty chn ny gm hai ch vit tt ca quc gia .V d i vi Hoa k, tp tin zaptel.conf c th cha ng: loadzone = us defaultzone = us Tip theo chng ta cn m t loi kt ni m chng ta dng .ng dy c th c nhiu dng khc nhau, loi kt ni chng ta s dng ph thuc vo loi dch v no c cung cp bi cng ty in thoi.Thng thng c hai s la chn thng dng cho Asterisk l Primary Rate ISDN (PRI) v Plain Old Telephone System (POST), thng c gi l ng dy Analog. i vi ng dy Analog thng thng (POST), trong tp tin zaptel.conf, chng ta cn ch ra loi bo hiu no chng ta s s dng .Nh trnh by phn trc, chng ta cn thit b FXO kt ni n PSTN . y chng ta nh ngha loi bo hiu m Asterisk s dng ch khng phi l dng thit b ang dng. i vi mi knh Zap, c th cho card TDM04B, ta phi nh ngha: fxsks =1,2,3,4 loadzone = us
- 39 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

defaultzone = us Vi khai bo fxsks=1,2,3,4 ta nh ngha ba tham s . u tin xc nh loi bo hiu, nu thit b chng ta dng l giao tip FXO th bo hiu s dng s l FXS v ngc li.Th hai chng ta nh ngha giao thc .iu ny ph thuc vo ng dy in thoi m chng ta dng.Thng thng chng ta c th s dng Koolstart(ks),hoc cc ty chn khc l: Loopstart(ls) v Groundstart(gs).Cui cng chng ta ch ra s knh l 4, nm trn knh t 1 n 4 ca card giao tip. Nu chng ta cu hnh loi bo hiu khng ph hp, khi reload Zaptel bng lnh ztcfg vvv, ta s thy bn tin li nh sau: #ztcfg vvv ZT_CHANCONFIG failed on channel 1: invalid argument (22) Did you forget that FXS interfaces are configured with FXO signalling and that FXO interfaces use FXS signalling? Nu chng ta dng ng dy s ISDN (PRI) hoc T1, th tp tin cu hnh ca chng ta s c mt vi khc bit so vi ng dy Analog .Chng ta nh ngha mi lung ISDN hay T1 nh l mt span .i vi mi span ny ,chng ta cn ch ra cc thng s chi tit nh sau : Span number: y l s th t n nh cho mi lung .Nu lung kt ni vo cng th nht trn card, ta nh ngha l span 1, cng s 2 l span 2, Timing: mi lung cn c mt ngun ng b 1 trong 2 u cui. Mt lung ISDN gn vo card giao tip ca Asterisk c th ng b da vo xung ng h cc b hoc c th da vo xung u ra pha telco hoc ni m PBX kt ni ti .ng b cc b (Internal timing) l khi xung ng b c ly ngay trn card, da vo xung chipset trn card. ng b ngoi l khi xung ng b c ly t ng dy PRI do u xa gi ti .Tham s timing trong nh ngha span trong tp tin zaptel.conf s quyt ng la chn l primary, secondary hay trn mt ngun xung ng b khc : 0: ngha l internal clocking, s dng tn hiu xung ca chipset trn card khi to xung ng b. 1: xung ng b l primary source, tc zaptel ng b xung da vo tn hiu nhn c t ng dy cho port (span) ny.y c gi l external clocling. 2: xung ng b l secondary clock source, ngha l s khi phc xung cho span ny t xung ca card nu span vi clock =1 b li. Line Build Out (LBO):s nguyn ny m t chiu di ca cable. Framing: thng tin ny m t cc thng s framing cho ng truyn ca chng ta. Nhng thng s ny cn m t chnh xc vi khai bo ca nh cung cp . Nu l lung T1: c cc tham s: d4 (cn gi l supperframe hay sf) v esf Nu l lung E1: c cc tham s: cas, ccs. Coding: tham s ny ch ra m ng truyn ca chng ta .Cng nh framing, thng s ny phi m t chnh xc vi nh cung cp ni kt: i vi T1: ami hoc b8zs
- 40 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

i vi E1: ami, hdb3 v thm vo tham s crc4 kch hot vic kim tra CRC-4 cho ng truyn. 5.2.1.b. zapata.conf Chng ta cu hnh xong tp tin zaptel.conf h thng Linux c th nhn dng c driver ca card cng nh hiu c cc thng s lin quan n ng truyn. Tuy nhin Asterisk c th bt tay c vi driver ny , ta phi cu hnh trong tp tin zapata.conf Tp tin cu hnh ny c c bi Asterisk . Do cp nht s thay i trong tp tin ny, chng ta dng lnh reload giao din console ca Asterisk . Zaptel khng cn phi restart trong trng hp ny. Sau y l rt nhiu tham s phi c thit lp trong tp tin ny: language: y l ngn ng mc nh s dng .Mc nh l en (ting Anh) conext: y l ni chng ta ni cho Asterisk cc cuc gi mi s t vo ng cnh no x l .Gi tr mc nh l default switchtype: ch dng khi ng truyn l PrimaryRate ISDN hoc T1, gm cc ty chn: - 4ess: giao thc 4ESS ca AT&T - 5ess: giao thc 5ESS ca Lucent - dms100: Nortel DMS100 - euroisdn-EuroISDN - national: National ISDN2(default) - ni1: Old National ISDN 1 pridialplan:thit lp ny cng ch dnh cho cc kt ni PRI.Gm cc ty chn : -unknow -private -local -national -international overlapdial:thit lp ny quyt nh gi cc s overlapping trong qu trnh quay s hay khng .Cc gi tr ty chn l: yes v no. signalling: thit lp ny chn phng php bo hiu .Gm cc gi tr: - em: bo hiu E&M - em_w: E&M Wink - fxY-zz: vi Y c th l o hoc s ( iu ny s tng t nh trong tp tin zaptel.conf) v zz c th l ks (Koolstart), gs (Groundstart), hoc ls (Loopstart). - pri_cpe: bo hiu PRI, pha CPE(Customer Premises Equipment). - pri_net: bo hiu PRI, pha mng.
- 41 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

sf: bo hiu SF sf_w: SF Wink

prewink :chu k prewink (chu k chp nhy), mc nh l 50ms. preflash: mt chu k flash, mc nh l 50 ms. start: thi gian bt u, mc nh l 1500 ms. usecallerid: chn yes nu chng ta mun s dng caller ID.Ch iu ny c th gy ra thi gian tr t khi Asterisk bt u nhn cuc gi cho n khi chung v Asterisk s phi i nhn c thng tin v caller ID.Nu khng mun s dng chn no. hidecallerid: chn yes nu chng ta mun n caller ID cho cc cuc gi ra ngoi . callwating: chn yes kch hot chc nng ch cuc gi trn thit b FXO. restrictcid:chn yes gi callerid Identification) di dng ANI (Automatic Number

callwaitingcallerid : chn yes nu mun h tr caller ID cho cuc gi ch . threewaycalling: chn yes nu mun h tr cuc gi 3 bn. transfer: thit lp chc nng ny l yes n u mun h tr flash-hook transfer. S dng chc nng ny i hi phi chn three-way calling . cancallforward: chn yes nu mun h tr chc nng call forward. callreturn: quyt nh c kch hot chc nng call return (gi li ) thng qua phm chc nng : *69 mailbox: thit lp voicemail number ca mailbox. echocancel: tham s ny c th chn l yes,no hoc mt s c th nh ngha mc trit ting vng. echocancelwhenbridget: thit lp iu ny thnh yes nu mun trit ting vng khi cuc gi ho n ton l TDM (Time Division Multiplexing) .Thng thng l khng cn thit , nhng trong cu hnh mu c thit lp l yes. relaxdtmf: thit lp ny gip Asterisk nhn ra c cc tn hiu phm dng DTMF c nhp vo trong qu trnh m thoi . thit lp li (Gian setting): -txgain: n v dB, thit lp TX gain, mc nh l 0.0 -rxgain: n v dB, thit lp RX gain, mc nh l 0.0
- 42 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

group: nh ngha mt nhm cho cc knh Zap. iu ny dng cho cc cuc gi ra . pickupgroup: y l mt nhm nhc my (pickup group).Nu mt in thoi no trong cng nhm pickup vi bn rung chung, bn c th nhc my t xa thng qua vic quay *8# callerid: thit lp s caller ID thnh asreceived hoc vi mt s c th. accountcode: chng ta c th n nh cc knh n tng m ti khon i vi vic qun l cc. adsi:chn yes nu chng ta c dng cc in thoi tng thch ADSI. busydetect: thit lp thnh yes c gng nhn dng xem ng dy hin l hung up hay busy. busycount : tham s ny nh ngha bao nhiu tn hiu bn (busy tone) c nhn trc khi hang up mt knh. Mc nh l 4, tng gi tr ny ln c th trnh cc trng hp b rt cuc gi mt cch ngu nhin . musiconhold: nh gha class music s dng cho nhc ch. channel: y c th l mt knh hay l mt nhm knh .Cc knh ny phi c nh ngha trc trong /etc/zaptel.conf. Sau y l v d minh ha : -Gi s chng ta c mt thit b FXO trn knh 1, cuc gi nhm 1, th khai bo trong tp tin zapata.conf nh sau: [trunkgroups] ;nh ngha cc nhm trung k ti y.Mc nh c th b qua [channels] ;cc gi tr mc nh usecallerid=yes hidecallerid=no callwaiting=no threewaycalling=yes transfer=yes echocancel=yes ;nh ngha cho cng FXO signalling=fxs_ks context=default group=1 channel=1
- 43 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

-i vi thit b FXS trn knh 2 th khai bo nh sau: [trunkgroups] ;nh ngha cc nhm trung k ti y.Mc nh c th b qua [channels] ;cc gi tr mc nh usecallerid=yes hidecallerid=no callwaiting=no threewaycalling=yes transfer=yes echocancel=yes ;khai bo cng FXS signalling=fxo_ks context=longdistance adsi=no callgroup=1 pickupgroup=1 channel=2 5.2.2. Giao din SIP Giao thc khi to phin (Session Initiation Protocal-SIP), l mt trong cc chun giao thc truyn thoi trn nn IP . Giao thc ny ch yu da vo giao th c thi gian thc (Real-time Transport Protocal), s dng cng UDP trong b TCP/IP truyn thoi . N cng ng ngha cc a ch c nh dng ging nh mt email, vd user@domain . Chng ta s cu hnh giao thc ny bng cch chnh sa tp tin /etc/asterisk/sip.conf. Tp tin ny gm mt s thit lp trong phn tng qut [general], v tip theo l cc nh ngha ca chng ta cho cc user. Cc ty chn trong phn [general] bao gm: context: thit lp ng cnh mc nh cho cc cuc gi vo. Cc cuc gi ny c th t cc user ca chng ta, hoc nu chng ta kt ni n Internet th n c th n t bt ni no . Mc nh l default. port: thit lp cng UDP lng nghe i vi cc kt ni. Mc nh l 5060 v chng ta khng nn thay i, tr khi chng ta c mt l do thc s tt. bindport: xc nh a ch IP m chng ta mun SIP phc v n . srvlookup:quyt nh c kch hot chc nng DNS SRV lookup hay khng . pedantic: nu chng ta c s dng pingtel, nn thit lp tham s ny l yes.

- 44 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

tos: y l thng s thit lp cht lng dch v (Quality of Service- QoS). Chng ta c th ch ra mt gi tr s c th no hoc c th dng t kha lowdelay, throughput,reliability,mincost hoc none. Chng ta nn thit lp gi tr ny l lowdelay nu khi m thoi nghe nhng tp m nh ting lp bp, si hoc cc m thanh khng ph hp khc. maxexpiry: thit lp thi lng ti a tnh bng giy, cho php mt phin ng k c gi tr . Mc nh l 3600, ngha l mt phin ng k ti a s phi time out sau 1 gi defaultexpiry : y l thi lng mc nh tnh bng giy cho mt phin ng k bt k. Mc nh l 120. notifymimetype: chng ta c th ghi dng MINE ln cc bn tin SIP NOTIFY. Chng ta khng nn sa tham s ny, nu nh khng phi v mt l do c bit no videosupport: chng ta c th thit lp tham s ny thnh yes cho php h tr hnh nh trong SIP.Asterisk hin ti h tr cc codec hnh nh nh H.263 v H.263+ musicclass: l ni thit lp cc bn nhc ch mc nh cho tt c cc cuc gi SIP. Mc nh l default. accountcode: thit lp cc m ti khon cho cc SIP user. Tnh nng ny ng dng trong vic tnh cc . language: thit lp ngn ng mc nh cho cc SIP user.Mc nh l en. relaxdtmf: gip cho Asterisk nhn c cc xung dng DTMF ca cc phm c nhn trong qu trnh m thoi. rtptimeout: ni y chng ta c th cu hnh chu k im lng ti a cho 1cuc gi .Nu RTP stream khng hot ng trong mt khong thi gian c thit lp .Cuc gi s c kt thc .Mc nh l 60 externip: ni y chng ta c th thit lp cc a ch IP bn ngoi ca server Astersik. iu ny rt hu ch cho cc trng hp lin quan n NAT v tng la . localnet: ni y chng ta s nh ngha cc a ch IP bn trong cho Asterisk servser. iu ny s ch cho Astersik bit cc bn tin SIP no dng cho a ch IP ngoi v nhng ci no cn cho a ch IP bn trong . register: tham s ny dng ng k vi mt nh cung cp hoc dch v bng giao thc SIP no . V d : abc@def@sipprovider.com. ,trong adb l username, def l password v sipprovider.com l SIP ca nh cung cp dch v . codes: chng ta phi nh ngha loi codec(encoder/decoder) no c s dng cho cc cuc gi SIP m chng ta cho php thng qua Astersik. u tin chng ta nn thit
- 45 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

lp disalow=all v hiu tt c cc codec. Sau thm tng codec bng cch dng allow=codec. V d ch cho php s dng codec g.723 v ulaw, ta dng : disallow=all allow=g723 allow=ulaw Chng ta cu hnh cc ty chn tng qut trong phn [general], tip theo chng ta phi nh ngha cho cc user .Sau y l cu hnh c th cho mt user: type: gm cc gia tr : user: kt ni ny c php gi cc cuc gi n chng ta. peer: chng ta c php gi cc cuc gi n kt ni ny. friend: kt ni ny l user ln peer. username: thit lp usename dng cho vic xc thc. secret: thit lp password dng cho vic xc thc. md5secret:m ha dng MD5 hash ca chui<user>:asterisk:<secret> cho vic xc thc thm bo mt. callerid: thit lp caller ID . V d callerid=Myname<1234> . host: thit lp a ch host cho user .a ch ny c th l mt a ch tnh hoc mt t kha dynamic. nat: thit lp cho d thit b SIP pha sau NAT firewal hay khng. mailbox: thit lp mailbox kim tra tin nhn cho user.iu ny c th ch l mt mailbox ID, hoc c th l mailbox ID v theo sau l @tn ng cnh. qualify: thit lp bao nhiu milisecond thit b c th mt kt ni(trn g thi unreachale) c xem nh l down. dtmfmode: thit lp ch d DTMF .S la chn gi tr no ph thuc vo phn cng chng ta ang s dng .Cc gi tr ty chn l: rfc2833, info, inband . security: chng ta c th dng t kha permit hoc deny thit lp cc mc bo mt. - deny: thit lp danh sch cc a ch IP khng cho php ng k, nu chng ta thit lp deny=0.0.0/0.0.0.0 th tt c cc ng k s b t chi. Nu cu hnh deny= 192.168.1.0/255.255.255.0 th tt cc ng k xut pht t a ch lp C ca 192.168.1.0 s b t chi. - permit: danh sch cc a ch IP cho php ng k n .Mc nh l tt c cc a ch u c php.

- 46 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

Sau y l 1 cu hnh mu trong tp tin sip.conf . Gi s cc ty chn tng qut c thit lp .Chng ta c 3 user: mt cho tt c cc cuc gi vo, mt cho cc cuc gi ra n dch v Free World Dial(FWD) v mt cho mt in thoi SIP [sip_incoming] type=user [FWD-out] type=peer secret=mypassword username=myusername password=mypassword host=host.provider.com [1000] ; y l extension ca in thoi SIP type=friend contex=longdistance username=1000 callerid=Myname<1000> host=dynamic defaultip=192.168.1.100 secret=2manysecrets nat=no canreinvite=yes dtmfmode=info mailbox=1000 disallow=all allow=ulaw accountcode=company123 5.2.3. Giao tip IAX Tt c cu hnh cho mt kt ni IAX nm trong tp tin /etc/asterisk/iax.conf. Cng ging nh cu hnh SIP, cn phi thit lp mt s ty chn tng qut cho kt ni IAX trong phn [general], bao gm cc ty chn : port: thit lp cng lng nghe cho cc cuc gi IAX. Mc nh l 5036 bindaddr: thit lp a ch IP kt ni ti .Mc nh l 0.0.0.0 ngha l tt c cc IP u c gi tr. accountcode: cng nh i vi SIP , chng ta cng c th thit lp mt m ti khon dng cho mc ch tnh cc. language: chng ta c th xc nh ngn ng, nu khng Asterisk s mc nh l English.

- 47 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

bandwidth: chng ta c th ch ra mt mc bng thng no .iu ny s t thit lp t ng cc codec no c th v khng th s dng. Cc gi tr gm low, medium, v high. codec selecton: cng nh trong sip.conf .Chng ta c th khng cho php tt c cc codec bng disallow=all v sau ch cho php mt s codec c th no ,v d: allow=ulaw. Nu chng ta dng allow=all th tng t nh dng bandwidth=high. trunkfreg:chng ta c th thit lp s mili giy gia cc bn tin trung k. Mc nh 20 ms l kh tt cho hu ht cc thit lp . register: nh trong sip.conf, chng ta c th ng k n mt server t xa.Gi s nu username l abc, mt khu l pw v chng ta mun ng k vi providerhost.com th cu lnh ng k s l: register=> abc:pw@providerhost.com tos: thit lp cc bt TOS, cc gi tr ty chn l lowdelay, throughput, reliability, mincost v none.Thng thng lowdelay c tin tng nht. Sau khi nh ngha xong cc ty chn tng qut, chng ta cn nh ngha cc tham s c th cho tng user . Mi tham s ty chn chi tit cho mt user IAX th tng t nh user trong cu hnh SIP .Mt s khc bit gia SIP v IAX l giao thc IAX h tr cc phng php xc thc dng m ha kha RSA chung/ring, cng vi MD5 v thun text. Sau y l mt v d: Gi s chng ta c mt user vi s extension l 2000 v cc tham s tng qut trong [general] c nh ngha th cc khai bo trong tp tin iax.conf l: [2000] type=friend secret=123456 host=dynamic defaultip=192.168.1.200 callerid=name<2000> context=longdistance deny=0.0.0.0/0.0.0.0 permit=192.168.1.1/255.255.255.0 5.2.4. Hp th thoi (Voicemail) 5.2.4.a. Gii thiu 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 k cuc gi in thoi no. Mt s tnh nng ca h thng voicemail:

- 48 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

Khi user khng tr li, user khng c kt ni mng hay user ang bn, h thng u c thng ip ring thng bo tnh trng ca thu bao c gi v pht thng ip mi li tin nhn . Mi hp th u c qun l bng password 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. C th kim tra VoiceMail trc tip trn my in thoi. Nhng thng ip li cho trong h thng ho n ton c th thay i ph hp vi ng cnh s dng, khng nht thit phi s dng thng ip mc nh . 5.2.4.b. Cu hnh chc nng voicemail Sau y l cc bc xy dng h thng Voicemail -To hp th c tn l [hopthu] trong tp tin voicemail.conf : [hopthu] 3003=>1234,hai,lxhai06@yahoo.com -Trong tp tin sip.conf khai bo nh sau: [3003] type=friend username=3003 secret=121212 host=dynamic context=testhopmail mailbox=3003@hopthu -Trong tp tin extensions.conf khai bo nh sau: [testhopmail] exten => 3003,1,Dial(SIP|3003,45) exten => 3003,2,VoiceMail(u3003@hopthu) ; nu khng tr li th chuyn n hp th thoi exten =>3003,102,VoiceMail(b3003@hopthu) ; ng dng Dial() gi cuc gi n priority n+1 nu ng dy bn. Kim tra Voicemail: ng dng VoicemailMain() qun l cc user ca PBX truy cp vo voicemail ca h. V d:
- 49 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

exten => 500,1,VoiceMailMan() Extension 500 a n h thng voicemail.Trong trng hp ny, h thng s nhc user a vo s ca mailbox v password, nu gi tr a vo hp l, user s nghe c ni dung ca mailbox . 5.2.5. Nhc ch (Music On Hold) 5.2.5.a. Gii thiu Tnh nng MOH ca Asterisk vi nhiu ng dng thc t rt thit thc, mt s ng dng tiu biu nh trong khi gi my gp ngi khc, 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, hoc pht ra mt thng ip thng bo cho mt tc v no . 5.2.5.b. Cu hnh tnh nng MOH Chp ton b tp tin nhc vo th mc mt nh /var/lib/asterisk/mohmp3 .Sau khai bo trong tp tin cu hnh /etc/asterisk/musiconhold.conf vi ni dung : [default] mode=files directory=/var/lib/asterisk/mohmp3 random=yes Nu random=no th tt c cc tp tin m thanh trong th mc mohmp3 s th hin theo th t. Nu random=yes s thc hin mt tp tin m thanh ngu nhin trong th mc . Sau khi cu hnh xong chng ta c th test bng cch cu hnh k hoch quay s trong tp tin /etc/asterisk/extensions.conf nh sau : ;cc dng ny phi c t cng ng cnh vi cc thu bao exten => 9000,1,Answer() exten => 9000,n,SetMusicOnHold(default) exten => 9000,n,WaitMusicOnHold(15) exten => 9000,n,Hangup()

Khi thu bao quay s 9000 h thng s tr li sau pht ra mt bi nhc ngu nhin trong th mc default, trong vng 15s sau gc my Chng ta c th to ra mt lp th mc khc vi lp default sau chp tt c cc tp tin m nhc vo th mc ny v ng thi khai bo trong tp tin cu hnh /etc/asterisk/musiconhold.conf th chng ta c th s dng chc nng MOH. Sau y l qu trnh thc hin :
- 50 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

-To th mc mi #mkdir /var/lib/asterisk/mohmp3/newclass -Khai bo tp tin cu hnh /etc/astersik/musiconhold.conf [newclass] mode=files directory=/var/lib/asterisk/mohmp3/newclass random=yes on k hoch quay s trong tp tin extensions.conf nh sau: exten=> 9000,1,Answer() exten=> 9000,n,SetMusicOnHold(newclass) exten=> 9000,n,WaitMusicOnHold(15) exten=> 9000,n,Hangup() 5.2.6. Hng i (Queue) 5.2.6.a. Gii thiu Hng i to ra mt ch logic xp cc caller vo cho n khi chng ta sn sng tr li cuc gi.Hng i l mt cung c rt mm do v mnh m cho cc h thng dch v khch hng. 5.2.6.b. Cu hnh: Tt c cc cu hnh lin quan n hng i, nm trong tp tin /etc/astersik/queues.conf. nh ngha mt hng i, chng ta bt u bng tn hng i, c t trong du ngoc vung [].y cng l s cc extension khc c th truy cp vo queue thng qua s ny.Do tt nht nn t tn hng i di dng s .V d: [1000]. Sau chng ta phi thit lp cc tham s cho hng i.u tin l nhc ch trong hng i, chng ta s ch ra class cha nhng tp tin m thanh upload ln h thng (nh m t trong phn Music On Hold): music = music_class Tip theo chng ta nh ngha mt thng bo, nu nh chng ta mun.iu ny gip pht mt tp tin m thanh thng bo n cc in thoi vin (agent) khi anh ta (c ta ) tr li cuc gi n t hng i. Chc nng ny s hu ch nu chng ta c cc agent tr li nhiu hng i, n s gip thng bo cho agent bit cuc gi ny i t hng i no ti . Nu mun dng, phi chc chn rng chng ta c tp tin m thanh: /var/lib/asterisk/sounds/<ten_file>.<extension>.Thit lp chc nng ny bng cu lnh: announce= <tn_file>
- 51 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

By gi chng ta cn cu hnh qui lut chung cho cc agent trong hng i . Chng ta nn quyt nh iu ny d a vo c th ca cng vic m hng i phi lm.V d nu thit lp chc nng ringall cho hng i, ta dng: strategy = ringall Khi ,nu mt cuc gi c vo hng i, tt c cc in thoi ca cc agent trong hng i m ang ri u chung v sn sng nhn cuc gi . Tip theo chng ta thit lp timeout. y l thi lng m mi cuc gi s chng trc khi hng i xem xt cuc gi khng c tr li .Chng ta nn thit lp thi gian ny ln cc agent thi gian nhc my v tr li in thoi .Gi tr thng dng l 15ms : timeout=15 By gi chng ta thit lp thi gian i trc khi bt u th li sau khi chung ht tt c cc extension trong hng i m khng c tr li .Gi tr thng dng l 0 retry=0 Tip theo chng ta thit lp gii hn bao nhiu cuc gi c xp vo hng i.Nu chng ta mun cho php mi cuc gi u vo hng i, th thit lp gi tr 0: maxlen=0 Cui cng, chng ta nh ngha cc thnh vin trong hng i.n gin chng ta ch cn thm cc dng lnh theo nh dng nh sau: member => agent/extension_number member => agent/extension_number Trong , extension_number l cc s ca agent m ta nh ngha trong tp tin agents.conf V c nh th ta tip tc ng ngha cc hng i khc vi cc tham s ph hp p ng nhu cu ra . S lng hng i chng ta nh ngha c th l khng gii hn, ch ph thc vo ngun ti nguyn ca server . 5.2.7. Xy dng h thng hi thoi (conference rooms) 5.2.7.a. Gii thiu Chc nng hi thai cho php nhiu ngi c th cng nhau trao i, ni m mi ngi cng gi n m thoi gi l phng hi thoi . Asterisk cho php to ra nhiu phng hi thoi ty vo nhu cu 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 .
- 52 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

5.2.7.b. Cu hnh cu hnh thc hin mt phng hi thoi chng ta ln lt cu hnh nh sau : To ra phng hi thoi room trong tp tin cu hnh meetme.conf . Khi chng ta m tp tin ny, chng ta c th thy nh sau ; ; configuration file for MeetMe simple conference rooms ; [room] ; ; Usage is conf => confno[,pin] ; conf => 1234 ; conf => 2345,9938 Khai bo phng hi thoi room trong k hoch quay s cho mi ngi c th gi n. To phng hi thoi room to phng hi thoi room chng ta khai bo trong tp tin meetme.conf theo c php sau : conf => conference_number[,pin][,adminpin] trong : conf=> l t kha to phng hi thoi. conference_number: con s t tn cho phng hi thoi, thu bao gi con s ny c vo phng hi thoi pin: mt khu nhn dng ng nhp, thu bao mun vo phng hi thoi phi nhp ng mt khu ny. adminpin: mt khu qun tr phng hi thoi , khi thu bao nhp ng mt khu ny th c th qun tr c h thng phng hi thoi nh kha phng chng hn.

V d: khai bo phng hi thoi trong tp tin meetme.conf : [rooms] ;hi thoi ca phng kinh doanh conf => 2000,123456 ;hi thoi ca phng k thut c adminpin l 1111 conf = >2001,2222,1111 thc hin k hoch quay s cho phng hi thoi:
- 53 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

tip nhn cc cuc gi hi thoi chng ta dng hm ng dng MeetMe() trong k hoch quay s C php : MeetMe([confno][,[option][,pin]]) trong : confno: con s ca phng hi thoi, nu thng s ny khng khai bo th khi ng nhp h thng s yu cu nhp vo. pin: s mt khu ng nhp . options: l thng s la chn khng c hoc c nhiu thng s kt hp vi nhau xc nh mt s chc nng hot ng ca phng hi thoi, cc chc nng c th lit k ra nh sau:

Tham s m t i p X d D e E v r

Chc nng Ngi tham gia hi thoi ch nghe, khng c ni chuyn . Ngi hi thoi ch ni khng c nghe . Pht thng bo c ngi kt ni hay ri khi phng User c th ri khi phng hi thoi bng cch nhn phm # User c th thot khi phng h i thoi bng cch nhp vo extension hp l, (thit lp qua bin ${MEETME_EXIT_CONTEXT}), nu bin ny khng c thit lp th s dng extension trong ng cnh hin ti. Thm ng vo phng hi thoi khng cn thit lp s pin Thm ng vo phng hi thoi phi cn thit lp s pin Chn phng hi thoi trng u tin Chn phng hi thoi trng u tin khng cn s pin Hi thoi vi ch Video Nu chc nng ny c chn th cuc m thoi trong phng hi thoi s c thu m vi nh dng tp tin ${MEETME_RECORDINGFORMAT} v lu vo v tr ${MEETME_RECORDINGFILE} Thit lp mode yn lng (Khng pht m khi c thu bao vo/ri khi phng hi thoi ) Cho php Music On Hold khi phng ch c mt cuc gi. ng phng hi thoi khi user ch tr thot phng hi thoi. i cho n khi user ch tr n phng hi thoi . Chy AGI script thit lp bin ${MEETME_AGI_BACKGROUND}, script mc nh l conf-background.agi Vo menu(user and administrator) khi nhn phm * Thit lp ch Admin
- 54 -

q M x w b s A

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

Lun lun hi s Pin ngay c ch nh trong i s hm ng dng meetme()

Cc bin s dng trong hm ng dng MeetMe() C php ${MEETME_RECORDINGFILE} ${MEETME_RECORDINGFORMAT} ${MEETME_EXIT_CONTEXT} ${MEETME_AGI_BACKGRUOND} ${MEETMESECS} Chc nng Tp tin thu m cuc hi thoi(option r) nh dng tp tin thu m (gsm,wav,) Ng cnh thot ra t phng hi thoi AGI script S giy thu bao trong phng hi thoi

5.3.To k hoch quay s(Dialplan) cho h thng 5.3.1. Gii thiu K hoch quay s l tri tim ca h thng Asterisk. K hoch quay s cho bit cc cuc gi s c x l nh th no qua h thng Asterisk . K hoch quay s bao gm tp hp cc dng lnh hay cc ng dng theo mt trnh t no m h thng phi thc hin p ng nhu cu chuyn mch cuc gi. cu hnh thnh cng h thng Asterisk th iu kin tin quyt l phi hiu r k hoch quay s . H thng chng ta hot ng c n nh v phong ph v chc nng hay khng ph thuc rt nhiu vo vic chng ta thit k mt k hoch quay s nh th no. 5.3.2. To mt ng cnh (context) u tin ng cnh l g ? nh ngha mt cch n gin, mt ng cnh l mt nhm cc extension. Mi extension phi tn ti trong mt ng cnh v mi extension thng i qua nhiu ng cnh khc nhau . Trong tp tin extensions.conf, mt ng cnh c nh ngha bi du ngoc vung [], c dng : [mycontext] Mt ng cnh bao gm mt nhm v hn cc extensions, trong thc t chng ta cn rt nhiu cc ng cnh to ra nhiu k hoch quay s cng nh nhng chc nng mm do, phong ph cho h thng .V d trong mt cng ty, khng phi tt c cc nhn vin u c kh nng gi in thoi theo nhu cu ca h. Mt nhn vin cn qu mi, lm nhng cng vic khng qu quan trng c l khng cn thit phi cho php gi nhng cuc gi quc t . Cng vy mt gim c cng khng mun b quy ry lin tc v nhng thc mc t khch hng bnh thng , Chng ta c th thit lp ton b cc qui lut hot ng cho cc extension bng cch nhm chng vo nhng context ring x l. Chng ta c th gi mt ng cnh khc t ng cnh hin ti bng cch dng c php:
- 55 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

include =>other_context V d chng ta c mt ng cnh tn l [mycontext].Nu chng ta mun [mycontext] bao gm c ng cnh [default] tn ti t trc, chng ta thm cc dng sau trong tp tin extensions.conf: [mycontext] include =>default Dng c php trn cung cp cho cc extension trong ng cnh [mycontext] kh nng truy nhp ti tt c cc extension trong ng cnh [default].iu ny cng c ngha l nu ng cnh [default] c bao gm mt s ng cnh khc nhau nh [conference] th tt c cc extension trong [mycontext]u c th gi ti extension trong [conference]. 5.3.3. To mt extension Mt estension l mt nhm cc lnh bo cho Asterisk thc thi mt s cng vic .K hoch quay s l mt tp gm nhiu extension, khi mt cuc gi tng ng vi extension no th ng dng cho cuc gi s c thc hin, extension c th n gin vi mt ch danh c th nh 1234 hay l mt chui s mu nh sau: _9xxx . Mt extension hon chnh trong tp tin extensions.conf c nh dng nh sau : exten => extensionnum,priority,action trong : exten => : mi dng bt u vi lnh exten => , chng ta khng c thay i iu ny extensionnum: l tn, s ,hoc l mt s i din tng qut ca extension . Mt extensionnum c nhiu dng nh sau: nh dng 8000 4321/4321 _4xxxx s Gi tr S c th :8000 S extension vi callerID S i din tng qut Extension khi to. Nu khng c s extension no khc c a vo, th y l extension thc thi Bt u mt s i din tng qut S bt k 1,3,4,5,6,7,8,9 S bt k t 0-9 S bt k t 1-9 S bt k t 2-9
- 56 -

_(gch di) .(du chm) [13-9]bao gm cc s X Z N

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

fax

Extension timeout .Nu mt user c i hi nhp mt phm hoc lm mt tc v no nhng khng kp, extension ny s c gi Extension khng c gi tr. Nu mt user chn sai cc ty chn cho php, extension ny s c gi Cc cuc gi fax . Nu Asterisk nhn thy tn hiu fax, cuc gi s c nh tuyn n extension ny.

priority : l th t thc hin cc ng dng trong k hoch quay s, Astersik s bt u priority 1, k tip l ng dng ti priority 2 c thc hin . Mt vi lnh c th buc Asterisk nhy n priority n +1 . K t version 1.2 ca Astersik, thay v gn mt con s c th cho th t thc hin nh trn, ta c th gn th t n cho mi dng exten=> , iu ny s ni vi Astersik l ng dng vi th t tip theo s thc hin. V d: exten => 123,1,Answer() exten => 123,n, do something exten => 123,n, do something else exten => 123,n, do one last thing exten => 123,n,Hangup() Version 1.2 cng cho php chng ta gn cc nhn dng text vo priority . gn mt nhn dng text vo mt priority, n gin ch l thm nhn vo bn trong du ngoc () sau priority nh sau : exten => 123,n(label),do something action : y l ni chng ta bo cho Astersik bit chng ta mun lm g ,tc l ng dng no s c thc hin mi khi extesion no c gi, cc ng dng nh thc hin quay s, tr li cuc gi hay n gin l nhc my hay gc my Mt vi ng dng tiu biu thng hay c dng gm : ng dng Answer() Ch thch Tr li cuc gi ny .Rt nhiu ng dng i hi rng cuc gi phi c tr li trc khi chng c th thc thi cc tc v khc. Dng pht mt file m thanh dng .wav hoc .gsm. Cuc gi phi c tr li trc khi thc thi tc v ny.
- 57 -

Playback(tn_tp tin)

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

Background(tn_tp tin)

Ging nh ng dng Playback, tuy nhin n c dng ch mt phm nhp vo t user, khng bt buc phi nghe ht file m thanh ri mi chuyn ti extension khc .ng dng n y i hi cuc gi phi tr li trc ng dng ny gip chng ta gi mt cut gi n mt context, extension v priority c ch nh c th. Chc nng ny dng chuyn cuc gi hin ti vo hp th thoi. ng dng ny cho php user lng nghe cc tin nhn thoi, cng nh ghi m cc li cho, tn v thit lp cc ty chn cu hnh khc .

Goto(contex,extension,priority)

Voicemail(extendsion)

VoicemailMain()

Dial(technology/id,options,timeout) y l ni chng ta bo cho Asterisk bit rung chung mt in thoi khi n c quay s. Cc ty chn bao gm: t : cho php user b gi chuyn cuc gi bng cch nhn phm # . T : cho php user gi chuyn cuc gi bng cch nhn phm # . r : rung chung m: cung cp nhc ch H : cho php gc my bng cch nhn phm *

Ngoi ra cn rt nhiu ng dng linh hot khc . bit thm thng tin v cc ng dng cng nh cc tham s km theo, dng lnh show aplications giao tip dng lnh ca Asterisk. CLI> show Aplications 5.3.4. To cc Extension gi ra (outgoing) Vi k hoch quay s, chng ta khng ch quan tm n vic x l cc cuc gi vo m tt nhin cn cn phi to cc extension gi ra . Cc extension gi ra hot ng nh th no ph thuc vo k hoch m chng ta thit k trc .N ph thuc vo vic bn mun nh tuyn cc cuc gi cho tng user

- 58 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

nh th no .Cn to cc k hoch mm do nhng phi tht gn gi vi cc h thng truyn thng ngi dng khng phi l lm khi tip xc. Hu ht cc h thng thng i hi user phi nhn mt phm no chim trung k gi ra trc khi c th quay s ra ngoi . lm iu ny, ta dng c php nh sau (gi s l phm 9): [outgoing] exten => _9.,1,Dial(Zap/g1/${EXTEN:1}) trong : extensionnum :chng ta ang dng mt s tng qut (pattern) i din cho phn extensionnum. g1 :l nhm cc knh Zap ca giao din Zaptel.Chng ta nhm cc ng dy (hoc cc knh )li vi nhau cc cuc gi c th t ng nhn thy ng dy (hay knh) no ri v thc hin cuc gi trn . ${EXTEN:1}: l bin lu s m chng ta quay tr i s u tin. Asterisk s b i s lng s bng vi s m chng ta ch ra sau du hai chm:, nu chng ta quay 9123456789 th s c gi i s l 123456789. Tng t, nu chng ta mun b qua 2 s u, ta dng ${EXTEN:2} 5.3.5. H thng tr li tng tc thoi (Automated Attendant) ng dng tng tc thoi l ng dng thng gp i vi bt c h thng tng i PBX no.Cho php cc thu bao tng tc vi h thng qua cc thng ip thoi . V d khi thu bao gi n PBX, s c thng ip pht ra Hn hnh cho bn gi n cng ty ABC ca chng ti , mi nhn phm 1 gp phng kinh doanh, nhn phm 2 gp phng h tr khch hng Trong phn ny s trnh by tng bc xy dng h thng tng tc thoi mt cch d hiu nht, khai bo trong tp tin extensions.conf nh sau : extensions.conf [default] exten => 100,1,Dial(SIP/100) exten => 200,1,Dial(SIP/200) [mainmenu] exten => s,1,Answer() exten => s,n,Background(thanks); pht thng ip cm n khi gi n cng ty exten => s,n,WaitExten() exten => 1,1,Goto(submenu,s,1) exten => 2,1,Hangup() [submenu] exten => s,1,Ringing ; rung chng trong vng 2 giy exten => s,n,Wait(2) exten => s,n,Background(submenuopts) ; Cn n gi n phng
- 59 -

http://my.opera.com/asteriskvn - CHNG V: THIT K CU HNH IP-PBX

kinh doanh exten => s,n,WaitExten() exten => 1,1,Goto(default,A,1) exten => 2,1,Goto(default,B,2)

on trn c th gii thch nh sau: tt c cc cuc gi n u c chuyn n ng cnh [mainmenu], trong ng cnh ny hm ng dng Background(thanks) s thc hin pht ra thng ip Cm n qu khch gi in n cng ty chng ti, mi nhn phm 1 gp phng kinh doanh , sau khi thu bao nhn phm 1 s c a n ng cnh [submenu] ng vi ng cnh ca phng kinh doanh. Ti ng cnh ca phng kinh doanh hm ng dng Background(submenuopts) s pht thng ip cm n gi n ph ng kinh doanh , mi nhn phm 1 gp ng A, phm 2 gp ng B , Ti y ty vo thu bao nhn phm 1 hoc 2 s c chuyn n ngi cn gp tng ng.

- 60 -

http://my.opera.com/asteriskvn- CHNGVI: THI CNG H THNG IP-PBX C BN

CHNG VI: THI CNG H THNG IP-PBX C BN 6.1. Cc thit b v phn mm s dng - Yu cu cu hnh ti thiu ca Asterisk server: Mc ch Th nghim, hc tp H thng cho vn phng hoc nh ring H thng cho doanh nghip nh H thng thng mi c va v ln S lng cc knh 1- 5 5-10 Ti 15 Hn 15 Cu hnh ti thiu 400-MHz x86, 256 MB RAM 1-GHz x86, 512MB RAM 3-GHz x86, 1GB RAM Dual CPUs, hay cng c th l nhiu server trong mt cu trc phn tn. (ngun : bng 2.1 [2]) - Asterisk server trong m hnh c bn trn c: + Cu hnh: CPU: Pentium IV 2.2 GHz RAM: 512MB HDD: 10GB + H iu hnh Linux: Fedora core 6.0 + Phn mm m ngun m Asterisk: asterisk: version 1.4.21.2 asterisk-addons: version 1.4.7 zaptel: version 1.4.12.1 libpri: version 1.4.7 - Card giao tip vi PSTN: TDM01B (0 FXS, 1 FXO) ca Digium, h tr giao thc SIP, IAX, H.323 . - ATA linksysPAP2: s dng giao thc SIP, c hai cng FXS v mt cng Ethernet:

- 61 -

http://my.opera.com/asteriskvn- CHNGVI: THI CNG H THNG IP-PBX C BN

- SoftPhone: Phn mm X-Lite version 3.0 (download t www.xten.com), ci trn my tnh, h tr giao thc SIP: cu hnh ti khon SIP cho X-Lite (my 3006), vo Show Menu - SIP Account Setting , ta nhp cc thng s nh hnh sau y:

- 62 -

http://my.opera.com/asteriskvn- CHNGVI: THI CNG H THNG IP-PBX C BN

Sau khi nhp y cc thng tin nh trn, X-Lite s tin hnh ng k vi Asterisk server . Nu ng k thnh cng, ta c mn hnh hin th ca X-Lite nh sau:

- in thoi IP: IP Phone AT-530, hai cng RJ45, h tr giao thc SIP :

- in thoi Analog thng thng 6.2. K hoch quay s Hng gi Gi ra( out-going calls) Gi vo ( in-coming calls) Ni b(internal) K hoch quay s-cch s dng Bm s 9 chim trung k gi ra Quay s vo trc tip Quay s Bm trc tip s Voicemail - li tin nhn:nu sau 10 hi chung khng c ngi nhc my, c th li tin nhn sau ting bip( kt thc tin nhn ,bm
- 63 -

http://my.opera.com/asteriskvn- CHNGVI: THI CNG H THNG IP-PBX C BN

#) -truy xut vo voice mail : quay s 9000 6.3. Mt s chc nng c bn Stt 1 2 Chc nng Hin th s thu bao ch gi Nhc my t xa (Call pickup) Cch s dng

T my in thoi bt k trong cng nhm, quay *8 nhn cuc gi ang rung chung.

Ngi gi hay ngi b gi Quay # 700, gc my v n mt my in dng my in thoi khc thoi khc quay 701, v tip tc cuc m tip tc cuc m thoi ( Call thoi. parking) Chuyn cuc gi trong khi m Nhn # v s in thoi cn chuyn. thoi (Call Transfer) Chuyn cuc gi( Call Forward) chuyn cuc gi tc thi: ng k : *30 s in thoi # hy:*31# chuyn cuc gi khi bn : ng k : *32 s in thoi # hy:*33# chuyn cuc gi khi khng tr li: ng k : *34 s in thoi # hy:*35# ng k : *94# hy:*95# nhn 1 s gi s 3005 nhn 2 s gi s 3006

T chi nhn cuc gi(Do Not Disturb) Quay s tt(Speed Dial)

6.4. Cu hnh Vi m hnh, cng vi k hoch quay s v cc chc nng c bn trnh by trn, chng ta s c ni dung cc tp tin cu hnh nh sau : 6.4.1.Cu hnh cng FXO (card TDM01B) 6.4.1.a. Tp tin zaptel.conf fxsks=1
- 64 -

http://my.opera.com/asteriskvn- CHNGVI: THI CNG H THNG IP-PBX C BN

loadzone=us defaultzone=us Sau khi thit lp cu hnh zaptel, np li module cho thit b bng lnh sau : # /etc/init.d/zaptel restart 6.4.1.b. Tp tin zapata.conf [trunkgroups] ;nh ngha cc nhm trung k ti y, mc nh c th b qua [channels] usecallerid=yes hidecallerid=no callwayting=no transfer=yes echocancel=yes echotraining=yes ; FXO interface context=incoming sinallinging=fxs_ks channel=1 6.4.2. Tp tin sip.conf [general] contex = default bindport=5060 bindaddr=0.0.0.0 disallow=all allow=ulaw srvlookup = yes ;khai bo cc user [3003] type=friend secret=pasword_03 qualify=yes nat=no host=dynamic canreinvite=no context=internal mailbox=3003 callgroup=1 pickupgroup=1

- 65 -

http://my.opera.com/asteriskvn- CHNGVI: THI CNG H THNG IP-PBX C BN

[3004] type=friend secret=pasword_04 qualify=yes nat=no host=dynamic canreinvite=no context=internal mailbox=3004 callgroup=1 pickupgroup=1 [3005] type=friend secret=pasword_05 qualify=yes nat=no host=dynamic canreinvite=no context=internal mailbox=3005 callgroup=1 pickupgroup=1 [3006] type=friend secret=pasword_06 qualify=yes nat=no host=dynamic canreinvite=no context=internal mailbox=3006 callgroup=1 pickupgroup=1 Ch : trng context=internal phi ng vi mt context c nh ngha [internal] trong tp tin extensions.conf , nh th th cc SIP Entry mi hot ng c bn trong mt context 6.4.3.Tp tin features.conf ( chc nng call parking) [general] parkext => 700 parkpos => 701-720 context => parkedcalls parkingtime => 25

- 66 -

http://my.opera.com/asteriskvn- CHNGVI: THI CNG H THNG IP-PBX C BN

Ch i vi tp tin ny, s thay i c nh hng th giao tip dng lnh Asterisk, ta dng lnh restart hoc reload res_feature.so.Nu dng lnh reload th s thay i trong tp tin s khng nh hng. 6.4.4.Tp tin voicemail.conf [general] format=wav49|gsm|wav servicemail=asterisk [default] 3003 => 1234,hai,lxhai@yahoo.com 3004 => 2134,hai,lxhai@yahoo.com 3003 => 3214,hai,lxhai@yahoo.com 3003 => 4231,hai,lxhai@yahoo.com 3003 => 1324,hai,lxhai@yahoo.com 6.4.5. Tp tin extensions.conf y l tp tin cu hnh quan trng nht, cc my in thoi trong m hnh c thc hin c cc cuc gi ni b, gi ra, t mng PSTN gi vo v cc dch v c trin khai c hay khng, tt c ph thuc vo tp tin ny. [general] static=yes writeprotect=no [incoming] exten => s,1,Dial(SIP/3003) [internal] include => parkedcalls include => tinhnang include => out-going exten => _3XXX,1,Macro(dial-voicemail,SIP/${EXTEN},20,${EXTEN}) exten => 9000,1,VoiceMailMain(${CALLERID(num)}) [out-going] exten => _9NXXXXXX,1,Dial(Zap/g1/${EXTEN:1}) exten => _9NXXXXXX,2,Congestion() exten => _9NXXXXXX,102,Congestion() [tinhnang] exten => _*30.,1,Set(FORWARD=${EXTEN:3}) exten => _*30.,2,Macro(CFIM-ON)
- 67 -

http://my.opera.com/asteriskvn- CHNGVI: THI CNG H THNG IP-PBX C BN

exten => *31,1,Macro(CFIM-OFF) exten => _*32.,1,Set(FORWARD=${EXTEN:3}) exten => _*32.,2,Macro(CFBS-ON) exten => *33,1,Macro(CFBS-OFF) exten => _*34.,1,Set(FORWARD=${EXTEN:3}) exten => _*34.,2,Macro(CFUN-ON) exten => *35,1,Macro(CFUN-OFF) exten => *94,1,Macro(DND-ON) exten => *95,1,Macro(DND-OFF) ;khai bo cc Macro [macro-dial-voicemail] ;Voicemail khi bn v khng tr li exten => s,1,Set(DESTINATION=${ARG1}) exten => s,n,Set(temp=${DB(DND/${MACRO_EXTEN})}) exten => s,n,GotoIf($[${temp} = 1]?DND_ON:DND_OFF) exten => s,n(DND_ON),NoOp(DND -ON) exten => s,n,Busy() exten => s,n(DND_OFF),NoOp(DND -OFF) exten => s,n,Set(temp=${DB(CIFM/${MACRO_EXTEN})}) exten => s,n,GotoIf(${temp} ?CFIM_ON:CFIM_OFF) exten => s,n(CFIM_ON),NoOp(CFIM -ON) exten => s,n,Goto(CF,1) exten => s,n(CFIM_OFF),NoOp(CFIM -OFF) exten => s,n,Dial(${ARG1},25,Tt) exten => CF,1,Dial(local/${temp}${EXTEN}) exten => CF,1,Dial(SIP/${temp},25,r) exten => CF,n,Dial(iax2/${temp},20,r) exten => CF,n,Dial(zap/g0/${temp},20,r) exten => s-NOANSWER,1,Set(temp=${DB(CFUN/${MACRO_EXTEN})}) exten => s-NOANSWER,n,GotoIf(${temp} ?CFUN_ON:CFUN_OFF) exten => s-NOANSWER,n(CFUN_ON),NoOp(CFUN- ON) exten => s-NOANSWER,n,Goto(CF,1) exten => s-NOANSWER,n(CFUN_OFF),NoOp(CFUN- OFF) exten => s-NOANSWER,n,Voicemail(u${ARG2}@default) exten => s-NOANSWER,n,Hangup() exten => s-CHANUNAVAIL,1,Voicemail(u${ARG2}@default) exten => s-CHANUNAVAIL,2,Hangup()

- 68 -

http://my.opera.com/asteriskvn- CHNGVI: THI CNG H THNG IP-PBX C BN

exten => s-BUSY,1,Set(temp=${DB(CFBS/${MACRO_EXTEN})}) exten => s-BUSY,n,GotoIf(${temp} ?CFBS_ON:CFBS_OFF) exten => s-BUSY,n(CFBS_ON),NoOp(CFBS- ON) exten => s-BUSY,n,Goto(CF,1) exten => s-BUSY,n(CFBS_OFF),NoOp(CFBS- OFF) exten => s-BUSY,n,Voicemail(b${ARG2}@default) exten => s-BUSY,n,Hangup() exten => _s-.,1,NoOp(STATUS = ${DIALSTATUS} Hanging up) exten =>_s-.,n,Hangup()

[macro-CFIM-ON] exten => s,1,NoOp() exten => s,n,Set(DB(CFIM/${CALLERID(num)})=${FORWARD}) exten => s,n,Playback(beep) exten => s,n,Wait(1) exten => s,n,Hangup() [macro-CFIM-OFF] exten => s,1,NoOp() exten => s,n,Dbdel(CFIM/${CALLERID(num)}) exten => s,n,Playback(beep) exten => s,n,Wait(1) exten => s,n,Hangup() [macro-CFBS-ON] exten => s,1,NoOp() exten => s,2,Set(DB(CFBS/${CALLERID(num)})=${FORWARD}) exten => s,3,Playback(beep) exten => s,4,Wait(1) exten => s,5,Hangup() [macro-CFBS-OFF] exten => s,1,NoOp() exten => s,n,Dbdel(CFBS/${CALLERID(num)}) exten => s,n,Playback(beep) exten => s,n,Wait(1) exten => s,n,Hangup() [macro-CFUN-ON] exten => s,1,NoOp() exten => s,n,Set(DB(CFUN/${CALLERID(num)})=${FORWARD}) exten => s,n,Playback(beep) exten => s,n,Wait(1) exten => s,n,Hangup()

- 69 -

http://my.opera.com/asteriskvn- CHNGVI: THI CNG H THNG IP-PBX C BN

[macro-CFUN-OFF] exten => s,1,NoOp() exten => s,2,Dbdel(CFUN/${CALLERID(num)}) exten => s,3,Playback(beep) exten => s,4,Wait(1) exten => s,5,Hangup() [macro-DND-ON] exten => s,1,NoOp() exten => s,2,Set(DB(DND/${CALLERID(num)})=1}) exten => s,3,Playback(beep) exten => s,4,Wait(1) exten => s,5,Hangup() [macro-DND-OFF] exten => s,1,NoOp() exten => s,n,Dbdel(DND/${CALLERID(num)}) exten => s,n,Playback(beep) exten => s,n,Wait(1) exten => s,n,Hangup() 6.5.Mt s kt qu thc hin -Bn ngoi gi vo PBX (quay s ca ng dy kt ni cng FXO) s chung my 3003 . -Bn trong thu bao bm s 9 s chim trung k gi ra, ri tip tc quay s ca mng PSTN. -Cc thu bao ni b quay s trc tip lin lc vi nhau -Cc dch v: +DND (t chi nhn cuc gi): v d khi thu bao 3004 quay *94# ng k dch v DND, th tt c cc thu bao khc khi gi s 3004 u nghe tone bn. hy dch v ny, thu bao 3004 quay *95# +Call parking: v d thu bao 3005 gi thu bao 3006 v thu bao 3006 nhc my m thoi, nu thu bao 3005 khng mun dng in thoi 3005 tip tc m thoi m mun dng in thoi 3004, th thu bao 3005 nhn # v tip theo l 700, gc my ri i n in thoi 3004 quay s 701, th s tip tc m thoi vi thu bao 3006(trong thi gian thu bao 3005 di chuyn n in thoi 3004 th thu bao 3006 s nghe c nhc ch). Tt c kch bn cuc gi trong phn 6.3 v cc dch v trong phn 6.4 test v cho kt qu tt.

- 70 -

http://my.opera.com/asteriskvn - KT LUN

KT LUN Truyn thoi qua IP (VoIP) l cng ngh v ang pht trin mnh m . Cng vi s pht trin ca h tng chuyn mch gi, IP-PBX s dn dn thay th cho cc PBX chuyn mch knh truyn thng .Yu t c bn nht to ra s thay i ny chnh l bt ngun t bn cht mm do v hiu sut ca chuyn mch gi ni chung v chuyn mch IP ni ring . Cng ngh Asterisk cc k linh hot, c th kt ni vi mng in thoi bn ngoi qua ng dy tng t (Analog) hay s (Digital) .Ch vi mt s thit b phn cng n gin, kt hp vi phn mm m ngun m Asterisk, chng ta c th xy dng nn mt h thng IP-BPX hon chnh vi y cc tnh nng. Ngoi cc dch v truyn thng v cc dch v tin tin cho IP-PBX, Asterisk c th m rng thm cc chc nng khc nh IVR vi chc nng Text To Speech , ly d liu ng t database v pht thnh li ni (n g dng trong ngn hng, t ch trong hng khng, tra im thi ),Voicemail, ghi m cuc gi, nh tuyn cuc gi theo ph thp nht bng cch ng k vi cc SIP Provider nh : Vietvoice,OCI, to cc cuc gi quc t gi r, do c pht trin bng phn mm nn IP-PBX Asterisk d dng tch hp c vi cc h thng qun l khch hng CRM (Customer Relationship Management) vi cc chc nng Click to talk, lu gi thng tin khch hng gi vo, l mi trng c s xy dng nn cc trung tm cuc gi (Call Center) hay cc trung tm lin lc (Contact center),

- 72 -

http://my.opera.com/asteriskvn PH LC

PH LC Th vin c php lnh v bin trong Asterisk 1. Cc lnh tng qut: Stt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 C php add extension debug channel help no debug channel pri debug span Tc dng Thm mt extension vo ng cnh M Debug cho channel Hin th danh sch cc dng lnh Tt debug cho mt channel Bt ch debug cho mt span(i vi kt ni E1) pri no debug span Tt ch debug cho mt span(i vi kt ni E1) show agents Hin th trng thi cc agent show applications Hin th cc ng dng ang ng k show channel Hin th cc thng tin v mt knh c th show channels Hin th thng tin v cc knh show codecs Hin th cc codec c h tr show conferences Hin th trng thi cc phng hi thoi show dialplan Hin th thng tin Dialplan show manager Hin th cc c php lnh v qun l command show manager connect Hin th cc user qun l ang ng k show parkedcalls Hin th danh sch cc parked call show queues Hin th thng tin cc hng i show voicemail users Danh sch cc hp th thoi c to show voicemail zones Danh sch cc nh dng bn tin zone shoft hangup Yu cu hangup 1 knh thoi c th no

2.C php lnh tng tc vi Database stt 1 2 3 4 5 C php database del database deltree database get database put database show Tc dng Xa mt gi tr/kha trong database Xa cc gi tr/cy kha trong database Ly d liu t database Lu d liu vo database Hin th ni dung database

- 74 -

http://my.opera.com/asteriskvn PH LC

3. C php dng lnh lin quan n knh IAX Stt 1 2 3 4 5 6 7 8 C php iax2 debug iax2 no debug iax2 show cache iax2 show channel iax2 show peers iax2 show registry iax2 show users iax set jitter Tc dng Debug knh iax Tt debug knh iax Hin th cc thng tin cache ca knh iax Hin th thng tin cc knh iax Hin th trng thi cc kt ni iax Hin th tnh trng ng k ca cc kt ni Hin th danh sch cc user iax c to Thit lp b m cho iax

4. C php lnh lin quan n knh SIP: Stt 1 2 3 4 5 6 7 C php sip debug sip no debug sip reload sip show channels sip show peers sip show registry sip show users Tc dng Bt debug knh sip Tt debug knh sip Ti li cc thng tin cu hnh sip Hin th danh sch cc knh sip Hin th danh sch cc ti khon sip c to Hin th trng thi ng k ca cc ti khon sip Hin th danh sch tt cc ti khon sip c to

5.C php lnh lin quan n qun tr h thng: Stt 1 2 3 4 5 6 7 8 9 10 11 C php restart gracefully restart now restart when convenient reload stop gracefully stop now stop when convenient extensions reload show modules show uptime show version Tc dng Khi ng li h thng ch cn thn (khi khng cn cuc gi no ang x l) Khi ng h thng ngay lp tc Khi ng li h thng khi thun tin (khi t ngi gi) Ti li asterisk Tt Asterisk mt cch cn trng Tt Asterisk ngay lp tc Tt asterisk khi thun tin Ti li cc thng tin cu hnh extension Hin th cc modules c cu hnh Hin th thi gian uptime ca h thng Hin th phin bn cc phn mm h thng
- 75 -

http://my.opera.com/asteriskvn PH LC

6.Cc bin nh ngha trong Asterisk: Stt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Bin ${ACCOUNTCODE} ${CALLERID} ${CALLERIDNAME} ${CALLERIDNUM} ${CHANNEL} ${CONTEX} ${DATETIME} ${DNID} ${ENUM} ${EXTEN} ${ENV(VAR)} ${HANGUPCAUSE} ${INVALID_EXTEN} ${LANGUAGE} ${LEN(VAR)} ${MEETMESECS} ${PRIORITY} ${TIMESTAMP} ${TXTCIDNAME} ${UNIQUEID} ${SIPUSERAGENT} Ch thch M ti khon Caller ID Ch tn ca phn caller ID Ch s ca phn Caller ID Tn ca knh hin ti Ng cnh hin ti Ngy gi hin ti theo nh dng:YYYY-MM-DDHH:MM:SS Nhn dng s quay Cha kt qu ca ng dng EnumLookup Extension hin ti Bin mi trng dng (VAR) Nguyn nhn hangup cuc gi Extension c gi khng ph hp Ngn ng hin ti Chiu di ca chui Thi gian(giy) ca mt user trong phng hi thoi Th t u tin Ngy gi hin ti,nh dng:YYYYMMDDHHMMSS Cha kt qu ca ng dng TXTCIDName Kha nhn dng cuc gi hin ti Cc agent SIP

- 76 -

http://my.opera.com/asteriskvn - TI LIU THAM KHO

TI LIU THAM KHO [1] Building Telephony Systems with Asterisk, David Gomillion & Barrie Dempster, 2006, PACKT. [2] Asterisk : The Future of Telephony , Leif Madsen, Jared Smith & Jim Van Meggelen, 2005,OReilly. [3] Asterisk Hacking, Benjamin Jackson & Champ Clark III,2007,Syngress. [4] http://www.asterisk.org [5] http://www.digium.com [6] http://www.voip-info/wiki-asterisk [7] http://www.asteriskguru.com [8] http://www.vfonex.com [9] http://my.opera.com/asteriskvn

http://my.opera.com/asteriskvn

- 77 -