Why WebRTC DataChannel excites me


Published on

Presented at the March 2013 SF WebRTC meetup.

Published in: Technology

Why WebRTC DataChannel excites me

  2. 2. BINARY TYPES INJAVASCRIPTYes binary types exists:ArrayBufferBlobArrayBufferView: Uint8Array, etc.. 2
  3. 3. WHY IS THIS COOLBinary support means we can doanything we want with data 3
  4. 4. BINARY TYPES INJAVASCRIPTDo these things with them:URL.createObjectURL(blob)XHR2WebSocketDataChannel 4
  5. 5. BACK TODATACHANNELVideo and audio is pretty coolBut I’m excited about DataChannelbecause 5
  6. 6. BACK TODATACHANNELArbitrary binary data betweenarbitrary peopleThat is a lot of powerNo permissions. No flags. 6
  7. 7. BUT WAIT THERESMOREBased on UDP – essential whentransmission delay mattersConfigurable with SCTP, for TCP likereliability if you want 7
  8. 8. WHAT I REALIZEDDataChannel fundamentally changesthe web.Data has always flowed betweenserver and client.DataChannel allows client to clientflow 8
  9. 9. THE POSSIBILITIESFile transferFasterNo privacy issuesNo bandwidth costs 9
  10. 10. THE POSSIBILITIESMultiplayer gamesSubstantially higher performancebecause of lower UDP latency +binary data 10
  11. 11. THE POSSIBILITIESHigh frequency events and messagingHigher message rates possible withUDP based transport 11
  12. 12. PRIVACYImagine a decentralized FacebookData actually downloaded from yourbrowser while you browse the web.Seamless experience 12
  14. 14. BROWSERCOMPATIBILITYGoogle Chrome - March 7th 2013 GOOD GOOD GOOD BADNo SCTP implementation = No binary, reliableNot coming until later in 27 14
  15. 15. BROWSERCOMPATIBILITYFirefox – March 7th 2013Nightly 22.0a1 - Several spec issuesbeing fixed RIGHT NOWBug 837919 - WebRTC: RTCPeerConnection constructor: FQDN not yet implemented (only IP-#s).Bug 846110 - PeerConnection ondatachannel callback receives channel in Firefox, butin Chrome an event is passed inBug 837035 - Hook up DataChannel SDP to implementation (in particular port andoptions)Aurora 21.01a2 - Flagless support 15
  16. 16. BROWSERCOMPATIBILITYBinary, reliable, and FF/Chromeinterop in stable versions at most afew months away 16
  17. 17. PROBLEM: JSONI now have a binary DataChannelbetween two browsers.I want to send some binary data. 17
  18. 18. PROBLEM: JSONJSON is an extremely bad choice forbinary data. Base64 uses 37% morebandwidth and is slow toencode/decode.You can never do this in JSON:JSON.stringify({x: 1, y: binary }); 18
  19. 19. PROBLEM: JSONOur DataChannel supports binary,why use string serialization at all?Binary serialization options:MsgPack, Thrift, Avro, BSON,ProtoBufs, BERT, and many more 19
  20. 20. PROBLEM: JSONMessagePack: Most JSON like. Verycompact. No schema, not designedfor typed languages like others.Shitty for Javascript. JS has distinctstring / byte array types unlike manyother dynamic languages. 20
  21. 21. PROBLEM: JSONSolution is simple. Add string type toMessagePack.They hate this.https://github.com/msgpack/msgpack/issues/121https://github.com/msgpack/msgpack/issues/128Talk to me about this afterwards 21
  22. 22. PROBLEM: JSONWith a binary serialization format youcan do this:blob = pack({x: 1, y: binary });unpack(blob)-> {x:1, y: binary}Caveat: JS makes serializing part of UTF8 to binary hard. JSON ismuch better. 22
  23. 23. PROBLEM:NAT TRAVERSALWebRTC takes care of NAT traversalfor youBut not if they are behind symmetricNATs~8% of connections according toGoogle Talk dev help pagehttps://code.google.com/p/libjingle/wiki/FAQ 23
  24. 24. PROBLEM:NAT TRAVERSALYou must provide both a TURN server,a proxy for connections when thingsdon’t work right.No bandwidth , latency savings in thiscase. 24
  25. 25. PROBLEM:NOTIFYING CLIENTSIn order to establish connection,offer/answer and ICE candidates mustbe exchanged.Solution:You have to keep a WebSocket or XHRstream or similar open. Considerscaling issues. 25
  27. 27. THIS ISNT LIKE THEIPHONEWhether you like it or not, almosteveryone is going to have WebRTCand DataChannels in their browserwithin a year. 27
  28. 28. THIS IS CRAZYThe model of the web canfundamentally change 28
  29. 29. THIS IS CRAZYSomeone is going to build the P2P filetransfer app that is ridiculously easy 29
  30. 30. THIS IS CRAZYSomeone is going to build thenetworking library for MMOs in thebrowser 30
  31. 31. THIS IS CRAZYSomeone is going to build theBitTorrent of the web – just go on thedamn page and start downloadingmovies (I mean Ubuntu ISOs). Crazy. 31
  32. 32. THIS IS CRAZYSomeone is going to build the Node.jsof the browser.File/network I/O, Sessions, persistentmemory in HTML5 storage, databasedrivers, etc. 32
  33. 33. THIS IS CRAZYSomeone is going to replace Skype,and fragmented VOIP apps , andtelephones in general with the onethat just works in your browser. 33
  34. 34. THIS IS CRAZYSomeone is going to build the peer-to-peer CDN of the future.http://peerkit.com 34
  35. 35. THIS IS CRAZYThese aren’t novel ideas.These are real problems. People havebeen talking about them forever.The technology just hasn’t existeduntil today. 35
  36. 36. THANKS FOR PAYINGATTENTIONNow go home and code.Twitter: @reallyezGithub: ericzI’m currently working on PeerJS andPeerKit. If you’re interested in this stuff, I’dlove to talk to you. 36