• Non ci sono risultati.

Peer to Peer

N/A
N/A
Protected

Academic year: 2021

Condividi "Peer to Peer"

Copied!
63
0
0

Testo completo

(1)

Architectural styles for software systems

Peer to Peer

Prof. Paolo Ciancarini Software Architecture CdL M Informatica Università di Bologna

(2)

Agenda

n

P2P: overview

n

Basic types of P2P systems

n

Case study: Skype

n

Case study: Bitcoin

(3)

Peer to peer computing

n

a class of applications that takes advantage of resources— storage, cycles, content, humans — available at the edges of the Internet

n

Because accessing these decentralized resources means operating in an environment of unstable

connectivity and unpredictable IP addresses, peer- to-peer nodes must operate outside the DNS

system and have autonomy from central servers

(4)

Layers in P2P

The overlay network layer is responsible for implementing an efficient routing algorithm: the nodes in the system are structured in order to decrease the search steps necessary to find the target identifier.

Each node maintains a local routing table, which holds the identifiers of other

(5)

Distributed hash tables

A distributed hash table (DHT) provides a lookup service

similar to a hash table: (key, value) pairs are stored in a DHT,

and any participating node can efficiently retrieve the value

associated with a given key

(6)

Distributed ledgers and blockchains

Distributed ledger

Blockchain

(7)

Distributed ledgers vs blockchains

(8)

n

A P2P system is a distributed collection of peer nodes

n

Each node is able to provide services, as well as to make requests, to other nodes

n

Each node acts as both a server and a client

n

The goal of this style:

n

To share resources and services (data, CPU, disk,…)

P2P: Overview

(9)

Peer-to-peer systems

n

File sharing systems based on BitTorrent

n

Messaging systems such as Jabber

n

Blockchains – Bitcoin and Ethereum

n

Databases – Freenet is a decentralized database

n

Phone systems – Viber or Skype

n

Computation systems - SETI@home

(10)

n

Typical functional characteristics of P2P systems:

n

File sharing system

n

File storage system

n

Distributed file system

n

Redundant storage

n

Distributed computation

n

Typical non-functional requirements:

n

Availability

n

Reliability

n

Performance

n

Scalability

P2P: requirements and drivers

(11)

Peer: CRC

Class Peer Responsibilities

•Component

•Handles User interaction

•Asks other Peers for searching some data

•Asks some Peers for obtaining some data

Collaborators

(12)

P2P: Brief History

n

Although they were proposed several years ago, they mainly evolved in the last 20 years

n

File sharing systems showed the power of the concept (Napster, 1999; Gnutella, 2000)

n

In 2000, the Napster client was downloaded in few days by 50 millions users

n

Traffic peak of 7 TB in a day

n

Gnutella followed Napster’s footprint

n

The first release was delivered in 2003

n

In June 2005, Gnutella's population was 1.81 million

computers; in 2007, it was the most popular file sharing network with an estimated market share > 40%

n

Host servers are listed at gnutellahost.com

(13)

The phases of a P2P application

A P2P application is organized in three phases:

n

Boot: a peer connects to the network and actually performs the connections (remark: P2P boot is rare)

n

Lookup: a peer looks for a provider of a given service or information (generally providers are SuperPeers)

n

Resource sharing: resources (requested and found)

are delivered, usually in several segments

(14)

P2P resource sharing example: bitTorrent

(15)

P2P: Classification

n

There are three types of P2P architecture, different with respect to the lookup phase:

n

Centralized

n Centralized network architecture uses a centralized indexed server to maintain a database of all the content and users at any time

n The database is updated whenever a peer logs on to the network

n

Decentralized (Pure P2P)

n Each peer acts as an index server, searches and holds its own local resources, and as a router, relaying queries between peers

n

Hybrid Architecture

n Deploys a hierarchical structure by establishing a backbone network of Super Nodes that take on the characteristics of a central index server

(16)

P2P: Centralized Index

n

There is a centralized index used to search the information

n

When peer connects, it informs central server:

n IP address

n Content

n

File transfer is decentralized, but locating content is highly centralized

n

Example: Napster

Copyright © Tore Mørkved, Peer-to-Peer Programming with Wireless Devices

(17)

Centralized: Architecture

n

Components:

n Peer

n An entity with capabilities similar to other entities in the system

n Each node is both a server and a client

n Autonomous: no administrative authority

n Unreliable: nodes enter and leave the network “frequently”

n Index Server

n An entity with special capabilities:

n Allow peer to join the system

n Allow the research of content

n Maintain a database of all the content and users at any time, which is updated whenever a peer logs on to the network

n

Connectors:

n Network protocol

n Often specialized for P2P communication

(18)

Centralized Index: Component Diagram

(19)

Centralized Index: Class Diagram

Peer

+ FileTransfer()

requester

provider

*

* Directory Index

+ Search() + Login()

1 *

(20)

Centralized Index: Sequence Diagram

(21)

Centralized Index Example: Napster

(22)

Centralized Index: Pro & Cons

n

Benefits:

n

Low per-node state

n

Limited bandwidth usage

n

High success rate

n

Fast search response time

n

Easy to implement and maintain

n

Pitfalls:

n

Single point of failure

n

Vulnerable to censorship

n

Limited scale

n

Possibly unbalanced load

(23)

P2P: Decentralized

n

Decentralized P2P organizes the overlay network as a random graph

n

Each node knows about a subset of nodes, its “neighbors”

n Neighbors are chosen in different ways:

n physically close nodes, nodes that joined at about the same time, etc.

n

Example: Gnutella, Bitcoin

Copyright © Tore Mørkved, Peer-to-Peer Programming with Wireless Devices

(24)

Decentralized : Class Diagram

Peer

service1() service2() serviceN()

requester

provider

*

*

(25)

Decentralized: Architecture

n

Components:

n

Peer

n An entity with capabilities similar to other entities in the system

n Each node is both a server and a client

n Autonomous: no administrative authority

n Unreliable: nodes enter and leave the network “frequently”

n Local knowledge: nodes only know a small set of other nodes

n

Connectors:

n

Network protocol

n Often specialized for P2P communication

(26)

Decentralized Example: Gnutella

(27)

Decentralized: Component Diagram

(28)

Decentralized: Sequence Diagram (1)

(29)

Decentralized: Sequence Diagram (2)

(30)

Decentralized: Pro & Cons

n

Benefits:

n

Limited per-node state

n

Fault tolerant

n

Pitfalls:

n

High bandwidth usage

n

Long time to locate item

n

No guarantee on success rate

n

Possibly unbalanced load

(31)

P2P: Hybrid Architecture

n

Deploys a hierarchical structure by establishing a backbone network of Super Nodes that take on the characteristics of a central index server

n

When a client logs on to the network, it makes a direct connection to a single Super Peer

Example: Skype

Copyright © Tore Mørkved, Peer-to-Peer Programming with Wireless Devices

(32)

Example: Skype

(33)

Hybrid: Architecture

n

Components:

n Peer

n An entity with capabilities similar to other entities in the system

n Each node is both a server and a client

n Autonomous: no administrative authority

n Unreliable: nodes enter and leave the network “frequently”

n Super Peer

n Gathers and stores information about peer and content available for sharing

n Act as servers to regular peer nodes, peers to other super Peers

n Maintain indexes to some or all nodes in the system

n

Connectors:

n Network protocol

n Often specialized for P2P communication

(34)

Hybrid Architecture: Component Diagram

(35)

Hybrid Architecture: Class Diagram

Simple Peer

requester

provider

*

*

Super Peer

Search() Login()

Peer

FileTransfer()

DisseminateQuery()

(36)

Hybrid Architecture: Sequence Diagram

(37)

Hybrid Architecture Example: Skype (1)

(38)

Hybrid Architecture Example: Skype (2)

n

A mixed client-server and peer-to-peer architecture addresses the discovery problem

n

Replication and distribution of the directories, in the form of supernodes, addresses the scalability problem and robustness problem encountered in Napster

n

Promotion of ordinary peers to supernodes based upon network and processing capabilities addresses another aspect of system performance:

n

“not just any peer” is relied upon for important services

(39)

Hybrid Architecture Example: Skype (3)

n

A proprietary protocol employing encryption provides privacy for calls that are relayed through supernode intermediaries

n

Restriction of participants to clients issued by

Skype, and making those clients highly resistant

to inspection or modification, prevents malicious

clients from entering the network

(40)

Hybrid Architecture: Pro & Cons

n

Benefits:

n

Manageable per-node state

n

Manageable bandwidth usage and time to locate item

n

Guaranteed success

n

Pitfalls:

n

Possibly unbalanced load

n

Harder to support fault tolerance

(41)

Bitcoins

n

Bitcoins are based on the idea of avoiding to let to spend twice the same digital coin using a chain of transactions recorded in a shared ledger

n

The Bitcoin system is the blockchain, a P2P

architecture, and transactions take place between anonimous users directly, without an intermediary

n

These transactions are verified by network nodes

and recorded in a public distributed ledger called a

blockchain

(42)

Bitcoin: dynamics

(43)

Bitcoins are finite, and some are lost forever

http://www.coinbuzz.com/2015/03/31/23-bitcoins-mined-13-may-lost/

(44)

Bitcoin wallet interface

(45)
(46)
(47)

Bitcoin nodes

Bitcoin node: main functions

(48)
(49)

Bitnodes

(50)

Bitcoin architecture

(51)

Anonimity

n

Bitcoin addresses are not tied to people

n

Transactions are not tied to people

n

Transaction data is transmitted to a random subset of nodes

n

However, there are some (expensive) methods to

de-anonymize a user, so Bitcoin is not perfectly

anonymous

(52)

Moving bitcoins between wallets

(53)

Bitcoin

(54)
(55)

Blockchain

(56)

Implementing bitcoins: blockchain

n

Each bitcoin (BTC) node retains a copy of the global, publicly shared blockchain.

n

the Blockchain has 380K+ Blocks.

n

Each Block has one or more validated BTC Transactions embedded within it.

n

Via the interface facilities provided by a

BTC Node, a User composes a Transaction and submits it to the network for validation and execution.

n

Each instance of a BTC Transaction contains a source address, destination

address, the BTC amount to be transacted,

and the source address owner’s signature

.

(57)

Bitcoin vs Ethereum

n

Since the sw infrastructure is open source, it is easy to develop new cryptocurrencies

n

The difference between Bitcoin and Ethereum is that Bitcoin is a currency, whereas Ethereum is a ledger technology.

n

Both Bitcoin and Ethereum operate on the

“blockchain”, however Ethereum is more robust.

n

Ethereum supports the building of decentralized

applications – smart contracts

(58)

Smart contracts are agents

n

A smart contract is a set of promises, specified in digital

form, including protocols within which the parties perform on these promises

n

A smart contract is a general purpose computation that takes place on a blockchain

n

The bitcoin is limited to the currency use case; ethereum replaces bitcoin's restrictive language (a scripting language of a hundred scripts) and replaces allowing developers to write their own programs

n

Smart contracts are similar to autonomous agents

(59)

Conclusions

n

P2P networks are quite old: the Internet is a P2P

n

Several new applications are implemented as p2p

n

Blockchains are a powerful architecture for

innovative financial applications

(60)

Self test

n

Which architectural drives support P2P applications?

n

What is an overlay network?

n

What is the relationship between p2p and C/S?

n

What is a hybrid p2p system?

n

What is a blockchain?

(61)

References

n Raval, Decentralized applications, O’Reilly 2016

n Grolimund, A Pattern Language for Overlay Networks in Peer-to-Peer Systems, EuroPloP 2006

n Ripeanu, Peer-to-peer architecture case study: Gnutella network, 2001

n Nakamoto, Bitcoin: A Peer-to-Peer Electronic Cash System, 2008

n Wang, Skype VoIP service-architecture and comparison, 2005

n Amoretti e Zanichelli, P2P-PL: A Pattern Language to Design Efficient and Robust Peer-to-Peer Systems, 2016

n Zheng, An Overview of Blockchain Technology: Architecture, Consensus, and Future Trends, IEEE BigData, 2017

(62)

Useful resources

n http://www.disruptivetelephony.com/2010/11/a-brief-primer-on-the-tech-behind-skype- p2psip-and-p2p-networks.html

n https://en.bitcoin.it/wiki/Help:FAQ

n http://www.vamsitalkstech.com/?cat=2

n https://www.theverge.com/2013/12/19/5183356/how-to-steal-bitcoin-in-three-easy-steps

n https://github.com/ethereum/wiki/wiki/White-Paper

(63)

Questions?

Riferimenti

Documenti correlati

We show an interesting relationship between the convergents of bifurcating continued fractions related to a couple of cubic irrationalities, and a particular generalization of

La costruzione dei saperi ludici attraverso la Ricerca Azione Partecipativa e il Teatro Tra gli approcci metodologici della Pedagogia ludica applicabile nei contesti

KEEx, each community of knowing (or Knowledge Nodes (KN), as they are called in [Bonifacio 02a]) is represented by a peer, and the two principles above are implemented

Method: 125 Bipolar Disorder and 60 Major Depressive Disorder patients were administered an Italian translation of the BDRS (I-BDRS), Hamilton Depression Rating Scale

In many models, specific algorithms/ mechanisms are adopted to optimize the bidding process and different methods (e.g. game-theoretic approaches [29] ) are used

provide only simulation-based experimental evaluations of the protocol properties, we started from this basing building block of clock synchronization (i.e. a mean) in order to

The comparison points out an interesting trade-off between reliability, in terms of guaranteeing overlay connectivity at any churn rate, and scalability in terms of creating

Horowitz and Malkhi [9]propose a scheme for dynamically estimating net- work size at each node of the network as the network evolves (that is, nodes join and leave the network),