GithubHelp home page GithubHelp logo

daviddias / webrtc-explorer Goto Github PK

View Code? Open in Web Editor NEW
286.0 20.0 37.0 4.79 MB

:earth_africa: P2P Network Routing Overlay designed for the Web platform (browsers)

License: MIT License

JavaScript 100.00%

webrtc-explorer's Introduction

Dependency Status js-standard-style

tl;dr webrtc-explorer is a Chord inspired, P2P Network Routing Overlay designed for the Web platform (browsers), using WebRTC as its layer of transport between peers and WebSockets for the exchange of signalling data (setting up a connection and NAT traversal). Essentially, webrtc-explorer enables your peers (browsers) to communicate between each other without the need to have a server to be the mediator.

Usage

Install

> npm install webrtc-explorer

If you want to use the Signalling Server that comes with webrtc-explorer, you can use it through your terminal after installing webrtc-explorer globally

> npm install webrtc-explorer --global
# ...
> sig-server
Signalling Server Started
# now the signalling server is running

Use browserify to load transpile your JS code that uses webrtc-explorer, so that all of the dependencies are correctly loaded.

API

const explorer = require('webrtc-explorer')

listen

Connects your explorer node to the signalling server, and listens for incomming connections from other peers.

const listener = explorer.createListener((socket) => {
  // socket with another peer
})

listener.listen((err) => {
  if (err) {
    return console.log('Error listening:', err)
  }
  console.log('explorer is now listining to incomming connections')
})

dial

Dials into another peer, using the P2P Overlay Routing.

const socket = explorer.dial(<peerId> [, <readyCallback>])

Note: since an explorer node routes messages for other peers and itself, it needs first to be ready to 'listen', in order to be able to use the network to send.

updateFinger

not implemented yet

updates a finger on the finger table (if no finger was present on that row, it is added).

explorer.updateFinger(<row>)

updateFingerTable

not implemented yet

updates all the rows on the finger table that already had a peer

explorer.updateFingerTable(<row>)

Architecture

Signalling

Currently signalling is performed through a central server. The signalling throught the Chord routing is under development.

Routing

To understand fully webrtc-explorer's core, it is important to be familiar with the [Chord][chord-paper].

I've delivered a talk before about an earlier version of webrtc-explorer, where I explain the routing scheme, you can find it here: https://youtu.be/fNQGGGE__zI?t=13m33s

Connection State

Connections in webrtc-explorer are very similar to typical network socket. Before going to the network, the messages are encasulated with srcId and dstId so that they be routed through the Chord routing (parallel to the encasulation with TCP headers, IP headers, etc)

Notes and other properties

  • Ids have 48 bits (so that is a multiple of 4 (for hex notation) and doesn't require importing a big-num lib to handle over 53 bits operations)
  • The number of fingers of each peer is flexible, however it is recommended to not pass 16 per node (due to browser resource constraints)
  • Each peer is responsible for a segment of the hash ring

Initial Development and release was supported by INESC-ID (circa Mar 2015)

David Dias MSc in Peer-to-Peer Networks by Technical University of Lisbon

This work was developed by David Dias with supervision by Luís Veiga, all in INESC-ID Lisboa (Distributed Systems Group), Instituto Superior Técnico, Universidade de Lisboa, with the support of Fundação para a Ciência e Tecnologia.

More info on the team's work at:

If you use this project, please acknowledge it in your work by referencing the following document:

David Dias and Luís Veiga. browserCloud.js A federated community cloud served by a P2P overlay network on top of the web platform. INESC-ID Tec. Rep. 14/2015, Apr. 2015

webrtc-explorer's People

Contributors

couto avatar daviddias avatar reggi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webrtc-explorer's Issues

RFC - Where to go next

There are a collection of things that I have in the top of my mind that could be done next, in order to make the project more interesting and useful for more people. I'm sure there might be a lot of use cases I still don't know yet, if you have one or anything you would like webrtc-explorer to do, please go ahead and share :)

  • Hybrid nodes - make webrtc-explorer both work on the browser and in node
  • Improve performance
    • Put RTCPeerConnections inside WebWorkers (when the WebRTC API is available inside a WebWorker)
  • Decentralised signalling - Enable to do signalling through the DHT, instead of using always the signalling server
  • Self healing - let the peers restore DHT state, if the signalling server goes down

Other ideas:

  • Right now routing works in a Store and Forward mode (like IP or DNS recursive mode), but it can be interesting to see if an iterative mode (like bittorrent or DNS iterative mode) could be also be practical and offer any benefit

Using several Explorer objects within one browser tab

Hi,

I want to use several peers (Explorer objects) within one browser tab such that one browser tab can register itself for several peerIDs.

e.g:
var peer = new Explorer(config);
var peer2 = new Explorer(config);

How should/can I modify the program code to make this work?

Reconnect error

Hi,

Hoping you have an idea on what is happening here.

In Chrome, using the re-connection option,

this.reconnection(opts.reconnection !== false);

results in the following error when attempting to connect to another peer:

Failed to set remote answer sdp: Called in wrong state: STATE_INPROGRESS

If I manually reconnect and re-register the peer, I also get this error when connecting to another peer.

Eventually consistent global state

I'm thinking it can be useful if there was a way to create some kind of shared object between all peers and a mechanism to synchronize it.

For example, a bloom filter with an expiration date(while the previous one is valid (not expired) system tries to build the next one.) that stores IDs of all online users. This way we can know in advance if some peer is unavailable.

Removed nonsense

Is this production ready?

Hi @daviddias ,

Is the code base production ready? Also i could not find a way to support media calls (audio, video). Is repo not meant for media calls?

Thanks in advance

Problem with the calculation of the finger table

I think there is a problem with the calculation of the finger table.
If creating less than explorer.min-peers nodes, everything works as expected and the finger table only contains the first finger, linking to its successor.

Increasing the nodes yields a problem. Take a look at the following finger tables:
https://gist.github.com/areiter/3818428f92d99a9e3d6b

It seems like, the calculation of the IDs of the fingers is only based on the local peer ID, and does not take the IDs of other peers into account.
This works fine as long as the IDs start at zero and are increased by one for each peer. In the case of a hash value, with a few nodes in the large ID space, the fingers should consider the IDs of the other nodes: successor(successor(...n)) and so on.

Any ideas on that?
Thanks

Error: Cannot find module 'Hapi'

$ git clone [email protected]:diasdavid/webrtc-explorer-signalling-server.git
$ cd webrtc-explorer-signalling-server/
$ npm install
$ npm start

Error: Cannot find module 'Hapi'
at Function.Module._resolveFilename (module.js:334:15)
at Function.Module._load (module.js:284:25)
at Module.require (module.js:363:17)
at require (module.js:382:17)
at Object. (/home/ds/webrtc-explorer-signalling-server/src/index.js:1:74)
at Module._compile (module.js:428:26)
at Object.Module._extensions..js (module.js:446:10)
at Module.load (module.js:353:32)
at Function.Module._load (module.js:308:12)
at Function.Module.runMain (module.js:469:10)

$ node -v
v2.3.1 (iojs)

System:
Ubuntu 14.04

[question] how is this diffrent then chord?

you said it's Chord inspired.

is it different somehow? I know how chord works, it only knows about peers in a clockwise direction. for ie. if you have 16 peers and 0 wants to send a message to 15. when doing so it has to send a message clockwise kinda like 0 -> 8 -> 12 -> 14 -> 15

But since webrtc needs to be connected to each other 15 has to connect to 0 and therefore 0 should know about peers in both directions (clockwise and anticlockwise). so 0 must be connected to 15 and 1 so the most beneficial would be to send a message in either direction depending on which one are closer to the destination. is that something you are doing?

dial to best candidate

Right now, if a peer with dstId doesn't exist, an error of 'Peer not found' is sent back. It is interesting however, to be able to dial to 'close peer to peerId', so that we can build storage overlays like PAST on top

BigInt

Ids have 48 bits (so that is a multiple of 4 (for hex notation) and doesn't require importing a big-num lib to handle over 53 bits operations)

it can be accomplish with new BigInt(num) and also be subfixed with n like 10n maybe something to consider?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.