SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
WebSockets
                      The Real-Time Web, Delivered
                                  July 23, 2011


                            Brian McKelvey
                            Co-Founder - Worlize Inc.



                        twitter - @theturtle32
                          www.worlize.com



Monday, July 25, 11
Whiteboard Demo

    • Get             FireFox 7 Alpha

         •   http://www.mozilla.com/firefox/channel/




Monday, July 25, 11
The Problem

    • No     officially supported way to do real-time communications
        in the browser.




Monday, July 25, 11
Hacks, Hacks, Hacks
    • Polling
    • Long-polling
    • IFrame
           Streaming
    • HTMLFile (MSIE)
    • XHR-Multipart (Firefox)




Monday, July 25, 11
Diagram from http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.ajax.devguide.help/docs/PureAjax_pubsub_clients.html




Monday, July 25, 11
Diagram from http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.ajax.devguide.help/docs/PureAjax_pubsub_clients.html




Monday, July 25, 11
The Solution: WebSockets

    • Maintains         a persistent bi-directional communications channel

    • Eliminates        the need for hacks




Monday, July 25, 11
Why not TCP Sockets?


    • API Simplicity
      • TCP is a stream-oriented protocol
      • We want a message-oriented protocol
    • Security
      • Scan a Local Network
      • DDOS Attack




Monday, July 25, 11
WebSocket Drafts

    • Started at WhatWG
      • WhatWG Draft-75 (old browsers)
      • WhatWG Draft-76 (Chrome, Safari)
    • Moved to IETF
      • HyBi - HyperText Bi-directional Working Group
        • Draft-00 (Same as WhatWG Draft-76)
        • Draft-07 (FireFox 6 beta)
        • Draft-09 (FireFox 7 alpha)



Monday, July 25, 11
The Details: Handshake



    • Built on HTTP
      • Traverse existing proxies/intermediaries
      • Co-exist on same port with HTTP/HTTPS      server




Monday, July 25, 11
The Details: Handshake
    Client Request
     GET /chat HTTP/1.1
     Connection: Upgrade
     Upgrade: websocket
     Sec-WebSocket-Version: 8
     Sec-WebSocket-Key: reaiKXo+d4Hkqt45PNTlNg==
     Sec-WebSocket-Origin: http://piglet.worlize.com:8080
     Sec-WebSocket-Protocol: superchat, boringchat
     Sec-WebSocket-Extensions: deflate-stream




Monday, July 25, 11
The Details: Handshake
     Server Response
     HTTP/1.1 101 Switching Protocols
     Connection: Upgrade
     Upgrade: websocket
     Sec-WebSocket-Accept: Iy0M3juCftp2uqk8/9fVWt4VfoI=
     Sec-WebSocket-Protocol: superchat
     Sec-WebSocket-Extensions: deflate-stream




Monday, July 25, 11
The Details: Handshake
    • Security
         • Cross-Origin    handling via Sec-WebSocket-Origin
         • Sec-WebSocket-Key Validation
           • Prevent cross-protocol attacks
           • Fail early if a dumb intermediary provides a cached
             response.
         • Sec- headers prevent XHR from being used to contact a
           WebSocket server




Monday, July 25, 11
The Details: Masking
    • Most  contentious issue in the HyBi Working Group.
    • All client-to-server messages are masked.
    • Why is this necessary?
      • Prevent cache-poisoning attacks
      • Prevent talking to overly permissive servers
      • Concern over this issue caused some browser vendors to
        pull support for WebSockets draft-76.




Monday, July 25, 11
The Details: Masking
    • How     does it work?
         • Randomly generated four-byte mask key per frame
         • Applied using XOR to frame payload


    • Reduces         compression efficiency for client-to-server messages




Monday, July 25, 11
The Details: Framing
    • Simple framing protocol facilitates message oriented API
    • 2 to 10 bytes for frame header
    • Contains flags, opcode, and payload length
    • Payload length is a variable length field.




Monday, July 25, 11
The Details: Framing

    • Data      frame types:    • Control   frame types:
         • Binary Message        • Ping
         • UTF-8 Text Message    • Pong
         • Continuation          • Close
           (fragmentation)




Monday, July 25, 11
The Details: Framing
    • Fragmentation

         • Allows     control frames in the middle of a long message
         • In coordination with a future extension can facilitate
             multiplexing.




Monday, July 25, 11
Basic Frame Header
                                  Frames less than 126 bytes
                      1   2   3   4   5     6   7   8   9   10   11 12 13 14 15 16

                          R   R   R
                      F                                 M
                          S   S   S
                      I                    OPCODE       S         7-BIT LENGTH
                          V   V   V
                      N                                 K
                          1   2   3

                                  Byte 1                           Byte 2




Monday, July 25, 11
Medium Frame Header
                              >= 126 bytes && < 65535 bytes
                      1   2   3   4    5    6   7   8   9   10   11 12 13 14 15 16

                          R   R   R
                      F                                 M
                          S   S   S                         Static Value "126" Indicating
                      I                    OPCODE       S
                          V   V   V                                 16-bit length
                      N                                 K
                          1   2   3

                                  Byte 1                            Byte 2




                              16-BIT LENGTH (BIG-ENDIAN UNSIGNED SHORT)




                                  Byte 3                            Byte 4




Monday, July 25, 11
Long Frame Header
                                             > 65535 bytes
                      1   2   3   4   5      6   7   8   9   10   11 12 13 14 15 16

                          R   R   R
                      F                                  M
                          S   S   S                          Static Value "127" Indicating
                      I                    OPCODE        S
                          V   V   V                                  63-bit length
                      N                                  K
                          1   2   3

                                  Byte 1                               Byte 2




                      0            63-BIT LENGTH (BIG-ENDIAN UNSIGNED)



                                           63-BIT LENGTH (Continued)



                                           63-BIT LENGTH (Continued)



                                           63-BIT LENGTH (Continued)



Monday, July 25, 11
Server Implementations
    • Node.JS: WebSocket-Node
      • https://github.com/Worlize/WebSocket-Node

    • ANSI C: libwebsockets
      • http://git.warmcat.com/cgi-bin/cgit/libwebsockets/

    • Java:           Jetty
         •   http://webtide.intalio.com/2011/04/getting-started-with-websockets/




Monday, July 25, 11
Client Implementations
    • Node.JS: WebSocket-Node
      • https://github.com/Worlize/WebSocket-Node

    • ActionScript 3: AS3WebSocket
      • https://github.com/Worlize/AS3WebSocket

    • ANSI C: libwebsockets
      • http://git.warmcat.com/cgi-bin/cgit/libwebsockets/




Monday, July 25, 11
Demo
                                    Shared Whiteboard Example

                      • Available in the ‘examples’ folder of:
                       https://github.com/Worlize/WebSocket-Node

                             Requires FireFox 7 Alpha!




Monday, July 25, 11

Contenu connexe

Tendances

nyoug-lxc-december-12-final
nyoug-lxc-december-12-finalnyoug-lxc-december-12-final
nyoug-lxc-december-12-final
Gilbert Standen
 
Power of Open SDN- The Vendor Neutral Approach to Optimizing Your Network 09...
Power of Open SDN- The Vendor Neutral Approach to Optimizing Your Network  09...Power of Open SDN- The Vendor Neutral Approach to Optimizing Your Network  09...
Power of Open SDN- The Vendor Neutral Approach to Optimizing Your Network 09...
Cary Hayward
 

Tendances (20)

Docker networking basics & coupling with Software Defined Networks
Docker networking basics & coupling with Software Defined NetworksDocker networking basics & coupling with Software Defined Networks
Docker networking basics & coupling with Software Defined Networks
 
Cumulus networks conversion guide
Cumulus networks conversion guideCumulus networks conversion guide
Cumulus networks conversion guide
 
nyoug-lxc-december-12-final
nyoug-lxc-december-12-finalnyoug-lxc-december-12-final
nyoug-lxc-december-12-final
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
 
Designing scalable Docker networks
Designing scalable Docker networksDesigning scalable Docker networks
Designing scalable Docker networks
 
Understanding Open vSwitch
Understanding Open vSwitch Understanding Open vSwitch
Understanding Open vSwitch
 
Sdnds tw-meetup-2
Sdnds tw-meetup-2Sdnds tw-meetup-2
Sdnds tw-meetup-2
 
Managing Open vSwitch Across a Large Heterogenous Fleet
Managing Open vSwitch Across a Large Heterogenous FleetManaging Open vSwitch Across a Large Heterogenous Fleet
Managing Open vSwitch Across a Large Heterogenous Fleet
 
Power of Open SDN- The Vendor Neutral Approach to Optimizing Your Network 09...
Power of Open SDN- The Vendor Neutral Approach to Optimizing Your Network  09...Power of Open SDN- The Vendor Neutral Approach to Optimizing Your Network  09...
Power of Open SDN- The Vendor Neutral Approach to Optimizing Your Network 09...
 
64-bit ARM Unikernels on uKVM
64-bit ARM Unikernels on uKVM64-bit ARM Unikernels on uKVM
64-bit ARM Unikernels on uKVM
 
"One network to rule them all" - OpenStack Summit Austin 2016
"One network to rule them all" - OpenStack Summit Austin 2016"One network to rule them all" - OpenStack Summit Austin 2016
"One network to rule them all" - OpenStack Summit Austin 2016
 
UEFI HTTP/HTTPS Boot
UEFI HTTP/HTTPS BootUEFI HTTP/HTTPS Boot
UEFI HTTP/HTTPS Boot
 
Obstacles & Solutions for Livepatch Support on ARM64 Architecture
Obstacles & Solutions for Livepatch Support on ARM64 ArchitectureObstacles & Solutions for Livepatch Support on ARM64 Architecture
Obstacles & Solutions for Livepatch Support on ARM64 Architecture
 
Install ovs on local pc
Install ovs on local pcInstall ovs on local pc
Install ovs on local pc
 
Infinit filesystem, Reactor reloaded
Infinit filesystem, Reactor reloadedInfinit filesystem, Reactor reloaded
Infinit filesystem, Reactor reloaded
 
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
 
See what happened with real time kvm when building real time cloud pezhang@re...
See what happened with real time kvm when building real time cloud pezhang@re...See what happened with real time kvm when building real time cloud pezhang@re...
See what happened with real time kvm when building real time cloud pezhang@re...
 
macvlan and ipvlan
macvlan and ipvlanmacvlan and ipvlan
macvlan and ipvlan
 
Docker-OVS
Docker-OVSDocker-OVS
Docker-OVS
 
OVS-NFV Tutorial
OVS-NFV TutorialOVS-NFV Tutorial
OVS-NFV Tutorial
 

Similaire à WebSockets: The Real-Time Web, Delivered

Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010
sullis
 
Andy Parsons Pivotal June 2011
Andy Parsons Pivotal June 2011Andy Parsons Pivotal June 2011
Andy Parsons Pivotal June 2011
Andy Parsons
 

Similaire à WebSockets: The Real-Time Web, Delivered (20)

RSK sidechain
RSK sidechainRSK sidechain
RSK sidechain
 
Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010
 
Hong kongopenstack2013 sdn_bluehost
Hong kongopenstack2013 sdn_bluehostHong kongopenstack2013 sdn_bluehost
Hong kongopenstack2013 sdn_bluehost
 
Scality S3 Server: Node js Meetup Presentation
Scality S3 Server: Node js Meetup PresentationScality S3 Server: Node js Meetup Presentation
Scality S3 Server: Node js Meetup Presentation
 
KUBEBOOT - SPRING BOOT DEPLOYMENT ON KUBERNETES
KUBEBOOT - SPRING BOOT DEPLOYMENT ON KUBERNETESKUBEBOOT - SPRING BOOT DEPLOYMENT ON KUBERNETES
KUBEBOOT - SPRING BOOT DEPLOYMENT ON KUBERNETES
 
JCache - It's finally here
JCache -  It's finally hereJCache -  It's finally here
JCache - It's finally here
 
JCache (JSR107) - QCon London 2015 & JBCNConf Barcelona 2015
JCache (JSR107) - QCon London 2015 & JBCNConf Barcelona 2015JCache (JSR107) - QCon London 2015 & JBCNConf Barcelona 2015
JCache (JSR107) - QCon London 2015 & JBCNConf Barcelona 2015
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! Framework
 
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMillDelivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012
 
Improvements in GlusterFS for Virtualization usecase
Improvements in GlusterFS for Virtualization usecaseImprovements in GlusterFS for Virtualization usecase
Improvements in GlusterFS for Virtualization usecase
 
Testing, CI Gating & Community Fast Feedback: The Challenge of Integration Pr...
Testing, CI Gating & Community Fast Feedback: The Challenge of Integration Pr...Testing, CI Gating & Community Fast Feedback: The Challenge of Integration Pr...
Testing, CI Gating & Community Fast Feedback: The Challenge of Integration Pr...
 
Andy Parsons Pivotal June 2011
Andy Parsons Pivotal June 2011Andy Parsons Pivotal June 2011
Andy Parsons Pivotal June 2011
 
Kubernetes Manchester - 6th December 2018
Kubernetes Manchester - 6th December 2018Kubernetes Manchester - 6th December 2018
Kubernetes Manchester - 6th December 2018
 
Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015
 
SQL for Elasticsearch
SQL for ElasticsearchSQL for Elasticsearch
SQL for Elasticsearch
 
ITSPA May 2013 - WebRTC, TURN, and WebSocket
ITSPA May 2013 - WebRTC, TURN, and WebSocketITSPA May 2013 - WebRTC, TURN, and WebSocket
ITSPA May 2013 - WebRTC, TURN, and WebSocket
 
Open vSwitch Introduction
Open vSwitch IntroductionOpen vSwitch Introduction
Open vSwitch Introduction
 
Batten Down the Hatches: A Practical Guide to Securing Kubernetes - RMISC 2019
Batten Down the Hatches: A Practical Guide to Securing Kubernetes - RMISC 2019Batten Down the Hatches: A Practical Guide to Securing Kubernetes - RMISC 2019
Batten Down the Hatches: A Practical Guide to Securing Kubernetes - RMISC 2019
 
2014 11-05 hpcac-kniep_christian_dockermpi
2014 11-05 hpcac-kniep_christian_dockermpi2014 11-05 hpcac-kniep_christian_dockermpi
2014 11-05 hpcac-kniep_christian_dockermpi
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

WebSockets: The Real-Time Web, Delivered

  • 1. WebSockets The Real-Time Web, Delivered July 23, 2011 Brian McKelvey Co-Founder - Worlize Inc. twitter - @theturtle32 www.worlize.com Monday, July 25, 11
  • 2. Whiteboard Demo • Get FireFox 7 Alpha • http://www.mozilla.com/firefox/channel/ Monday, July 25, 11
  • 3. The Problem • No officially supported way to do real-time communications in the browser. Monday, July 25, 11
  • 4. Hacks, Hacks, Hacks • Polling • Long-polling • IFrame Streaming • HTMLFile (MSIE) • XHR-Multipart (Firefox) Monday, July 25, 11
  • 7. The Solution: WebSockets • Maintains a persistent bi-directional communications channel • Eliminates the need for hacks Monday, July 25, 11
  • 8. Why not TCP Sockets? • API Simplicity • TCP is a stream-oriented protocol • We want a message-oriented protocol • Security • Scan a Local Network • DDOS Attack Monday, July 25, 11
  • 9. WebSocket Drafts • Started at WhatWG • WhatWG Draft-75 (old browsers) • WhatWG Draft-76 (Chrome, Safari) • Moved to IETF • HyBi - HyperText Bi-directional Working Group • Draft-00 (Same as WhatWG Draft-76) • Draft-07 (FireFox 6 beta) • Draft-09 (FireFox 7 alpha) Monday, July 25, 11
  • 10. The Details: Handshake • Built on HTTP • Traverse existing proxies/intermediaries • Co-exist on same port with HTTP/HTTPS server Monday, July 25, 11
  • 11. The Details: Handshake Client Request GET /chat HTTP/1.1 Connection: Upgrade Upgrade: websocket Sec-WebSocket-Version: 8 Sec-WebSocket-Key: reaiKXo+d4Hkqt45PNTlNg== Sec-WebSocket-Origin: http://piglet.worlize.com:8080 Sec-WebSocket-Protocol: superchat, boringchat Sec-WebSocket-Extensions: deflate-stream Monday, July 25, 11
  • 12. The Details: Handshake Server Response HTTP/1.1 101 Switching Protocols Connection: Upgrade Upgrade: websocket Sec-WebSocket-Accept: Iy0M3juCftp2uqk8/9fVWt4VfoI= Sec-WebSocket-Protocol: superchat Sec-WebSocket-Extensions: deflate-stream Monday, July 25, 11
  • 13. The Details: Handshake • Security • Cross-Origin handling via Sec-WebSocket-Origin • Sec-WebSocket-Key Validation • Prevent cross-protocol attacks • Fail early if a dumb intermediary provides a cached response. • Sec- headers prevent XHR from being used to contact a WebSocket server Monday, July 25, 11
  • 14. The Details: Masking • Most contentious issue in the HyBi Working Group. • All client-to-server messages are masked. • Why is this necessary? • Prevent cache-poisoning attacks • Prevent talking to overly permissive servers • Concern over this issue caused some browser vendors to pull support for WebSockets draft-76. Monday, July 25, 11
  • 15. The Details: Masking • How does it work? • Randomly generated four-byte mask key per frame • Applied using XOR to frame payload • Reduces compression efficiency for client-to-server messages Monday, July 25, 11
  • 16. The Details: Framing • Simple framing protocol facilitates message oriented API • 2 to 10 bytes for frame header • Contains flags, opcode, and payload length • Payload length is a variable length field. Monday, July 25, 11
  • 17. The Details: Framing • Data frame types: • Control frame types: • Binary Message • Ping • UTF-8 Text Message • Pong • Continuation • Close (fragmentation) Monday, July 25, 11
  • 18. The Details: Framing • Fragmentation • Allows control frames in the middle of a long message • In coordination with a future extension can facilitate multiplexing. Monday, July 25, 11
  • 19. Basic Frame Header Frames less than 126 bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 R R R F M S S S I OPCODE S 7-BIT LENGTH V V V N K 1 2 3 Byte 1 Byte 2 Monday, July 25, 11
  • 20. Medium Frame Header >= 126 bytes && < 65535 bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 R R R F M S S S Static Value "126" Indicating I OPCODE S V V V 16-bit length N K 1 2 3 Byte 1 Byte 2 16-BIT LENGTH (BIG-ENDIAN UNSIGNED SHORT) Byte 3 Byte 4 Monday, July 25, 11
  • 21. Long Frame Header > 65535 bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 R R R F M S S S Static Value "127" Indicating I OPCODE S V V V 63-bit length N K 1 2 3 Byte 1 Byte 2 0 63-BIT LENGTH (BIG-ENDIAN UNSIGNED) 63-BIT LENGTH (Continued) 63-BIT LENGTH (Continued) 63-BIT LENGTH (Continued) Monday, July 25, 11
  • 22. Server Implementations • Node.JS: WebSocket-Node • https://github.com/Worlize/WebSocket-Node • ANSI C: libwebsockets • http://git.warmcat.com/cgi-bin/cgit/libwebsockets/ • Java: Jetty • http://webtide.intalio.com/2011/04/getting-started-with-websockets/ Monday, July 25, 11
  • 23. Client Implementations • Node.JS: WebSocket-Node • https://github.com/Worlize/WebSocket-Node • ActionScript 3: AS3WebSocket • https://github.com/Worlize/AS3WebSocket • ANSI C: libwebsockets • http://git.warmcat.com/cgi-bin/cgit/libwebsockets/ Monday, July 25, 11
  • 24. Demo Shared Whiteboard Example • Available in the ‘examples’ folder of: https://github.com/Worlize/WebSocket-Node Requires FireFox 7 Alpha! Monday, July 25, 11