[Docs] [txt|pdf] [Tracker] [Email] [Diff1] [Diff2] [Nits]

Versions: 00 01 02 03 04 05 06 draft-ietf-hybi-websocket-perframe-compression

HyBi Working Group                                            T. Yoshino
Internet-Draft                                              Google, Inc.
Intended status: Standards Track                        February 2, 2012
Expires: August 5, 2012


                 WebSocket Per-frame DEFLATE Extension
           draft-tyoshino-hybi-websocket-perframe-deflate-05

Abstract

   This specification defines a per-frame DEFLATE compression extension
   for the WebSocket Protocol.  This extension compresses the
   "Application data" part of WebSocket data frames using DEFLATE.

   Please send feedback to the hybi@ietf.org mailing list.

Status of this Memo

   This Internet-Draft is submitted to IETF in full conformance with the
   provisions of BCP 78 and BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at http://datatracker.ietf.org/drafts/current.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on August 5, 2012.

Copyright Notice

   Copyright (c) 2012 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   (http://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.



Yoshino                  Expires August 5, 2012                 [Page 1]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


Table of Contents

   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  3
   2.  Conformance Requirements . . . . . . . . . . . . . . . . . . .  4
   3.  Extension Negotiation  . . . . . . . . . . . . . . . . . . . .  5
   4.  Application Data Transformation  . . . . . . . . . . . . . . .  6
     4.1.  Sending  . . . . . . . . . . . . . . . . . . . . . . . . .  6
     4.2.  Receiving  . . . . . . . . . . . . . . . . . . . . . . . .  7
     4.3.  Examples . . . . . . . . . . . . . . . . . . . . . . . . .  7
   5.  Implementation Note  . . . . . . . . . . . . . . . . . . . . .  9
   6.  Security Considerations  . . . . . . . . . . . . . . . . . . . 10
   7.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 11
     7.1.  Registration of the "deflate-frame" WebSocket
           Extension Name . . . . . . . . . . . . . . . . . . . . . . 11
     7.2.  Registration of the "COMP" WebSocket Framing Header Bit  . 11
   8.  Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 12
   9.  References . . . . . . . . . . . . . . . . . . . . . . . . . . 13
     9.1.  Normative References . . . . . . . . . . . . . . . . . . . 13
     9.2.  Informative References . . . . . . . . . . . . . . . . . . 13
   Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 14































Yoshino                  Expires August 5, 2012                 [Page 2]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


1.  Introduction

   _This section is non-normative._

   As well as other protocols, octets exchanged over the WebSocket
   Protocol [RFC6455] can benefit from compression.  This specification
   adds DEFLATE [RFC1951] based compression functionality to the
   WebSocket Protocol using its extension framework.

   Per-frame DEFLATE extension applies DEFLATE to the octets in the
   "Application data" part of data frames.  To align the end of
   compressed data to octet boundary, this extension uses the algorithm
   described in the Section 2.1 of the PPP Deflate Protocol [RFC1979].
   Endpoints can take over the LZ77 sliding window [LZ77] used to build
   previous frames to get better compression ratio.

   The simplest "Sec-WebSocket-Extensions" header in the client's
   opening handshake to request per-frame DEFLATE extension is the
   following:

       Sec-WebSocket-Extensions: deflate-frame

   The simplest header from the server to accept this extension is the
   same.



























Yoshino                  Expires August 5, 2012                 [Page 3]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


2.  Conformance Requirements

   Everything in this specification except for sections explicitly
   marked non-normative is normative.

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
   document are to be interpreted as described in [RFC2119].











































Yoshino                  Expires August 5, 2012                 [Page 4]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


3.  Extension Negotiation

   The registered extension token for this extension is "deflate-frame".

   To request use of per-frame DEFLATE extension, a client MUST include
   the "deflate-frame" extension token in the "Sec-WebSocket-Extensions"
   header in its opening handshake.

   To accept use of per-frame DEFLATE extension requested by the client,
   a server MUST include the "deflate-frame" extension token in the
   "Sec-WebSocket-Extensions" header in its opening handshake.

   An endpoint MAY attach one or more extension parameters as defined
   below to the extension token.

   Maximum LZ77 sliding window size
      An endpoint MAY attach "max_window_bits" extension parameter to
      limit the LZ77 sliding window size that the other peer uses to
      build frames.  This parameter MUST have an integer value in the
      range between 8 to 15 indicating the base-2 logarithm of the LZ77
      sliding window size.  An endpoint that received this parameter
      MUST NOT use LZ77 sliding window size greater than this value to
      build frames.

   Disallow compression context takeover
      An endpoint MAY attach "no_context_takeover" extension parameter
      to disallow the other peer to take over the LZ77 sliding window
      used to build previous frames.  This parameter has no value.  An
      endpoint that received this parameter MUST use an empty LZ77
      sliding window to build every frame.

   A server MUST ignore any unknown extension parameter attached to
   "deflate-frame" extension token in the client's opening handshake.

   A client MUST _Fail the WebSocket Connection_ if any unknown
   extension parameter is attached to "deflate-frame" extension token in
   the server's opening handshake.

   Once per-frame DEFLATE extension is accepted, both endpoints MUST use
   the algorithm described in Section 4 to exchange frames.











Yoshino                  Expires August 5, 2012                 [Page 5]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


4.  Application Data Transformation

   This extension uses one reserved bit to indicate whether DEFLATE is
   applied to the frame or not.  We call this "COMP" bit.

   This extension operates only on data frames, and only on the
   "Application data" therein (it does not affect the "Extension data"
   portion of the "Payload data").

4.1.  Sending

   To send a frame with DEFLATE applied, an endpoint MUST use the
   following algorithm.

   1.  Apply DEFLATE [RFC1951] to all the octets in the "Application
       data" part of the frame.  Multiple blocks MAY be used.  Any type
       of block MAY be used.  Both block with "BFINAL" set to 0 and 1
       MAY be used.

   2.  If the resulting data does not end with an empty block with no
       compression ("BTYPE" set to 0), append an empty block with no
       compression to the tail.

   3.  Remove 4 octets (that are 0x00 0x00 0xff 0xff) from the tail.

   4.  Build a frame by putting the resulting octets in the "Application
       data" part instead of the original octets.  The payload length
       field of the frame MUST be the sum of the size of the "Extension
       data" part and these resulting octets.  "COMP" bit MUST be set to
       1.

   An endpoint MUST NOT use LZ77 sliding window size greater than 32,768
   to build frames.

   If an endpoint received the "max_window_bits" extension parameter on
   opening handshake, it MUST NOT use LZ77 sliding window size greater
   than the "max_window_bits"-th power of 2 to build frames.

   Unless it's prohibited by the other peer by the "no_context_takeover"
   extension parameter on opening handshake, an endpoint MAY take over
   the LZ77 sliding window used to build the last frame with DEFLATE
   applied.

   To send a frame with DEFLATE not applied, an endpoint MUST set "COMP"
   bit of the frame to 0.






Yoshino                  Expires August 5, 2012                 [Page 6]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


4.2.  Receiving

   To receive a frame with "COMP" bit set to 1, an endpoint MUST use the
   following algorithm.

   1.  Append 4 octets of 0x00 0x00 0xff 0xff to the tail of the
       "Application data" part.

   2.  Decode the resulting octets using DEFLATE.

   Unless an endpoint sent the "max_window_bits" extension parameter on
   opening handshake, the endpoint MUST use 32,768 byte LZ77 sliding
   window to decode frames.

   If an endpoint sent the "max_window_bits" extension parameter on
   opening handshake, it MAY reduce LZ77 sliding window size down to the
   "max_window_bits"-th power of 2 to decode frames.

   Unless the endpoint sent the "no_context_takeover" extension
   parameter on opening handshake, an endpoint MUST take over the LZ77
   sliding window used to decode the last frame with DEFLATE applied.

   To receive a frame with "COMP" bit set to 0, an endpoint MUST receive
   it without any DEFLATE processing.

4.3.  Examples

   _This section is non-normative._

   These are examples of resulting data after applying the algorithm
   above.

   o  "Hello" in one compressed block

      *  0xf2 0x48 0xcd 0xc9 0xc9 0x07 0x00

      "Hello" in one compressed block in the next frame

      *  0xf2 0x00 0x11 0x00 0x00

   o  "Hello" in one block with no compression

      *  0x00 0x05 0x00 0xfa 0xff 0x48 0x65 0x6c 0x6c 0x6f 0x00

   o  "Hello" in one block with "BFINAL" set to 1

      *  0xf3 0x48 0xcd 0xc9 0xc9 0x07 0x00 0x00




Yoshino                  Expires August 5, 2012                 [Page 7]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


   o  "He" and "llo" in separate blocks

      *  0xf2 0x48 0x05 0x00 0x00 0x00 0xff 0xff 0xca 0xc9 0xc9 0x07
         0x00















































Yoshino                  Expires August 5, 2012                 [Page 8]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


5.  Implementation Note

   _This section is non-normative._

   On common software development platforms, the operation of aligning
   compressed data to octet boundary using an empty block with no
   compression is available as library.  For example, Zlib [Zlib] does
   this when "Z_SYNC_FLUSH" is passed to deflate function.

   To get sufficient compression ratio, LZ77 sliding window size of
   1,024 or more is recommended.








































Yoshino                  Expires August 5, 2012                 [Page 9]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


6.  Security Considerations

   There's no security concern for now.
















































Yoshino                  Expires August 5, 2012                [Page 10]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


7.  IANA Considerations

7.1.  Registration of the "deflate-frame" WebSocket Extension Name

   This section describes a WebSocket extension name registration in the
   WebSocket Extension Name Registry.  [RFC6455].

   Extension Identifier
      deflate-frame

   Extension Common Name
      WebSocket Per-frame DEFLATE

   Extension Definition
      Section 3 and Section 4 of this document.

   Known Incompatible Extensions
      None

   The "deflate-frame" token is used in the "Sec-WebSocket-Extensions"
   header in the WebSocket opening handshake to negotiate use of per-
   frame DEFLATE compression extension.

7.2.  Registration of the "COMP" WebSocket Framing Header Bit

   This section describes a WebSocket framing header bit registration in
   the WebSocket Framing Header Bits Registry.  [RFC6455]

   Header Bit
      RSV1

   Common Name
      COMP

   Meaning
      DEFLATE is applied to the frame or not.

   Reference
      Section 4 of this document.

   The "COMP" framing header bit is used to indicate whether the
   "Application data" part of the frame contains octets generated using
   DEFLATE or not.








Yoshino                  Expires August 5, 2012                [Page 11]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


8.  Acknowledgements

   Special thanks to Patrick McManus who wrote up the initial
   specification of DEFLATE based compression extension for the
   WebSocket Protocol which I referred to write this specification.














































Yoshino                  Expires August 5, 2012                [Page 12]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


9.  References

9.1.  Normative References

   [RFC6455]  Fette, I. and A. Melnikov, "The WebSocket Protocol",
              RFC 6455, December 2011.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119, March 1997.

   [LZ77]     Ziv, J. and A. Lempel, "A Universal Algorithm for
              Sequential Data Compression", IEEE Transactions on
              Information Theory, Vol. 23, No. 3, pp. 337-343.

9.2.  Informative References

   [RFC1951]  Deutsch, P., "DEFLATE Compressed Data Format Specification
              version 1.3", RFC 1951, May 1996.

   [RFC1979]  Woods, J., "PPP Deflate Protocol", RFC 1979, August 1996.

   [Zlib]     Gailly, J. and M. Adler, "Zlib", <http://zlib.net/>.





























Yoshino                  Expires August 5, 2012                [Page 13]

Internet-Draft    WebSocket Per-frame DEFLATE Extension    February 2012


Author's Address

   Takeshi Yoshino
   Google, Inc.

   Email: tyoshino@google.com













































Yoshino                  Expires August 5, 2012                [Page 14]


Html markup produced by rfcmarkup 1.109, available from https://tools.ietf.org/tools/rfcmarkup/