Resource Discovery for the Web Platform using a P2P Overlay Network with WebRTC as the layer of...

73
HI, I’M DAVID ://daviddias.me ://blog.daviddias.me ://github.com/diasdavid ://twitter.com/daviddias

Transcript of Resource Discovery for the Web Platform using a P2P Overlay Network with WebRTC as the layer of...

HI, I’M DAVID://daviddias.me://blog.daviddias.me://github.com/diasdavid://twitter.com/daviddias

RESOURCE DISCOVERY

RESOURCE DISCOVERY FOR THE WEB PLATFORM ON TOP OF A P2P

OVERLAY NETWORK USING WEBRTC AS THE LAYER OF TRANSPORT

THE INTERNET

MEMEX

URL

{“KEY” : ”VALUE”

}

GET http://recipes.com/francesinha

GET http://recipes.com/latest

GET http://recipes.com/latest

GET http://recipes.com/latest

GET http://recipes.com/latest LB

GET http://recipes.com/latest LB

Centralized

GET http://recipes.com/latest

L

L L

L

DECENTRALISED ARCHITECTURES

P2P networks are only as useful as their Resource Discovery capabilities remain efficient when they scale up

GNUTELA 0.4

• march 2000, Justin Frankel and Tom Pepper

• topology is completely random

• routing and search using flooding with TTL and hop counter

• really slow

• lot’s of signalling traffic

GNUTELA 0.6

UNSTRUCTURED P2P NETWORKS

Without an implicit way to organize content

STRUCTURED P2P NETWORKS

CHORD

• DHT

• Highly scalable

• Each node only knows of m number of other nodes

• Each node has a unique identifier

• Each node is responsible for a segment of the data

• Ids are 160 bits (SHA-1 for Uniform Distribution)

• CHORD is awesome

02160

• 160 bit namespace

0

1

2

3

4

5

6

7

• 3 bit namespace

• Id = hash(IP)

0

1

2

3

4

5

6

7

• each node is responsible for a segment

0

1

2

3

4

5

6

7

• minimum requirement - each node has to know their successor

0

1

2

3

4

5

6

7

• each node is going to have it’s finger table

start interval sucessor

start(k) = (n+2k-1) mod 2m, 1 ≤ k ≤ m

interval(k) = start(k) = start(k+1)

sucessor - first node after start(k)

0

1

2

3

4

5

6

7

start interval sucessor

start(k) = (n+2k-1) mod 2m, 1 ≤ k ≤ minterval(k) = [start(k), start(k+1) )sucessor - first node after start(k)

0

1

2

3

4

5

6

7

start interval sucessor1

start(k) = (n+2k-1) mod 2m, 1 ≤ k ≤ minterval(k) = [start(k), start(k+1) )sucessor - first node after start(k)

interval(k) = [(0+2*1-1) mod 23 ,(0+2*2-1) mod 23) =[1,2)

0

1

2

3

4

5

6

7

start interval sucessor1 [1,2) 1

start(k) = (n+2k-1) mod 2m, 1 ≤ k ≤ minterval(k) = [start(k), start(k+1) )sucessor - first node after start(k)

interval(k) = [(0+2*1-1) mod 23 ,(0+2*2-1) mod 23) =

0

1

2

3

4

5

6

7

start interval sucessor1 [1,2) 12

start(k) = (n+2k-1) mod 2m, 1 ≤ k ≤ minterval(k) = [start(k), start(k+1) )sucessor - first node after start(k)

interval(k) = [(0+2*2-1) mod 23 ,(0+2*3-1) mod 23)

0

1

2

3

4

5

6

7

start interval sucessor1 [1,2) 12 [2,4) 3

start(k) = (n+2k-1) mod 2m, 1 ≤ k ≤ minterval(k) = [start(k), start(k+1) )sucessor - first node after start(k)

interval(k) = [(0+2*2-1) mod 23 ,(0+2*3-1) mod 23)

0

1

2

3

4

5

6

7

start interval sucessor1 [1,2) 12 [2,4) 34

start(k) = (n+2k-1) mod 2m, 1 ≤ k ≤ minterval(k) = [start(k), start(k+1) )sucessor - first node after start(k)

interval(k) = [(0+2*3-1) mod 23 ,(0+2*4-1) mod 23)

0

1

2

3

4

5

6

7

start interval sucessor1 [1,2) 12 [2,4) 34 [4,0) 6

start(k) = (n+2k-1) mod 2m, 1 ≤ k ≤ minterval(k) = [start(k), start(k+1) )sucessor - first node after start(k)

interval(k) = [(0+2*3-1) mod 23 ,(0+2*4-1) mod 23)

• API drafted by W3C

• enables voice, video and data transfer between browsers in a P2P fashion

DEMO

WEBRTC-EXPLORER

• Chord inspired P2P overlay network designed for the Web Platform

• Uses CHORD routing scheme

• Uses WebRTC for transport

• WebSockets for Signalling

• Peers (browsers) route messages amongst them

• 48 bits Ids

• Brings a full DHT to the browser

WEBRTC-EXPLORER

WEBRTC-RINGhttp://blog.daviddias.me/2014/12/20/webrtc-ring

HOW DOES IT WORK

var Explorer = require(‘webrtc-explorer’);

var config = { signalingURL: '<url>'};

var peer = new Explorer(config);

peer.events.on(‘registered', function(data) { console.log('Id:', data.peerId);});

peer.events.on('ready', function() { console.log('ready to send messages');});

peer.events.on('message', function(envelope) { console.log(envelope);});

peer.register();

//peer.send(‘<dst_id>’, <data_to_send>);

s-register

c-registered{

id: “<this_node_id>”}

1

2

c-finger-update

c-finger-update

c-finger-update

s-send-offer

c-offer-accepted

1

4

s-accept-offer

s-offer-accepted

2

3

5

DEMO

PAPERS• A study on peer-to-peer based discovery of grid resource information by

Rajiv Ranjan, Aaron Harwood, Rajkumar Buyya

• Peer-to-peer architecture case study: Gnutella network by M. Ripeanu

• Dynamo : Amazon ’ s Highly Available Key-value Store by Giuseppe DeCandia, Deniz Hastorun, Madan Jampani, Gunavardhan Kakulapati, Avinash Lakshman, Alex Pilchin, Swaminathan Sivasubramanian, Peter Vosshall, Werner Vogels

• The Gnutella Protocol Specification v0.6 by Tor Klingberg, Raphael Manfredi

• Chord : A Scalable Peer-to-peer Lookup Service for Internet by Ion Stoica, Robert Morris, David Karger, M Frans Kaashoek, Hari Balakrishnan Ý

THANK YOU! :D