[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                          August 4, 2011
Expires: February 5, 2012


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

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), its areas, and its working groups.  Note that
   other groups may also distribute working documents as Internet-
   Drafts.

   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."

   The list of current Internet-Drafts can be accessed at
   http://www.ietf.org/ietf/1id-abstracts.txt.

   The list of Internet-Draft Shadow Directories can be accessed at
   http://www.ietf.org/shadow.html.

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

Copyright Notice

   Copyright (c) 2011 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



Yoshino                 Expires February 5, 2012                [Page 1]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


   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.


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  . . . . . . . . . . . . . . . . . . . . .  8
   6.  Security Considerations  . . . . . . . . . . . . . . . . . . .  9
   7.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 10
     7.1.  Registration of the "deflate-frame" WebSocket
           Extension Name . . . . . . . . . . . . . . . . . . . . . . 10
     7.2.  Registration of the "COMP" WebSocket Framing Header Bit  . 10
   8.  Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 11
   9.  References . . . . . . . . . . . . . . . . . . . . . . . . . . 12
     9.1.  Normative References . . . . . . . . . . . . . . . . . . . 12
     9.2.  Informative References . . . . . . . . . . . . . . . . . . 12
   Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 13























Yoshino                 Expires February 5, 2012                [Page 2]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


1.  Introduction

   _This section is non-normative._

   As well as other protocols, octets exchanged over the WebSocket
   protocol [I-D.ietf-hybi-thewebsocketprotocol] 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 LZ77 sliding window [LZ77] from previous frames to get
   better compression ratio.

   The simplest "Sec-WebSocket-Extensions" header in the client 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 February 5, 2012                [Page 3]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


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 February 5, 2012                [Page 4]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


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 request.

   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 response.

   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.  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 compress a frame.

   Disallow compression context takeover
      An endpoint MAY attach "no_context_takeover" extension parameter
      to disallow the other peer to take over LZ77 sliding window
      fromprevious frames.  This parameter has no value.  An endpoint
      that received this parameter MUST NOT take over LZ77 sliding
      window from previous frames to compress a frame.

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

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

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












Yoshino                 Expires February 5, 2012                [Page 5]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


4.  Application Data Transformation

   This extension uses one reserved bit to indicate 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 is 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 this resulting octets.  "COMP" bit MUST be set to
       1.

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

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

   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.

   An endpoint MAY take over LZ77 sliding window from the last frame it
   applied DEFLATE unless it's prohibited by the other peer by
   "no_context_takeover" extension parameter.







Yoshino                 Expires February 5, 2012                [Page 6]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


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.

   An endpoint MUST take over LZ77 sliding window from the last frame it
   decoded by applying DEFLATE unless it sent the "no_context_takeover"
   extension parameter.

   An endpoint MUST use 32,768 byte LZ77 sliding window unless it sent
   "max_window_bits" extension parameter.

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

   o  "He" and "llo" in separate blocks

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







Yoshino                 Expires February 5, 2012                [Page 7]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


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 enough compression ratio, LZ77 sliding window size of 1,024 or
   more is recommended.








































Yoshino                 Expires February 5, 2012                [Page 8]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


6.  Security Considerations

   There's no security concern for now.
















































Yoshino                 Expires February 5, 2012                [Page 9]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


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.
   [I-D.ietf-hybi-thewebsocketprotocol].

   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 Bit Registry.
   [I-D.ietf-hybi-thewebsocketprotocol]

   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 the application
   data part of the frame contains octets generated by DEFLATE or not.







Yoshino                 Expires February 5, 2012               [Page 10]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


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 February 5, 2012               [Page 11]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


9.  References

9.1.  Normative References

   [I-D.ietf-hybi-thewebsocketprotocol]
              Fette, I. and A. Melnikov, "The WebSocket protocol",
              draft-ietf-hybi-thewebsocketprotocol (work in progress),
              July 2011.

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

   [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

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

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



























Yoshino                 Expires February 5, 2012               [Page 12]

Internet-Draft    WebSocket Per-frame DEFLATE Extension      August 2011


Author's Address

   Takeshi Yoshino
   Google, Inc.

   Email: tyoshino@google.com













































Yoshino                 Expires February 5, 2012               [Page 13]


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