Re: [hybi] frame length encoding

Scott Ferguson <ferg@caucho.com> Sun, 22 August 2010 19:31 UTC

Return-Path: <ferg@caucho.com>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 87E633A68D2 for <hybi@core3.amsl.com>; Sun, 22 Aug 2010 12:31:43 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.171
X-Spam-Level:
X-Spam-Status: No, score=-2.171 tagged_above=-999 required=5 tests=[AWL=0.094, BAYES_00=-2.599, IP_NOT_FRIENDLY=0.334]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YUbaS7iqX+U1 for <hybi@core3.amsl.com>; Sun, 22 Aug 2010 12:31:42 -0700 (PDT)
Received: from smtp112.biz.mail.sp1.yahoo.com (smtp112.biz.mail.sp1.yahoo.com [69.147.92.225]) by core3.amsl.com (Postfix) with SMTP id 7811B3A688B for <hybi@ietf.org>; Sun, 22 Aug 2010 12:31:42 -0700 (PDT)
Received: (qmail 9259 invoked from network); 22 Aug 2010 19:32:13 -0000
Received: from [192.168.1.11] (ferg@66.92.8.203 with plain) by smtp112.biz.mail.sp1.yahoo.com with SMTP; 22 Aug 2010 12:32:13 -0700 PDT
X-Yahoo-SMTP: L1_TBRiswBB5.MuzAo8Yf89wczFo0A2C
X-YMail-OSG: ZvUvYhUVM1m2karILlHvtr5chZMH1gK17_DhTwUZ45LcyK. nrOmk5tbEsx.xgBo_tmoKrEeSi41_fYhf8VDfoi7FO.gZIGP_joiLCkRLLYB sLnn9Ti6JZ7K.Bv1iQp7ZGZK0mODFShTvhz1WJzegkguKjmT47D7wQAYZrIy 4T9ElXLm0mQRNxlqKTw_iaQFvtO2MJs6dc5Y00ep1ft3aKoWoKomZkasHlBi .XWJRSr.KAoy7nNIvYpjuc8p.Cwqvukajqe2RhOXZf3an_kfwm.f5mnJOwMy RnZQcjq853YfQkPS_mu2gmHCZjx2VxaEkgKUvdhzWZA2aiQOxWF4-
X-Yahoo-Newman-Property: ymail-3
Message-ID: <4C717B28.4070009@caucho.com>
Date: Sun, 22 Aug 2010 12:31:52 -0700
From: Scott Ferguson <ferg@caucho.com>
User-Agent: Thunderbird 2.0.0.24 (X11/20100411)
MIME-Version: 1.0
To: Salvatore Loreto <salvatore.loreto@ericsson.com>
References: <AANLkTimKbmcpgx8k0uXUWvCO=8w9pPrtV=3y4qh6363k@mail.gmail.com> <20100820192927.GA32620@1wt.eu> <4C6EEA55.2050205@hs-weingarten.de> <AANLkTinHqxUOZaVANFpC52t8FfgNw2L5_A-s9Az3Fm7p@mail.gmail.com> <AANLkTinvkxMP8FYz9xjDu_Kt9FfzYotgsqXUDB4MZMEo@mail.gmail.com> <AANLkTim3KRq1arso7wN_b+1TH3sWabYW6uFu7AbYw6-P@mail.gmail.com> <AANLkTikhhajho895WyEoJMwMk9GJ98kA0Mjy5qr4apC8@mail.gmail.com> <AANLkTi=kdk6BRvza_7bpoLNTFzUkjcRRijGLMe_NGXZV@mail.gmail.com> <AANLkTi=VE298Tg+qyfufhzMswE5pBxtPZhA0t2k=sf2A@mail.gmail.com> <4C717048.5020309@ericsson.com>
In-Reply-To: <4C717048.5020309@ericsson.com>
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
Content-Transfer-Encoding: 7bit
Cc: hybi@ietf.org
Subject: Re: [hybi] frame length encoding
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 22 Aug 2010 19:31:43 -0000

Salvatore Loreto wrote:
> On 8/21/10 9:59 PM, Pieter Hintjens wrote:
>> On Sat, Aug 21, 2010 at 9:34 PM, John Tamplin<jat@google.com>  wrote:
>>
>>    
>>> The main difference between #0 and #1 is that #0 uses one of three 
>>> reserved
>>> bits.  They are easy to spend, but then when we find out we need 
>>> them it
>>> becomes much more expensive to get them back.
>>>      
>> Indeed.  Adding another 8 reserved bits in the header does not seem 
>> wasteful.
>>    
> (as individual)
>
> I agree on the fact that with the fact that adding an extra byte to 
> the WebSocket header would
> cost very little also for very small payload.
>
> I don't understand because 4bytes basic header (+length field 
> +payload) as defined in 
> http://tools.ietf.org/html/draft-ietf-core-coap-01#section-3.1
> is good for constrained devices and constrained networks: btw 
> constrained devices are the one usually just exchanging 1byte payload
>
> and we can not define a 2byte basic header (+length field +payload) 
> for WebSocket, reducing the complexity present in the previous proposals
> using 1 or 2 bits to indicate the length header,
> and also providing more room (bits) for future extensions (actually we 
> could also think to use 2bits for version the protocol)


Something like the following?

 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+---+-------+---------------+
|F|T|LEN|OPCODE | reserved(8)   |
|I|M|   |       |               |
|N|L|   |       |               |
+-+-+---+-------+---------------+

LEN: 00 = 1 byte length
     01 = 2 byte length
     10 = reserved (or 4 byte)
     11 = 8 byte length

It might also be possible to define 00 to use the reserved byte for an 
ultra-compact header, or 00 could be ultra-compact, and 01 could be the 
normal 1 byte after the reserved and 10 be 2 byte.

LEN: 00 = 0 byte length (uses reserved byte)
     01 = 1 byte length
     10 = 2 byte length
     11 = 8 byte length

(For versioning, a hello opcode might be better than taking up frame 
bits, and a hello opcode would also allow digest-authentication 
credentials to piggyback on the handshake replacing the 8 random bytes, 
which is an idea I'd like to bring up when we get to discussing the 
handshake because I'd love to save a roundtrip when authenticating 
non-browser clients.)

-- Scott
>
> cheers
> /Sal
>