twilio signal 2016 bringing p2p to the masses with webrtc
TRANSCRIPT
WEB TORRENTBRINGING P2P TO THE MASSES
WITH WEBRTC
ONCE UPON A TIME...
RESILIENT
NO MIDDLEMEN
DIVERSE
PEOPLE POWERED
P2PPEER TO PEER
P2P ADVANTAGES
> Censorship resistant> Privacy preserving
> User controls their data> Safe against user-hostile changes
P2P APPLICATIONS
> Currency Bitcoin> Web Tor, I2P, Freenet> Storage IPFS, Tahoe
> Computation Ethereum> File sharing BitTorrent, WebTorrent
APPLICATIONS THAT USE P2P
> Communication Skype, Hangouts> Music Spotify
> OS Windows Update> Game Updates Blizzard, EVE Online> Content Delivery Network PeerCDN
CENTRALIZED APPS
> ALL THE REST
SERVER → CLIENT
MAINFRAME → PC → CLOUD → ?
PEER ↔ PEER
P2P APPLICATIONS
> Currency Bitcoin> Web Tor, I2P, Freenet> Storage IPFS, Tahoe
> Computation Ethereum> File sharing BitTorrent, WebTorrent
WEB APPSTRAPPED IN THE BROWSER
DOMAINS, DNS, URLS
WEB ≠ P2P
WHAT IF IT WAS?
The way we code the Web will determine the way we live online. So we need to bake our values
into our code.— Brewster Kahle, Internet Archive
WEB RTCREAL TIME COMMUNICATIONS
DATA CHANNELHIDDEN GEM IN WEBRTC
DATA CHANNEL APIvar channel = peer.createDataChannel()
channel.send('hi')
channel.addEventListener('message', function (event) { console.log('got message: ' + event.data)})
THE ONLY P2P TRANSPORTTHAT WORKS IN THE BROWSER
NAT TRAVERSAL
NO CROSS-ORIGIN POLICY
TRANSPORT ENCRYPTION
WEBRTC DATA CHANNELIS UNIVERSAL
> WebRTC in web apps (desktop & mobile)> WebRTC in desktop apps> WebRTC in mobile apps
> WebRTC in server/cli apps
BUILD P2P APPS
BUILD P2P PROTOCOLS
TORRENT CLIENTFOR THE WEB
DEMO
var WebTorrent = require('webtorrent')
var client = new WebTorrent()
client.add('magnet:...', function (torrent) { var file = torrent.files[0]
// Display the file by adding it to the DOM. // Supports video, audio, image files, and more! file.appendTo('body')})
WEBTORRENT PROTOCOLIS 95% BITTORRENT
BITTORRENT WIRE PROTOCOL
> TCP> uTP (UDP)> WebRTC
BITTORRENT TRACKER PROTOCOL
> HTTP> UDP
> WebSocket
HTTP/UDP TRACKERS
1. Send message to tracker (info hash, IP address, port)2. Receive response with list of peers3. Tracker adds you to list of peers
OFFER. ANSWER.
WEBSOCKET TRACKERS
1. Open WebSocket connection to tracker2. Send message (info hash, WebRTC offers)
3. Receive some WebRTC answers4. Keep WebSocket open to receive remote offers
WIRE PROTOCOL IS 100% THE SAME
BITTORRENT TRACKER PROTOCOL
> HTTP> UDP
> WebSocket
WEBTORRENT ON NPM
> Lightweight (just 75 KB)> Pure JavaScript (no native dependencies)
> Full-featured (magnet uris, dht, tracker, pex)> Stream from files (On-demand piece prioritization)
DESKTOP APP
WEBTORRENT DESKTOP
AIRPLAY, CHROMECAST, CLOSED CAPTIONS
DEMO
ELECTRONBUILD CROSS PLATFORM DESKTOP APPS
WITH JAVASCRIPT, HTML, & CSS
PERFECT FOR WEBTORRENT DESKTOP
PERFECT FOR WEBRTC APPS
NODE.JS + CHROME
ELECTRON INCLUDES WEBRTC
WORKS IN NODE.JS & THE BROWSER
TORRENT TRANSPORTS
> BitTorrent TCP/UDP> WebTorrent WebRTC
TORRENT TRANSPORTS
> Node.js → TCP/UDP
> Browser → WebRTC
> Electron → TCP/UDP, WebRTC
WEBTORRENT DESKTOP ISA HYBRID TORRENT CLIENT
TALKS TO TRADITIONAL TORRENT CLIENTS& BROWSER TORRENT CLIENTS
OS INTEGRATION
AUTO UPDATER
WEBRTC EVERYWHERE
LEARN MOREAT WEBTORRENT.IO
THANKS!SAY HI AT @FEROSS OR FEROSS.ORG