Está en la página 1de 22

2012

Lab 3-Trin khai h thng VOIP bng Asterisk

Sinh vin thc hin: Nguyn Trung Nim Lp:09DTHM MSSV:0951020186

Gio vin hng dn: Nguyn c Quang 3/21/2012

Lab 3-Trin khai h thng VOIP bng Asterisk

Phn I : Tng quan v Asterisk


Asterisk l h thng chuyn mch mm, l phn mm ngun m c vit bng ngn ng C chy trn h iu hnh linux thc hin tt c cc tnh nng ca tng i PBX v hn th na. Asterisk ra i vo nm 1999 bi mt sinh vin sinh nm 1977 tn l Mark Spencer. Anh ta vit phn mm ny ban u vi mc ch h tr cho cng ty ca mnh trong vic lin lc m thoi. Asterisk l mt phn mm mang tnh cch mng, tin cy, m ngun m v min ph m bin mt PC r tin thng thng chy Linux thnh mt h thng in thoi doanh nghip mnh m. Asterisk 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 ho kin trcb 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 em n cho ngi s dng tt c cc tnh nng v ng dng ca h thng tng i PBX v cung cp nhiu tnh nng m tng i PBX thng thng khng c c, 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 cuc gi 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 cho php gi ra bt c s in thoi no c trn mng PSTN.

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

Lab 3-Trin khai h thng VOIP bng Asterisk

I. 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 cho VOIP nh SIP, H323, IAX, MGCP... cc cng ngh in thoi cho h thng chuyn mch mch TDM nh T1, E1, ISDN v cc giao tip ng truyn thoi Analog. Khi khi ng h thng Asterisk th chc nng Dynamic Module Loader thc hin np driver ca thit b, np cc knh giao tip, cc format, codec v cc ng dng lin quan, ng thi cc hm API cng c lin kt np vo h thng. Sau h thng PBX Switching Coreca Asterisk chuyn sang trng thi sn sng hot ng chuyn mch cuc gi, cc cuc gi c chuyn mch tu vo k hoch quay s (Dialplan) c thc hin cu hnh trong file extension.conf. Application Launchar rung chung thu bao, quay s, nh hng cuc gi, kt ni vi hp th thoi Scheduler and I/O Manager m nhim cc ng dng nng cao. Codec Translator xc nhn cc knh nn d liu ng vi cc chun khc nhau c th kt hp lin lc c vi nhau. H thng cng
2 SV: Nguyn Trung Nim | Gio vin hng dn: Nguyn c Quang

Lab 3-Trin khai h thng VOIP bng Asterisk

bao gm 4 chc nng API chnh: Codec translator API: cc hm thc thi, gii nn cc chun nh G711, G729 Asterisk Channel API : Giao tip vi cc knh lin lc khc nhau . Asterisk file format API : x l cc loi file c nh dng nh Mp3, wav, gsm Asterisk Aplication API : Bao gm tt c cc ng dng c thc thi trong h thng Asterisk nh voicemail, callerID II Giao thc IAX ( Inter Asterisk eXchange) IAX l giao thc chun dnh ring cho Asterisk, c pht trin bi tc gi ca phn mm Asterisk khc phc nhng hn ch trong giao thc SIP. N cung cp hot ng lin kt trong sut vi tng la NAT v PAT. N h tr vic thit lp, nhn, chuyn cuc gi v ng k cuc gi. Khng ging nh giao thc SIP chuyn ti thoi v bo hiu trn hai knh khc nhau (out of band), IAX chuyn ti thoi v bo hiu trn cng mt knh(in band). IAX gii quyt c vn NAT cp trn phn giao thc SIP. Mc khc IAX l giao thc ti u trong vic s dng bng thng, cho php nhiu gi d liu thoi trn cng mt IP header, c ch chuyn ti nhiu cuc gi trn cng mt gi IP c gi l trung k(Trunk). Vi IAX, cc in thoi hon ton c ng. Ch cn kt ni in thoi vi Asterisk server bt c u trn mng Internet, chng s ng k vi PBX ch v c nh tuyn cuc gi ngay tc th. IAX c on mo u rt nh. Vi bn byte ca mo u, so snh vi 12 byte mo u ca SIP hay H.323, bn tin IAX c th ni l nh hn rt nhiu.

III Cc tnh nng c bn ca tng i Asterisk Ngoi nhng tnh nng tng t nh tng i PBX, Asterisk cn c thm nhiu tnh nng khc m ch c th c c nhng tng i rt t tin. l cc tnh nng: - Voicemail Services with Directory - Conferencing Server - Packet Voice Server - Encryption of Telephone or Fax Calls
3 SV: Nguyn Trung Nim | Gio vin hng dn: Nguyn c Quang

Lab 3-Trin khai h thng VOIP bng Asterisk


- Heterogeneous Voice over IP gateway (H.323, SIP, MGCP, IAX) - Custom Interactive Voice Response (IVR) system - Soft switch - Number Translation - Calling Card Server - Predictive Dialer - Call Queuing with Remote Agents - Gateway and Aggregation for Legacy PBX systems - Remote Office or User Telephone Services - PBX long distance Gateway - Telemarketing Block - Standalone Voicemail System

Phn II: Giao thc SIP.


SIP (Session Initiation Protcol ) l giao thc bo hiu iu khin lp ng dng c dng thit lp, duy tr, kt thc cc phin truyn thng a phng tin (multimedia). Cc phin multimedia bao gm thoi Internet, hi ngh, v cc ng dng tng t c lin quan n cc phng tin truyn t (media) nh m thanh, hnh nh, v d liu. SIP s dng cc bn tin mi (INVITE) thit lp cc phin v mang cc thng tin m t phin truyn dn. SIP h tr cc phin n b (unicast) v qung b (multicast) tng ng cc cuc gi im ti im v cuc gi a im. 1.cc thnh phn trong mng SIP. Ni chung SIP gm 2 thnh phn ln l SIP client (l thit b h tr

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

Lab 3-Trin khai h thng VOIP bng Asterisk


giao thc SIP nh SIP phone), v SIP server (l thit b trong mng x l cc bn tin SIP). Trong SIP server c cc thnh phn quan trng nh: Proxy server, Redirect server, Location server, Registrar server... Proxy Server: l thc th trong mng SIP lm nhim v chuyn tip cc SIP request ti thc th khc trong mng. Nh vy, chc nng chnh ca n trong mng l nh tuyn cho cc bn tin n ch. Proxy server cng cung cp cc chc nng xc thc trc khi cho khai thc dch v. Mt proxy c th lu (stateful) hoc khng lu trng thi (stateless) ca bn tin trc . Thng thng, proxy c lu trng thi, chng duy tr trng thi trong sut transaction (khong 32 giy). Redirect Server: tr v bn tin lp 300 thng bo thit b l chuyn hng bn tin ti a ch khc t lin lc thng qua a ch tr v. Registrar server: l server nhn bn tin SIP REGISTER yu cu v cp nht thng tin t bn tin request vo location database nm trong Location Server Location Server: lu thng tin trng thi hin ti ca ngi dng trong mng SIP

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

Lab 3-Trin khai h thng VOIP bng Asterisk


Cc bn tin SIP, mo u v nh s Di y l cc bn tin ca SIP : INVITE : bt u thit lp cuc gi bng cch gi bn tin mi u cui khc tham gia ACK : bn tin ny khng nh my trm nhn c bn tin tr li bn tin INVITE BYE : bt u kt thc cuc gi CANCEL : hy yu cu nm trong hng i REGISTER : u cui SIP s dng bn tin ny ng k vi my ch ng k OPTION : s dng xc nh nng lc ca my ch INFO : s dng ti cc thng tin nh m bo DTMF Giao thc SIP c nhiu im trng hp vi giao thc HTTP. Cc bn tin tr li cc bn tin SIP nu trn gm c : 1xx cc bn tin chung 2xx thnh cng 3xx - chuyn a ch 4xx yu cu khng c p ng 5xx - s c ca my ch 6xx - s c ton mng Cc bn tin SIP c khun dng text, tng t nh HTTP. Mo u ca bn tin SIP cng tng t nh HTTP v SIP cng h tr MIME (mt s chun v email) Tnh nng ca SIP. Giao thc SIP c thit k vi nhng ch tiu sau: Tch hp vi cc giao thc c ca IETF n gin v c kh nng m rng H tr ti a s di ng ca u cui D dng to tnh nng mi cho dch v a) Tch hp vi cc giao thc c ca IETF Cc giao thc khc ca IETF c th xy dng xy dng nhng ng dng SIP. SIP c th hot ng cng vi nhu giao thc nh : - RSVP (Resource Reservation Protocol) : Giao thc ginh trc ti nguyn mng. - RTP (Real-time transport Protocol) : Giao thc truyn ti thi gian thc - RTSP (Real Time Streaming Protocol) : Giao thc to lung thi gian thc - SAP (Session Advertisement Protocol) : Giao thc thng bo trong phin kt ni - SDP (Session Description Protocol) : Giao thc m t phin kt ni a phng tin
6 SV: Nguyn Trung Nim | Gio vin hng dn: Nguyn c Quang

Lab 3-Trin khai h thng VOIP bng Asterisk


- MIME (Multipurpose Internet Mail Extension - M rng th tn Internet a mc ch) : Giao thc th in t - HTTP (Hypertext Transfer Protocol) : Giao thc truyn siu vn bn - COPS (Common Open Policy Service) : Dch v chnh sch m chung - OSP (Open Settlement Protocol) : Giao thc tha thun m b) n gin v c kh nng m rng SIP c rt t bn tin, khng c cc chc nng tha nhng SIP c th s dng thit lp nhng phin kt ni phc tp nh hi ngh n gin, gn nh, da trn khun dng vn bn, SIP l giao thc ra i sau v khc phc c im yu ca nhiu giao thc trc y. Cc phn mm ca my ch y quyn, my ch ng k, my ch chuyn i a ch, my ch nh v c th chy trn cc my ch khc nhau v vic ci t thm my ch hon ton khng nh hng n cc my ch c. Chnh v th h thng chuyn mch SIP c th d dng nng cp. c) H tr ti a s di ng ca u cui Do c my ch y quyn, my ch ng k v my ch chuyn i a ch h thng lun nm c a im chnh xc ca thu bao. d) D dng to tnh nng mi cho dch v v dch v mi. L giao thc khi to phin trong mng chuyn mch gi SIP cho php to ra nhng tnh nng mi hay dch v mi mt cch nhanh chng. Ngn ng x l cuc gi (Call Processing Language) v Giao din cng kt ni chung (Common Gateway Interface) l mt s cng c thc hin iu ny. SIP h tr cc dch v thoi nh ch cuc gi, chuyn tip cuc gi, kha cuc gi (call waiting, call forwarding, call blocking), h tr thng ip thng nht Cu trc gi SIP Header:

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

Lab 3-Trin khai h thng VOIP bng Asterisk

Hnh 10 Mt s trng header n gin INVITE : ch th rng thu bao hoc dch v c mi tham gia vo mt phin. N bao gm mt m t phin v i vi cc cuc gi song cng th b n c h g i c h t h p h n g t h c t r u y n t h n g ( m e d i a ) t r o n g b n t i n n y. Theo phng php n gin ny cc bn c th xc nh c cc kh nngca bn kia v bt u mt phin hi thoi . ACK : Nhng yu cu ny tng ng vi mt yu cu INVITE. Chng l sxc nhn cui cng t mt h thng cui v chm dt mt giao dch ckhi to bi INVITE. OPTIONS : Bn tin ny cho php truy vn v tp hp cc kh nng ca user agent v network server. Tuy nhin yu cu ny khng c dng thitlp phin. BYE: B n c h g i v b g i s d n g y u c u n y g i i p h n g c u c g i . Trc khi thc s gii phng cuc gi, user agent gi yu cu ny ti server cnh bo rng n mun gii phng phin lm vic. CANCEL: Yu cu ny cho php user agent v network server xo b btk mt yu cu no ang thi hnh. REGISTER: y u c u n y c c l i e n t d n g n g k t h n g t i n v i S I P server.

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

Lab 3-Trin khai h thng VOIP bng Asterisk

Phn III: M Hnh


M hnh gm c 2 chi nhnh ca mt cng ty. Cng ty mun trin khai h thng VOIP lin lc gia 2 chi nhnh. Mi chi nhnh c mt Server Asterisk ng ra lm tng i. Ni b CN SG c s in thoi l :1xxx v CN HN l 2xxx

Cc thit b v phn mn c s dng xy dng lab: -GNS 3 -Vmware 7 -Asterisk NOW 1.8 -Xlite 4 softphone -Wireshark 1.6.4

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

10

Lab 3-Trin khai h thng VOIP bng Asterisk

Phn III: Trin khai m hnh


1/M hnh trn GNS3:

10

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

11

Lab 3-Trin khai h thng VOIP bng Asterisk

2/Ci t Asterisk:

1) Hard disk layout. Chn "Remove all partitions on selected drives and create default layout." V click chn next screen. Hin bng *ERASE ALL DATA* chn Yes. 2) Timezone settings. Chn mi gi thch hp v nhn next. 3) Root password. The 'root' user is the administrative account for Linux systems. Most system configuration requires 'root' access. If this password is lost, it is impossible to recover. It is recommended that your password contain a mix of lowercase and UPPERCASE letters, numbers, and/or symbols

11

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

12

Lab 3-Trin khai h thng VOIP bng Asterisk

3/Cu hnh Asterisk Server:


-Cu hnh Asterisk server 1: -Cu hnh file Sip.Conf cha cc account sip: G lnh vo file sip.conf cu hnh:

Thm ni dung sau vo file sip.conf:

[name]: y l phn khai bo my in thoi extention ip sip, c th l k tnhng thng l cc con s quay v trn cc phmin thoi thng l cc con sm thi Type: Kiu kt ni thng tin user, peer hay friend Host : a ch IP hay tn min m client kt ni vi knh ny thng dng gitr l dynamic cho tt c client kt nin Secret : mt khu s dng knh ny. My in thoi pha client phi khai bo trng vi thng s ny th mi s dngc.

-Cu hnh file Extensions.conf: G lnh vo file Extensions.conf cu hnh:

12

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

13

Lab 3-Trin khai h thng VOIP bng Asterisk

Thm ni dung sau vo file Extensions.conf:

. Extenstion hon chnh gm c cc phn : exten => Name,priority,application( ) Name (Tn k t hoc con s) ca extension Priority (Mi extension c th bao gm nhiu bc mi bcc gi lpriority) Application (or command) Thc hin mt ng dng c th no cho cucgiMt v d c th nh -Cu hnh Asterisk server 2: Cu hnh file Sip.Conf cha cc account sip: G lnh vo file sip.conf cu hnh:

Thm ni dung sau vo file Sip.conf:

Cu hnh file Extensions.conf: G lnh vo file Extensions.conf cu hnh: Thm ni dung sau vo file Extensions.conf:

13

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

14

Lab 3-Trin khai h thng VOIP bng Asterisk

3/Cu hnh kt ni hai Asterisk Server bng SIP Trunking:


-Trn Asterisk server 1: Ta thm site2 vo file cu hnh sip.conf dng vo to kt ni peer-peer n Asterisk server khc: G lnh sau vo cu hnh file sip.conf Thm ni dung sau vo file sip.conf:

Thit lp cuc gi n Asterisk Server 2. Khi s in thoi c dng 2xxx th Astrisk server 1 s chuyn tip n Asterisk server 2, t y s kt ni n Client ang s hu s in thoi .

-Trn Asterisk server 2: Ta thm site1 vo file cu hnh sip.conf dng vo to kt ni peer-peer n Asterisk server khc: G lnh sau vo cu hnh file sip.conf Thm ni dung sau vo file sip.conf

Thit lp cuc gi n Asterisk Server 2. Khi s in thoi c dng 1xxx th Astrisk server 2s chuyn tip n Asterisk server 1, t y s kt ni n Client ang s hu s in thoi .

14

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

15

Lab 3-Trin khai h thng VOIP bng Asterisk

4/Khi to dch v Asterisk v kim tra cc thng s:


-Khi chy dch v:

-Kim tra cc peer hin c:

-Kim tra cc user hin c:

5/Kt ni Xlite n Asterisk:


-Sau khi ci t Xlite 4 vo client. Khi chy chng trnh c giao din.

15

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

16

Lab 3-Trin khai h thng VOIP bng Asterisk

-Account name: tn ti khon, ty -User ID : tn username khai bo trn Asterkris trong file Sip.conf -Domain: a chi Ip Asterisk server -Display name : Tn hin th

Click vo menu Softphone->Account Settings

16

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

17

Lab 3-Trin khai h thng VOIP bng Asterisk

17

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

18

Lab 3-Trin khai h thng VOIP bng Asterisk

Phn IV: Demo kt qu bi lab

Nhan vien 2 : 2001 Gi Nhan vien 1: 1001

18

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

19

Lab 3-Trin khai h thng VOIP bng Asterisk

Nhan vien1 : 1001 Gi Nhan Vien 2: 2001

-Log khi thc hin cuc gia 1001 v 2001: Trn Asterisk Server 1:

19

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

20

Lab 3-Trin khai h thng VOIP bng Asterisk

Trn Asterisk Server 2:

Phn V: Cc gi tin trong m hnh


-Khi thc hin gi t 1001 n 2001 s c cc gi tin nh sau:

20

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang

21

Lab 3-Trin khai h thng VOIP bng Asterisk

-Khi 2001 nhn cuc gi t 1001 s c cc gi tin nh sau:

-Khi 2001 cp my s c cc gi tin sau:

21

SV: Nguyn Trung Nim

| Gio vin hng dn: Nguyn c Quang