SlideShare a Scribd company logo
OMG
DATA
CHANNELS
AND HOW TO USE THEM


ERIC ZHANG




                      1
BINARY TYPES IN
JAVASCRIPT
Yes binary types exists:


ArrayBuffer
Blob
ArrayBufferView: Uint8Array, etc..




                                     2
WHY IS THIS COOL


Binary support means we can do
anything we want with data




                                 3
BINARY TYPES IN
JAVASCRIPT
Do these things with them:


URL.createObjectURL(blob)
XHR2
WebSocket
DataChannel




                             4
BACK TO
DATACHANNEL


Video and audio is pretty cool


But I’m excited about DataChannel
because




                                    5
BACK TO
DATACHANNEL


Arbitrary binary data between
arbitrary people


That is a lot of power


No permissions. No flags.




                                6
BUT WAIT THERES
MORE


Based on UDP – essential when
transmission delay matters


Configurable with SCTP, for TCP like
reliability if you want




                                       7
WHAT I REALIZED
DataChannel fundamentally changes
the web.


Data has always flowed between
server and client.


DataChannel allows client to client
flow




                                      8
THE POSSIBILITIES


File transfer


Faster
No privacy issues
No bandwidth costs




                     9
THE POSSIBILITIES


Multiplayer games


Substantially higher performance
because of lower UDP latency +
binary data




                                   10
THE POSSIBILITIES


High frequency events and messaging


Higher message rates possible with
UDP based transport




                                      11
PRIVACY


Imagine a decentralized Facebook


Data actually downloaded from your
browser while you browse the web.


Seamless experience




                                     12
DATACHANNEL
CHALLENGES




              13
BROWSER
COMPATIBILITY
Google Chrome - March 7th 2013

                                 GOOD
                                 GOOD
                                 GOOD
                                 BAD
No SCTP implementation = No binary, reliable
Not coming until later in 27




                                               14
BROWSER
COMPATIBILITY
Firefox – March 7th 2013


Nightly 22.0a1 - Several spec issues
being fixed RIGHT NOW
Bug 837919 - WebRTC: RTCPeerConnection constructor: FQDN not yet implemented (only IP-
#s).
Bug 846110 - PeerConnection ondatachannel callback receives channel in Firefox, but
in Chrome an event is passed in
Bug 837035 - Hook up DataChannel SDP to implementation (in particular port and
options)


Aurora 21.01a2 - Flagless support




                                                                                         15
BROWSER
COMPATIBILITY


Binary, reliable, and FF/Chrome
interop in stable versions at most a
few months away




                                       16
PROBLEM: JSON


I now have a binary DataChannel
between two browsers.


I want to send some binary data.




                                   17
PROBLEM: JSON
JSON is an extremely bad choice for
binary data. Base64 uses 37% more
bandwidth and is slow to
encode/decode.
You can never do this in JSON:
JSON.stringify({x: 1, y: binary });




                                      18
PROBLEM: JSON
Our DataChannel supports binary,
why use string serialization at all?


Binary serialization options:
MsgPack, Thrift, Avro, BSON,
ProtoBufs, BERT, and many more




                                       19
PROBLEM: JSON


MessagePack: Most JSON like. Very
compact. No schema, not designed
for typed languages like others.


Shitty for Javascript. JS has distinct
string / byte array types unlike many
other dynamic languages.




                                         20
PROBLEM: JSON
Solution is simple. Add string type to
MessagePack.
They hate this.
https://github.com/msgpack/msgpack/issues/121
https://github.com/msgpack/msgpack/issues/128




Talk to me about this afterwards




                                                21
PROBLEM: JSON
With a binary serialization format you
can 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 is
much better.




                                                                    22
PROBLEM:
NAT TRAVERSAL
WebRTC takes care of NAT traversal
for you
But not if they are behind symmetric
NATs


~8% of connections according to
Google Talk dev help page
https://code.google.com/p/libjingle/wiki/FAQ




                                               23
PROBLEM:
NAT TRAVERSAL


You must provide both a TURN server,
a proxy for connections when things
don’t work right.


No bandwidth , latency savings in this
case.




                                         24
PROBLEM:
NOTIFYING CLIENTS
In order to establish connection,
offer/answer and ICE candidates must
be exchanged.


Solution:
You have to keep a WebSocket or XHR
stream or similar open. Consider
scaling issues.




                                       25
WEBRTC IS
SUPER
HAPPENING
GUARANTEED




             26
THIS ISNT LIKE THE
IPHONE


Whether you like it or not, almost
everyone is going to have WebRTC
and DataChannels in their browser
within a year.




                                     27
THIS IS CRAZY



The model of the web can
fundamentally change




                           28
THIS IS CRAZY


Someone is going to build the P2P file
transfer app that is ridiculously easy




                                         29
THIS IS CRAZY


Someone is going to build the
networking library for MMOs in the
browser




                                     30
THIS IS CRAZY


Someone is going to build the
BitTorrent of the web – just go on the
damn page and start downloading
movies (I mean Ubuntu ISOs). Crazy.




                                         31
THIS IS CRAZY


Someone is going to build the Node.js
of the browser.


File/network I/O, Sessions, persistent
memory in HTML5 storage, database
drivers, etc.




                                         32
THIS IS CRAZY


Someone is going to replace Skype,
and fragmented VOIP apps , and
telephones in general with the one
that just works in your browser.




                                     33
THIS IS CRAZY


Someone is going to build the peer-to-
peer CDN of the future.


http://peerkit.com




                                         34
THIS IS CRAZY
These aren’t novel ideas.
These are real problems. People have
been talking about them forever.


The technology just hasn’t existed
until today.




                                       35
THANKS FOR PAYING
ATTENTION
Now go home and code.


Twitter: @reallyez
Github: ericz

I’m currently working on PeerJS and
PeerKit. If you’re interested in this stuff, I’d
love to talk to you.




                                                   36

More Related Content

PPTX
HTML5 Japan Cup (5jCup) WebRTC賞
PDF
HTML5 & WebRTC: New Horizons for P2P streaming
PPTX
overview-peerconnection-lifetime
PDF
深入浅出Netty l.t
PDF
【デブサミ福岡B5】コードレビューの進め方~全員で行う品質の維持~
PDF
WebRTC multistream
PDF
Web technology is getting physical, join the journey
PDF
The State of WebRTC
HTML5 Japan Cup (5jCup) WebRTC賞
HTML5 & WebRTC: New Horizons for P2P streaming
overview-peerconnection-lifetime
深入浅出Netty l.t
【デブサミ福岡B5】コードレビューの進め方~全員で行う品質の維持~
WebRTC multistream
Web technology is getting physical, join the journey
The State of WebRTC

Similar to Why WebRTC DataChannel excites me (20)

PDF
Kamailio World 2017: Getting Real with WebRTC
PDF
Architecting for a scalable enterprise - John Davies
PDF
The Next Chapter in the Sordid Love/Hate Relationship Between DBs and OSes by...
PPTX
chapter-1-business-data-networks-and-security-10-th-edition.pptx
PDF
PDF
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
PDF
Web apps of the future
PDF
JAX London 2015 - Architecting a Highly Scalable Enterprise
PDF
Sydgraph presentation 2004
PPTX
Cloud Computing By #Manoj_Rockstar
PDF
FFMUC goes wild - Infrastructure recap 2020 #rc3
PDF
WebRTC: A front-end perspective
PPTX
Os in-a-browser
PDF
Big Data: fall seven times, stand up eight!
PPTX
Benefits of an Agile Data Fabric for Business Intelligence
KEY
Thin Server Architecture
PDF
NOSQL in the Cloud
PDF
From data centers to fog computing: the evaporating cloud
PDF
Geo in the cloud
PPTX
The Future of Web Application Architectures
Kamailio World 2017: Getting Real with WebRTC
Architecting for a scalable enterprise - John Davies
The Next Chapter in the Sordid Love/Hate Relationship Between DBs and OSes by...
chapter-1-business-data-networks-and-security-10-th-edition.pptx
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
Web apps of the future
JAX London 2015 - Architecting a Highly Scalable Enterprise
Sydgraph presentation 2004
Cloud Computing By #Manoj_Rockstar
FFMUC goes wild - Infrastructure recap 2020 #rc3
WebRTC: A front-end perspective
Os in-a-browser
Big Data: fall seven times, stand up eight!
Benefits of an Agile Data Fabric for Business Intelligence
Thin Server Architecture
NOSQL in the Cloud
From data centers to fog computing: the evaporating cloud
Geo in the cloud
The Future of Web Application Architectures
Ad

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Getting Started with Data Integration: FME Form 101
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Tartificialntelligence_presentation.pptx
PPT
Teaching material agriculture food technology
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Spectroscopy.pptx food analysis technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Electronic commerce courselecture one. Pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Reach Out and Touch Someone: Haptics and Empathic Computing
Getting Started with Data Integration: FME Form 101
Mobile App Security Testing_ A Comprehensive Guide.pdf
Machine learning based COVID-19 study performance prediction
Digital-Transformation-Roadmap-for-Companies.pptx
Tartificialntelligence_presentation.pptx
Teaching material agriculture food technology
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Group 1 Presentation -Planning and Decision Making .pptx
20250228 LYD VKU AI Blended-Learning.pptx
Ad

Why WebRTC DataChannel excites me

  • 1. OMG DATA CHANNELS AND HOW TO USE THEM ERIC ZHANG 1
  • 2. BINARY TYPES IN JAVASCRIPT Yes binary types exists: ArrayBuffer Blob ArrayBufferView: Uint8Array, etc.. 2
  • 3. WHY IS THIS COOL Binary support means we can do anything we want with data 3
  • 4. BINARY TYPES IN JAVASCRIPT Do these things with them: URL.createObjectURL(blob) XHR2 WebSocket DataChannel 4
  • 5. BACK TO DATACHANNEL Video and audio is pretty cool But I’m excited about DataChannel because 5
  • 6. BACK TO DATACHANNEL Arbitrary binary data between arbitrary people That is a lot of power No permissions. No flags. 6
  • 7. BUT WAIT THERES MORE Based on UDP – essential when transmission delay matters Configurable with SCTP, for TCP like reliability if you want 7
  • 8. WHAT I REALIZED DataChannel fundamentally changes the web. Data has always flowed between server and client. DataChannel allows client to client flow 8
  • 9. THE POSSIBILITIES File transfer Faster No privacy issues No bandwidth costs 9
  • 10. THE POSSIBILITIES Multiplayer games Substantially higher performance because of lower UDP latency + binary data 10
  • 11. THE POSSIBILITIES High frequency events and messaging Higher message rates possible with UDP based transport 11
  • 12. PRIVACY Imagine a decentralized Facebook Data actually downloaded from your browser while you browse the web. Seamless experience 12
  • 14. BROWSER COMPATIBILITY Google Chrome - March 7th 2013 GOOD GOOD GOOD BAD No SCTP implementation = No binary, reliable Not coming until later in 27 14
  • 15. BROWSER COMPATIBILITY Firefox – March 7th 2013 Nightly 22.0a1 - Several spec issues being fixed RIGHT NOW Bug 837919 - WebRTC: RTCPeerConnection constructor: FQDN not yet implemented (only IP- #s). Bug 846110 - PeerConnection ondatachannel callback receives channel in Firefox, but in Chrome an event is passed in Bug 837035 - Hook up DataChannel SDP to implementation (in particular port and options) Aurora 21.01a2 - Flagless support 15
  • 16. BROWSER COMPATIBILITY Binary, reliable, and FF/Chrome interop in stable versions at most a few months away 16
  • 17. PROBLEM: JSON I now have a binary DataChannel between two browsers. I want to send some binary data. 17
  • 18. PROBLEM: JSON JSON is an extremely bad choice for binary data. Base64 uses 37% more bandwidth and is slow to encode/decode. You can never do this in JSON: JSON.stringify({x: 1, y: binary }); 18
  • 19. PROBLEM: JSON Our DataChannel supports binary, why use string serialization at all? Binary serialization options: MsgPack, Thrift, Avro, BSON, ProtoBufs, BERT, and many more 19
  • 20. PROBLEM: JSON MessagePack: Most JSON like. Very compact. No schema, not designed for typed languages like others. Shitty for Javascript. JS has distinct string / byte array types unlike many other dynamic languages. 20
  • 21. PROBLEM: JSON Solution is simple. Add string type to MessagePack. They hate this. https://github.com/msgpack/msgpack/issues/121 https://github.com/msgpack/msgpack/issues/128 Talk to me about this afterwards 21
  • 22. PROBLEM: JSON With a binary serialization format you can 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 is much better. 22
  • 23. PROBLEM: NAT TRAVERSAL WebRTC takes care of NAT traversal for you But not if they are behind symmetric NATs ~8% of connections according to Google Talk dev help page https://code.google.com/p/libjingle/wiki/FAQ 23
  • 24. PROBLEM: NAT TRAVERSAL You must provide both a TURN server, a proxy for connections when things don’t work right. No bandwidth , latency savings in this case. 24
  • 25. PROBLEM: NOTIFYING CLIENTS In order to establish connection, offer/answer and ICE candidates must be exchanged. Solution: You have to keep a WebSocket or XHR stream or similar open. Consider scaling issues. 25
  • 27. THIS ISNT LIKE THE IPHONE Whether you like it or not, almost everyone is going to have WebRTC and DataChannels in their browser within a year. 27
  • 28. THIS IS CRAZY The model of the web can fundamentally change 28
  • 29. THIS IS CRAZY Someone is going to build the P2P file transfer app that is ridiculously easy 29
  • 30. THIS IS CRAZY Someone is going to build the networking library for MMOs in the browser 30
  • 31. THIS IS CRAZY Someone is going to build the BitTorrent of the web – just go on the damn page and start downloading movies (I mean Ubuntu ISOs). Crazy. 31
  • 32. THIS IS CRAZY Someone is going to build the Node.js of the browser. File/network I/O, Sessions, persistent memory in HTML5 storage, database drivers, etc. 32
  • 33. THIS IS CRAZY Someone is going to replace Skype, and fragmented VOIP apps , and telephones in general with the one that just works in your browser. 33
  • 34. THIS IS CRAZY Someone is going to build the peer-to- peer CDN of the future. http://peerkit.com 34
  • 35. THIS IS CRAZY These aren’t novel ideas. These are real problems. People have been talking about them forever. The technology just hasn’t existed until today. 35
  • 36. THANKS FOR PAYING ATTENTION Now go home and code. Twitter: @reallyez Github: ericz I’m currently working on PeerJS and PeerKit. If you’re interested in this stuff, I’d love to talk to you. 36