You are on page 1of 27

Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

MC LC

LI M U................................................................................................................ 2
MC LC..................................................................................................................... 3
]Chng 1: Tng quan v mng ngang hng P2P......................................................................5
1.1. Gii thiu.......................................................................................................... 5
1.2. nh ngha P2P................................................................................................... 5
1.3. So snh m hnh P2P vi m hnh Client/Server:.........................................................6
1.4. u, nhc im ca mng P2P, Client/Server:..............................................6
1.5. Phn loi mng ngang hng..........................................................................8
1.5.1. H thng ngang hng lai (Hybrid Peer to Peer System)...........................9
1.5.2. Mng ngang hng thun ty (Pure Peer-to-peer System)........................................11
1.5.3 Kin trc siu ngang hng (Super-peer Architecture).................................................12
1.5.4 Mng ngang hng c cu trc (Structured)..............................................................14
1.6. Tm thong tin qung b qua mng P2P........................................................16
Chng 2 : nh tuyn trong cc h thng P2P th h mi........................................................18
2.1 Tng quan nh tuyn.............................................................................................. 18
2.1.1. Khi nim..................................................................................................... 18
2.1.2. Nguyn tc..................................................................................................... 18
2.1.3. nh tuyn tnh v nh tuyn ng......................................................................18
2.2 nh tuyn trong mng ngang hang P2P.......................................................................19
2.2.1 Tng quan...................................................................................................... 19
2.2.2. nh tuyn da vo tin t (Prefix routing).............................................................20
2.2.3. Thut ton Plaxon et al..................................................................................... 20
2.2.4. Thut ton Tapetry.......................................................................................... 21
2.2.5. Thut ton Pastry............................................................................................ 24
2.2.6. Thut ton Chord............................................................................................ 24
2.2.6.1. Giao thc Chord.................................................................................... 24
2.2.6.2. nh x kha vo mt nt trong Chord..................................................25

Trang 1
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

2.2.6.3. c im H Thng Chord..............................................................................26


2.3. Mt s nhn xt v nh tuyn trong mng ngang hng c cu trc.....................................27
Ti liu tham kho......................................................................................................... 29

Trang 2
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

]Chng 1: Tng quan v mng ngang hng P2P

1.1. Gii thiu


Mng ngang hng (Peer-to-Peer P2P) bt u xut hin t 1999 v thu ht s
quan tm ca gii CNTT trong nhng nm gn y. c bit vic p dng cc m hnh
P2P trong vic xy dng nhng ng dng chia s file (file sharing), in thoi trn nn
Internet (Internet-based telephony) t c nhiu thnh cng.

Hin nay cc ng dng P2P chim khong 50% (thm ch 75%) bng thng trn
Internet.

Cc ng dng ca kiu mng ny nh l: Napster, Skype, BitTorrent, FlashGet,


Sopcast, ICQ...vv..

1.2. nh ngha P2P


Mng ngang hng l mt kiu mng c thit k cho cc thit b trong c chc
nng v kh nng ca cc thit b l nh nhau
Mng P2P khng c khi nim my trm (client) hay my ch (server), m ch c
khi nim cc nt (peers) ng vai tr nh c client v server.

Trang 3
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Hnh 1. Kin trc mng ngang hang Peer-to-Peer


Mng ngang hng l mt h thng phn tn c bit trong tng ng dng,
mi cp im nt c th giao tip vi nhau thng qua giao thc nh tuyn trng cc tng
mng ngang hng. Mi im nt gi 1 i tng d liu no c th l nhc, nh, ti
liu,..vv... Mi im nt c th truy vn ti i tng n cn t cc im nt khc thng
qua kt ni logic trong tng mng ngang hng.
Overlay network:L mng my tnh c xy dng trn nn ca mt mng
khc. Cc nodes trong mng overlay c xem l ni vi nhau bng lin kt o (logical
links), mi lin kt o c th bao gm rt nhiu cc lin kt vt l ca mng nn.
Rt nhiu cc mng P2P c gi l overlay networks v n c xy dng v hot
ng trn nn ca Internet. VD: Gnutella, Freenet, DHTs .
Dial-up Internet cng l mt overlay network trn nn telephone network.

1.3. So snh m hnh P2P vi m hnh Client/Server:

P2P Client/Server

Trang 4
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

- Mt mng ngang hng cho php cc - D liu c lu tr mt Server


node (PCs) ng gp, chia s ngun ti trung tm, tc cao (Tc truy cp
nguyn vi nhau. Ti nguyn ring r thng ln hn so vi mng P2P).
ca cc node ( cng, CD-ROM,
my in . Cc ngun ti nguyn ny - Khi mt my client yu cu ly thng
c th c truy cp t bt c node no tin v thi gian n s phi gi mt yu
trong mng. cu theo mt tiu chun do server nh

1.4. u, nhc im ca mng P2P, Client/Server:

P2P Client/Server

+ u im: + u im:

- Khng cn server ring, cc client - Tc truy cp nhanh.


chia s ti nguyn. Khi mng cng
c m rng th kh nng hot - Kh nng m rng cao.
ng ca h thng cng tt.
- Hot ng vi bt k loi ng dng
- R. no.

+ Nhc + Nhc
im: im:

- Chm. - Cn server ring (nghn c chai).

- Khng tt cho cc ng dng CSDL. - t.

Trang 5
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Hnh 1.2. Tng quan c tnh mng P2P v mng Client-Server


1.5. Phn loi mng ngang hng

Hai tiu ch c bn phn loi mng ngang hng:

Theo mc ch s dng:

Chia s file (file sharing)

in thoi VoIP (telephony)

a phng tin media streaming (audio, video)

Trang 6
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Din n tho lun (Discussion forums)

Tiu ch ny thng c cc nh pht trin ng dng quan tm. Theo cc


ng dng vi c im ring s c phn loi v p dng theo nhng m hnh sn
c, chuyn bit.

Theo topo ca mng tng vt l v mng ph.

y l tiu ch c pht trin qua tng thi k v c xem xt nghin cu


tm ra nhng gii php tt nht, xy dng nn tng vng chc cho cc ng dng
sau ny.
1.5.1. H thng ngang hng lai (Hybrid Peer to Peer System)

y l mng ngang hng th h th nht, c im l vn cn da trn mt


my ch tm kim trung tm - c im ca m hnh khch ch, chnh v vy n cn
c gi l mng ngang hng lai hay mng tp trung (centralized Peer-to-Peer
networks). Cu trc Overlay ca mng ngang hng lai c th c m t nh mt
mng hnh sao.

Nguyn tc hot ng:

Mi client lu tr files nh chia s vi cc nt khc trong mng.

Mt bng lu tr thng tin kt ni ca ngi dng ng k (IP address,


connection bandwidth).

Mt bng lit k danh sch cc files m mi ngi dng nh chia


s (tn file, dung lng, thi gian to file).

Mi my tnh tham gia mng c kt ni vi my ch tm kim trung


tm, cc yu cu tm kim c gi ti my ch trung tm phn tch, nu
yu cu c gii quyt my ch s gi tr li a ch IP ca my cha
ti nguyn trong mng v qu trnh truyn file c thc hin theo ng
c ch ca mng ngang hng, gia cc host vi nhau m khng cn quan
my ch trung tm.

Trang 7
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Hnh 1.3. M hnh mng lai ngang hang(Hibrid P2P)

Hnh 1.3 M hnh mng Hibrid P2P c th

Trang 8
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

u im:

D xy dng.

Tm kim file nhanh v hiu qu.

Nhc im:

Vn lut php, bn quyn.

D b tn cng.

Cn qun tr (central server).

Napster l mng ngang hng c trng cho h thng mng ngang hng ca th h
th nht, chng c dng cho vic chia s cc file gia cc ngi dng Internet, c
s dng rng ri, tuy nhin nhanh chng b mt th trng bi yu t v lut php. Khi
nim v kin trc ca Napster vn cn c s dng trong cc ng dng khc nh:
Audiogalaxy, WinMX.
Vi Napster, vic tm kim file b tht bi khi bng tm kim trn my ch v l do
no khng thc hin c. Ch c cc file truy vn v vic lu tr c phn tn, v
vy my ch ng vai tr l mt nt c chai. Kh nng tnh ton v lu tr ca my ch
tm kim phi tng xng vi s nt mng trong h thng, do kh nng m rng mng
b hn ch rt nhiu.

1.5.2. Mng ngang hng thun ty (Pure Peer-to-peer System)

Mng ngang hng thun ty l mt dng khc ca th h th nht trong h


thng cc mng ngang hng. Khng cn my ch tm kim tp trung nh trong
mng Napster, n khc phc c vn nt c chai trong m hnh tp trung. Tuy
nhin vn tm kim trong mng ngang hng thun ty li s dng c ch
Flooding, yu cu tm kim c gi cho tt c cc nt mng l lng ging vi n,
iu ny lm tng ng k lu lng trong mng. y l mt yu im ca cc
mng ngang hng thun ty. Cc phn mm tiu biu cho mng ngang hng dng
ny l Gnutella 0.4, FreeNet.

Trang 9
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Hnh1. 4. Mng ngang hng thun ty (Gnutella 0.4, FreeNet)

u im:

D xy dng.

m bo tnh phn tn hon ton cho cc nt tham gia mng, cc nt


tham gia v ri khi mng mt cch ty m khng nh hng n cu
trc ca mng.

Nhc im:

Tn bng thng.

Phc tp trong tm kim.

Cc nt c kh nng khc nhau (CPU power, bandwidth, storage) u c


th phi chu ti (load) nh nhau.

1.5.3 Kin trc siu ngang hng (Super-peer Architecture)

khc phc nhc im ca mng ngang hng thun ty, mt m hnh mang
ngang hng mi c pht trin vi tn gi l mng siu ngang hng. y c gi
l mng ngang hng th h 2. Phn mm tiu biu cho mng ngang hng kiu ny
l Gnutella 0.6 v JXTA (Juxtapose). JXTA c bt u pht trin bi SUN t

Trang 10
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

2001 (y l giao thc P2P m ngun m). JXTA c s dng cho PCs,
mainframes, cell phones, PDAs - giao tip theo cch khng tp trung. Skype
cng c xy dng da trn cu trc ny.

Hnh 1.5. Kin trc siu ngang hng(Gnutella 0.6, JXTA)

Nguyn tc hot ng:

Trong m hnh mng siu ngang hng tn ti mt trt t phn cp bng


vic nh ngha cc Super-peers.

Cc Super-peer to thnh mt mng khng cu trc, c s khc nhau


gia Super-peers v Client-peers trong mng, mi Super-peer c nhiu
kt ni n cc Client-peers.

Mi Supper-peer cha mt danh sch cc file c cung cp bi cc


Client-peer v a ch IP ca chng v vy n c th tr li ngay lp tc
cc yu cu truy vn t cc Client-peer gi ti.

u im:

Trang 11
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Hn ch vic Flooding cc query, lm gim lu lng trong mng, nhng


vn trnh c hin tng nt c chai (do c nhiu Super-peers).

Khc phc c nhc im v s khc nhau v CPU power,


bandwidth mng ngang hng thun ty, cc Super-peer s chu ti
chnh, cc nt khc chu ti nh.

Nhc im:

Mi im Super-peer tr thnh im gy li cho nhm siu ngang hng


tng ng trong trng hp s lng Client trong nhm l rt ln (tuy
nhin, nhc im ny c gii quyt bng vic ci tin mng siu
ngang hng thng thng, a ra khi nim siu ngang hng d cp k).

1.5.4 Mng ngang hng c cu trc (Structured)

H thng mng ngang hng khng cu trc th hin nhc im: khng c g
m bo tm kim s thnh cng. i vi tm kim cc d liu ph bin c chia
s trn nhiu my, t l thnh cng l kh cao, ngc li, nu d liu ch c chia
s trn mt vi my th xc sut tm thy l kh nh. Tnh cht ny l hin nhin v
trong mng ngang hng khng cu trc, khng c bt k mi tng quan no gia
mt my v d liu n qun l trong mng, do yu cu tm kim c chuyn
mt cch ngu nhin n mt s my trong mng. S lng my trong mng cng
ln th kh nng tm thy thng tin cng nh. Mt nhc im khc ca h thng
ny l do khng c nh hng, mt yu cu tm kim thng c chuyn cho mt
s lng ln my trong mng lm tiu tn mt lng ln bng thng ca mng, dn
n hiu qu tm kim chung ca mng thp.

Mng ngang hng c cu trc khc phc nhc im ca mng khng cu trc
bng cch s dng h thng DHT (Distributed Hash Table - Bng Bm Phn Tn).
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 cn tm mt d

Trang 12
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

liu, n ch cn p dng mt giao thc chung xc nh nt mng no chu trch


nhim cho d liu v sau lin lc trc tip n nt mng ly kt qu.

Nguyn tc hot ng:

Topo mng c kim sot cht ch.

Files (hoc con tr tr ti files) c t mt v tr xc nh.

iu quan trng i vi nhng h thng c cu trc l cung cp s lin


kt (mapping) gia ni dung (v d: id ca file) v v tr nt (v d: a
ch nt). Vic ny thng da trn mt cu trc d liu bng bm phn
tn (Distributed Hash Table).

Hnh 1. 6. C ch ca bng bm phn tn (DHT)

Da trn cu trc bng bm phn tn c nhiu nghin cu v xut ra cc


m hnh mng ngang hng c cu trc, in hnh l cu trc dng vng (nh
trong hnh v m t): Chord, Pastry, v cu trc khng gian a chiu: CAN,
Viceroy.

u im:

Kh nng m rng c nng cao r rt do khng c im tp trung


gy ra hin tng tht nt c chai ti nhng im ny.

Cc truy vn tm kim c pht i theo mt thut ton c th, hn ch


ti a lng truy vn hay k thut flooding, tit kim bng thng mng.

Trang 13
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Nhc im:

Vic qun l cu trc ca topo mng gp kh khn, c bit trong trong


trng hp t l vo/ra mng ca cc nt cao.

Vn cn bng ti trong mng.

S khc bit v topology trn mng overlay v mng lin kt vt l dn n thi gian tr
truy vn trung bnh cao.

1.6. Tm thong tin qung b qua mng P2P

1 Peer c th c c 1 bn tin qung b bng 1 trong 3 cch

Khng c tin discovery

Discovery trc tip

Discovery gin tip

Hnh 1.7.Peer discovery thong qua catched qung b

Trang 14
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Hnh 1.8.Discover trc tip

Hnh 1.9 Discovery gin tip

Trang 15
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Chng 2 : nh tuyn trong cc h thng P2P th h mi

2.1 Tng quan nh tuyn

2.1.1. Khi nim

- nh tuyn l 1 qu trnh chn la cc ng i trn mt mng my tnh gi d liu


qua .
- nh tuyn ch ra hng v ng i tt nht t ngun n ch ca cc gi tin
(packer) thng qua cc node trung gian l router.

2.1.2. Nguyn tc

- Trong hot ng nh tuyn , ngi ta chia lm hai loi l nh tuyn trc tip v nh
tuyn gin tip. nh tuyn trc tip l nh tuyn gia hai my tnh ni vi nhau vo
mt mng vt l. nh tuyn gin tip l nh tuyn gia hai my tnh xa cc mng vt
l khc nhau nn chng phi thc hin thng qua cac Gateway.
- kim tra xem my ch c nm trn cng mt mng vt l vi my ngun hay
khng th ngi gi phi tch ly a ch mng ca my ch trong phn tiu ca gi
d liu v so snh vi phn a ch mng trong phn a ch IP ca n. Nu trng th gi
tin s c truyn trc tip nu khng cn phi xc nh Gateway truyn cc gi ny
thng qua n ra mng ngoi thch hp.

2.1.3. nh tuyn tnh v nh tuyn ng


- nh tuyn l qu trnh m router thc hin chuyn gi d liu ti mng ch. Tt c
cc router dc theo ng i u da vo a ch IP ch ca gi d liu chuyn gi
theo ng hng n ch cui cng . thc hin c iu ny, router phi hc thng
tin v ng i ti cc mng khc .Nu router chy nh tuyn ng th router t ng
hc nhng thng tin ny t cc router khc .Cn nu router chy nh tuyn tnh th
ngi qun tr mng phi cu hnh cc thng tin n cc mng khc cho router .

Trang 16
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

- i vi nh tuyn tnh ,cc thng tin v ng i phi do ngi qun tr mng nhp
cho router . Khi cu trc mng c bt k thay i no th chnh ngi qun tr mng phi
xo hoc thm cc thng tin v ng i cho router . Nhng loi ng i nh vy gi l
ng i c n. i vi h thng mng ln th cng vic bo tr mng nh tuyn cho
router nh trn tn rt nhiu thi gian .Cn i vi h thng mng nh ,t c thay i th
cng vic ny mt cng hn . Chnh v nh tuyn tnh i hi ngi qun tr mng
phi cu hnh mi thng tin v ng i cho router nn n khng c c tnh linh hot
nh nh tuyn ng .Trong nhng h thng mng ln , nh tuyn tnh thng c s
dng kt hp vi giao thc nh tuyn ng cho mt mc ch c bit.

2.2 nh tuyn trong mng ngang hang P2P

2.2.1 Tng quan


Cc h thng chia s d liu peer-to-peer (P2P) hin l mt trong nhng ng
dng Internet ph bin nht v ang tr thnh ngun lu lng Internet chnh. Do vy,
vic m rng quy m cho cc h thng ny l cc k quan trng. Tuy nhin, cc thit k
ban u cho cc h thng P2P khng ph hp vi cc mng c quy m ln, v d nh
Napster v Gnutella. Nhm p ng cc vn m rng quy m, th h mi cc h
thng P2P h tr tnh nng bng hm bm phn tn (DHT), trong s l Tapestry,
Pastry, Chord v CAN (Content-Addressable Networks). Trong cc h thng ny (cn
gi l cc h thng DHT), cc file c rng buc vi cc kho (key).

Hu nh cc thut ton hin ti ng dng trong mng ngang hng th h mi


(mng c cu trc) u nh tuyn da trn key. N nhn mt key, v hi p, chng
nh tuyn mt bn tin ti node c trch nhim vi key y. Cc key l cc chui s c
mt di no y. Ccnode l cc b nhn dng, ly t cng khng gian vi cc key (c
ngha l cng s lngdigits). Mi node lu gi mt bng nh tuyn bao gm mt tp
nh cc node trong h thng.Cc thut ton nh tuyn u c gng nh tuyn ti node
c key ph hp v qua t s hop nht. Di y l mt s thut ton nh tuyn hin ti:

Trang 17
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

2.2.2. nh tuyn da vo tin t (Prefix routing)


nh tuyn da vo tin t (Prefix routing) - PRR: y l thut ton u tin cho
vic tm kim v nh tuyn ca mng ngang hng. Bng cch nh x nhn dng
i tng thnh khng gian a ch ca cc peers, PRR nh tuyn da trn key v c
th tr gip cc thao tc: c, chn v xa i tng lu tr trong mng chng ph.
Nguyn l ca thut ton ny l nn tng cho cc thit k DHT sau ny. PRR l nh
tuyn da trn hu t, l trng hp i xng ca nh tuyn tin t. nh tuyn hu
t v tin t u da trn s ging nhau tng v tr ca a ch ch ti mi hop dc
theo ng cho n khi ch t ti. Thit k PPR da trn tp cc node tnh; khng
quan tm ti thnh vin l cc node ng, khng c k thut cp nht bng nh tuyn
khi node ra nhp hoc ri mng. Phin bn n gin ca PRR c gi l SPRR c
a ra bi Li and Paxton. Mt s cc thut ton Tapestry, Pastry, P-Grid, Cycloid,
and Z-Grid. Plaxton, Rajaraman u da trn PRR.

2.2.3. Thut ton Plaxon et al


Plaxon et al: Plaxon et al l mt phin bn ca PRR, y l thut ton u tin
c s dng trn quy m ln bi cc DHT, nhng khng cung cp vic nh tuyn tm
kim hiu qu. Thut ton ca Plaxton ban u c to ra nh tuyn cc truy vn
Web ti cc cache ln cn, v n nh hng n thit k ca Pastry, Tapestry v
Chord. Phng php Plaxton c phc tp tham gia/ri b theo hm loga. Plaxton
m bo cc truy vn khng bao gi i xa hn trong khong cch mng so vi peer
m lu gi key. Tuy nhin, Plaxton cng c mt s nhc im: yu cu hiu bit
ton b xy dng mng chng; peer gc ca i tng l im li n; khng c
s chn thm hoc xo b peer; khng c s trnh cc im tc nghn nng. i vi
mt h thng n node, mi node c O(log n) ln cn, di ng nh tuyn O(log
n) bc nhy

Trang 18
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

2.2.4. Thut ton Tapetry


Tapestry s dng m t bin th ca thu t tonPalaxon et al v thm vo tnh nng
n g cho cc pees trong mng chng. S dng nh tuyn da vo tin t, Tapestry s
dng thu t ton SHA-1 bm cc a ch node thnh cc ID biu din theo h s 2b .
hiu r hn v vn ta s tm hiu v thu t ton SHA-1 :

Khi gn cc bin:

H0:=0x67452301

H1:=0xEFCDAB89

H2:=0x98BADCFE

H3:=0x10325476

H4:=0xC3D2E1F0

Tin x l:

Thm 1 bt vo thng i p.

Thm vo k bit 0 sao cho di thng di p ng du 448 (mod 512).

Thm 64 bt biu din di ca thng i p gc ( gi tr lu dng big endian)

Trang 19
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

M 1 00

m
1 bit
Hnh 2.1. di thng ip gc ca khi 512 bt

T hnh v 2.1 ta chia thng i p ( pha inh) thnh cc khi 512 bt.

Mi khi 512 bt:

Chia thnh 16 word (32 bt, big-endian) w[0..15]


w[i]=(w[i-3] w[i-8] w[i-14] w[i-16]) <<< 1 vi 16 i < 80
A= h0, B= h1, C= h2, D= h3, E= h4
80 chu k x l
h0+=A, h1+=B, h2+=C, h3+=D, h4+=E
Kt qu:= h0 | h1 | h2 | h3 | h4
:php Xor

Chu ky x ly:

t l s th t ca chu k
A, B, C, D, E l 5 word (32 bit) ca trng thi
F l hm phi tuyn (thay i ty theo chu k)
<<< n l php quay tri n v tr
php cng modulo 232.

Trang 20
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Kt l hng s .
X Y php ton AND trn bt gia X v Y
X Y php ton OR trn bt gia X v Y
X Y php ton XOR trn bt gia X v Y
X php ton NOT trn bt X

X Y X Z , 0 t 19
X Y Z, 20 t 39

F t X , Y , Z
X Y X Z Y Z , 40 t 59
X Y Z , 60 t 79

0x5a827999,0 t 19
0x6ed9eba1,20 t 39

Kt
0x8f1bbcdc,40 t 59
0xca62c1d6,60 t 79

Trang 21
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Hnh 2.2 . Bng nh Tuyn Cha cc Node c ID

Mi node lu gi m t bng nh tuyn gm log 2 b (N) hng v 2 b c t. Hng th


nht trong bng nh tuyn cha cc node c ID khc vi ID ca node ch s th
nht. Hng th hai trong bng nh tuyn cha cc node c ID ging vi ID ca node
ch s th nht nhng khc ch s th hai. Cc hng cn li ca bng nh tuyn
cng c t chc tng t. Qu trnh tm kim c thc hi n bng cch so snh ln
lt cc ch s tin t ca ID. V d 4*** 42** 422* 4227, qu trnh ny gi l
nh x ln c n. Bng nh tuyn ca m t node X c chia thnh nhiu mc (log2b
(N)), mi mc i bao gm cc lin kt (2 b -1) n cc node c tin t ging n ch s
th i-1 vi ID ca X. khi m t node nh tuyn n node ch n s i theo ng n
node c ID gn ging vi ID ch nht (da theo bng nh tuyn). Sau mi ch ng node
tip theo s c mc cao hn t nht l 1, v v y sau nhiu nht l log 2 b (N) ch ng qu
trnh tm kim kt thc.

2.2.5. Thut ton Pastry


Trong Pastry vic nh tuyn bao gm vic chuyn truy vn ti node ln cn c
tin t c chia s di nht vi key (v, trong trng hp cht ch, th ti node c b
nhn dng gn nht v s i vi key). Pastry c O(log n) ln cn v nh tuyn trong
vng O (log n) bc nhy .

2.2.6. Thut ton Chord

H thng v cc ng dng peer-to-peer l cc h thng phn tn khng cn b x l trung


tm, cc phn mm c chy trn cc node v thc hin cc chc nng ca n. Cc c
im ca ng dng peer-2-peer nh : lu tr bn d phng, lu di, la chn im gn, tm
kim, xc thc, phn cp tn.Thc t vi nhiu c im tt, li (core)ca hu ht cc h
thng peer-2-peer u da trn xc nh v tr d liu.

2.2.6.1. Giao thc Chord

Trang 22
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Giao thc Chord c thit k ging nh giao thc nh tuyn DHT nhm mc ch pht
trin mt cch phn tn d liu tt nht, cc node c phn phi IDs v Keys vi nhiu c
trng nh Scalability(nh gi), Complete Decentralization(phn quyn), Efficient Load
Blancing(cn bng ti), v Simplicity( n gin). Chord coi cc kha Key l cc im trn
mt ng trn. Khng gian kha ng trn c chia thnh cc cung lin tip m im
cui ca cung ny l cc nh danh ID ca cc node. Mi node lu tr thng tin nh tuyn
ti cc node khc trong mt bng nh tuyn c gi l Finger Table.

Hnh 2.3. Bng Finger table v cp key cho tng node 0,1,3 v keys 1,2,6

Giao thc Chord h tr duy nht mt hot ng : a ra 1 key, n s nh x key vo 1


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 cn bng ti, mi node s nhn c s lng key gn
ngang nhau, vo lm c vic chuyn s lng key khi c node tham gia hay ri khi h
thng. K thut consistent hashing u tin s nhn bit cc node trong h thng, to ra s
cn chnh v s lng cc node. Mi node trong Chord cn c "routing" bit thng tin
v mt vi node khc. V bng nh tuyn l phn tn, 1 node s s dng hm bm giao
tip vi cc node khc. Khi mng c thit lp, 1 h thng gm N-node, trong mi node
Trang 23
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

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 duy tr thng tin nh tuyn khi cc node tham gia/ri
khi h thng. Vi mt h thng c tn sut cao, mt node cng ch cn gi khng qu
O(log2 N) thng ip nh tuyn.

2.2.6.2. nh x kha vo mt nt trong Chord

Chord nh x cc kha vo cc nt, thng s l mt cp key v value. Mt value c th l 1


address, 1 vn bn, hoc 1 mc d liu. Chord c th thc hin chc nng ny bng cch lu
cc cp key/value cc nt m key c nh x. Mt nt s chu trch nhim lu gi mt
kha k nu nt l nt c nh danh id nh nht v ln hn k. Mt nt khi lu gi kha k
cng s c gi l Successor(k).

Hnh 2.4. Lu gi key trong mng Chord

2.2.6.3. c im H Thng Chord


Chord c thit k da trn cc vn sau :
- Load Balance ( phn ti) : Chord s dng bng bm phn tn, phn ti trn cc node, mt
node s khng cha qu nhiu kay.
- Decntralization (phn quyn): Chord l phn tn hon ton, khng node no quan trng

Trang 24
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

hn node no, vic ny ci thin c s vng chc ca h thng.


- Scalability ( nh gi) : gi ca vic tm kim tng ln theo Log ca s node : Log(n)
- Availability (tin dng) : Chord t iu chnh cc bng nh tuyn khi c node tham gia v
ri khi mng Flexible naming ( nh ngha tn linh hot) : Chord khng rng buc v cu
trc ca key m n tm kim, khng gian key l phng bng vic gn cho key mt ci tn v
tm kim. ( v d phng tc l a tt c cc loi key v thnh 1 kiu nh id , khi tm th ch
cn tm id ca key) Phn mm Chord to ra mt lin kt gia client v server ca ng dng.
ng dng tng tc vi Chord qua 2 ng :
- Chord cung cp cc thut ton lookup(key)

Hnh 2.5.Tng tc vi chord qua 2 ng

Chord nhn bit s thay i ca key khi node phn ng ( v d khi c 1 node tham gia
vo mng, n s c node bn cnh chuyn cho mt s lng key lu gi)

2.3. Mt s nhn xt v nh tuyn trong mng ngang hng c cu trc


Mng c cu trc, thng gi l cc mng P2P th h mi, thng s dng m
hnh nh tuyn da trn bng bm phn tn DHT lm gim chi ph nh tuyn v
cung cp mt giihn cho s bc nhy c yu cu trong vic tm kim mt mc d

Trang 25
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

liu. Cc h thng nh vy c cc u im nh: tnh phn tn, kh nng m rng, tnh


sn sng, khong cch nh tuyn ngn, sc chu ng li. nh tuyn DHT da trn khi
nim nh tuyn trn c s tin t, ban u c gii thiu bi Plaxton h tr s tham
gia/ ri b ng ca cc peer v cung cp cc c ch khi phc khi gp li. Ni cch
khc, cc mng P2P c cu trc c ngha l t p mng P2P c iu khin cht ch v
cc cc i tng d liu c t ti cc v tr c th sao cho t c hiu nng truy
vn tt hn. V d cho cc mng nh vy l Plaxton,Pastry, Tapestry, Chord v CAN,
ang trin khai cc thut ton nh tuyn DHT khc nhau.Cc c tnh l thuyt th
c s dng xc nh v ci thin hiu nng ca cch thng nh vy. Thng
thng, cc th nh th thng c ng knh (log n ) v(log n ) mc ti mi node,
n l s peers trong h thng.Mt vn quan trng ca cc h thng c cu trc lin quan
n tnh n nh (churn) n nh hng nghim trng n hiu nng mng. Cc nhc
im khc l mo u cao, thiu h tr cho truy tm keyword v cc truy vn phc tp.
Tuy nhin, cc n lc gn y hng n vic pht trin ca mt nn tng thng nht cho
cc h thng DHT khc nhau, l lm cho cc mng c cu trc ngy cng hp dn
hn. Mt nn tng nh vy c mong i l s cung cp mt API trn c s KBR (nh
tuyn trn c s Key), kt hp vi mt m hnh dch vDHT c bn trin khai cc ng
dng DHT mt cch d dng.
Mt vn quan trng khc l cc k thut nh tuyn tm kim s dng trong cc h
thng P2P v cc cch ti u chng. Mt k thut nh tuyn m bo tnh hiu qu v
QOS t u vo ngi dng. Thch thc t ra l vic pht trin cc m hnh nh tuyn
ti u mi chocc mng ln t vi nghn n vi chc nghn server v hng triu khch
hng.
Tiu chun c bn cho vic pht trin cc thut ton nh tuyn DHT hiu qu l cung
cptradeoff tt nht vi mt tp cc tham s nh: hiu qu nh tuyn, n hi vi
node li,nh tuyn cc im nng v hiu nng trn c s th. Cc tham s khc nh
tiu tn ti nguyn t nht cng quan trng khng km, c bit l trong trng hp cc
mng Ad-hoc di ng.

Trang 26
Mng ngang hng v nh tuyn trong mng ngang hng (P2P)

Ti liu tham kho

1. Ralf Steinmetz and Klaus Wehrle Peer-to-Peer Systems and Applications


2. Juniper Networks doccuments System Basics Configuration Guide
www.juniper.net.
3. Morgan.Kaufmann.P2P.Networking.and.Applications.Dec.2008.
4. Juniper Networks doccuments ERX Command Reference Guide
www.juniper.net.
5. Juniper Networks doccuments M320 Hwguide www.juniper.net.
6. Andy Oram. Peer to Peer: Harnessing the Power of Disruptive
Technologies. OReilly Publishing, first edition March 2001. Page 9,page 19.
Chapter 8.

Trang 27