Está en la página 1de 42

TRNG. KHOA.

Bocottnghip
ti:
Xy dng ng dng video streamming da trn mng ngang hng Chord

Tm tt
Kha lun ny a ra mt phng thc truyn tin multicast trn nn tng mng ngang hng mi nhm khc phc nhng nhc im ca mt s phng thc truyn tin multicast tn ti t trc. Nhng nhc im gm c vic phi ph thuc hon ton vo kh nng ca router i vi IP multicast hay vn qun l cy multicast kh khn i vi mt s giao thc truyn tin multicast trn tng ng dng khc. Kha lun m t chi tit giao thc mng ngang hng c cu trc Chord v cch thc truyn tin multicast trn nn mng ngang hng Chord. Trong kha lun, vn truyn video streaming cng c cp n. T kha lun xy dng nn ng dng truyn video streaming multicast trn nn Chord. Vic nh gi kt qu thu c qua qu trnh xy dng ng dng cho ta thy c nhng u im ca vic trin khai multicast trn mng ngang hng, cng nh nhng nhc im cn khc phc.

MC LC
M u ......................................................................................................................................................... 5 Chng I: Tng quan v video streaming multicast .............................................................................. 7 1.1. Gii thiu v video streaming................................................................................................. 7 1.2. Gii thiu multicast ................................................................................................................. 9 1.3. IP multicast ............................................................................................................................ 10 1.4. Multicast tng ng dng ( ALM Application-layer Multicast) ...................................... 12 1.4.1. Gii thiu................................................................................................................... 12 1.4.2. Mt s gii php truyn tin multicast trn tng ng dng................................... 13 Chng II: Truyn tin multicast trn nn mng ngang hng c cu trc Chord............................... 16 2.1. Gii thiu mng ngang hng ................................................................................................ 16 2.2.1. Khi nim .................................................................................................................. 16 2.2.2. u th ca mng ngang hng.................................................................................. 16 2.2.3. Phn loi mng ngang hng .................................................................................... 16 2.2. Mng ngang hng c cu trc Chord .................................................................................. 18 2.2.1. Gii thiu chung ....................................................................................................... 18 2.2.2. Finger table ............................................................................................................... 20 2.2.3. Node tham gia/ ri mng v qu trnh ng b ( stabilization) ........................... 21 2.3. Thut ton truyn tin multicast da trn nn mng Chord.............................................. 22 Chng III: Xy dng ng dng truyn tin video streaming multicast thi gian thc trn nn mng ngang hng c cu trc Chord................................................................................................................. 26 3.1. Mc tiu v yu cu ca vic xy dng ng dng .............................................................. 26 3.2. tng................................................................................................................................... 26 3.3. Thit k h thng ................................................................................................................... 27 3.3.1. To cy multicast...................................................................................................... 27 3.3.1. To d liu thi gian thc........................................................................................ 28 3.3.2. Truyn hnh nh ....................................................................................................... 28 3.3.3. X l v hin hnh nh ............................................................................................. 29 3.4. Thit k giao thc .................................................................................................................. 29

3.4.1. Giao thc my ch ................................................................................................... 29 3.4.2. Giao thc my khch ............................................................................................... 31 3.5. Thit k chng trnh ........................................................................................................... 33 3.5.1. Lp WebcamServer ................................................................................................. 34 3.5.2. Lp WebcamClient .................................................................................................. 36 Chng IV: Kt qu nh gi h thng................................................................................................. 39 4.1. Kt qu th nghim............................................................................................................... 39 4.1.1. Mi trng chy th ................................................................................................ 39 4.1.2. Kt qu t c ...................................................................................................... 39 4.2. Kt qu nh gi hiu nng.................................................................................................. 39 Chng V: Kt lun.................................................................................................................................. 41 Ti liu tham kho .................................................................................................................................... 42

M u
Trong nhng ngy u pht trin ca ng dng a phng tin, khong na cui thp nin 90, vic xem mt video trn mng gn nh l iu khng th. Ngy nay, cng vi s bng n ca Internet, cc ng dng a phng tin trong c video streaming tr thnh nhu cu khng th thiu ca nhiu c dn mng.Theo thng k, ring ti M c khong 13,5 t video c xem trong thng 10 2008 (ngun comScore). Con s trn cho ta thy c s ln mnh khng ngng ca cc ng dng video streaming. Tuy nhin, pht trin mt ng dng video streaming tt gp phi nhiu vn . ng dng video streaming i hi nhiu bng thng v yu cu tr thp. Chnh v vy cn phi c mt phng thc phn pht video trn ng truyn hp l. IP multicast vi kh nng ti u ha ng truyn l mt gii php cho vn ny. Tuy nhin, vic trin khai IP multicast li rt tn km bi n i hi ton mng phi c nhng Router t tin, chuyn dng. iu ny hon ton khng kh thi trong mt mng din rng nh Internet. Trin khai multicast trn tng ng dng vi vic khng lm thay i h tng mng pha di l mt gii php thay th hu hiu cho IP multicast. Hin nay, trn th gii v ang pht trin rt nhiu phng php truyn tin multiast trn tng ng dng khc nhau. Trong truyn tin multicast da mng ngang hng ha hn c nhiu u im. c th ca truyn tin multicast l phi to c mt cy multicast ti u, c s lin kt cht ch gia cc node vi nhau, c kh nng phc hi li nhanh. Mng ngang hng c cu trc hon ton c th p ng c yu cu vi vic cc node c lin kt vi nhau bng mt thut ton c th. lm r hn nhng li th ca mng ngang hng c cu trc trong vic truyn tin multicast, kha lun ny nghin cu xy dng mt ng dng truyn video streaming multicast da trn nn tng mng ngang hng c cu trc Chord. Sau y l tm tt ni dung kha lun gm 5 chng. Chng 1: Tng quan v video streaming v multicast Gii thiu v video streaming v trnh by nhng khi c bn v multicast, so snh vi cc phng thc truyn tin khc. IP multicast v multicast tng ng dng c trnh by mt cch ngn gn t c th thy c u im ca multicast tng ng dng so vi IP multicast. Chng 2: Truyn tin multicast trn nn mng ngang hng c cu trc Chord

Phn ny a ra ci nhn tng quan v mng ngang hng bao gm: khi nim, phn loi v u im chung ca mng ngang hng. Tip , s gii thiu hot ng ca giao thc Chord. c bit, vic truyn tin multicast da trn nn mng Chord c cp mt cch chi tit. Chng 3: Xy dng ng dng truyn multicast video streaming thi gian thc trn nn Chord Chng 3 cp n nhng yu cu, mc tiu ca ng dng v cch thc xy dng ng dng sao cho ph hp vi nhng mc tiu . Trong , trnh by chi tit v thit k h thng, thit k giao thc v thit k chng trnh ca ng dng. Chng 4: Kt qu nh gi h thng Sau cc nghin cu cc phn trn, chng 4 trnh by v mi trng chy th chng trnh, cc kt qu v nh gi thu c sau qu trnh th nghim. Chng 5: Kt lun

Chng I: Tng quan v video streaming multicast 1.1. Gii thiu v video streaming

Video l mt loi d liu a phng tin quan trng phc v cho truyn thng hoc cho nhu cu gii tr ca con ngi trong nhiu thp nin. Trong thi k u video c x l v truyn di dng tn hiu tng t (analog). Vi s pht trin khng ngng ca mch in t v my tnh dn n vic s ha video v m ra mt cuc cch mng v nn v truyn thng video. S pht trin v ph bin ca Internet gia nhng nm 90 nh hng truyn thng video qua mng chuyn mch gi best-effort. Video qua mng qua mng Internet gp phi rt nhiu yu t bt li v bng thng, tr v mt gi tin, cng vi mt s vn nh lm th no chia s ti nguyn mng gia cc lung hay lm th no c th trin khai hiu qu phng thc truyn thng mt- nhiu ( truyn d liu t mt ngun n nhiu ch cng mt lc). T c rt nhiu gii php c nghin cu v pht trin nhm khc phc nhng vn ny. Video streaming c nh ngha l mt dng chy video , ngha l d liu video c truyn lin tc t mt ngun n mt ch no . tng c bn ca video streaming l chia video thnh tng frame, sau lin tc truyn nhng phn c chia ra v bn nhn c th hin th nhng phn video nhn c m khng phi i cho n khi ton b video c truyn xong. Tuy nhin c mt vi vn nh hng trc tip n video streaming. Video streaming qua mng Internet gp rt nhiu kh khn bi Internet ch cung cp dch v truyn best-effort (c gng ti a). Do , n khng m bo v bng thng, tr, jitter hay s mt gi tin. Nhng nhn t ny thng khng on trc c v ng. Chnh v vy, mc tiu chnh ca vic xy dng mt ng dng video streaming l phi thit kt mt h thng phn pht video cht lng cao ng tin cy qua mng Internet. Cc ng dng video streaming thng c nhiu ngi dng cng mt lc, tc l video phi c truyn cng lc ti nhiu ngi nh video conference hay truyn hnh trc tuyn. Truyn tin multicast l mt gii php thch hp cho nhng ng dng . Phn di y s trnh by chi tit v multicast. Cu thnh nn mt h thng video streaming gm c 6 yu t c bn: c ch nn video, c ch iu khin cht lng dch v tng ng dng, dch v phn pht video, my

ch streaming, c ch ng b d liu v giao thc dnh cho video streaming [10]. Hnh 1 cho ta thy c mi lin h gia cc yu t ny vi nhau.

Hnh 1: Cu trc ng dng video streaming C ch nn video. D liu video nguyn gc cn phi c nn trc khi c truyn nhm tit kim bng thng. C ch iu khin cht lng dch v tng ng dng. i ph vi s bin thin ca ti nguyn mng hoc cung cp cht lng hnh nh thay i theo tng ngi dng, nhiu k thut iu kin cht lng dch v tng ng dng c a ra. K thut bao gm iu khin tc nghn v iu khin li. iu khin tc nghn c trin khai ngn nga vic mt gi tin v gim tr. Trong khi , iu khin li ci thin cht lng hnh nh khi c gi tin b mt. Dch v phn pht video trn ng truyn. c xy dng trn nn ca Internet ( giao thc IP), dch v phn pht video trn ng truyn cho php t c QoS ( cht lng dch v) v hiu qu cho vic phn pht video qua mng Internet. My ch streaming. My ch streaming ng vai tr quan trng trong vic cung cp dch v streaming. My ch streaming c yu cu phi x l cc d liu video vi s rng buc v thi gian, ng thi h tr cc hnh ng tng tc nh dng (pause), tua (fast forward). Mt server streaming gm 3

h thng con: b truyn tin (communicator) v d nh giao thc tng giao vn, h iu hnh v h thng lu tr. C ch ng b d liu. Vi c ch ng b, ng dng ti bn nhn c th hin th video gn ging nh khi n c khi to ti bn gi. Mt v d ca c ch ng b l c ng mi ca ngi ni phi ph hp vi ting ni h pht ra. Giao thc dnh cho video streaming. Giao thc c thit k v chun ha cho truyn thng gia my khch v my ch streaming. Giao thc c th c chia lm 3 loi: giao thc tng mng nh Internet Protocol (IP), giao thc tng giao vn nh User Datagram Protocol (UDP) v giao thc iu khin phin nh Real-time Streaming Protocol (RTSP). 1.2. Gii thiu multicast Trong h thng mng ca chng ta hin nay c 3 cch truyn tin c bn l unicast, multicast v broadcast (Hnh 2). Unicast l phng thc truyn tin c s ca IP network. Vi unicast mt my truyn v ch c mt my nhn theo kiu point to point. Hin nay hu ht cc ng dng mng c pht trin v s dng trn nn phng thc unicast nh HTTP, Telnet, FTP Nhng vi nhng ng dng i hi phi truyn tin t mt ngun cho mt nhm ngi dng nh video streaming th vic trin khai trn unicast l khng hiu qu v truyn tin multicast l gii php thay th. Multicast l cch truyn d liu t mt nhiu (one-to-many) tc l d liu c gi t mt node ngun v mt nhm node ch s nhn c cng d liu . Cch truyn ny khc vi unicast gi thng tin trn mng theo cch truyn gi tin mt- mt (one to one). Nu multicast c th so snh vi cuc gi chung cho nhiu ngi (conference call) th unicast c th so snh vi cuc gi ring gia hai ngi. Broadcast c m t nh truyn thng tin cho ton mng, tt c cc im trong mng u nhn c thng bo ny. Trong trng hp ny ch mt ngi gi nhng tt c ngi trong mng u nhn c. Broadcast c h tr trong mng LAN (v d Ethernet) v c s dng gi nhng gi tin ging nhau n cc my trong mng LAN (v d ARP c s dng gi a ch n ton b my trong mng LAN). Network protocol (nh IP) h tr khun dng gi tin gi n bt k h thng no trong logical network.

C th ni, multicast l cch thc hiu qu nht truyn d liu n mt nhm ngi trn Internet. Chng ta cng c th s dng unicast truyn tin ln lt t ngun n tng node trong nhm. Tuy nhin, vi cch ny th node ngun s phi lp i lp li vic truyn 1 gi tin cho rt nhiu node khc, dn n vic tiu tn ti nguyn ca node ngun ( CPU, memory ). ng thi, s c rt nhiu gi tin khng cn thit c lu thng trn mng, dn n lng ph ti nguyn mng. Vi multicast, mt cy multicast s c hnh thnh vi ngun l gc ca cy v cc thnh phn cn li ca cy c th l node u cui ( end host ) hoc c th l router ty vo tng cng ngh multicast khc nhau. Thay v vic node ngun nhn bn gi tin v gi n tng node trong nhm th n ch truyn cho 1 hoc vi node nht nh v cc node ny c nhim v sao chp v truyn gi tin theo cy multicast.

Hnh 2: Cc phng thc truyn tin trn mng

1.3.

IP multicast

IP multicast (Hnh 3) l chun m ca IETF (Internet Engineering Task Force)[3], dng truyn d liu ti nhiu ngi nhn.Trong IP multicast, cc router s ng vai tr l node trung gian trong cy multicast v c trch nhim sao chp gi tin ri truyn cho cc node ng dng - y, cc node ny s ng vai tr l ngn ca cy.

Hnh 3: Thnh phn ca IP multicast Trong IP multicast mi node s gi yu cu mt router gn vi n khi mun ra nhp hoc ri khi nhm. Sau cc router multicast s trao i cc thng tin v vic qun l nhm thng qua cy multicast. Tt c cc cng vic nh to nhm, nhp nhm, ri nhm u c thc hin bi giao thc IGMP (Internet Group Membership Protocol)(Hnh 4)[4]. IP multicast s dng a ch IP lp D nh danh cc nhm multicast. y l dng a ch IP c bit dnh ring cho multicast. Tt c cc my ni kt vo Internet phi c a ch IP thuc lp A, lp B, hoc lp C. Mt my c th c mt hoc nhiu a ch multicast lp D ty thuc vo s nhm multicast m n tham gia. a ch lp D c di l 32 bit. 4 bit u tin c dng xc nh n thuc lp D, 28 bit cn li c dng xc nh nhm multicast. Mt a ch lp D c th so snh vi mt knh trn tivi. Khi bn truy cp mt a ch lp D, bn s nhn c tt c thng tin c multicasting n a ch .

Hnh 4: Internet Group Management Protocol Thng ip Query IGMP ch c trch nhim qun l cc nhm multicast v vic phn pht cc gi tin multicast t router ni b n cc node trong nhm. Vic gi tin lm th no i c t ngun n cc router bin ( cc router trc tip ni vi node) ph thuc vo giao thc nh tuyn multicast chy trn cc router trong mng. Hin nay c mt vi giao thc nh tuyn c pht trin dnh ring cho IP multicast nh DVMRP (Distance Vector Multicast Routing Protocol) giao thc nh tuyn multicast u tin hay nh PIM (Protocol Independent Multicast) giao thc multicast c dng ph bin nht hin nay. Vi cc giao thc nh tuyn multicast trong IP multicast, s lng gi tin phi sao chp nhn bn trn ng truyn c gim thiu so vi cc phng thc truyn tin khc t tit kim ng k bng thng mng. Tuy nhin mt nhc im khin n khng c s dng nhiu v khng c kh nng m rng l cc router trong mng phi h tr multicast. ng thi, IP multicast ch h tr cc ng dng chy trn nn UDP giao thc truyn tin khng tin cy. Nhm khc phc nhng nhc im ny, truyn tin multicast tng ng v ang c nghin cu, pht trin rt nhiu trong nhng nm gn y. Phn tip ca kha lun s trnh by v phng thc truyn tin multicast tng ng dng. 1.4. Multicast tng ng dng ( ALM Application-layer Multicast) 1.4.1. Gii thiu

Khi nim multicast tng ng dng ch n gin l vic thi hnh multicasting nh mt dch v tng ng dng ch khng phi nh mt dch v tng mng. Hnh 5 m t

vic truyn multicast cho cng mt nhm ngi nhn v ngi gi ca multicast tng ng dng v IP multicast. y, cy multicast c hnh thnh tng ng dng. Vi vic ch s dng phng thc truyn tin unicast ca tng mng, node ngun S gi hai gi tin cho D1 v D2; ti D1, D2 gi tin c nhn bn v chuyn tip cho D4,D3.

Hnh 5: (a) IP multicast

(b) Multicast tng ng dng

IP multicast c trin khai ti cc node mng ( Router) trong khi muticast tng ng dng c trin khai ti cc node ng dng ( end host hoc proxy ). Do cc node ng dng bit t thng tin v tng mng hn l cc router nn cy multicast tng ng dng thng khng c ti u bng IP multicast. Trong multicast tng ng dng, cc cng vic iu khin nh ra nhp nhm, ri nhm, sao lu v chuyn tip gi tin, nh tuyn multicast u c thc hin ti im u cui (end system hoc proxy) chnh v vy m khng yu cu cn c nhng router h tr multicast mng li. 1.4.2. Mt s gii php truyn tin multicast trn tng ng dng

Da vo cu trc mng hoc cch to cy multicast m ta c cc gii php truyn tin multicast tng ng dng khc nhau: Proxy-based ALM v end system ALM; mesh first v tree first [7] Proxy-based ALM v end system ALM

Hnh 6: (a) Proxy-based ALM

(b) End-system ALM

Trong m hnh Proxy-based ALM (Hnh 6a), yu cu trin khai nhiu proxy hoc server trn Internet, cc proxy hay server ny s t thnh lp mt mng ph (overlay network) vi nhau v cng cp dch v multicast trong sut cho cc ngi dng cui (end-user). Ngc li, m hnh end-system ALM (Hnh 6b) ch yu cu h tng mng pha di cng cp duy nht dch v truyn tin unicast, vic truyn multicast s c thc hin bi cc node u cui (end-system). Vi m hnh proxy-based ALM th cc ng dng chy trn node u cui s t phc tp hn bi v dch v multicast trong sut vi chng. Mt im mnh na ca m hnh ny l bng thng ti cc proxy thng ln hn ti cc node u cui chnh v vy m trnh xy ra hin tng nt tht c chai nh trong m hnh end-system ALM. Nhc im ca m hnh ny l chi ph phi tr cho h thng proxy hay server l rt cao. Mesh-fist v tree-first Trong m hnh mesh-first, cc node mun tham gia vo qu trnh truyn hoc nhn multicast s tham gia vo mt mng ph hnh thnh nn mt t p dng li lin kt cc node vi nhau (Hnh 7a). Sau khi t p mng c hnh thnh th node ngun s s dng thut ton nh tuyn truyn multicast thng qua mng (Hnh 7b). Thng thng cy multicast to ra t phng thc khng c ti u do gp phi vn vn nt c chai khi mt node c ti nguyn km m phi chu ti cao. Hn na vic duy tr mng ph cng i hi mt phn bng thng cho cc thng tin iu khin mng. Tuy nhin li th ca m hnh ny l kh nng chu li cao bi cc node trong cy khng ch bit n

node cha ca n m cn bit thng tin v cc node khc. M hnh ny thng c s dng vi cc ng dng a ngun multicast nh video conference. Vi m hnh tree-first, cy multicast c hnh thnh m khng cn cc node to thnh mng ph vi nhau. Mt node chn cha ca n t mt s thnh vin bit trong cy. M hnh ny cn c thut ton pht hin v trnh lp xy ra trong cy multicast. Cc node trong cy s chn c v tr ti u nht trnh hin tng nt tht c chai. Tuy nhin iu ny c th dn n cy b lch. Hn na khi mt node b li hoc ri mng th vic khi phc li cy multicast s kh khn hn rt nhiu so vi m hnh mesh-first.

Hnh 7: (a) Mng ph 7 node

(b) Cy multicast to t mng ph

Chng II: Truyn tin multicast trn nn mng ngang hng c cu trc Chord 2.1. Gii thiu mng ngang hng 2.2.1. Khi nim

Mt mng my tnh ngang hng (Peer-to-peer hoc P2P) ch yu da trn sc mnh tnh ton v bng thng ca cc my tham gia trong mng hn l tp trung vo mt s lng nh cc my ch (server). Mng P2P c s dng in hnh cho vic kt ni cc node thng qua nhng kt ni ad-hoc ln. Nhng mng nh vy c ch cho nhiu mc ch s dng. Chia s file cha audio, video, data hoc mi th nh dng s, cc d liu thi gian thc, v d nh truyn ti ging ni, video streaming u c th thc hin vi cng ngh P2P. Mt mng P2P thun ty s khng c khi nim v khch (client) v ch (server), m ch c nhng node ngang hang thc hin c hai chc nng ca mt my ch v my khch i vi nhng node khc trong mng. M hnh mng ny khc vi m hnh mng khch-ch m vic giao tip thng l vi cc my ch trung tm. Mt v d in hnh cho vic truyn file theo m hnh khch-ch l gia mt FTP Client v mt FTP Server, hai chng trnh FTP Client v FTP Server c vai tr rt khc nhau, client khi to vic download/upload file, cn server th tip nhn v phc v cc yu cu . 2.2.2. u th ca mng ngang hng

Mc ch quan trng ca mng ngang hng l trong mng tt c cc my tham gia u ng gp ti nguyn, bao gm bng thng, lu tr, v kh nng tnh ton. Do khi cng c nhiu my tham gia mng th kh nng tng th ca h thng mng cng ln. Ngc li, trong m hnh my khch-ch, nu s lng my ch l c nh, th khi s lng my khch tng ln kh nng chuyn d liu t cc my ch cho mi my khch s gim xung. Tnh cht phn tn ca mng ngang hng cng gip cho mng hot ng tt khi mt s my gp s c. i vi cu trc tp trung, ch cn my ch gp s c th c h thng s ngng tr. 2.2.3. Phn loi mng ngang hng

Mng ngang hng P2P c chia lm hai loi chnh: mng ngang hng thun ty v mng ngang hng lai ghp (Hnh 8).

Peer-to-Peer

Thun ty

Lai ghp

Khng cu trc

C cu trc

Gnutella

CAN

Chord

Napster

Hinh 8: Phn loi mng ngang hng Mng ngang hng thun ty c chia lm 2 loi: mng ngang hng c cu trc v mng ngang hng khng cu trc. Mng ngang hng khng cu trc l khi cc lin kt gia cc nt mng trong mng ph c thit lp ngu nhin (tc l khng theo qui lut no). Nhng mng nh th ny d dng c xy dng v mt my mi khi mun tham gia mng c th ly cc lin kt c sn ca mt my khc ang trong mng v sau dn dn t bn thn n s thm vo cc lin kt mi ca ring mnh. Khi mt my mun tm mt d liu trong mng ng ng khng cu trc, yu cu tm kim s c truyn trn c mng tm ra cng nhiu my chia s cng tt. S hiu bit v mng ca cc node trong mng khng cu trc l rt t, mi node ch nm bt thng tin v nhng node kt trc tip v mt s t cc node khc, thng tin v nhng node cn li hon thng qua broadcast. Chnh v vy vi nhng ng dng cn c s lin kt cht ch gia cc node vi nhau nh multicast th mng ngang hng khng cu trc khng phi l s la chn ti u. Mng ngang hng c cu trc khc phc nhc im ca mng khng cu trc bng cch s dng h thng DHT (Bng Bm Phn Tn, ting anh: Distributed Hash Table). H thng ny nh ngha lin kt gia cc nt mng trong mng ph theo mt

thut ton c th, ng thi xc nh cht ch mi nt mng s chu trch nhim i vi mt phn d liu chia s trong mng. Vi cu trc ny, khi mt my nh tuyn thng bo, n ch cn p dng mt giao thc chung xc nh nt cn thng bo v sau lin lc trc tip n nt mng . Bi vy vic tao cy multicast s din ra rt d dng v vic qun l cy cng c nhiu thun li khi cc node u c lin kt cht ch vi nhau. Mt s mng ngang hng c cu trc ni ting bao gm Chord, CAN, Kademlia, Pastry v Tapestry.[5,6,9] Mng ngang hng lai ghp: Trong m hnh mng ngang hng li ghp, tn ti mt server trung gian c trch nhim iu khin hot ng ca mng. Server ny lu d cc ch mc bao gm thng tin v cc node n qun l v v tr cc cp key-value trn mng. Cc node trong mng phi to lin kt vi server ny. Mt node mun trao i thng tin vi mt node khc th n s phi lin lc trc tip vi server, sau server s tm kim trong c s d liu v gi li a ch node ch. Qu trnh trao i thng tin sau c din ra trc tip gia 2 node. Vic trin khai truyn tin multicast trn mng ngang hng lai ghp gn ging nh m hnh proxy-base ALM. Nhc im chnh ca n vn l chi ph cao cho cc server trung gian. ng dng in hnh cho m hnh mng ny l Napster. 2.2. Mng ngang hng c cu trc Chord 2.2.1. Gii thiu chung

Giao thc Chord l mt giao thc nh tuyn DHT bi mt nhm sinh vin t trng i hc California Berkeley v MIT nhm mc ch phn tn v tm kim d liu mt cch tt nht vi nhiu c trng nh scalability (kh nng m rng), complete decentralization (phn tn hon ton), load blancing (cn bng ti), v simplicity (n gin). Chord[6] c m t di dng mt vng trn v c khng gian nh danh c m, vi m l s bit nh danh ca khng gian. Mng Chord s c ti a 2m nh danh. Mt Chord node (hay mt phn t - mt my tnh trong mng Chord) c mt nh danh id, v cc id trong mng Chord sp xp thnh vng trn v tng theo chiu kim ng h. Mi node trn vng trn s bit thng tin v node trc v sau n trn vng trn gi l predecessor v successor ca node . Thm vo , mi node s lu mt bng nh tuyn gi l bng Finger table, cho php node nh tuyn ti cc node xa. Mi dng trong bng Finger table s lu thng tin v 1 node xa, gi l 1 entry. Khng gian nh

danh c bao nhiu bit th Finger Table c by nhiu entry. V d trong hnh 9 predescessor ca node 1 s l node 6 v successor ca n l node 3. K thut Consistent hashing cp cho mi node v key m-bit nh danh da trn c s hm bm SHA-1[1]. nh danh ca mt node c xc nh bng cch bm a ch IP node , nh danh ca mt key xc nh bng cch bm key ( y chng ta quy c t kha key va l key gc va l nh danh ca key). Chiu di ca nh danh cn ln khi bm trnh xy ra trng hp 2 key hoc node c nh danh ging nhau.

Hnh 9: Vng trn Chord Giao thc Chord h tr duy nht mt hot ng : a ra 1 key, n s nh x key vo mt node. Ty thuc vo ng dng s dng Chord ( vn bn, hnh nh, media..), node s lu tr mt gi tr kt hp vi key. Chord s dng k thut consistent hashing cp key cho cc node. Consistent hashing dng phn b cc node cng nh cc key u trn vng trn t nng cao kh nng cn bng ti, mi node s nhn c s lng key gn ngang nhau, ng thi gip cho vic n nh mng khi c node tham gia hay ri khi h thng. Trong mng Chord mi node khng cn bit thng tin v tt c cc node khc. Mi node Chord ch cn bit mt lng nh thng tin nh tuyn v cc node khc. V nhng thng tin ny l phn tn, mt node s s dng finger table giao tip vi cc node khc. Khi mng c thit lp, mt h thng Chord gm N-node, trong mi node cha thng tin v O(log N) node xung quanh n, v tm kim cc node khc thng qua O(log

N) thng ip ti cc node . Chord cn phi cp nhp li thng tin nh tuyn khi cc node tham gia/ri khi h thng, vi s tham gia hay vo mng ca mt node cng ch cn khng qu O(log2 N) thng ip c gi i cp nhp li thng tin nh tuyn. 2.2.2. Finger table

Trong mng Chord, mi node cn mt lng nh thng tin nh tuyn trong 1 mi trng phn tn. Chord node ch cn bit node successor ca n trong mng. Cc truy vn n mt nh danh ( mt key hoc mt node) no c truyn theo vng trn thng qua cc node successor cho n khi tm c node bit thng tin v nh danh . Vi vic mi node u duy tr mt im successor ca n cng m bo mi truy vn tm kim u c thc hin chnh xc. Tuy nhin gii php ny t ra khng hiu qu khi mt truy vn c th phi lan truyn qua ton b cc node mng tm c node nh x vi n. y qu trnh ny, mi node Chord duy tr thm mt s thng tin nh tuyn. Vi chiu di nh danh key/node l m bit, mi node n s duy tr mt bng nh tuyn vi m entry, c gi l bng finger table. Entry th i trong bng finger table cha nh danh ca node u tin, s, m tip sau n t nht 2i -1 trn vng trn nh danh, s = successor(n + 2i - 1 ), vi 1 i m. Node s c gi l finger th i ca node n v k hiu l n.finger[i].node. Mt entry trong bng finger table cn bao gm a ch IP, nh danh, cng ca node finger . C th nhn thy rng, entry u tin trong bng finger table ca node n chnh l successor ca node n.

Hnh 10: Bng Finger table v cc key gn cho tng node 0, 1, 3

Nhn vo hnh 10 ta thy c mi entry trong bng finger table ca node 1 tr n successor node ca cc nh danh (1+20) mod 23 = 2, (1+21) mod 23 = 3, (1+22) mod 23 = 5. Successor ca nh danh 2 l node 3, n chnh l node u tin theo sau 2 trn vng trn Chord; successor ca nh danh 3 chnh l node 3 v successcor ca nh danh 5 l node 0. 2.2.3. Node tham gia/ ri mng v qu trnh ng b ( stabilization)

Trong mng Chord, mi node s chy nh k thut ton ng b mng nhm cp nhp bng finger table v cc thng tin v successor, predecessor ca n. Vic ny s gip cho mng Chord lun hot ng chnh xc k c khi c node mi tham gia/ri mng hay mt node b li. Khi mt node mi mun tham gia vo mng, n s tri qua cc bc sau: Bc 1: Node mi s dng consistent hashing bm a ch IP ca chnh n mt nh danh ID. Bc 2: Node mi gi thng ip join vi nh danh ID ca n cho mt node no tn ti trn mng gi l bootstrap node Bc 3: Bootstrap node s dng bng finger table tm kim successor ca nh danh ID successor(ID) v sau s gi kt qu tm kim cho node mi. Bc 4: Sau khi bit c successor ca mnh, node mi s gi thng ip cnh bo v vic gia nhp mng ca mnh cho successor . Successor nhn c thng ip cnh bo n s tr n predecessor mi l node mi gia nhp mng. Bc 5: Node mi s dng thut ton ng b cp nhp cc thng tin v mng. Thut ton ng b chy nh k ti mi node Chord. Gi s node A ang nh k chy thut ton ng b. A s yu cu successor ca n gi thng tin v predecessor ( predecessor ca successor ca A). Nu khng c node no join vo gia node A v successor ca A th kt qu tr v chnh l nh danh ca node A. Ngc li nu c mt node mi join vo gia node A v successor ca n th kt qu tr v s l nh danh ca node mi, t node A c th nhn bit c c node mi tham gia vo mng. V n ln ng b tip theo, node A s gi thng bo n node mi, node mi s cp nhp li predecessor ca n tr thnh node A.

Qu trnh mt node Chord ri mng din ra n gin hn khi mt node tham gia mng. Trc khi ri mng, node s gi ton b d liu ca n cc cp (key - value) cho successor. Sau n s thng bo cho successor cp nhp li predecessor v thng bo cho predecessor cp nhp li successor. Cui cng node s gii phng cc ti nguyn ca n v thot khi mng. Trong trng hp, mt node ri mng khng ng theo quy tc ( node b li) th ton b d liu m node nm d s b mt v phi nh n qu trnh ng b th mng mi pht hin v khi phc c li. 2.3. Thut ton truyn tin multicast da trn nn mng Chord

Mt trong nhng vn quan trng nht ca multicast l to nhm multicast, tham gia v ri nhm. Thay v lin lc vi Router tham gia hoc l ri nhm multicast nh IP multicast, tt c cc node mun tham gia vo nhm multicast s hnh thnh mt mng ph ( overlay network) . Trong trng hp ny mng ph chnh l mng Chord. Node ngun khi to mng Chord. Cc node trong nhm multicast tham gia vo nhm bng cch kt ni vo mng Chord m node ngun va to. T vic truyn multicast tr thnh vic truyn broadcast trn ton mng Chord. Phn di y m t chi tit thut ton truyn broadcast trong mng Chord [8]. Thut ton truyn tin broadcast trn mng Chord M hnh h thng v k hiu Chng ta gi thit h thng ca chng ta gm tp hp N node hnh thnh mt mng Chord v bng finger ti mi node c cp nhp y . Thut ton phn tn c chy trn mi node ca ht thng c miu t di dng mt lut c dng sau: receive(Sender: Receiver: Message(arg1.argn)) action(s) Lut ny miu t s kin khi mt node nhn c mt thng ip (Message) v hnh ng action(s) s c gi vi s kin . Node gi s gi lnh send(Sender: Receiver: Message(arg1.argn)) gi mt thng ip cho node nhn.

Khi to mt phin broadcast Broadcast c th c khi to bt k node no nu nh lp ng dng trn lp yu cu. l khi, mt thc th ng dng multicast ti node Q c th yu cu node Q mt thng ip InitBroadCast(Info) vi Info l mt phn ca thng tin cn c broadcast v d nh mt phn ca hnh nh cn c gi i trong ng dng video streaming.
start
1 2 4 8 16 ..

int.
[1, 2) [2, 4) [4, 8) [8, 16) [16, 32)

succ.
2 2 5 11 16

Hnh 11: Node Q ng vi nh danh 0 khi to broadcast v finger table ca node 0 Trong hnh 11, hnh ng ca node Q vi nh danh l 0, khi nhn c yu cu gi thng ip InitBroadCast(Info) t ng dng P: receive(P : 0 : InitBroadcast(Info)) send(0 : 2 : Broadcast(Info, 5)) send(0 : 5 : Broadcast(Info, 11)) send(0 : 11 : Broadcast(Info, 16)) send(0 : 16 : Broadcast(Info, 0)) Node Q s hot ng nh gc ca mt cy khng lp. Nh trong hnh 11, node Q thc hin vic bng cch gi mt thng ip broadcast ti tt c cc hng xm ca n trong bng finger table. Thng ip Broadcast(Info, Limit) cha ng thng tin Info cn c broadcast v mt tham s gii hn Limit. Limit c s dng hn ch khng gian chuyn tip gi tin ca node nhn c gi tin. Limit ca finger[i] chnh l finger[i+1], ( 1 i M - 1)

vi M l s entry trong bng finger table. Gii hn cho entry cui cng trong bng finger table l mt trng hp c bit khi Limit c t l nh danh ca chnh node gi gi tin. X l mt thng ip Broadcast Khi node Q nhn c mt thng ip Broadcast(Info, Limit) , node Q phi chu trch nhim chuyn tip thng ip cho cy con c xc nh trong khong (Q, Limit). Node Q s chuyn tip thng ip cho bt c finger no m c nh danh ng trc Limit (nh hn Limit). Hn na, khi chuyn tip cho mi finger, node Q s p t mt gii hn mi NewLimit nh ngha mt cy con nh hn cho node nhn tip theo. NewLimit c xc nh trong bng finger table tng t nh ti node ngun. Ch l, NewLimit ch c xc nh khi NewLimit vn cn thuc khong (Q, Limit). Hnh sau y m t lut khi mt node nhn c mt thng ip broadcast

start
6 7 9 13 21 ..

int.
[6, 7) [7, 9) [9, 13) [13, 21) [21, 37)

succ.
7 7 11 13 22

(a)

(b)

Hnh 12: (a)Hnh ng ca cc node khi nhn c gi tin broadcast (b)finger table ca node 5 Trong hnh 12, khi node 5 nhn c thng ip Broadcast(Info, 11) t node 0 th n s gi chuyn tip gi thng ip cho node 7 vi gii hn Limit vn l 11.

receive(0 : 5 : Broadcast(Info,11)) send(5 : 7 : Broadcast(Info, 11))

Phn hi (Reply) Vic phn hi thng ip broadcast nhn c ph thuc vo loi thng tin cha ng trong n hoc ph thuc vo yu cu ca ng dng. C 2 cch phn hi l: (i) Gi tin phn hi s c gi ngc li theo cy broadcast c hnh thnh t trc (ii) Gi tin phn hi c gi trc tip n node ngun ca broadcast.

Chng III: Xy dng ng dng truyn tin video streaming multicast thi gian thc trn nn mng ngang hng c cu trc Chord 3.1. Mc tiu v yu cu ca vic xy dng ng dng Hin nay trn th gii c rt nhiu ng dng truyn video streaming, hu ht trong s chng s dng m hnh khch ch (client server) da trn unicast, tc l my khch gi yu cu n my ch, my ch gi d liu cho tng my khch s dng truyn tin unicast; hoc c s t ng dng video streaming s dng truyn tin IP multicast cho vic phn pht video cho ngi dng v d nh Cisco IPTV. Cc ng dng trn u c nhc im ca n. l, vi m hnh khch ch da trn unicast n thun th my ch s b qu ti khi c qu nhiu ngi dng, vi IP multicast th cn c nhng router h tr multicast. ng dng c xy dng trong kha lun ny phi p ng c nhng yu cu sau: Ti u ha bng thng ca my ch, my ch khng phi chu ti qu nhiu khi s lng ngi s dng tng ln. Cc my khch chia s ti cng my ch. Xy dng mt phng thc truyn tin multicast tng ng dng theo kiu endsystem ALM, khng cn s h tr ca router hay proxy chuyn dng. Vic tham gia vo cy multicast phi c din ra mt cch nhanh chng, d dng. Cy multicast c kh nng khi phc li khi c mt node b li. Thng tin duy tr v iu khin cy multicast cng nh cng tt. Vi c th l mt ng dng v video nn hnh nh hin th ti my khch phi tng i r rng khng gy kh chu cho ngi dng. Vi nhng yu cu trn, mc tiu ca kha lun t ra l: a ra gii php v thit k giao thc truyn video streaming. Xy dng chng trnh th nghim da trn gii php v thit k c a ra. Cui cng, nh gi chng trnh xy dng kim tra xem ng dng c t c nhng yu cu t ra ban u hay khng. 3.2. tng

Nh trnh by nhng phn trn, giao thc Chord l mt giao thc mng ngang hng c cu trc n gin v mnh m, lng thng tin c truyn duy tr mng l thp; Chord c c ch phc hi khi mt node hoc nhiu node b li. Thut ton truyn

multicast trn nn Chord cng rt n gin v hiu qu. Chnh v vy, truyn video streaming multicast c xy dng trn nn mng Chord. Giao thc UDP c s dng truyn d liu video. UDP c u im l truyn d liu nhanh nht c th. Tuy nhin nhc im ca n l khng c c ch sp xp li gi tin n khng ng th t. tng c a ra y l s dng thm mt s gii php trong giao thc RTP (Real-time Transport Protocol) mt giao thc h tr truyn ng dng thi gian thc nh nh s th t gi tin [2]. 3.3. Thit k h thng

Hnh di y m t cc cha nng ca h thng. H thng truyn video streaming thi gian thc multicast nn Chord

To cy multicast

To d liu video thi gian thc

Truyn hnh nh

X l v hin th hnh nh

Hnh 13: Cc chc nng ca h thng 3.3.1. To cy multicast

Giao thc Chord c s dng to nhm multicast. Qua trnh to nhm mulicast gm cc bc: Node ngun khi to mng Chord. Cc node khc tham gia vo mng Chord. Node ngun s dng thut ton truyn broadcast trn mng Chord to cy multicast. Nh trong v d Hnh 12(a) ta thu c cy multicast nh hnh di y.

Hnh 14: Cy multicast thu c t mng Chord Nhn vo hnh 14 ta thy c, cy multicast c xy dng l cy lch phi. Do cc node cui vng trn Chord thng c su ln hn nhiu so vi cc node u vng trn. Chnh v vy, tr tng i ca d liu nhn c gia cc node l khng u nhau. Tuy nhin, nu hm bm c xy dng tt th c th lm gim ng k s chnh lch trn. 3.3.1. To d liu thi gian thc

Trong ng dng video streaming, video c th l cc bn ghi sn t trc hoc c th c bt ly trc tip theo thi gian thc vi cc thit b thu hnh. H thng s dng webcam to d liu thi gian thc. Hnh nh s c bt ly (capture) t webcam theo nhng khong thi gian lin tip. Vic tnh ton khong thi gian gia 2 ln capture ph thuc vo nhiu yu t nh bng thng mng, kh nng x l ca my, cht lng hnh nh thu c. 3.3.2. Truyn hnh nh

Truyn hnh nh l mt trong nhng bc quan trng nht trong video streaming. K thut truyn khng tt s nh hng trc tip n cht lng ca hnh nh thu c. Thc cht vic truyn video stream l vic truyn mt chui lin tip cc hnh nh (frame). Mi hnh nh nguyn gc thng c dung lng ln. Nn nh l gii php c ngh ti nhm ti u ha ng truyn, tit kim bng thng. JPEG l mt chun nn nh

m cht lng ca hnh nh khng thay i nhiu so vi nguyn bn. Vi JPEG hnh nh thu c c dung lng gim ng k. Do mi ng truyn mng u c mt gi tr MTU ( Maximum Transmission Unit) gii hn kch thc gi tin gi trn ng truyn nn khng th gi c frame ln ng truyn cng mt lc. Cch khc phc duy nht l phn mnh frame ra thnh cch gi tin nh hn truyn trn mng. Vic ny i hi c ch nh s th t cho tng gi tin nhm m bo cc gi tin s c ghp theo ng th t ti bn nhn. 3.3.3. X l v hin hnh nh

Sau khi c phn mnh ti my gi d liu bt u c gi n my nhn. Trong qu trnh gi c th c s mt mt gi tin, hoc cc gi tin n khng theo ng th t. Chnh v vy ti my nhn c c ch sp xp li gi tin n khng ng th t, ng s dng timeout khng phi ch qu lu gi tin b mt. hnh nh hin th khng gy kh chu cho ngi dng, cc hnh nh sau khi c ghp li s c lu trong buffer v hin th trong nhng khong thi gian u nhau. 3.4. Thit k giao thc 3.4.1. Giao thc my ch

Quy trnh hot ng ca my ch c biu din di hnh sau:

To nhm multicast

To d liu thi gian thc

Hin th hnh nh

Phn mnh frame

Khi to multicast

To nhm multicast My ch s dng hm create() vi a ch IP v port khi to mt mng Chord. My khch s lin lc vi my ch bng a ch IP v port c khai bo trn. To d liu thi gian thc D liu thc c to ra bng cch bt ly (capture) hnh nh thu c t webcam trong nhng khong thi gian nh k. Vi mi ln capture ta thu c mt frame di dng mt chui byte. Phn mnh hnh nh u vo ca qu trnh phn mnh l hnh nh di dng mt chui byte. Chui byte s c chia thnh cc phn nh hn c th gi c trn mng. Khi to multicast Sau khi hnh nh c phn mnh thnh cc phn nh, n s c thm vo mt s trc ri ng gi trong gi tin UDP v cui cng s c gi i n node ph hp. Cu trc gi tin multicast tng ng dng:

LimitID

ImageID

NumberOfParts

PartID

Data

- LimitID (8 byte) : ID gii hn khng gian chuyn tip gi tin ti node nhn - ImageID (2 byte): ID ca nh capture t webcam - NumberOfParts (2 byte): s lng phn c chia ra t nh - Data : mt phn ca nh c chia ra Theo thut ton multicast c trnh by trn trong qu trnh khi to multicast, bng finger table c bao nhiu entry th my ch s phi gi gi tin n by nhiu node, nhng entry ging nhau s c gi mt ln duy nht. Cc entry trong finger table chnh l lp u tin ca cy multicast. 3.4.2. Giao thc my khch Tham gia nhm multicast

Nhn gi tin

X l gi tin

Chuyn tip gi

Hin th hnh nh

Tham gia mng Chord Mi node mun tham gia vo qu trnh nhn d liu t my ch th bc u tin l phi tham gia vo mng Chord do my ch to ra. Hm join() trong giao thc Chord c gi khi mt node mun ra nhp mng. Thng tin h thng yu cu l a ch IP v cng kt ni ca my ch. Nhn gi tin

My khch s khi to mt cng UDP lun lun lng nghe gi tin gi n t my ch hoc t mt my khch khc. Khi nhn c gi tin th mt hng i c s dng lu tr gi tin phc v cho vic x l v sau. Chuyn tip gi tin C mi khi nhn c mt gi tin th hm decodePacket() c gi bc tch gi tin v ly v trng LimitID quy nh gii hn chuyn tip. Sau gi tin s c chuyn tip cho cc finger trong bng Finger table vi ID trong khong ID t chnh n cho n LimitID. nh dng gi tin chuyn tip newLimitID imageID numberOfParts partID data

- newLimitID l gii hn mi c p dng cho node nhn tip theo - Cc trng cn li s c d nguyn nh khi gi tin c nhn X l gi tin Do mi frame u c phn mnh ti ngun nn ti my khch cn thc hin qu trnh ghp cc gi tin li vi nhau to thnh frame gc. Qu trnh c thc hin bi 2 lp Image v ProccessImage. Gi s ta nhn c gi tin vi trng imageID l i, numberOfParts l n, partID l j. Qu trnh ghp nh thc hin theo nguyn tc sau: Nu y l ln u tin nhn c gi tin vi imageID l i th khi to danh sch Li c chiu di bng n v lu gi tin mi nhn vo v tr j trong danh sch. Ngc li, lu gi tin vo v tri j trong danh sch Li tn ti t trc, kim tra xem danh sch y hay cha. Gi hm merge() ghp cc gi tin khi danh sch y hoc khi ht thi gian timeout. Hnh nh thu c sau khi ghp di dng chui byte s c lu vo hng i phc v cho vic hin th. Hin th hnh nh trnh hin tng hin tng tc hnh nh thay i mt cch t ngt, lc qu nhanh, lc qu chm, thay v hin th ngay lp tc hnh nh khi n c nhn th hnh nh s c lu vo hng i cng vi thi gian bc nh c nhn .

Gi s ta quy nh c 150 ms th hin th mt hnh nh, tc 7 hnh/s. t1 t2 t3 t4

frame1 frame2 frame3 frame4 Hin ti c 4 frame trong hng i vi t1, t2, t3, t4 ln lt l thi gian cc frame c nhn . Ta c 1, 2, 3, 4 ln lt l khong thi gian t khi nhn c mnh u tin cho n khi nhn c mnh cui cng. Sau khi hin th frame1 ta s i mt khong thi gian l (150 (t2 - t1 ) - 2 ) ri tip tc hin th frame2. Tng t vi frame3 v frame4. Gi tr 150 c th c thay i bng cc gi tr khc ty thuc vo tng loi mng. 3.5. Thit k chng trnh

Chng trnh gm 4 lp chnh MessageHandler, Node v lp WebcamServer trin khai ti my ch (Hnh 15a) v lp WebcamClient ti my khch (Hnh 15b). MessageHandler l lp nn dng trao i tin cy cc thng tin iu khin, qun l mng gia cc node vi nhau. Node l lp chnh trong giao thc Chord. Node ny chu trch nhim trin khai cc thut ton giao thc trong Chord nh tm successor, thut ton ng b Hai lp Node v MessageHandler c xy dng trong giao thc Chord nn s khng c trnh by di y. WebcamServer v WebcamClient l 2 lp ng dng, thc hin trn nn giao thc Chord. C th WebcamServer v WebcamClient s dng bng finger table ca giao thc Chord thc hin nh tuyn multicast gia cc node vi nhau.

(a) Hnh 15: (a) Cu trc chng trnh my ch

(b) (b) Cu trc chng trnh my khch

3.5.1.

Lp WebcamServer

Hnh 16: Thuc tnh v cc phng thc ca lp WebcamServer Lp WebcamServer (Hnh 16) l lp duy nht ca ng dng truyn video multicast da trn nn Chord ti my ch. WebcamServer chu trch nhim to lung d liu video thi gian thc. C th WebcamServer s nh k bt hnh nh thu c t webcam, sau tin hnh gi broadcast trn ton mng Chord. Mt s phng thc chnh
//Hm khi to //Tham s: // localNode: mt th hin ca lp Node public WebcamServer(Node localNode) // Bt ly hnh nh t webcam // Hm tr v hnh nh di dng chui byte public byte[] captureImage()

// Phn mnh hnh nh thu c hm captureImage() thnh nhng phn nh // Gi tr tr v l danh sch cc phn mnh ca hnh nh public List<byte[]> fragmentImage(byte[] image) // ng gi gi tin tng ng dng vi cc trng khc nhau // Tham s: // limitID: gii hn chuyn tip dnh cho node nhn // imageID: s th t ca bc nh // numberOfPart: s phn b phn ra t bc nh gc // partID: s th t ca phn mnh // fragment: d liu ca mt phn bc nh // Hm tr v gi tin tng ng dng di dng chui byte public byte[] PacketToByte(long limitID, short imageID, short numberOfPart, short partID, byte[] fragment) // Hm khi to broadcast // Tham s: // image: chui byte d liu ca hnh nh // Hm s dng thut ton truyn broadcast gi hnh nh cho cc my khch public void SendBroadcastImage(byte[] image) // Gi mt gi tin tng ng dng cho mt node // Tham s: // desIP: IP ca node nhn // limitID: gii hn chuyn tip dnh cho node nhn // iID: s th t ca bc nh // part: d liu ca mt phn bc nh // partID: s th t ca phn mnh // numberOfPart: s phn b phn ra t bc nh gc public void send(string desIP, long limitID,short iID, byte[] part, short partID, short numberOfPart)

3.5.2.

Lp WebcamClient

(a) Hnh 17: (a) Cc thuc tnh

(b) (b) Cc phng thc

(c) (c) Lp lng

Ti mi node, lp WebcamClient (Hnh 17) thc hin 2 cng vic: x l v hin th lung hnh nh thu c t my ch, ng thi chuyn tip hnh nh cho cc node khc. Mt s phng thc quan trng
// Hm khi to // Tham s: // gui: giao din chng trnh // localNode: th hin ca lp Node public WebcamClient(MainForm gui, Node localNode) // Lng nghe kt ni n v lu d liu vo hng i listReceivePackets public void receive() // Hm x l gi tin nhn c public void processPacket() // Hm ly gi tr cc trng t gi tin nhn c // Tham s: // packet: gi tin nhn c di dng chui byte // limitID: lu thng tin v gii hn chuyn tip // imageID: lu s th t ca frame // numberOfPart: lu s phn ca frame // partID: lu s th t ca phn mnh

// fragmentImage: lu d liu ca phn mnh public void decodePacket(byte[] packet, ref long limitID, ref short imageID, ref short numberOfPart, ref short partID, ref byte[] fragmentImage) // Hm ng gi d liu gi i trn mng // Tham s: // limitID: gii hn chuyn tip // imageID: stt ca frame // numberOfPart: s phn mnh ca frame // partID: stt ca phn mnh // fragment: d liu phn mnh // Hm tr v d liu dng chui byte gi qua mng public byte[] PacketToByte(long limitID, short imageID,short numberOfPart, short partID, byte[] fragment) // Hm hin th video public void show() // Hm hin th tng hnh nh // Tham s: // image: hnh nh dng chui byte public void showRemoteWebcam(byte[] image) // Hm gi chuyn tip gi tin theo thut ton multicast public void forwardPacket(long limitID, short imageID,short numberOfPart, short partID, byte[] fragmentImage)

Khc phc nhc im ca UDP l khng c c ch sp xp li gi tin n khng ng th t, lp WebcamClient s dng 2 lp con Image v ProcessImage (Hnh 18) thc hin vic . Lp Image c s dng lu cc mnh ca cng mt frame. Lp ProcessImage thc hin kim tra xem nhn cc phn cha hoc ht thi gian timeout cha ri tin hnh ghp cc phn li vi nhau.

Hnh 18: Lp Image v lp ProcessImage

Chng IV: Kt qu nh gi h thng 4.1. Kt qu th nghim 4.1.1. Mi trng chy th

Chng trnh c chy th trn mi trng mng LAN vi tc ng truyn trong iu kin l tng l 100 Mbps. Mi my khch kt ni mng qua cng Ethenet tc 100 Mbps, RAM 1 G, CPU 2.4 GHz. My ch c cu hnh RAM 3G, CPU 2x2.4, kt ni Ethenet 100 Mbps. Qu trnh chy th din ra nhiu ln vi s lng my khch tng dn bt u vi 2 my v ti a l 7 my. 4.1.2. Kt qu t c

Qua qu trnh quan st ta c th thy c tng hnh nh hin th r nt, tuy nhin v thi tc hin th hnh nh vn cn chm ( s hnh / s) chnh v vy gy ra hin tng dt hnh gy kh chu cho ngi xem. 4.2. Kt qu nh gi hiu nng

Vi m hnh 7 my tnh c my ch, ta c bng thng tiu tn ca cc my o c (s liu trong bng gi tr trung bnh): Node ID 3724 7620 8598 (server) 13347 15105 19948 21901 110 KB/s 0 0 110 KB/s 0 110 KB/s 0 Upload Download 110 KB/s 110 KB/s 330 KB/s 110 KB/s 110 KB/s 110 KB/s 110 KB/s

Ta c d dng nhn thy rng, server c trch nhim phi truyn video cho 6 my m bng thng tiu tn ch l 330 KB/s. Nu s dng phng php truyn tin unicast thng thng th bng thng tiu tn phi l 660 KB/s.

Chng V: Kt lun Trn th gii, cc ng dng mng ngang hng ni chung v multicast trn mng ngang hng ang c nghin cu v pht trin mt cch mnh m. N s v ang dn thay th cc m hnh mng truyn thng nh m hnh khch ch hay IP multicast. Trong kha lun trnh by mt cch ngn gn v cch th hot ng ca mng ngang hng, c th l Chord t ta c th thy c nhng li th ca n s vi m hnh mng truyn thng l kh nng phn tn, khng ph thuc qu nhiu vo h tng mng pha di lm r hn u im ca mng ngang hng, kha lun xy dng th ng dng truyn video streaming multicast thi gian thc trn nn mng Chord. Trong ng dng s dng webcam to lung d liu thi gian thc, s dng Chord to cy multicast. Qua bc u th nghim trn mng LAN ta c th thy c u im ca n l my ch khng phi chu ti qu nng v vic truyn multicast hon ton khng ph thuc vo router. Tuy nhin ng dng xy dng vn cn mt s nhc im, khng c c ch m ha video, mi ch nn tng frame theo dng JPEG, chnh v vy t l nn vn cn thp. Mt nhc im na l tr gia cc node lp di cy multicast so vi cc node lp trn chnh lch nhau kh nhiu. Hin ti khi mt node b li hoc ri mng, vic phc hi cy multicast vn da vo giao thc ng b c xy dng trn giao thc Chord. Vi vic giao thc ny ch chy nh k s khin cho qu trnh khi phc din ra chm gy gin on lung video streaming trong khong thi gian di. Vi nhng kt qu t c v nhng mt cn tn ti ca vic xy dng ng dng, sau y l mt s hng pht trin tip theo : Khc phc nhng nhc im nu trn. Xy dng ng dng hi tho trc tuyn vi nhiu ngun pht muticast.

Ti liu tham kho


[1] http://en.wikipedia.org/wiki/SHA_hash_functions [2] http://www.ietf.org/rfc/rfc1889.txt [3] http://www.ietf.org/rfc/rfc3170.txt
[4] http://www.rfc-editor.org/rfc/rfc3376.txt

[5] B. Zhao, K. Kubiatowicz, and A. Joseph, Tapestry: An infrastructure for faultresilient wide-area location and routing, Tech. Rep. UCB//CSD-01-1141, University of California at Berkeley Technical Report, April 2001. [6] Ion Stoica, Robert Morris, David Karger, M. Frans Kaashoek, Hari Balakrishnan. Chord: A scalable peer-to-peer lookup protocol for internet applications. [7] Mojtaba Hosseini, Dewan Tanvir Ahmed, Shervin Shirmohammadi, and Nicolas D.Georganas. A Survey of Application-Layer Multicast Protocols. [8] Sameh El-Ansary, Luc Onana Alima, Per Brand, Seif Haridi Swedish Institute of Computer Science, Kista, Sweden IMIT-Royal Institute of Technology, Kista, Sweden. Effcient Broadcast in Structured P2P Networks [9] Sylvia Ratnasamy, Paul Francis, Mark Handley, Richard Karp, Scott Shenker. A Scalable Content-Addressable Network [10] Wenwu Zhu, Member, IEEE, Dapeng Wu, Student Member, IEEE, Yiwei Thomas Hou, Member, IEEE, Ya-Qin Zhang, Fellow, IEEE, Jon M. Peha, Senior Member, IEEE. Streaming Video over the Internet: Approaches and Directions