Está en la página 1de 19

TM HIEU VA CAU HNH CAC CHC NANG C BAN CUA TONG AI IP PBX TREN NEN ASTERISK

Trong phan thc tap nay s dung Asterisk1.4.33 (moi phien ban khac nhau se co mot so cac cu phap khac nhau do Asterisk la mot phan mem ma nguon m. ) I/ Cac chc nang cua tong ai IP PBX tren nen Asterisk. 1. Y ngha cua cac file cau hnh. Phan ly thuyet cac chc nang cua nhng file cau hnh nh Sip.conf, extensions.conf a c e cap s qua trong bao cao o an mon hoc 2, trong phan nay nhom em xin c gii thieu lai ve nhng phan nay e de hieu hn cach cau hnh trong tong ai cua nhom em. a. Sip.conf (Session Initiation Prorocol) Sip la giao thc Internet danh cho bao hieu VoIP c phat trien bi IETF cung cap vai chc nang giong he thong bao hieu so 7 nhng da tren nen IP. Mot chc nang giong bao hieu so 7 o la bao hieu va thoai chuyen tai tren hai kenh rieng. Giao thc SIP thc hien chc nang thiet lap va bao hieu cuoc goi, khi noi en bao hieu cuoc goi la ch nh cac tn hieu bao hieu nh: tn hieu mi quay so, tn hieu ban SIP l giao thc dng thit lp , chnh sa v kt thc cc phin lm v trong cc dch v multimedia , chng hn nh cc cuc gi in thoi qua Internet. Vic cu hnh sip l to ti khon trong file sip.conf , user s s dng ti khon ny s dng cc dch v hay tin ch do Asterisk cung cp cho mt SIP account. Cc thng tin cu hnh SIP c lu tr trong file /etc/asterisk/sip.conf Trong file Sip nay cau hnh t

[general] Cc la chn cho vic cu hnh : Context: thit lp context mc nh cho cc cuc gi n server. S mc nh ca context l default. Port: thit lp port UDP cho vic lng nghe cc connection. Port mc nh l 5060, v chng ta s khng thay i mc nh ny nu khng cn thit. Bindaddr: ch nh a ch IP m chng ta mong mun dch v SIP cho php. Mt my c nhiu a ch IP, chng ta c th ch nh cho n c th tm n tt c bng cch, gn cho Bindaddr l 0.0.0.0 Tos: l s thit lp QoS (Quality of Service). Chng ta c th ch nh trc tip gi tr hoc chng ta dng cc t kho nh: lowdelay, throughput, reliability, mincost, or none. Chng ta nn thit lp l lowdelay. Maxexpiry: l thi gian ti a,m chng ta cho php vic ng k c gi tr. S mc nh l 3600 giy, qua thi gian ny, vic ng k s timeout. Defaultexpiry: l thi gian mc nh m chng ta thit lp vic ng k vo. S mc nh ny l 120 giy. Videosupport: vic thit lp yes l cho php h tr video trong giao thc SIP, Asterisk l c php h tr video H263 t Linphones, Microsoft Windows Messenger, v Wooksung WVP-2000 videophone. Musicclass: thit lp mc nh lp music on hold cho tt c cuc gi SIP. Thit lp mc nh l default. Accountcode: chng ta thit lp m ti khon s dng cho cc cuc gi t user SIP ny, iu ny c th gip cho vic billing. Language: l ngn ng mc nh cho cc user SIP, chng ta c th thit lp vi nhiu ngn ng khc nhau. S thit lp mc nh l en. Rtptimeout: l thi gian RTP stream khng lu thng trn ng truyn cuc gi s timeout trc khi Asterisk kt thc cuc gi. S thit lp mc nh l 60 giy.

Externip: thit lp a ch IP ngoi mng ni b ca server Asterisk. iu ny s c ch cho vic NAT v firewall. a ch ny s c t trn cc thng ip SIP gi ra mng ngoi. Localnet: nh ngha tt c cc a ch IP ni. iu ny s bo cho Asterisk thng ip SIP dng IP ngoi ti mt ni ch s dng IP ni b. Register: chng ta c th bo cho Asterisk ng k vi nh cung cp hoc dch v SIP. Codec: nh ngha cc chun m ho v gii m m chng ta cho php. Chng ta c 2 trng thi allow v disallow. u tin, chng ta nn cm tt c cc chun codec bng cch thc hin disallow=all. Sau chng ta c th cho php cc chun codec m chng t among mun, v d: allow=alaw,ilbc,.. nh ngha cho cc user: [usename] type: c 3 chn la user: cho php thc hin cuc gi n user. peer: cho php user thc hin cuc gi i. Friend: cho php user nhn cuc gi n v gi cuc gi i. Username: thit lp username cho vic chng thc. Secret: thit lp password cho vic chng thc. Md5secret: MD5 bm v m ho username v password. Callerid: thit lp nh danh caller ID. Host: thit lp a ch host ca user. y c ch ra IP tnh hoc t kho dynamic. Defaultip: vi host = dynamic, y thit lp a ch IP mc nh cho vic khi nhnh khng c ng k.

Nat: thit lp yes, hoc no tu vic thit b SIP c nm sau firewall khng. Mailbox: thit lp hp mail cho vic kim tra thng ip t cc user khc. Outgoinglimit: thit lp s lng ti a cuc gi, m thit b c th thc hin trong mt thi gian nht nh. Incominglimit: thit lp s lng ti a cuc gi, m thit b c th khi to ti mt thi im. ( Do bang thong han che ) Callgroup: Nhom goi. Pickupgroup: Nhom co the pick up cho nhau. Deny: l danh sch cc a ch IP loi b khi my ch asterisk. Permit: danh sch cc a ch IP c php truy cp my ch asterisk. b. Extconfig.conf S dung database e ng dung trong realtime: - s dung database cho user cau hnh trong IAX Iaxusers => odbc,asterisk Iaxpeers => odbc,asterisk - Database cho account c nh ngha nhu SIP Sipusers => mysql,<name_database>,<name_table_sip> Sippeers => mysql,<name_database>,<name_table_sip> - Extensions: Extensions => mysql,<name_database>,<name_table_exten> - Voicemail Voicemail => odbc,asterisk - Queues Queues => odbc,asterisk - Queues_member Queues_member => odbc,asterisk

c. Extensions.conf Trong file nay. Cac ng canh se c bat au bang [name_exten] va ket thuc khi co mot ng canh khac, va no hoan toan tach biet nhau va khong the long vao nhau bang cach thong thng. Do o ta phai cung cac lenh nh include => XXX , Goto, hoac Gotoif Cu phap: exten => extension,priority,Command(parameters) e nam c chc nang file nay th se thong qua cac phan cau hnh cu the trong phan trnh bay tiep theo. d. Agents.conf Co 2 phan chnh can cau hnh: [genaral] Autologoffunvail = yes ;(mac nh la: no) nh ngha phan nay e cac Agent ( t van vien) co the t ong logged out khi ma extension cua no trang thai CHANUNAVIAL ( mot kenh nao o khong thong thoai ) khi mot cuoc goi c gi en. Ackcall = yes . nh ngha ackcall e yeu cau cac agent ang nhap bang phm #, cung co the at cho no la always, va mac nh la no. Chang han mot agent co account la 700 va pass la 7777, th khi ang nhap, agent o bam 700# sau o se co yeu cau nhap pass, agent o nhap pass la 7777#. Endcall = yes . nh ngha endcall e cho phep cac agent c gac may (hangup) mot cuoc goi bi phm *. Wrapuptime = 2000 . ay la thi lng toi thieu e 1 agent tam ngh trc khi nhan cuoc goi tiep theo ( tnh bang ms ). Musiconhold => music_class Musiconhold => defauld . Play nhac nen. Goodbye => goodbye_file ; Am thanh ma agent se nghe c khi thoat ang nhap khoi he thong. [agents]

Cu phap nh ngha mot agent: Agent => agentID,AgentPassword,Name V du: agent => 700,7777,tu_van_vien1 e. Queues.conf Cu phap: Queue (queuename | options | optionalURL | announceoverride| timeout ) Options: d - cht lng d liu (modem) gi s (s chm tr ti thiu). h - cho php callee treo bng cch bm *. H - cho php ngi gi (caller) treo ln bng cch bm *. n - khng th li trong khong thi gian ch; s thot ng dng ny v i n bc tip theo. r chung thay v play Moh. R dng Moh v chung n mt agent. t - cho php agent chuyn cuc gi ngi s dng gi in thoi sang 1 agent khc. T - cho php agent chuyn cuc gi. w - cho php agent ghi cc cuc hi thoi vo a v xut ra mn hnh. W - cho php agent ghi cc cuc hi thoi vo a v xut ra mn hnh. c Tip tc quay s nu callee gc my (Asterisk 1.6.0 v trn). i - b qua cuc gi c yu cu chuyn tip t cc thnh vin queue khc v khng phi lm g khi h c yu cu (Asterisk 1.6.0 v trn). k - Cho php cc agent c packing cuc gi bng cch gi cc chui DTMF quy nh packing trong features.conf (Asterisk 1.6.0 v trn). K - Cho php cc agent c packing cuc gi bng cch gi cc chui DTMF quy nh packing trong features.conf (Asterisk 1.6.0 v trn). x ging nh w (Asterisk 1.6.0 v trn).

X - ging nh w (Asterisk 1.6.0 v trn). [genaral] ; cac th vien nh kem cho file nay #include queues_custom.conf #include queues_additional.conf #include queues_port.conf persistentmembers = yes ; Cha moi user ong trong mot queue trong astdb v vay moi khi Asterisk khi ong lai th moi user se c oc ra mot cach t ong trong recorded queues cua chung. Keepstart = no ( yes) ;gi nguyen trang thai cua queues trc o trong qua trnh reload. Default no. Autofill = yes ; He thong se t ong ket noi cac khach hang ti cac agent, neu agent ban th no se cho khach hang ch theo kieu noi tiep. Autopause = yes ; Se tam dng mot queue member khi cuoc goi b loi. Maxlen = 0 ; so ngi toi a c xep trong hang i (chu y: 0 la khong gii han ) Setinterfacevar = no ; Neu at la co, ngay trc khi ngi goi ket noi vi thanh vien trong hang i ( agent) th cac bien sau c thiet lap: - Memberinterface l tn giao din (v d Agent/1234) - Membername l tn thnh vin (v d tu_van_vien1) - Membercalls l s cuc gi m giao din thc hin, - Memberlastcall l ln cui cng cc thnh vin thc hin mt cuc gi. - Memberpenalty. - Memberdynamic cho bit nu mt thnh vin l thnh vin ng hay khng. - Memberrealtime cho bit mt thnh vin l thi gian thc hay khng. Queueentryvar = no ; Neu at la co, ngay trc khi ngi goi ket noi vi thanh vien trong hang i ( agent) th cac bien sau c thiet lap:

Qeholdtime ngi gi s gi my

Qeoriginalpos v tr ban u ca ngi gi trong hng i.

Membermacro = somemacro ; chy macro ny khi kt ni n 1 thnh vin trong hng i. Monitor-format = gsm|wav|wav49 ; Cc cuc gi c th c ghi li bng cch s dng hin th ca ti nguyn Asterisk/MixMonitor. C th kch hot chng t bn trong ng dng queue, bt u ghi m khi cuc gi thc hin thnh cng, v n s khng ghi khi ngi gi nghe nhc ch (moh) kch hot tnh nng ny th ch cn dng monitor-format , cn khng n s b v hiu ha. Cch lm: Set (MONITOR_FILENAME = foo) ; nu khng th n s s dng MONITOR_FILENAME = $(UNIQUEID) ,tc l s dng bin UNIQUEID. Monitor-type = MixMonitor ; Khi cc nh dng c bit c kch hot ghi m cc cuc gi ca cc thnh vin trong queue, th app_queue s s dng mt MixMonitor mi. Cng c th t mc nh ( default ) cho tt c cc queue yv sau thay i monitor-type cho cc queue ring l no bng cch s dng cc tham s cu hnh ging nhau trong mt khi cu hnh hng i. Joinempty = yes - Yes: ngi gi c th nhp (join) vo hng i ngay c khng c agent no ch trong hng i hoc agent khng lm vic. - No: ngi gi khng th nhp (join) vo hng i khi khng c agent no trong hng i. - Strict: ging nh yes. - Loose: ging nh strick nhng cc agent trong hng i tm dng hot ng th xem nh khng c trong hng i.

Wrapuptime = 15 ; thi gian c th tip nhn mt cuc gi n sau mt cuc gi thnh cng. Memberdelay = 5 ; khong thi gian tr agent tr li mt cuc gi v khi n c kt ni . Strategy = options Vi options: ringall: vng tt c cc knh c sn cho n khi mt trong nhng agent bt my (mc nh) roundrobin: ln lt chung mi agent c sn (trong phin bn1.4, s dng rrmemory) leastrecent: chung agent nhn c t nht cc cuc gi trong s cc agent trong nhm ny. fewestcalls: chung n mt agent vi s cuc gi hon thnh t nht t hng i ny. ramdom: chung n mt agent ngu nhin trong hng i ny. rrmemory: chung theo vng trn, bt u ngay ch m ln cui 1 agent bt my. linear: chung ti agent theo th t chng c lit k trong tp tin cu hnh. thnh vin ng s c chung theo th t m h c thm vo. (Mi trong 1,6) wrandom: chng n mt agent ngu nhin.(mi trong 1,6) Timeout = 5; khong thi gian ch reo cho 1 agent . Retry = 5; thi gian trc khi th gi li cc agent. Contex = <context> ; mt bi cnh c s dng, trong ngi gi ch cn s dng 1 s thc hin 1 cng vic no , chng hn bm phm 1 li li nhn .

Announce = XXX Nhng "announce = XXX" trong queues.conf lm cho Asterisk play thng bo XXX cho thnh vin ca hng i, cc la chn cho cc cuc gi mt cch tng t nh A () ty chn ca Dial () cmd. iu ny cng c th c vin dn trong Queue () ng dng ('Queue (queuename, ty chn, URL, announceoverride, thi gian ch, AGI, v m, gosub, quy tc)'). f. MusicOnHold Khi hai ngi ang thong thoai vi nhau, nhng 1 ngi muon ngi kia ch mot khoang thi gian nao o trong khi ngi kia thc hien cong viec g o, hac la ch e chuyen cuoc goi cho ngi ma ngi goi can gap th ta dung chc nang nay e cho ngi ch nghe mot ban nhac nao o ma ta at san lam cho ngi ch thay de chu hn la nghe nhng am thanh kho chu khac. [default] Mode = files Directory = /var/lib/asterisk/moh ; neu file am thanh cha trong moh Random = yes ; phat ngau nhien 1 file am thanh co trong th muc moh 2. Chc nang goi thong thng Trong phan nay ta cau hnh cho mot cong ty co chi nhanh tai TpHCM ( tong ai 8XXX) va mot chi nhanh tai mot v tr khac, chang han a Nang ( Tong ai 7XXX). a/ Hai may goi cho nhau. Chc nang c ban au tien la cho cac may goi cho nhau trong cung mot tong ai ( Goi noi hat) Cau hnh trong file SIP. Gia s cu hnh cho tong ai tai a Nang: [general] allow=all ; cho phep s dung tat ca cac loai ma ng truyen.

contex=incoming [7000] type=friend ; friend = user + peer, moi lien he vi account o. context=danang-sip ; contex trong extensions.conf username=7000 ; secret=7777 ; password cua account 7000. nat=yes ; cho phep goi t ben ngoai vao may noi bo . host=dynamic ; cho phep goi vao tong ai t bat c a ch IP nao. canreinvite=yes dtmfmode=rfc2833 ; mac nh mode cua ma dtmf (ma ban phm ien ;thoai la rfc2388.)

[7001] type=friend context=hieu-sip username=7007 secret=7777 nat=yes host=dynamic canreinvite=yes dtmfmode=rfc2833 disallow=all allow=ulaw Cau hnh trong file extensions.conf [danang-sip] exten=>_7XXX,1,Dial(Sip/${EXTEN}|90|rt) exten=>_7XXX,2,SetmusicOnHold(moh) exten=>_7XXX,n,Hangup()

Giai thch code. exten=>_7XXX,1,Dial(Sip/${EXTEN}|90|rt) ; cac account tro ti danang-sip th khi goi ti cac may co 4 ch so va bat au bang au so 7, no se quay so (Dial) en cac account trong sip ma tro ti extension nay no se o chuong (ringing) 90 giay. Option r: phat ra am thanh cho ngi goi cho en khi ngi c goi tra li. Option t: cho phep ngi goi transfer cuoc goi. exten=>_7XXX,2,SetmusicOnHold(moh) ; file nhac nam trong th muc /var/lib/asterisk/moh se c phat ra co ngi goi khi ngi kia bam phm hold exten=>_7XXX,n,Hangup() ; gac may. Vay ta co the cau hnh cho cac may goi c cho nhau trong cung mot tong ai. Tong ai no bo th bang thong len en 100Mbps nen chung ta t quan tam en viec gii han cuoc goi. Va van e nay se c e cap trong phan ngay sau ay. b/ Hai may hai tong ai khac nhau goi cho nhau - Tong ai chi nhanh a Nang + file sip.conf [general] allow=all [default] include=>parkedcalls [7000] type=friend context=hieu-sip username=7000

secret=7777 nat=yes host=dynamic canreinvite=yes dtmfmode=rfc2833 [7001] type=friend context=hieu-sip username=7007 secret=7777 nat=yes host=dynamic canreinvite=yes dtmfmode=rfc2833

[PBX2] type=friend host=192.168.1.220 ; IP tong ai tai chi nhanh Tp HCM port=5060 qualify=yes dtmfmode=rfc2833 canreinvite=yes disallow=all ; khong s dung tat ca cac loai ma ng truyen. allow = g711 allow=ulaw ; s dung ma ng truyen ulaw allow=alaw ; s dung ma ng truyen alaw. allow=gsm ; s dung ma ng truyen gsm. nat=yes

context=danang-sip + file extensions.conf ; Goi noi bo vi nhau ( au so 7 ) exten=>_7XXX,1,Dial(Sip/${EXTEN}|90|rt) exten=>_7XXX,2,SetmusicOnHold(moh) exten=>_7XXX,n,Hangup() ;Goi ra au so 8 exten=>_8XXX,1,Dial(Sip/${EXTEN}|90|rt) exten=>_8XXX,2,SetmusicOnHold(moh) exten=>_8XXX,n,Hangup() - Tong ai Tp HCM + file sip.conf [general] allow=all [default] include=>parkedcalls [8000] type=friend context=hieu-sip username=8888 secret=7777 nat=yes host=dynamic canreinvite=yes dtmfmode=rfc2833

[8001] type=friend context=hieu-sip username=8001 secret=8888 nat=yes host=dynamic canreinvite=yes dtmfmode=rfc2833 [PBX2] type=friend host=192.168.1.119 ; IP tong ai tai chi nhanh a Nang. port=5060 qualify=yes dtmfmode=rfc2833 canreinvite=yes disallow=all ; allow = g711 allow=ulaw allow=alaw allow=gsm nat=yes context=danang-sip + file extensions.conf ; Goi noi bo vi nhau ( au so 8 ) exten=>_8XXX,1,Dial(Sip/${EXTEN}|90|rt) exten=>_8XXX,2,SetmusicOnHold(moh) exten=>_8XXX,n,Hangup()

; Goi ra au so 7 exten=>_7XXX,1,Dial(Sip/${EXTEN}|90|rt) exten=>_7XXX,2,SetmusicOnHold(moh) exten=>_7XXX,n,Hangup() Nh ta thay trong phan nay, moi khi them hay bt account, hay thay oi thong so nao tren cac file cau hnh khac th cung ta phai lam trc tiep tren file cau hnh, va sau khi thay oi bat c phan nao trong file cau hnh th ta phai reload lai server, ieu nay rat la bat tien. V khong the bat ngi dung phai hoc asterisk c nen ta phai dung phng phap cau hnh khac la realtimes, vi phng phap nay chung ta se dung c s d lieu e lam, va chung ta se de dang dung cac ngon ng lap trnh khac e tao giao dien ngi dung, va ngi s dung se de dang thay oi pass va ten ngi dung vi account c cap, ong thi ngi quan tr cung them hay bt account rat de dang ma khong can hieu sau ve asterisk. c/ Real times Trong phan nay chung ta se dung MySQL e tao databases cho sip.conf - Cai at MySQL: + n gian la ta s dung lenh sau: Yum y install mysql mysql-server ->Mysql se t ong cai at sau lenh tren. +Config mysql: chkconfig --levels 235 mysqld on + khi ong Mysql /etc/init.d/mysqld start + ang nhap account root mysql -u root p Nhap pass sau dong lenh tren e quan ly mysql th ta phai grant quyen user e truy cap t xa

GRANT ALL PRIVILEGES ON db_base.* TO 'root' @'%' IDENTIFIED BY '7777'; Trao tat ca cac quyen quan ly cho account root, ang nhap vi bat ky IP nao ( root@ %) vi password la 7777. - Cai at them Asterisk-addon Sau khi download goi asterisk-addon ve, ta tien hanh cai at. + tar xzvf asterisk-addon-<version>.tar.gz + make clean + make install Copy "res_mysql.conf.sample" t /usr/src/asteriskaddons/configs" vao "/etc/asterisk/" va oi thanh "res_mysql.conf" - Tao database cho account sip.conf + Tao 1 database ten la example. Create database example; + Tao ban vi database example. Use example; + tao bang account_sip create table `account_sip` (

`name` varchar(20), `type`

varchar(7), `context` varchar(20), `username` varchar(20), `secret` varchar(16), `nat` varchar(3), `host` varchar(15), `canreinvite` varchar(3), `dtmfmode` varchar(7), `huntinggroup` varchar(3) , `pickup` varchar(2) , `group` varchar (2) , `callbackgroup` varchar (2) , `unknow` varchar(2) , `port` varchar(4) , `insecure` varchar(4) ); Upload d lieu t file account_sip dang txt, cac cot cach nhau bang khoang trang, cha trong th muc /var/soft/ vao bang account_sip.

load data local infile '/var/soft/account_sip.txt' into table account_sip fields TERMINATED by ' ' lines TERMINATED by '\r\n' ;

Nh hnh tren, ta co the s dung phan mem quan ly khac e de dang thay oi bat k thong so nao trong table, t o thong tin account sip cung thay oi theo ma ta khong phai can thiep vao file cau hnh trong asterisk. - Cau hnh realtimes. + File res_mysql.conf [general] dbhost = localhost dbname = example dbuser = root dbpass = 7777 dbport = 3306 dbsock = /var/lib/mysql/mysql.sock

+ File extconfig.conf sipusers => mysql,example,account_sip sippeers => mysql,example,account_sip + File sip.conf [general] rtcachefriends=yes d/ Call forward e/ Call Pickup f/ Call transfer 3. Tong ai noi bo cho mot doanh nghiep (Continue) 4. Tong ai IVR

II/ Hng phat trien luan van tot nghiep. III/ Hieu qua cua tong ai IP PBX tren nen Asterisk va giai phap cho doanh nghiep.