Está en la página 1de 39

Tm hiu h thng VoIP trn Asterisk

Mc lc
CHNG I: GII THIU V MNG VOIP .......................................................................... 4 1.1 1.2 1.3 1.4 1.5 Gii thiu v VoIP ...................................................................................................... 4 u im ca VoIP ....................................................................................................... 5 Nhc im ca VoIP ................................................................................................. 7 Cc chun thoi dng trong VoIP ............................................................................... 7 Cc t chc pht trin VoIP ........................................................................................ 7 Tng quan v giao thc khi to phin SIP ................................................................ 9 Cu trc ca SIP ........................................................................................................ 10 Cc thnh phn ca SIP ..................................................................................... 10 2.2.1.1 a ch ca SIP ............................................................................................... 11 2.2.1.2 nh v server SIP .......................................................................................... 11 2.2.1.3 nh v ngi dng ........................................................................................ 12 2.2.1.4 Thay i mt phin ang tn ti..................................................................... 12 2.2.1.5 Cc bn tin ca SIP ........................................................................................ 12 2.2.1.6 Tiu bn tin ................................................................................................ 13 2.2.1.7 Bn tin yu cu ............................................................................................... 14 2.2.1.8 Bn tin p ng .............................................................................................. 15 2.2.1.9 Thit lp v hy cuc gi SIP ........................................................................ 17 2.2.1.10 a. b. Lin vn gia SIP v SS7 ........................................................................... 20 Thit lp cuc gi c bn gia SIP v PSTN .................................................... 20 nh hng cuc gi SIP ................................................................................... 21 Tnh nng ca SIP....................................................................................... 22 NG DNG VOIP ...................................... 24

CHNG II: T NG QUAN V GIAO TH C SIP ................................................................ 9 2.1 2.2

2.2.1

2.2.1.11

CHNG III: GII THIU BA PHN MM 3.1

Asterisk...................................................................................................................... 24 Gii thiu v phn mm Asterisk ...................................................................... 24 Tnh nng v li ch ca Asterisk ...................................................................... 24

3.1.1 3.1.2 3.2

OpenSIP .................................................................................................................... 25 Khi nim OpenSIPS ......................................................................................... 25 Tnh nng v li ch ca OpenSIPS ................................................................... 25
Page 1

3.2.1 3.2.2

Nhm 1-07VTA1

Tm hiu h thng VoIP trn Asterisk


3.2.3 3.3 Kt lun .............................................................................................................. 27

Kamailio .................................................................................................................... 27

CHNG IV: TRIN KHAI H THNG ASTERISK ......................................................... 29 4.1 4.2 4.3 4.4 Gii thiu chung ........................................................................................................ 29 Kt ni phn cng ..................................................................................................... 29 Ci t phn mm ...................................................................................................... 30 Thc hin cuc gi VoIP, bt v phn tch gi ......................................................... 32 Khi to phin .................................................................................................... 32 Qu trnh m thoi ........................................................................................... 33 Kt thc phin: ................................................................................................... 36

4.4.1 4.4.2 4.4.3

CHNG V: KT LUN ...................................................................................................... 37 Hn ch v hng pht trin ca ti .................................................................................... 37 Hn ch ca ti .............................................................................................. 37 Hng pht trin ca ti ................................................................................ 37

DANH MC HNH V V BNG BIU


Hnh 2-1: V tr ca SIP trong m hnh OSI. ............................................................................. 9 Hnh 2-2: Cc thnh phn ca SIP ........................................................................................... 10 Hnh 2-3: Hot ng Proxy Server .......................................................................................... 17 Hnh 2-4: Hot ng ca Redirect Server. ............................................................................... 18 Hnh 2-5: Thit lp v hy cuc gi SIP. ................................................................................ 19 Hnh 2-6: Thit lp cuc gi c bn gia SIP v PSTN. ......................................................... 20 Hnh 2-7: nh hng cuc gi SIP. ....................................................................................... 21 Hnh 2-8: OpenSIPS trong VoIP ............................................................................................. 25 Hnh 4-1: Cc thit b trong h thng Asterisk ........................................................................ 29 Hnh 4-2: Giao din h iu hnh ............................................................................................ 30 Hnh 4-3: Giao din ca freepbx .............................................................................................. 31 Hnh 4-4: Giao din ca phn mm X Lite .............................................................................. 31 Hnh 4-5: Cu trc khung ca gi tin RTP .............................................................................. 33 Hnh 4-6: Gi tin th 49 .......................................................................................................... 34 Bng 2-1: Cc tiu bn tin .................................................................................................. 13 Bng 2-2: Gii thch mt s tiu chnh ca SIP .................................................................. 14 Bng 2-3: Cc bn tin yu cu ca SIP. ................................................................................... 15 Bng 2-4: Cc loi bn tin p ng ca SIP. ........................................................................... 15 Bng 2-5: Mt s m trng thi c nh ngha trong SIP ................................................... 17

Nhm 1-07VTA1

Page 2

Tm hiu h thng VoIP trn Asterisk

Li m u

Trong nhng nm gn y, chng ta nghe ni nhiu v VoIP nh l mt cng ngh mang tnh cch mng trong vic truyn tn hiu thoi qua mi trng Internet. Cng vi s bng n Internet, VoIP cng c nhng bc pht trin di, ngy cng hon thin v cng ngh, cht lng n nh, tch hp c truyn thng a phng tin v rt cnh tranh v gi cc. Nhiu h thng VoIP ra i v c trin khai rng khp. V vy vic nghin cu v nm bt cc cng ngh v VoIP ang rt c quan tm. Trong qu trnh tm hiu v VoIP, nhm 1-07VTA1 quyt nh chn ti Tm hiu h thng VoIP trn Asterisk, ni dung c trnh by trong 5 chng: Chng I: Tm hiu khi qut v cng ngh truyn thoi trn nn internet (VoIP). Qua chng ta c th tng qut hnh dung v VoIP l g, cch thc hat ng ca n ra sao v u nhc im ca cng ngh ny. Chng II: Tm hiu mt trong nhng giao thc bo hiu quan trng trong VoIP l giao thc bo hiu SIP y l mt trong nhng giao thc ca VoIP c s dng rng ri v SIP cng chnh l giao thc bo hiu s dng trong chng trnh ng dng Asterisk c trnh by cc chng tip theo. Chng III: xut 3 gii php VoIP, so snh cc gii php v quyt nh gii php trin khai chng IV Chng IV : Trin khai VoIP trn h thng Asterisk, cc bc thit lp phn cng, ci t phn mm, thc hin cuc gi, bt v phn tch cc gi tin. Chng V: Kt lun, hn ch, hng pht trin ca ti. Trong qu trnh lm ti, d c gng song do kin thc hn ch nn khng th trnh khi nhng thiu st. Chng em rt mong nhn c s gp , hng dn gip ca Thy C, bn b. Chng em xin chn thnh cm n

Tp. H Ch Minh, thng 6 nm 2011 Nhm thc hin Nhm 1 07VTA1

Nhm 1-07VTA1

Page 3

Tm hiu h thng VoIP trn Asterisk

CHNG I: GII THIU V MNG VOIP


Internet Voice, c bit nh thoi qua giao thc (Voice Over IP), l mt cng ngh cho php to cuc gi dng kt ni bng thng rng thay v dng ng dy in thoi tng t (analog). Nhiu dch v dng Voice over IP c th ch cho php bn gi ngi khc dng cng loi dch v, tuy nhin cng c nhng dch v cho php gi dng s in thoi nh s ni b, ng di, di ng, quc t. Nhng dch v ch lm vic qua my tnh, hay loi in thoi qua IP (IP phone) c bit. Vi dch v cho php dng in thoi truyn thng qua mt b iu hp (adaptor) 1.1 Gii thiu v VoIP 1.1.1 VoIP l g Voice over Internet Protocol (VoIP) l mt cng ngh cho php truyn thoi s dng giao thc mng IP, trn c s h tng sn c 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 cho php thc hin cuc gi dng my tnh qua mng d liu nh Internet VoIP chuyn i tn hiu thoi t in thoi tng t analog vo tn hiu s (digital) trc khi truyn qua Internet, sau chuyn i ngc li u nhn. Khi to mt cuc gi VoIP dng in thoi vi mt b iu hp, ta s nghe m mi gi, quay s sau tin trnh ny VoIP cng cho php to mt cuc gi trc tip t my tnh dng loi in thoi tng ng hay dng microphone. VoIP cho php to cuc gi ng di qua mng d liu IP c sn thay v phi c truyn qua mng PSTN (Public Switched Telephone Network). Ngy nay nhiu cng ty thc hin gii php VoIP ca h gim chi ph cho nhng cuc gi ng di gia nhiu chi nhnh xa nhau. Trc y, khi da vo giao tip thoi trn mng PSTN. Trong sut cuc gi gia hai a im, ng kt ni c dnh ring cho bn thc hin cuc gi. Khng c thng tin khc c th truyn qua ng truyn ny, cho d vn cn tha lng bng thng sn dng Sau vi s xut hin ca mng giao tip d liu, nhiu cng ty u t cho mng giao tip d liu chia s thng tin vi nhau, trong khi thoi v fax vn tip tc s dng mng PSTN. Nhng ngy nay iu ny khng cn l vn na, vi s pht trin nhanh chng v s dng rng ri ca IP, chng ta tin rt xa trong kh nng gim chi ph trong vic h tr truyn thoi v d liu. Gii php tch hp thoi vo mng d liu, v cng hot ng bn cnh h thng PBX hin ti hay nhng thit b in thoi khc, n gin cho vic m rng kh nng thoi cho nhng v tr xa. Lu lng thoi thc cht s c mang t do (free) bn trn mng d liu thng qua c s h tng v thit b phn cng c sn Mc d nhng khi nim v VoIP l n gin, nhng thc hin v ng dng VoIP l phc tp gi voice, thng tin phi c tch bit thnh nhng gi
Nhm 1-07VTA1 Page 4

Tm hiu h thng VoIP trn Asterisk (packet) ging nh d liu. Gi l nhng phn thng tin c chia nh d dng cho vic gi gi, cng c th dng k thut nn gi tit kim bng thng, thng qua nhng tin trnh codec (compressor/de-compressor). C rt nhiu loi giao thc dng thc hin dch v VoIP, nhng giao thc bo hiu VoIP ph bin SIP v H323. C SIP v H323 u cho php ngi dng thc hin cng cng vic: thit lp giao tip cho nhng ng dng a phng tin (multimedia) nh audio, video, nhng giao tip d liu khc Nhng H323 ch yu c thit k cho nhng dch v a phng tin, trong khi SIP th ph hp cho nhng dch v VoIP. RTP (Real-time Transport Protocol) nh ngha nh dng chun ca gi tin cho vic phn phi audio v video qua Internet. 1.1.2 Phng thc hot ng Khi ni vo ng nghe hay microphone, ging ni s to ra tn hiu in t, l nhng tn hiu analog. Tn hiu analog c chuyn sang tn hiu s dng thut ton c bit chuyn i. Nhng thit b khc nhau c cch chuyn i khc nhau nh VoIP phone hay softphone, nu dng in thoi analog thng thng th cn mt Telephony Adapter (TA) Sau ging ni c s ha s c ng vo gi tin v gi trn mng IP. Trong sut tin trnh mt giao thc nh SIP hay H323 s c dng iu khin (control) cuc gi nh l thit lp, quay s, ngt kt ni v RTP th c dng cho tnh nng m bo tin cy v duy tr cht lng dch v trong qu trnh truyn. 1.2 u im ca VoIP 1.2.1 a dng tnh nng Hiu qu kinh t cao Tt c tnh nng, ng dng thng tin lin lc mi hin c mt trn th gii vin thng hi t u h tr nn tng mng IP. Tt c tnh nng ny c sn m khng i hi thm bt k chi ph u t no bi v chng hot ng trn nn tng mng IP v c "vn chuyn" trn mng my tnh y nh cc ng dng my tnh thng thng. 1.2.2 Tit kim chi ph u t VoIP H thng IP Telephony v VoIP h tr tt hn cho cng vic kinh doanh. Nu doanh nghip trang b thit b k thut s (nh tng i PBX), th c th tit kim c ng k chi ph u t bng cch ti s dng hu ht cc thit b ny vi h thng VoIP mi. 1.2.3 D bo tr Vic ci t v qun l h thng IP Telephony v VoIP tr nn d dng hn Vi h thng IP Telephony th mng VoIP s t ng t iu chnh tng thch vi v tr mi ca ngi dng. Nh qun l h thng c th t bt k my tnh ni mng no tin hnh kim tra, thit lp mc ch s dng, ti khon v nhiu d liu khc cho ngi dng. Vi h thng vin thng nn IP, cng vic qun l v bo tr mng in thoi tr nn kinh t v hiu qu hn
Nhm 1-07VTA1 Page 5

Tm hiu h thng VoIP trn Asterisk


1.2.4 Linh hot v c ng

IP Softphone l gii php phn mm gi in thoi Internet dnh cho cc my tnh s dng h iu hnh Windows. Phn mm ny cho php ngi dng d dng truy xut n cc dch v vin thng thi gian thc v nhng tnh nng ci tin khc vi cch thc s dng tht n gin: ch cn nhn chut quay s cuc gi. Trong mt mng vin thng nn IP, nhn vin c th t do i li bt k u trong vn phng cng ty, ni my tnh xch tay vo mng, bt u lm vic v nhn/thc hin cc cuc gi. 1.2.5 Nhiu tnh nng hp dn VoIP vi nhng u im nh gim chi ph lin lc,kh nng tch hp d dng cc h thng d liu, thoi v video, c s d liu c kh nng kim sot tp trung, tnh nng thoi di ng ci tin gip tit kim thi gian v chi ph...Vi giao thc SIP (Session Initiation Protocol) cho php nhiu ng dng, thit b phn cng mi d dng trin khai gii php VoIP trn mng LAN, WAN hoc Internet. Hu ht cc modem v router ADSL hin nay u h tr VoIP v giao thc SIP, cc doanh nghip va v nh c th nhanh chng trin khai m hnh in thoi Internet thng qua ng truyn internet vi cc dch v VoIP min ph nh ifone, IPTel, DrayTel, MediaRing... 1.2.6 Kh nng qun l ton din Bn c kh nng kim sot chi tit n tng bit d liu ang c lu chuyn trn mng IP Telephony (LAN) hay mng VoIP (WAN). Trong cc mng mng vin thng nn IP, cht lng thoi c th t n 99,99% Ngha l trong mi trng mng hi t nn IP, kh nng pht hin sm cc triu chng v thay i nhng ci t trc khi c bt k trc trc no xy ra c ci tin ng k. 1.2.7 Cng tc thi gian thc Ngi dng c th b sung gii php in thoi km hnh nh Video Telephony Solution bng cc phn mm ng dng video trn nn IP, qua cho php mt my tnh bn hay my tnh xch tay gi lp mt chic in thoi IP trong vn phng Cht lng hnh nh v m thanh khi s dng trn mng ni b thng tt hn khi s dng qua kt ni Internet do him khi gp phi tnh trng tr ting hay khng hnh. 1.2.8 S dng bng thng hp l Lu lng truyn d liu my tnh (khng phi l d liu thoi) trn h thng mng in thoi thng ch chim khong 30% bng thng ca ton h thng u im ca VoIP l d liu c ng li thnh gi v cc gi d liu ny c truyn thng qua kt ni T-1 trn mt phn nh bng thng ca knh DSO. 1.2.9 Gim chi ph in thoi ng di Vi mt h thng VoIP hon chnh, doanh nghip thm ch cn c th trin khai gii php chuyn tip cuc gi thng minh, cho php "hn ch" cc cuc gi ng di trc tip t mt khu vc (tnh, thnh ph hay quc gia) sang mt khu vc khc (c 2 khu vc ny phi c vn phng ca doanh nghip ny) bng cch chuyn d liu thoi thng qua mng VoIP ni b ri sau chuyn tip sang h thng PSTN.
Nhm 1-07VTA1 Page 6

Tm hiu h thng VoIP trn Asterisk 1.3 Nhc im ca VoIP Cht lng dch v: do cc mng truyn s liu vn d khng c thit k truyn thoi thi gian thc cho nn vic tr truyn hay vic mt mt cc gi tin hon ton c th xy ra v s gy ra cht lng dch v thp. Bo mt: do mng Internet l mt mng hn hp v rng khp bao gm rt nhiu my tnh cng s dng cho nn vic bo mt cc thng tin c nhn l rt kh. 1.4 Cc chun thoi dng trong VoIP Cc chun thoi dng trong VoIP: SIP, H323, IAX2, MGCP... Chun SIP (Session Initiation Protocol ): chun ca IETF, thng dng nht hin nay v t tn thit b phn cng v c th m rng h thng d dng y l giao thc chi tit xc nh nhng ch th v nhng p ng, thit lp hay kt thc cuc gi. SIP cng m t chi tit v cc tnh nng nh bo mt (sercurity), s y nhim (proxy), vn chuyn (transport) SIP nh ngha ra c ch bo hiu cuc gi end-to end gia cc thit b. SIP l giao thc text-base c nhiu tnh nng tng t HTTP, nh l cng m hnh yu cu (request) v p ng (response). Chun H323: y l giao thc chun ca ITU. Giao thc ny ban u c pht trin cho h thng a phng tin(multimedia) phng tin trong mi trng khng hng kt ni (connectionless), nh LAN H323 l chun nh ngha tt c tin trnh lin quan n vn ng b cho thoi, video, v truyn d liu H323 nh ngha tn hiu cuc gi end-to-end. Chun MGCP (Media Gateway Control Protocol - Giao thc iu khin cng truyn thng) n l mt giao thc trong VoIP c a ra theo xut ca Cisco v Telcordia nh ngha s lin lc gia nhng phn iu khin cuc gi Media Gateway. MGCP l giao thc iu khin, cho php trung tm iu khin theo di nhng s kin trong cuc gi IP v nhng Gateway v ch o chng gi thng tin ti nhng a ch c th. 1.5 Cc t chc pht trin VoIP Nh cung cp dch v VoIP ln : Skype, Yahoo, Google Cc thit b phn cng VoIP : - Tng i IP, VoIP Gateway : Cisco, Avaya, Alcatel, Nortel, Digium.. - Card giao tip PCI : Digium, Openvox, Sangoma - in thoi IP : Alcatel, Nortel, Welltech Cc phn mm ng dng tng i VoIP PBX : CCM ca Cisco, Asterisk trn Linux, Avaya... Trn h iu hnh WINDOWS: ch yu s dng giao thc SIP, phn mm ny c th d dng ci t v s dng. Tuy nhin phi mua License ty theo cu hnh doanh nghip cn ng dng. - 3CX : ca hng 3CX www.3cx.com - Brekeke : ca hng phn mm BREKEKE www.brekeke.com - Axon : ca hng NCH www.nch.com.au/pbx Trn h iu hnh LINUX:
Nhm 1-07VTA1 Page 7

Tm hiu h thng VoIP trn Asterisk - CCM ( Cisco Call Manager ) : chy trn h hnh Linux, c bn min ph cho ngi dng. Tuy nhin, bn min ph cn nhiu tnh nng cha Update, mun s dng cc tnh nng Update th phi mua thm License. - Asterisk : chy trn h iu hnh LiNux, hon ton min ph cho ngi dng. Phn ny s c trnh by r hn phn sau.

Nhm 1-07VTA1

Page 8

Tm hiu h thng VoIP trn Asterisk

CHNG II: T NG QU N V GI O TH C SIP


2.1 Tng quan v giao thc khi to phin SIP SIP (Session Initiation Protocol) l giao thc iu khin bo hiu thuc lp ng dng trong m hnh OSI (hnh II 1), c pht trin nh l mt chuun m RFC 2543 ca IEFT. Khc vi H.323, n da trn ngun gc Web (HTTP) v c thit k kiu module, n gin v d dng m rng vi cc ng dng thoi SIP. SIP l mt giao thc bo hiu thit lp, duy tr v kt thc cc phin a phng tin nh : thoi IP, hi ngh v cc ng dng tng t khc lin quan n vic truyn thng tin a phng tin. 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. C th s dng nm chc nng ca SIP thit lp v kt thc truyn dn l : nh v thu bao, kh nng thu bao, sn sng ca thu bao, thit lp cuc gi v x l cuc gi. SIP c s dng kt hp vi cc chun giao thc IETF khc nh l SAP, SDP v MGCP (MEGACO) cung cp mt lnh vc rng hn cho cc dch v VoIP. Cu trc ca SIP tng t vi cu trc ca HTTP (giao thc client-server). N bao gm cc yu cu c gi n t ngi s dng SIP client n SIP server. Server x l cc yu cu v p ng n client. Mt thng ip yu cu, cng vi cc thng ip p ng to nn s thc thi SIP.

Hnh 0-1: V tr ca SIP trong m hnh OSI.

Ni chung, SIP h tr cc hot ng chnh sau: - nh v tr ca ngi dng. - nh media cho phin lm vic. - nh s sn sng ca ngi dng tham gia vo mt phin lm vic.
Nhm 1-07VTA1 Page 9

Tm hiu h thng VoIP trn Asterisk - Thit lp cuc gi, chuyn cuc gi v kt thc. - SIP l mt giao thc theo thit k m do n c th c m rng pht trin thm cc chc nng mi. S linh hot ca cc bn tin SIP cng cho php p ng cc dch v thoi tin tin bao gm c cc dch v di ng. 2.2 Cu trc ca SIP 2.2.1 Cc thnh phn ca SIP
SIP Components

Location Server

Redirect Server

Registrar Server

PSTN User Agent Proxy Server Proxy Server Gateway

Hnh 0-2: Cc thnh phn ca SIP

H thng SIP gm 5 thnh phn chnh : - User Agent (UA) : ng vai tr ca thit b u cui trong bo hiu SIP , c th l mt my in thoi SIP, c th l my tnh chy phn mm u cui SIP...UA bao gm hai loi User Agent Client (UAC) v User Agent Server (UAS). UAC khi to cuc gi v UAS tr li cuc gi iu ny cho php thc hin cuc gi ngang hng thng qua m hnh client-server. - My ch y quyn (Proxy server) : l mt chng trnh trung gian, hot ng nh l mt server v mt client cho mc ch to cc yu cu thay mt cho cc client khc. Cc yu cu c phc v bn trong hoc truyn chng n cc server khc. Mt proxy c th dch v nu cn thit c th to li cc bn tin yu cu SIP trc khi chuyn chng n server khc hoc mt UA Trong trng hp ny trng Via trong bn tin p ng, yu cu ch ra cc proxy trung gian tham gia vo tin trnh x l yu cu .

Nhm 1-07VTA1

Page 10

Tm hiu h thng VoIP trn Asterisk - My ch nh v (Location Server) : l phn mm nh v thu bao, cung cp thng tin v nhng v tr c th ca thu bao b gi cho cc phn mm my ch y quyn v my ch chuyn i a ch. - My ch chuyn i a ch (Redirect Server) : l phn mm nhn yu cu SIP v chuyn i a ch SIP sang mt s a ch khc v gi li cho u cui. Khng ging nh my ch y quyn, my ch chuyn i a ch khng bao gi hot ng nh mt u cui, tc l khng gi i bt c yu cu no. My ch chuyn i a ch cng khng nhn hoc hu cuc gi. - My ch ng k (Register Server) : l phn mm nhn cc yu cu ng k Trong nhiu trng hp my ch ng k m nhim lun mt s chc nng an ninh nh xc nhn ngi s dng Thng thng my ch ng k c ci t cng vi my ch y quyn v my ch hay a ch hoc cung cp dch v nh v thu bao. Mi ln u cui c bt ln (v d my in thoi hoc phn mm SIP) th u cui li ng k vi my ch. Nu u cui cn thng bo cho my ch v a im ca mnh th bn tin REGISTER cng c gi i Ni chung cc u cui u thc hin vic ng k li mt cch nh k.

2.2.2 Hot ng ca cc bn tin SIP


SIP l mt giao thc da trn k t vn bn vi c php bn in v cc trng mo u ng nht vi giao thc truyn siu vn bn HTTP (Hypper Text Transfer Protocol). Cc bn tin ca SIP truyn trn cng mt kt ni TCP hoc b d liu UDP. 2.2.1.1 a ch ca SIP a ch ca SIP cn c gi l b nh v ti nguyn chung URL (Universal Resource Locator), tn ti di dng user@host. Phn user trong phn a ch c th l tn ngi s dng hoc s in thoi. Phn host c th l tn min hoc a ch mng. V d a ch SIP : SIP: ptithcm@ptithcm.edu.cn SIP: 401160020@203.162.17.8 2.2.1.2 nh v server SIP Khi client mun gi mt yu cu, client gi yu cu n mt proxy server SIP c cu hnh hoc gi n a ch IP v s cng tng ng vi URL SIP. Gi yu cu trc tip n proxy server th d dng nu ng dng cui bit proxy server. Gi yu cu theo cch th hai th phc tp hn Client phi c gng tip xc vi server s cng c lit k trong b nh v ti nguyn ng nht URL SIP. Nu s hiu cng khng c trong URL SIP th client s dng s cng 5060. Nu URL SIP ch nh mt giao thc (UDP hoc TCP) th client tip xc vi server s dng giao thc Nu khng c giao thc no c ch nh hoc nu client khng h tr UDP nhng
Nhm 1-07VTA1 Page 11

Tm hiu h thng VoIP trn Asterisk c h tr TCP th n c gng dng TCP Client c gng tm mt hoc nhiu a ch server SIP bng cch truy vn DNS (Domain Name System). Tin trnh nh sau: - Nu phn host ca URL SIP l a ch IP, client tip xc vi server a ch cho trc Ngc li n x l bc k tip. - Client truy vn server DNS cho a ch phn host ca URL SIP. Nu server DNS khng tr v a ch ca URL SIP, client s ngng v n khng th nh v c server. 2.2.1.3 nh v ngi dng Ngi b gi c th di chuyn gia nhiu h thng u cui theo thi gian. Cc v tr ny c th ng k ng vi server SIP. Mt server v tr c th tr v nhiu v tr bi v ngi dng ng nhp nhiu trm mt cch ng thi hoc server v tr c thng tin khng chnh xc. Server SIP kt hp cc kt qu cung cp mt danh sch cc v tr hoc khng c v tr no. Hot ng nhn danh sch cc v tr thay i ty thuc vo SIP server. Mt Redirect server tr v mt danh sch hon chnh cc v tr v cho php cc client nh v ngi dng chnh xc. Mt Proxy server cng c gng nh a ch cho n khi cuc gi thnh cng hoc ngi b gi t chi cuc gi. 2.2.1.4 Thay i mt phin ang tn ti iu ny c thc hin bng cch pht li bn tin INVITE, s dng cng CallID nhng ni dung mi hoc cc trng tiu mang thng tin mi. Chng hn, hai i tc ang tr chuyn v mun thm v mt ngi th ba. Mt trong hai mi ngi th ba vi a ch multicast mi v ng thi gi bn tin INVITE n i tc th hai vi s m t phin mulicast mi, ngoi tr s nhn dng c 2.2.1.5 Cc bn tin ca SIP C hai loi bn tin SIP: - Bn tin yu cu c khi to t client. - Bn tin p ng c tr li t server. Mi bn tin cha mt tiu m t chi tit v s truyn thng. SIP c th s dng UDP Khi c gi trn UDP hoc TCP, nhiu giao dch SIP c th c mang trn mt kt ni TCP n l hoc gi d liu UDP. Gi d liu UDP (bao gm tt c cc tiu ) th khng vt qu n v truyn dn ln nht MTU (Maximum Transmission Unit) nu MTU c nh ngha, hoc khng qu 1500 byte nu MTU khng c nh ngha Mt bn tin SIP c bn bao gm: dng bt u (start-line), mt hoc nhiu trng tiu , mt dng trng (CRLF) dng kt thc cc trng tiu v mt ni dung bn tin ty chn.

Nhm 1-07VTA1

Page 12

Tm hiu h thng VoIP trn Asterisk Bn tin chung = Dng bt u Tiu bn tin CRLF [ ni dung bn tin] 2.2.1.6 Tiu bn tin Tiu bn tin dng ch ra ngi gi, ngi b gi, ng nh tuyn v loi bn tin ca cuc gi C 4 nhm tiu bn tin nh sau: - Tiu chung: p dng cho cc yu cu v cc p ng. - Tiu thc th: nh ngha thng tin v loi bn tin v chiu di. - Tiu yu cu: cho php client thm vo cc thng tin yu cu. - Tiu p ng: cho php server thm vo cc thng tin p ng.
Tiu chung Accept Accept-Encoding Tiu thc th Tiu yu cu Tiu p ng Allow Proxy-Authenticate Retry-After Server Unsupported Warning

Content-Encoding Authorization Content-Length Contact Hide Max-Forwards Organization Priority

Accept-Language Content-Type Call-ID Contact CSeq Date Encryption Expires From Record-Route Timestamp To Via

Proxy-Authorization www-Authenticate Proxy-Require Route Require Response-Key Subject User-Agent

Bng 0-1: Cc tiu bn tin

Nhm 1-07VTA1

Page 13

Tm hiu h thng VoIP trn Asterisk Gii thch mt s tiu chnh ca SIP:
Tiu Call-ID Gii thch So khp cc yu cu vi cc p ng tng ng, nhn dng duy nht li mi hoc s ng k ca client Cseq Trong mt cuc gi, Cseq tng ln khi mt yu cu mi c gi i v bt u mt gi tr ngu nhin Tuy nhin, i vi yu cu ACK v Cancel th Cseq khng tng To From C mt trong tt c cc yu cu v p ng ch ra ni nhn yu cu C mt trong tt c yu cu v p ng cha tn v a ch ca ni khi to yu cu Via Ghi li ng i ca yu cu cho php cc server SIP trung gian chuyn cc cu tr li tr li cng ng i Encryption Ch nh ni dung v mt s tiu bn tin c m ha nh th no Content-Length Content-type Expires Accept Subject Ch ra kch thc ca ni dung bn tin (tnh bng octet) Ch ra loi media ca ni dung bn tin (vn bn/html,). Nhn dng ngy v thi gian khi bn tin ht hn . Ch ra loi media no c chp nhn trong bn tin p ng Cho thng tin v bn cht ca cuc gi

Bng 0-2: Gii thch mt s tiu chnh ca SIP 2.2.1.7 Bn tin yu cu Cc yu cu cng c th c xem nh cc phng php cho php User Agent v server mng nh v, mi v qun l cc cuc gi. Bn tin yu cu SIP c dng sau:
Yu cu = Dng yu cu (Request-line) Tiu chung/tiu yu cu/tiu thc th CRLF [Ni dung bn tin]

Dng yu cu bt u vi m phng php, b nhn dng ti nguyn ng nht yu cu, phin bn giao thc SIP v kt thc vi CRLF. Cc thnh phn c phn cch bi k t SP. Dng yu cu = Method SP Request-URI SP SIP-Version CRLF.

Nhm 1-07VTA1

Page 14

Tm hiu h thng VoIP trn Asterisk C 6 loi bn tin yu cu SIP: INVITE, ACK, OPTIONS, BYE, CANCEL v REGISTER.
Bn tin INVITE ACK BYE CANCEL ngha Khi to mt phin Khng nh rng client nhn c bn tin p ng cho bn tin INVITE Yu cu kt thc phin Hu yu cu ang nm trong hng i

REGISTER u cui SIP ng k vi registrar server OPTIONS INFO S dng xc nh nng lc ca server S dng ti cc thng tin

Bng 0-3: Cc bn tin yu cu ca SIP 2.2.1.8 Bn tin p ng Cc bn tin p ng c dng nh sau:


p ng = Dng trng thi Tiu chung/tiu p ng/tiu CRLF [ni dung bn tin]

Dng trng thi = SIP-version SP Status-Code SP Reason-Phrase CRLF M trng thi c 3 ch s ch ra kt qu ca vic p ng yu cu. L do (Reason-Phrase) l s m t ngn gn v m trng thi. Ch s u tin ca m trng thi nh ngha lp p ng. SIP phin bn 2 0 nh ngha 6 gi tr cho lp p ng :
Bn tin ngha 1xx 2xx 3xx 4xx 5xx 6xx Cc bn tin chung Thnh cng Chuyn a ch Yu cu khng c p ng S c ca server S c ton mng

Bng 0-4: Cc loi bn tin p ng ca SIP.


Nhm 1-07VTA1 Page 15

Tm hiu h thng VoIP trn Asterisk Mt s m trng thi c nh ngha trong SIP c trnh by trong bng sau:
Lp p ng Thng tin M trng thi 100 180 181 182 Thnh cng i hng 200 300 301 302 380 Li client 400 401 402 403 404 405 406 407 408 409 410 411 413 414 415 420 480 481 482 483 484 485 486 Li server Nhm 1-07VTA1 500 Gii thch ang c gng Rung chung Cuc gi c chuyn c xp hng i OK Nhiu chn la c di chuyn thng xuyn c di chuyn tm thi Dch v thay i Yu cu li Khng nhn thc c Yu cu tr tin (payment required) Cm Khng tm thy Bn tin khng cho php Khng chp nhn Yu cu nhn thc proxy Yu cu timeout Xung t Tip tc (gone) Yu cu chiu di Thc th yu cu qu ln URL yu cu qu ln Khng h tr loi media M rng sai Khng sn c Cuc gi hoc s trao i Vng lp c pht hin Qu nhiu hop a ch khng hon thnh M h ang bn Li server bn trong Page 16

Tm hiu h thng VoIP trn Asterisk


501 502 503 504 505 Li ton cu 600 603 604 606 Khng thc thi Gateway li Dch v khng c sn Gateway timeout Phin bn SIP khng h tr Bn mi ni T chi Khng tn ti mi ni Khng chp nhn

Bng 0-5: Mt s m trng thi c nh ngha trong SIP 2.2.1.9 Thit lp v hy cuc gi SIP Trc tin ta tm hiu hot ng ca my ch y quyn v my ch chuyn i : a. Hot ng ca my ch y quyn (Proxy Server)

Hnh 0-2: Hot ng Proxy Server

Client SIP userA@yahoo.com gi bn tin INVITE cho userB@hotmail.com mi tham gia cuc gi. Cc bc nh sau: - Bc1: userA@yahoo.comgi bn tin INVITE cho userB min hotmail.com bn tin ny n proxy server SIP ca min hotmail.com (bn tin INVITE c th i t
Nhm 1-07VTA1 Page 17

Tm hiu h thng VoIP trn Asterisk Proxy server SIP ca min yahoo com v c Proxy ny chuyn n Proxy server ca min hotmail.com). - Bc 2: Proxy server ca min hotmail.com s tham kho server nh v (Location server) quyt nh v tr hin ti ca UserB. - Bc 3: Server nh v tr li v tr hin ti ca UserB (gi s l UserB@hotmail.com). - Bc 4: Proxy server gi bn tin INVITE ti userB@hotmail.com. Proxyserver thm a ch ca n trong mt trng ca bn tin INVITE. - Bc 5: UAS ca UserB p ng cho server Proxy vi bn tin 200 OK. - Bc 6: Proxy server gi p ng 200 OK tr v userA@yahoo.com. - Bc 7: userA@yahoo.com gi bn tin ACK cho UserB thng qua proxy server. - Bc 8: Proxy server chuyn bn tin ACK cho userB@hostmail.com. - Bc 9: Sau khi c hai bn ng tham d cuc gi, mt knh RTP/RTCP c m gia hai im cui truyn tn hiu thoi. - Bc 10: Sau khi qu trnh truyn dn hon tt, phin lm vic b xa bng cch s dng bn tin BYE v ACK gia hai im cui. b. Hot ng ca my ch chuyn i a ch (Redirect Server):

Hnh 0-3: Hot ng ca Redirect Server.

Cc bc nh sau: - Bc 1: Redirect server nhn c yu cu INVITE t ngi gi (Yu cu ny c th i t mt proxy server khc). - Bc 2: Redirect server truy vn server nh v a ch ca B. - Bc 3: Server nh v tr li a ch ca B cho Redirect server.
Nhm 1-07VTA1 Page 18

Tm hiu h thng VoIP trn Asterisk - Bc 4: Redirect server tr li a ch ca B n ngi gi A. N khng pht yu cu INVITE nh proxy server - Bc 5: User Agent bn A gi li bn tin ACK n Redirect server xc nhn s trao i thnh cng. - Bc 6: Ngi gi A gi yu cu INVITE trc tip n a ch c tr li bi Redirect server (n B) Ngi b gi B p ng vi ch th thnh cng (200 OK), v ngi gi p tr bn tin ACK xc nhn, cuc gi c thit lp.Ngoi ra SIP cn c cc m hnh hot ng lin mng vi SS7 (n PSTN) hoc l lin mng vi chng giao thc H.323. Tng qut li trong mng SIP qu trnh thit lp v hy mt phin kt ni:

Hnh 0-4: Thit lp v hy cuc gi SIP.

Bc 1: ng k, khi to v nh v u cui. Bc 2: Xc nh phng tin ca cuc gi, tc l m t phin m u cui c mi tham gia. Bc 3: Xc nh mong mun ca u cui b gi, tr li hay khng. Pha b gi phi gi bn tin xc nhn chp thun cuc gi hay t chi. Bc 4: Thit lp cuc gi. Bc 5: Thay i hay iu khin cuc gi (v d nh chuyn cuc gi). Bc 6: Hy cuc gi.
Page 19

Nhm 1-07VTA1

Tm hiu h thng VoIP trn Asterisk 2.2.1.10 Lin vn gia SIP v SS7 a. Thit lp cuc gi c bn gia SIP v PSTN

Hnh 0-5: Thit lp cuc gi c bn gia SIP v PSTN.

- Bc 1: Khi ngi dng SIP mun bt u mt phin hi thoi vi ngi dng PSTN, SIP s pht bn tin yu cu INVITE. Bn tin ny tng t nh bn tin SETUP ISDN. Gateway bt u x l cc ti nguyn dnh ring cho cuc gi. Cc ti nguyn ny bao gm cng RTP/UDP bn pha IP v cc khe E1/T1 bn pha PSTN. - Bc 2: Bn tin INVITE c xc nhn bi Gateway vi bn tin SIP cha m trng thi 100. Bn tin ny cng xc nhn l Gateway ng iu khin cuc gi. - Bc 3: Bn tin INVITE c nh x thnh bn tin IAM ISUP v c gi n PSTN. V kt ni audio c thc hin. - Bc 4: PSTN p ng vi bn tin ACM ISUP thng bo rng bn tin IAM c nhn thnh cng. - Bc 5: Bn tin ACM cha mt trng c gi l m trng thi ngi b gi v c nh x n p ng SIP tm thi p ng tm thi l 180 cho thu bao ri v 183 cho khng ch nh p ng tm thi ny c Gateway gi n SIP. V Gateway thc hin kt ni audio. - Bc 6: Xc nhn p ng tm thi ACK (PRACK, Provisional Response ACK) c gi tr li Gateway t SIP. - Bc 7: M 200 c gi tr li SIP y l mt ACK.
Nhm 1-07VTA1 Page 20

Tm hiu h thng VoIP trn Asterisk - Bc 8: Bn tin xl cuc gi (CPM, Call Proceeding Message) c gi tr v t PSTN vi cc m ch ra trng thi ca cuc gi. - Bc 9: Thng tin trong bn tin CPM c t trong thn ca p ng SIP 18x v c Gateway gi n SIP M s kin ISUP c nh x thnh m trng thi SIP nh sau:
M s kin ISUP M trng thi SIP

1: thng bo 2: tin hnh 3: thng tin inband 4: chuyn cuc gi, ng dy bn 5: chuyn cuc gi, khng tr li 6: chuyn cuc gi, v iu kin

180: rung chung 183: tin hnh cuc gi 183: tin hnh cuc gi 181: cuc gi ang c chuyn 181: cuc gi ang c chuyn 181: cuc gi ang c chuyn

Bc 10 v 11: p ng tm thi c tr v v c xc nhn. Bc 12: ngi b gi tr li cuc gi, PSTN gi n Gateway bn tin ANM. Gateway thc hin kt ni audio hai chiu. Bc 13 v 14: cuc gi hon thnh bn pha IP ca kt ni. b. nh hng cuc gi SIP

Hnh 0-6: nh hng cuc gi SIP.


Nhm 1-07VTA1 Page 21

Tm hiu h thng VoIP trn Asterisk - Bc 1: Cuc gi c khi u t mng PSTN, bn tin IAM c gi n Gateway. Gateway thc hin kt ni audio n PSTN. - Bc 2: Da vo thng tin m n nhn c trong bc 1, Gateway gi bn tin INVITE n SIP 1. - Bc 3: SIP 1 tr li bn tin 3xx thng bo rng ngi b gi mt v tr khc. Thng tin ny c m ha trong trng Contact ca bn tin SIP. - Bc 4: Gateway gi li PSTN bn tin x l cuc gi CPG thng bo rng cuc gi c chuyn. - Bc 5: Gateway cng nhn bn tin 3xx. - Bc 6: Da vo thng tin nhn c trong bc 3, Gateway gi bn tin INVITE n SIP 2. - Bc 7: Khi SIP 2 nhn c thng tin a ch y , n tr li p ng tm thi l 18x. Gateway thc hin kt ni audio n SIP. - Bc 8: Da vo m trng thi 18x, Gateway gi bn tin ACM n PSTN. - Bc 9: Bn tin PRACK c gi t Gateway xc nhn vic nhn p ng tm thi. - Bc 10: SIP 2 p tr bn tin thnh cng vi m trng thi 200. - Bc 11: SIP 2 tr li cuc gi. - Bc 12:SIP 2 gi bn tin 200 n Gateway thng bo rng cuc gi c trli v audio hai chiu c vt ngng (cut through) bi Gateway. - Bc 13: Gateway gi bn tin ANM n PSTN v to kt ni audio hai chiu. - Bc 14: Gateway xc nhn bn tin c SIP 2 gi i trong bc 12 2.2.1.11 Tnh nng ca SIP Giao thc SIP c thit k vi nhng ch tiu sau: - 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 nhiu 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. 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.
Nhm 1-07VTA1 Page 22

Tm hiu h thng VoIP trn Asterisk - n gin v c kh nng m rng SIP, 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, v SIP 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. - 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. V d thu bao vi a ch ptit@vnpt.com.vn c th nhn c cuc gi thoi hay thng ip bt c a im no qua bt c u cui no nh my tnh bn, my xch tay, in thoi SIP Vi SIP rt nhiu dch v di ng mi c h tr. - 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

Nhm 1-07VTA1

Page 23

Tm hiu h thng VoIP trn Asterisk

CHNG III: GII THIU BA PHN MM VOIP


3.1 Asterisk 3.1.1 Gii thiu v phn mm Asterisk

NG DNG

Asterisk l phn mm m ngun m min ph v thoi qua VoIP, cho php cc doanh nghip c th lp t h thng tng i PBX m khng cn phi mua mt h thng tng i o hay phn mm s hu c quyn cho mt h thng tng i ni b. Asterisk l cng c phn mm m cho thoi ph bin nht trn th gii. N cho php cc my tnh ca mt t chc c th lin lc thng tin bng thoi vi nhau thng qua giao thc VoIP, tch hp chuyn mch TDM, v n p ng c nhu cu giao tip vi mng in thoi chuyn mch cng cng (PTSNs). Asterisk hot ng trn nhiu h iu hnh bao gm FreeBSD, Linux, OS X, Windows, v Solaris. Asterisk c o ch n cho php cc doanh nghip thit lpmt h thng tng i ni b PBX chuyn nghip vi y cc tnh nng cn thit, truy nhp s dng dch v thoi khng tnh cc, v n cn cung cp mt mc ln cc tu bin v tnh linh hot cho cc nhu cu s dng c th ca tng i tng. i vi cc c nhn, t chc bit cch s dng Asterisk th s c nhiu li ch v tnh nng m n c th cung cp. Mt s nh cung cp m ngun m PBX s dng Asterisk nh mt k thut nn tng cho cc gii php v tng i ring PBX hoc phn mm VoIP ca h Cc nh cung cp, chng hn nh Free PBX, Elastix, Trixbox v Call Weaver, tt c u s dng Asterisk nh l k thut li cho cc gii php phn mm ca h 3.1.2 Tnh nng v li ch ca Asterisk Asterisk c mt s li ch v mt s nhc im. Nhng li ch ca vic s dng Asterisk lm cho n tr thnh mt gii php ngy cng ph bin cho nhiu t chc. Mt s li ch ca vic s dng Asterisk : - Cc c nhn v cng ty c th chnh sa phn mm cho ph hp vi nhu cu c th ca h. - u im chnh chnh l tit kim chi ph lp t cng nh chi ph cho thoi. - Asterisk linh hot v c kh nng chnh sa lm vic vi mt lot cc thit b phn cng. - Truy cp vo hng ngn hng dn trn internet to cc gii php PBX khc nhau. - H tr k thut v truy cp vo cc din n vi chi ph h tr k thut hng thng thp. - Cc chc nng cho mt gii php tng i PBX chuyn nghip thng c cp nht.
Nhm 1-07VTA1 Page 24

Tm hiu h thng VoIP trn Asterisk - Asterisk c cc GUI v giao din ngi dng cho php truy cp trc quan v d qun l. Mt s nhc im m cc gii php phn mm m ngun m PBX cn l : - H tr l mt chi ph thm trong hu ht cc gii php - Kh khn trong vic trin khai thc hin hoc hiu r lm th no s dng phn mm. - i vi doanh nghip: cn c thi gian v ngun lc cn thit chi tr cho vic o to nhn vin bit cch ci t, cu hnh, v s dng phn mm. 3.2 OpenSIP 3.2.1 Khi nim OpenSIPS OpenSIPS (Open SIP Server) l mt h thng m ngun m ca mt SIP server N khng ch l mt SIP proxy/router v OpenSIPS bao gm nhng chc nng cp ng dng, OpenSIPS nh l mt my ch SIP, l thnh phn ct li ca bt k gii php VoIP trn SIP server a chc nng, a mc ch: router, switch, applicationserver, redirect-server, gateway, load-balancer.. Vi mt c cu nh tuyn linh hot v ty bin OpenSIPS hp nht ting ni, video, IM(Instant Message) v cc dch v Presence mt cch c hiu qu cao nh thit k dng Module c th m rng V vy, OpenSIPS c hiu qu cao, ng tin cy OpenSIPS l mt trong nhng my ch SIP nhanh nht, vi mt thng lng c xc nh n nh l mt gii php ti u cho doanh nghip, cc ngnh cng nghip 3.2.2 Tnh nng v li ch ca OpenSIPS 3.2.2.1 OpenSIPS trong VoIP

Hnh 0-8: OpenSIPS trong VoIP

Nhm 1-07VTA1

Page 25

Tm hiu h thng VoIP trn Asterisk 3.2.2.2 Kin trc OpenSIPS OpenSIPS l mt SIP proxy, n n gin hn B2BUA trong Asterisk bi v mt SIP proxy ch lin quan n bo hiu. OpenSIPS bao gm hn 70 module, mi module c mt chc nng ring, vi giao din module PLUG and PLAY th OpenSIPS d dng m rng v nng cp cc tnh nng ca m khng nh hng ti phn li v cng lm tng s n nh ca h thng li. 3.2.2.3 Kh nng kt ni n PSTN OpenSIPS cn mt SIP gateway kt ni ti PSTN. N khng c kh nng ci t th in thoi trong server. Thng thng, ngi ta s thc hin Asterisk nh l mt cng PSTN cho OpenSIPS. 3.2.2.4 Giao tip vi NAT OpenSIPS c lin quan nhiu n NAT, cho php thoi hoc lung d liu t in thoi IP hoc phn mm VoIP ca khch hng trc tip n mt nh cung cp dch v trong nhiu trng hp (khng i xng NAT). OpenSIPS cng cho php bn thao tc trc tip SIP truyn thng x l cc trng hp c bit, chng hn nh khi bn c hai my in thoi VoIP pha sau cng mt NAT router v mun gi cc phng tin truyn thng trc tip gia chng. 3.2.2.5 Cn bng ti Mt sc mnh c o ca OpenSIPS l kh nng cn bng ti cho cc cuc gi VoIP. Thut ton chuyn ngnh bm trong OpenSIPS c th c cu hnh cn bng ti bi cc"tn ngi dng", "ruri", "callid", v cc c tnh khc. OpenSIPS l "failover aware" v c th lm mt phn b sung rt hu ch ca gii php Asterisk. 3.2.2.6 Giao din qun l v c s d liu Giao din qun l (cho tch hp ngoi) thng qua FIFO file, XMLRPC hoc Datagram (UDP hoc Unixsockets). OpenSIPS a c s d liu backends - MySQL, PostgreSQL, Oracle, Berkeley, flat files v cc loi database khc c th x l unixodbc 3.2.2.7 Dch v truyn thng OpenSIPS l mt Proxy SIP v khng c kh nng ca bt k mng li dch v truyn thng tin lin quan (phn ting ni ca mt cuc in thoi). OpenSIPS khng phi l mt nn tng m bn s dng to ra h thng nh IVR, th thoi, TTS v nhn bit ting ni, iu ny l do thit k. 3.2.2.8 Kh nng nng cp OpenSIPS OpenSIPS c th chy trn h thng nhng, hiu sut c th ln n hng trm thit lp cuc gi/giy. Vi h thng c b nh 4GB, OpenSIP c th phc v hn 300000 thu bao trc tuyn. H thng c th d dng m rng bng cch thm my ch OpenSIPS. OpenSIPS h tr IPv4 v IPv6 v c th phc v c multiple domain.

Nhm 1-07VTA1

Page 26

Tm hiu h thng VoIP trn Asterisk 3.2.3 Kt lun OpenSIPS l Carrier Class SIP proxy server c s dng ch yu bi cc nh cung cp VoIP N c thit k x l khi lng ln cc cuc gi, cn bng truyn ti SIP, gii quyt cc kch bn nng cao cho NAT v lin quan n bo hiu trong SIP. Ni bt v tinh nng linh hot v s n nh, OpenSIPS ang lin tc pht trin cc cc tnh nng trong Vin thng. Rt ph bin trong cc dch v cung cp VoIP/Internet Telephony, OpenSIPS cung cp nn tng truyn thng hon chnh: Vocie,Video, Instant Messaging v Presence. Hn th na, cu hnh OpenSIPS server khng phi l d dng, nhng l cha kha thnh cng v bo mt cho d n IP. Vi c tnh linh hot ca OpenSIPS cho php trin khai dich v tin tin v tit kim c thi gian v chi ph 3.3 Kamailio Cng ging nh OpenSIP, Kamailio c pht trin ln t OpenSER, nhng OpenSIP th li i theo hng khc, hai nhnh ny do s xung t v nhm core nn c tch ra lm hai n Kamailio phin bn 3.0 th hai nhm li kt hp v cng chia s nhiu chc nng chung tng thch vi nhau, c th s hp nht li trong tng lai Kamailio l SIP Server, gm cc vai tr: - SIP Registrar - SIP Proxy - SIP Redirector. Asterisk l BUA: Back-to-back User Agent, ngoi x l, SIP cn c mt s giao thc khc nh: - IAX - H323 X l c media ln control, Asterisk ging nh mt media gateway trong m hnh lm vic ca SIP, ngoi ra cn lm c: - SIP Registrar - SIP Client (UA). Asterisk l IP PBX, h tr rt y tnh nng ca mt tng i ni b, cn Kamailio th c gi l SIP Server, mt phn ca h thng SIP (ch quan tm ti control), ch khng gi l IP PBX (mt b hon chnh c control ln media) Cng v l do ch quan tm ti control, nn kh nng x l ca Kamailio l rt khng khip. Mt server bnh thng (2 core, vi GB RAM) c kh nng qun l hng chc ngn subsciber, nh tuyn hng ngn hng khc nhau, v hng trm cuc gi/1 giy. Asterisk t c kh nng th phi s dng rt nhiu server mnh. Nhn chung c Asterisk vkamailio u h tr SIP. im khc nhau l ch, trong khi Asterisk l mt h thng kh hon chnh, h tr c iu khin v cc dch v a phng tin th Kamailio n thun ch l SIP server trong m hnh VoIP, chnh v tnh chuyn bit nh vy nn hiu sut ca n l rt cao. Tuy nhin, mt mnh Kamailio th cha
Nhm 1-07VTA1 Page 27

Tm hiu h thng VoIP trn Asterisk to nn mt h thng VoIP kiu nh PBX m Asterisk vn lm, phi c thm hng lot cc thit b lin quan n mediana mi gn chc nng nh Asterisk: Media gateway (v d FXO gate kt ni i PSTN, ci ny Asterisk c th t lm hoc l s dng ngoi) - MCU (conference server) - IVR gateway - ACD Gateway - Recording Server - Voice Mail server Trong khi cc chc nng ny Asterisk c sn. Nhn chung, Kamailio l mt sn phm ca hng pht trin VoIP, l chia nh v chuyn bit ha cc thnh phn ca h thng. Vi vic bc u lm quen vi VoIP, kin thc cn hn ch nhiu mt, nn trong chuyn ny chng em s tm hiu v Asterisk, do hin nay Asterisk kh ph bin v c s dng nhiu, cc ti liu h tr tm hiu cng a dng. Vic xy dng m hnh mng cng tng i n gin, nm trong kh nng ca nhm.

Nhm 1-07VTA1

Page 28

Tm hiu h thng VoIP trn Asterisk

CHNG IV: TRIN KHAI H THNG ASTERISK


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. 4.1 Gii thiu chung - Mc ch: Thc hin th nghim cc hnh thc truyn thoi qua mi trng IP Nghin cu cc tnh nng ti u m h thng Asterisk em li. - Quy m h thng: Do hn ch v c s h tng, thit b nn th nghim y c xy dng vi quy m nh, ch yu nhm mc ch nghin cu cc tnh nng mt h thng VoIP. 4.2 Kt ni phn cng Cc thit b dng cho trin khai h thng Asterisk c kt ni theo m hnh sau:

Hnh 4-1: Cc thit b trong h thng Asterisk

PBX l mt my ch s dng OS l linux (ubuntu), ci t Asterisk 1.6. Cu hnh my ch: - RAM: 512MB - CPU: 2GHz - HDD: 10GB
Nhm 1-07VTA1 Page 29

Tm hiu h thng VoIP trn Asterisk 2 laptop s dng c ci t softphone. Switch c cng kt ni ti cc my tnh khc. Kt qu mong mun t c l thc hin c cuc gi VoIP trong mng LAN, dng phn mm Wireshark bt v phn tch cc gi tin ri so snh vi l thuyt ca SIP. 4.3 Ci t phn mm 4.3.1 My ch PBX Ci t OS l ubuntu version 11.04, giao din ca h iu hnh:

Hnh 4-2: Giao din h iu hnh

4.3.2 Ci t phn mm Asterisk trn my ch Cp nht th vin: Cc th vin cn thit cho ci t Asterisk bao gm :bison, bison-devel, ncurses, ncurses-devel, zlib, zlib-devel, openssl, openssl-devel, gnutls-devel, gcc, gcc-c++ Ci t bng cu lnh : apt get install * Vi * l tn cc th vin trn. Ln lt ci t 5 gi phn mm sau: dahdi-linux-2.4.1.2 dahdi-tools-2.4.1 libpri-1.4.11.5 asterisk-1.6.2.18 asterisk-addons-1.6.2.3 Tt c cc gi trn u c th tm thy trn website ca Asterisk: http://www.asterisk.org/downloads

Nhm 1-07VTA1

Page 30

Tm hiu h thng VoIP trn Asterisk 4.3.3 Ci t freepbx qun l server asterisk Download freepbx-2.9.0 t a ch: http://www.freepbx.org/download-freepbx, ci t trn my ch PBX, set IP cho my ch l 10.10.10.10. Vic ci t freebpx l to ra 1 giao din web d s dng v qua , ngi qun l c th cu hnh cho tng i PBX t bt k my no trong mng LAN min l c ti khon admin. Giao din ca freepbx nhn t mt laptop trong mng LAN:

Hnh 4-3: Giao din ca freepbx

4.3.4 Ci t softphone trn cc laptop Softphone c s dng l phn mm X Lite ( download phn mm min ph t a ch: http://www.counterpath.com/x-lite-4.0-for-windows-download.html)

Hnh 4-4: Giao din ca phn mm X Lite

Nhm 1-07VTA1

Page 31

Tm hiu h thng VoIP trn Asterisk 4.4 Thc hin cuc gi VoIP, bt v phn tch gi Ta tin hnh khai bo 2 thu bao 101 v 103 ti tng i ri nhp user name, password vo giao din X Lite, chn domain l IP ca tng i PBX 10.10.10.10, khai bo cc thng s thu bao. Kch bn cuc gi: sau khi khai bo thu bao xong c hai softphone, softphone 1(IP:10.10.10.5) thc hin cuc gi ti soft phone 2 (IP:10.10.10.14). Softphone 2 nhc my, m thoi, softphone 1 gc my kt thc cuc gi Sau y l qu trnh phn tch cc gi tin bt c trn wireshark, lu rng, my ch PBX thc cht l 1 my o ci trong laptop 1, s dng chung card mng LAN nhng khc a ch IP, v vy wireshark bt c cc bn tin n v i trn c laptop 1 v my ch PBX. 4.4.1 Khi to phin Qu trnh thit lp phin khi to cuc gi gia 2 thu bao 101( 10.10.10.5) v 103 (10 10 10 14) c thc hin bi giao thc Sip (session initiation protocol) u tin, 101 (10.10.10.5) gi bn tin Invite thu bao 103 n PBX (10.10.10.10) gi s 14, PBX xc nhn 103 c trong danh sch thu bao ca mnh (ang IP 10.10.10.14) v ang trong trng thi kt ni PBX p ng cho yu cu Invite ny bng vic gi li mt m p ng 100 Trying ( gi s 15) ng thi chuyn tip bn tin Invite ny n 103 (10.10.10.14)-gi s 16 Sau , p ng Ringing m 180 (gi 17) cho bit 103 ang c cnh bo c cuc gi ti, p ng ny c tc dng nh khi mt thu bao gi in thoi v nghe hi chung reo t pha ngi b gi. Sau qu trnh rung chung bt u thc hin, ti lc ny khng c bt k bn tin no c trao i gia cc thu bao.

Tip theo 103 chp nhn cuc gi nn n gi mt p ng OK vi m l 200 cho PBX (gi 34), PBX xc nhn li bng bn tin Ack (gi 35) Sau , PBX gi p ng OK vn vi m l 200 v cho 101 thng bo cho 101 bit c l 103 chp nhn cuc gi ca 101(gi 36), 101 xc nhn nhn c bn tin OK bng bn tin Ack n PBX.

Sau khi Ack c gi v nhn th hai user ca cuc gi c th bt u m thoi vi nhau.


Nhm 1-07VTA1 Page 32

Tm hiu h thng VoIP trn Asterisk 4.4.2 Qu trnh m thoi Sau khi phin m thoi c khi to, c 2 softphone s thc hin m ha tn hiu ri truyn i theo giao thc RTP. u tin chng ta tm hiu khi nim giao thc RTP: RTP ( vit tt ca Real-time Transport Protocol) l mt giao thc Internetchun c s dng rng ri trong cc ng dng thi gian thc nh in thoi Internet, video streaming. Giao thc RTP nh ngha cch thc cho php cc ng dng qun l vic truyn ti thng tin vi thi gian thc (real-time transmission). Di y l cu trc khung ca mt gi tin RTP:

RTP packet

Hnh 4-5: Cu trc khung ca gi tin RTP

- Header RTP gm cc thng tin cn thit cho ng dng ch cu trc li mu ting ni c chia nh truyn trn ng truyn. V (Version): Ch ra version ca RTP 2bit P (Padding) : Cho bit c cc byte m cui vng payload hay khng ( Do chiu di vng payload ca gi RTP phi l bi s ca 32) 1 bit X (Extension) : Cho bit header RTP c phn header extension hay khng 1bit CSRC count: Cho bit s nhn din ngun pht trong vng CSRC 4bit M (Marker): nh du khi bt u truyn d liu thoi. H tr tnh nng loi b khong lng 1bit PT (Payload Type): Ch ra loi chun m ha c dng m ha d liu thoi trong vng payload 7bit Sequence number: S th t ca cc gi RTP c gi i Gip u thu xc nh c s mt gi v th t gi. Gi tr ban u c thit lp ngu nhin 16bit
Nhm 1-07VTA1 Page 33

Tm hiu h thng VoIP trn Asterisk Timestamp: Ch ra thi im m mu u tin trong payload c to ra (Thi im ly mu c tham chiu ti ng h xung clock). Gi tr ban u ca timestamp l mt gi tr ngu nhin 32bit Synchonization Source Identifier (SSRC): Gip u thu nhn dng ng b pha u pht 32bit Contributing source (CSRC): Cha mt gi tr SSCR cho mt thnh phn tham gia vo phin giao dch Vng ny c s dng khi dng RTP xut pht t mt b trn 32bit - Header Extension: S dng cho cc dng tin yu cu thm thng tin c bit no 32bit - Payload: D liu cn truyn trong mt gi RTP, trong trng hp VoIP d liu ny l tn hiu thoi c m ha bi s ca 32bit Sau y chng ta s bt mt gi tin RTP trong qu trnh thc hin m thoi phn tch: Gi tin c bt l gi tin th 49 trong s cc gi tin giao tip gia hai my trong qu trnh thit lp cuc gi: My ngun PBX c a ch IP: 10.10.10.10 gi ti my ch c a ch IP: 10.10.10.5

Hnh 4-6: Gi tin th 49

Nhm 1-07VTA1

Page 34

Tm hiu h thng VoIP trn Asterisk Giao thc RTP nm bn trn giao thc UDP trong cu trc ca mt khung Ethernet m chng ta bt c Di y l phn gi tin RTP di dng cc k t h hexa:

ngha ca cc byte trong gi tin bt c:

So snh vi cu trc khung c a ra trn, gi tin bt c c: V=2, tc l RFC 1889 version 2 P = 0 : Khng c m cui vng payload X = 0 : Khng c phn header extension (phn m rng header) CSRC count = 0: Do khng c b trn (mixed) M=0: y khng phi l gi u tin trong lung ting ni. Payload type = 0: Chun m ha d liu trong vng payload l ITU-T G.711 PCMU Sequence number = 37116: S th t ca gi tin RTP ny l 37116 Timestamp = 3025776: Mc thi gian ca mu u tin trong payload Synchronization Source Identifier = 4be8f7e4 (1273559012) : Gi tr u thu s nhn dng ngun ng b ti pha u pht. Do khng s dng b trn (mixed) nn khng cn trng Contributing source (CSRC) Paload: Phn cn li ca gi tin
Page 35

Nhm 1-07VTA1

Tm hiu h thng VoIP trn Asterisk Cc bn tin RTP nh vy c trao i qua li cho n khi kt thc phin m thoi. 4.4.3 Kt thc phin: Khi 101 hay 103 mun kt thc cuc gi th chng s a ra yu cu BYE, bt c bn no trong cuc gi u c th a ra yu cu ny, trong trng hp ny th bn 101 yu cu kt thc cuc gi trc, gi bn tin bye n PBX (gi 681), PBX xc nhn li bng bn tin 200 OK (gi 682) Sau , PBX gi request BYE ti 103 (gi 687), 101 chp nhn kt thc cuc gi, xc nhn li bng gi 200 OK (gi 688).

Nhm 1-07VTA1

Page 36

Tm hiu h thng VoIP trn Asterisk

CHNG V: KT LUN
SIP l giao thc bo hiu linh hot, mm do v rt thch hp khi s dng trong mng IP. SIP ngy cng tr nn ph bin v tr thnh mt giao thc bo hiu chnh trong mng VoIP. SIP c phn m rng s cho nhng tnh nng, ng dng, dch v v mi trng c th. V vy vn quan trng cn xc nh trc tin i vi nh cung cp dch v l xc nh phng hng pht trin dch v, trn c s s tip tc xy dng ti liu chun cho cc phn m rng lin quan. OpenSIPS l SIP Proxy Server m ngun m ch o. OpenSIPS c kh nng nh tuyn hng t pht v x l hng triu hot ng cc cuc gi in thoi VoIP mi thng. Ni bt v tinh nng linh hot v s n nh, OpenSIPS ang lin tc pht trin cc cc tnh nng trong Vin thng. Rt ph bin trong cc dch v cung cp VoIP/Internet Telephony, OpenSIPS cung cp nn tng truyn thng hon chnh : Vocie ,Video, Instant Messaging v Presence Hn th na.Cu hnh OpenSIPS server khng phi l d dng ,nhng l cha kha thnh cng v bo mt cho d n IP. Vi c tnh linh hot ca OpenSIPS cho php trin khai dich v tin tin v tit kim c thi gian v chi ph

Hn ch v hng pht trin ca ti


Hn ch ca ti Cha khai thc v th hin c ht cc chc nng ca OpenSIPS Mi thc hin thit lp cuc gi gia PC PC , cha thc hin c nhng ng dng ca OpenSIPS trong thc m hnh thc t khc v d nh thc hin cuc gi t IP telephone PC, IP telephone IP telephone thng qua OpenSIPS - Hng pht trin ca ti Tm hiu v nghin cu cch cu hnh OpenSIPS c th ng dng c cc chc nng ca n trong mng VoIP, phc v cho cc doanh nghip, cc ngnh Cng nghip mt cch ti u nht

Nhm 1-07VTA1

Page 37

Tm hiu h thng VoIP trn Asterisk

D NH MC T
DNS HTTP IEFT ISDN MGCP MTU NAT PBX PSTN RSVP RTP RTSP SAP SCTP SDP SIP SMS TCP UDP UAC URL VoIP XCAP XML XMPP
Nhm 1-07VTA1

VIT TT

Domain Name System Hypertext Transfer Protocol Internet Engineering Task Force Integrated Service Digital Network Media Gateway Control Protocol Maximum Transmission Unit Network address translation Private Branch Exchange Public Switched Telephone Network Resource Reservation Protocol Real-time transport Protocol) Real Time Streaming Protocol) Session Advertisement Protocol Stream Transmission Control Protocol Session Description Protocol Session Initiation Protocol Short Message Service Transmission Control Protocol User Datagram Protocol User Agent Client Universal Resource Locator Voice over Internet Protocol XML Configuration Access Protocol Extensible Markup Language The Extensible Messaging and Presence Protocol
Page 38

Tm hiu h thng VoIP trn Asterisk

Ti liu tham kho :


[1] Mark A Miller, P E 2002 Voice over IP Technologies Building the Converged Network, M&T Books [2] Henry Sinnreich, Alan B Johnston, Delivering VoIP and Multimedia Services with Session Initiation Protocol, Second Edition, Wiley Publishing_Inc, 2006 [3] Wiliam C Hardy, VoIP service quality, McGraw Hill, 2003

Nhm 1-07VTA1

Page 39