What is P2P?

‫معماری نرم افزار‬
‫‪ :DS ‬اگر به لحاظ کامپوننت های نرم افزاری به آن نگاه شود‪،‬‬
‫عبارت است از قطعات پیچیده ای که برروی ماشین های‬
‫مختلف سازمان دهی شده اند‪ .‬پس‬
‫→ ‪ Distributed system needs Organization‬‬
‫‪Architecture‬‬
‫‪ ‬معماری نرم افزار چگونگی سازمان دهی نرم افزاری کامپوننت‬
‫ها‬
‫‪ ‬سبک معماری (َ‪)Architecture style‬‬
‫‪ ‬معماری سیستم (‪)System Architecture‬‬
‫‪By Ali Bagherinia 4 Distributed System‬‬
‫سبک معماری‬
‫• برگرفته از دید منطقی (به صورت ‪ logic‬همه کامپوننت ها در یک‬
‫محدوده قرار می گیرند) است‪.‬‬
‫• چگونگی قرار گرفتن و ارتباط کامپوننت ها را بیان می کند‪ .‬بعبارتی‬
‫تعداد کامپوننت ها و چگونگی ارتباط آنها را بیان می کند‪.‬‬
‫‪By Ali Bagherinia 4 Distributed System Dr‬‬
‫‪JabEhdari‬‬
‫انواع سبک های معماری‬
•
•
•
•
Layered Architecture
Object based Architecture
Data centered Architecture
Event based Architecture
By Ali Bagherinia 4 Distributed System Dr
JabEhdari
‫معماری سیستم‬
‫• مفهومی است عام و برای هر سیستمی قابل کاربرد است‪ .‬از دیدگاه‬
‫سیستمی نگاه می کند و پیاده سازی نهایی را بیان می کند‪.‬‬
‫• برگرفته از دیدگاه فیزیکی (آن چیزی که در واقع هست‪ ،‬چه کامپوننتی‬
‫برروی چه ماشینی قرار می گیرد)‪.‬‬
‫• در مورد معماری سیستم می توان از هرکدام از سبک های معماری‬
‫مذکور استفاده کرد‪.‬‬
‫‪By Ali Bagherinia 4 Distributed System Dr‬‬
‫‪JabEhdari‬‬
‫انواع معماری سیستم‬
‫‪ - 1‬متمرکز (توزیع عمودی)‪ :‬یک کامپوننت مرکزی است که خدمات را ارایه می کند‪.‬‬
‫• توزیع شدگی باال به پایین (‪)vertical distribution‬‬
‫نمونه‪Client/Server :‬‬
‫‪ -2‬غیر متمرکز (توزیع افقی)‪ :‬همه چیز پخش است‪ ،‬کامپوننت ها خیلی باهم متفاوت نیستند‪.‬‬
‫توزیع شدگی افقی (‪)horizontal distribution‬‬
‫• ‪ -‬پراسس ها یکسان هستند و می توانند در صورت لزوم ‪ client‬و یا ‪ server‬باشند (‪.)servent‬‬
‫• هر کدام می توانند در صورت لزوم بخش ی از کار را انجام دهند‪ ،‬یا اینکه هر کدام می توانند مساوی‬
‫کار معدل را انجام دهند‪.‬‬
‫نمونه‪Peer2peer :‬‬
‫‪ -3‬ترکیبی‬
‫‪By Ali Bagherinia 4 Distributed System Dr‬‬
‫‪JabEhdari‬‬
‫‪Peer to Peer‬‬
‫• همه کامپوننت ها (پراسس ها) از لحاظ ارتباط متقارن (‪ )symmetric‬هستند‬
‫(بر خالف ‪.)C/S‬‬
‫• پراسس ها ‪ servent‬هستند‪.‬‬
‫• همه پراسس ها معادل بوده و هیچکدام نقش خاص ی را ندارند که دیگری نتواند‬
‫انجام دهد‪.‬‬
‫• ارتباطی که پراسس ها با یکدیگر دارند را شبکه فوقانی ( ‪overlay‬‬
‫‪ ) network‬گویند‪.‬‬
‫• دیگر یک نقطه شکست (‪ )server‬وجود ندارد‪.‬‬
‫‪By Ali Bagherinia 4 Distributed System Dr‬‬
‫‪JabEhdari‬‬
What is P2P?
• “the sharing of computer resources and
services by direct exchange of information”
By Ali Bagherinia 4 Distributed System Dr
JabEhdari
What is P2P?
 “P2P is a class of applications that take
advantage of resources – storage, cycles,
content, human presence – available at the
edges of the Internet. Because accessing
these decentralized resources means
operating in an environment of unstable and
unpredictable IP addresses P2P nodes must
operate outside the DNS system and have
significant, or total autonomy from central
servers”
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
What is P2P?

A distributed system
architecture






No centralized control
Typically many nodes, but
unreliable and heterogeneous
Nodes are symmetric in function
Take advantage of distributed,
shared resources (bandwidth,
CPU, storage) on peer-nodes
Fault-tolerant, self-organizing
Operate in dynamic
environment, frequent join and
leave is the norm
By Ali Bagherinia 4 Distributed System Dr JabEhdari
Internet
What is P2P?
 Various definitions seem to agree on
sharing of resources
 direct communication between equals (peers)
 no centralized control

By Ali Bagherinia 4 Distributed
System Dr JabEhdari
What is a peer?
 “…an entity with capabilities similar
to other entities in the system.”
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
Client/Server Limitations
 Scalability is hard to achieve
 Presents a single point of failure
 Requires administration
 Unused resources at the network edge
 P2P systems try to address these
limitations
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
P2P Architecture
 All nodes are both
clients and servers


Provide and consume
data
Any node can initiate a
connection
Node
 No centralized data
Internet
source


“The ultimate form of
democracy on the
Internet”
“The ultimate threat to
copy-right protection
on the Internet”
Node
Node
Node
Node
* Content from http://project-iris.net/talks/dht-toronto-03.ppt
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
‫انواع شبکه فوقانی‬
)structured( ‫ ساخت یافته‬-1
)non- structured( ‫ غیر ساخت یافته‬-2
By Ali Bagherinia 4 Distributed System Dr
JabEhdari
Structured p-to-p
•
•
•
•
•
Based on Distributed Hash Table
Data itme: assign a random key
Node: assign a random number
Scheme for assign data item to node: deterministic
Look up (request for data item on the node→ routing
): deterministic scheme
By Ali Bagherinia 4 Distributed System Dr
JabEhdari
Peer2peer ‫انواع‬
Structured P2P
 Chord
 CAN
Unstructured P2P
Gnutella
By Ali Bagherinia 4 Distributed System Dr
JabEhdari
‫‪Chord‬‬
‫•‬
‫•‬
‫•‬
‫•‬
‫•‬
‫یک شبکه فوقانی با ساختار منطقی حلقه دارد‪.‬‬
‫‪Random number for node‬‬
‫‪Random number for data item‬‬
‫انتساب یک ‪ data item‬با کلید ‪ k‬به یک گره‪ :‬از گرهی با شماره ‪ k‬نگاه‬
‫کرده و‪ k‬را اولین گرهی که پیدا شد‪ ،‬انتساب می دهیم‪.‬‬
‫{)‪assign(data item k‬‬
‫‪succecor(k)=id ≥k‬‬
‫}‬
‫یک گره ممکن است در بردارنده چندین ‪ data item‬باشد‪.‬‬
‫‪By Ali Bagherinia 4 Distributed System Dr‬‬
‫‪JabEhdari‬‬
chord
By Ali Bagherinia 4 Distributed System Dr
JabEhdari
Chord State and Lookup (1)

Basic Chord: each node
knows only 2 other
nodes on the ring



Successor
Predecessor (for ring
management)
Lookup is achieved by
forwarding requests
around the ring through
successor pointers

Requires O(N) hops
m=6
2m-1 0
N1
N56
K54
N8
lookup(K54)
N51
N14
N48
N42
N21
N38
N32
By Ali Bagherinia 4 Distributed System Dr JabEhdari
Chord State and Lookup (2)

Each node knows m
other nodes on the ring




Successors: finger i of n
points to node at n+2i (or
successor)
Predecessor (for ring
management)
O(log N) state per node
Lookup is achieved by
following closest
preceding fingers, then
successor

Finger table
N8+1
N8+2
N8+4
N8+8
N8+16
N8+32
m=6
2m-1 0
N1
N56
K54
lookup(K54)
N14
N14
N14
N21
N32
N42
N8
+1
+2
N51
+4
N48
+16
N14
+8
+32
N42
N21
N38
O(log N) hops
N32
By Ali Bagherinia 4 Distributed System Dr JabEhdari
Lookup
Lookup(data item key){
succecor(key)
}
‫ که بدانجا‬،‫ هست‬node ‫ در کدام‬key ‫ی با کلید‬Data item •
.‫ارتباط پیدا کنیم‬
By Ali Bagherinia 4 Distributed System Dr
JabEhdari
Membership management
‫• مدیریت عضویت یعنی اینکه گره ها چگونه در شبکه فوقانی سازماندهی‬
‫ (نود جدیدی می خواهد وارد حلقه‬join ‫می شوند؟ که شامل دو عمل‬
.‫ می باشد‬leave ‫شود) و‬
Join
1- generate a random number id
2- look up (id)→ successor (id)
3- contact to successor (id) & predecessor (id)
4- insert id between them (successor (id) & predecessor (id))
4- data item(s) transferred from successor (id) to id
By Ali Bagherinia 4 Distributed System Dr
JabEhdari
Leave
1- Id node informs successor (id) & predecessor
(id) for leaving
2- transfer data items from id to successor (id)
By Ali Bagherinia 4 Distributed System Dr
JabEhdari
‫‪CAN ( Content Addressable‬‬
‫)‪Network‬‬
‫‪ ‬دارای یک فضای ‪ d‬بعدی می باشد‪.‬‬
‫‪ ‬فضا به تعداد ‪node‬ها تقسیم می شود‪.‬‬
‫‪ ‬همانند ‪ chord‬گره ها و ‪data item‬ها دارای ‪ id‬و ‪key‬‬
‫منحصربفرد هستند‪.‬‬
‫‪ ‬در هر ناحیه (مستطیل) نقطه مرکز ناحیه با مختصات )‪ (x,y‬به عنوان‬
‫‪ node‬در نظر گرفته شده که )‪ (x,y‬همان ‪id‬گره می باشد‪.‬‬
‫‪ ‬هر ‪data item‬ی که مختصاتش (کلیدش) در ناحیه بیفتد به آن‬
‫‪( node‬مرکز مستطیل) منتسب می شود‪.‬‬
‫مثال‪ :‬در شکل ‪data item‬ی با کلید )‪ (0.15, 0.25‬به گره ‪(0.2,‬‬
‫)‪ 0.3‬منتسب می شود‪.‬‬
‫‪By Ali Bagherinia 4 Distributed‬‬
‫‪System Dr JabEhdari‬‬
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
Membership mangement in CAN
 Join
1- pick an arbitrary point p for node id
2- look up( p)→ find a region with Q center
3- split the region to segment
4- p finds data items by asking Q
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
 Leave
.‫ می باشد‬join ‫عمل ترک کردن دشوارتر از‬
1- region (of leaved node) assign to one of
the its neighbors
2- a background process periodically
reapportioned entire space
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
CAN (Berkeley)

Cartesian space (ddimensional)



d=2
hx(k)
insert(k,data)
Space wraps up: d-torus
Incrementally split
space between nodes
that join
Node (cell) responsible
for key k is determined
by hashing k for each
dimension
4
hy(k)
By Ali Bagherinia 4 Distributed System Dr JabEhdari
2
2
1
1
2
retrieve(k)
3
CAN State and Lookup

A node A only maintains
state for its immediate
neighbors (N, S, E, W)


d=2
2d neighbors per node
B
Messages are routed to
neighbor that minimizes
Cartesian distance


More dimensions means
faster the routing but also
more state
(dN1/d)/4 hops on average
N
W
A
S

Multiple choices: we can
route around failures
By Ali Bagherinia 4 Distributed System Dr JabEhdari
E
‫‪Unstructured p-to-p‬‬
‫•‬
‫طرح ساخت شبکه فوقانی قطعی نیست بلکه الگوریتم های آن ‪ random‬می باشند‪.‬‬
‫•‬
‫هر ‪ node‬الزم نیست تمام شبکه را بشناسد‪ ،‬بلکه تعدادی (‪c‬تا) از همسایه های خودش را می‬
‫شناسد (‪ .)partial view‬شبکه فوقانی بسیارشبیه شبکه ‪ Graph random‬می شود‪.‬‬
‫هر ‪ node‬دارای جدولی با ‪c‬مدخل بوده که هر مدخل دربردارنده ‪id‬همسایه و ‪age( age‬بیشتر‬
‫یعنی ارجاع کمتر (قدیمی تر)) بوده که بر اساس ‪ age‬مرتب می شود‪.‬‬
‫برای اینکه ‪ partial view‬درست باشد (ممکن است‪ node‬هایی رفته و ‪node‬هایی آمده باشند)‬
‫‪node‬ها می بایست بطور مرتب اطالعات خود (مدخل های جداولشان) را ردوبدل نمایند‪.‬‬
‫هر گره ‪ c/2+1‬از مدخل باالیی اش را ارسال می کند‪.‬‬
‫‪c‬تا مدخلش را مرتب کرده‬
‫‪ c/2+1‬مدخل پایینی اش را حذف می کند‬
‫•‬
‫•‬
‫‬‫‬‫‪-‬‬
‫‪By Ali Bagherinia 4 Distributed System Dr‬‬
‫‪JabEhdari‬‬
‫• که با هر ‪exchange‬ی ‪ age‬یک واحد افزایش می یابد‪.‬‬
‫• اگر به هر کدام از ‪data item‬ها مراجعه شود ‪age‬ش صفر می‬
‫شود‪.‬‬
‫• برای ‪ exchange‬بهتر است نود ترکیب ‪ push‬و ‪ pull‬باشد وگرنه‬
‫شبکه فوقانی به صورت جزیره جزیره (‪node‬ها بدون ارتباط) می‬
‫شود‪.‬‬
‫‪By Ali Bagherinia 4 Distributed System Dr‬‬
‫‪JabEhdari‬‬
‫‪Membership management in unstru..‬‬
‫‪• Join‬‬
‫گره جدید با یکی از ‪node‬های شبکه ( ‪well known access‬‬
‫‪ )point‬به صورت تصادفی تماس گرفته و لیست همسایه هایش را‬
‫بدست آورده و خودش را را در لیست آن گره وارد می کند‪.‬‬
‫‪• Leave‬‬
‫خیلی ساده‪،‬هیچ کاری الزم نیست انجام دهد‪ ،‬زیرا به آن دیگر مراجعه‬
‫نشده و ‪age‬ش به تدریج زیاد شده و بتدریج از لیست ها ‪ discard‬می‬
‫شود‪.‬‬
‫‪By Ali Bagherinia 4 Distributed System Dr‬‬
‫‪JabEhdari‬‬
P2P Network Characteristics
 Clients are also servers and routers
 Nodes contribute content, storage, memory, CPU
 Nodes are autonomous (no administrative
authority)
 Network is dynamic: nodes enter and leave the
network “frequently”
 Nodes collaborate directly with each other (not
through well-known servers)
 Nodes have widely varying capabilities
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
‫ها‬overlay network ‫ترکیب‬
 Two layered approach
 Super peers
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
P2P Applications
 File sharing (Napster, Gnutella, Kazaa)
 Multiplayer games (Unreal Tournament, DOOM)
 Collaborative applications (ICQ, shared whiteboard)
 Distributed computation (Seti@home)
 Ad-hoc networks
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
P2P Goals and Benefits

Efficient use of resources


Scalability






Nodes self-organize
Built-in fault tolerance, replication, and load balancing
Increased autonomy

not easy in a centralized system


Replicas
Geographic distribution
No single point of failure
Ease of administration


No central information, communication and computation bottleneck
Aggregate resources grow naturally with utilization
Reliability


Unused bandwidth, storage, processing power at the “edge of the network”
Anonymity – Privacy
Dynamism


highly dynamic environment
ad-hoc communication and collaboration
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
P2P Goals/Benefits
 Cost sharing
 Resource aggregation
 Improved scalability/reliability
 Increased autonomy
 Anonymity/privacy
 Dynamism
 Ad-hoc communication
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
P2P Challenges
 Decentralization
 Scalability and Performance
 Anonymity
 Fairness
 Dynamism
 Security
 Transparency
 Fault Resilience and Robustness
By Ali Bagherinia 4 Distributed
System Dr JabEhdari
Popular file sharing P2P Systems
 Napster, Gnutella, Kazaa, Freenet
 Large scale sharing of files.
 User A makes files (music, video, etc.) on their
computer available to others
 User B connects to the network, searches for
files and downloads files directly from user A
 Issues of copyright infringement
By Ali Bagherinia 4 Distributed
System Dr JabEhdari