Re: [hybi] how do we move forward on agreeing on framing?

gustav trede <gustav.trede@gmail.com> Thu, 19 August 2010 19:18 UTC

Return-Path: <gustav.trede@gmail.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 88ACF3A68AB for <hybi@core3.amsl.com>; Thu, 19 Aug 2010 12:18:13 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.598
X-Spam-Level:
X-Spam-Status: No, score=-2.598 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, HTML_MESSAGE=0.001]
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 Y9bwhQXg2gPg for <hybi@core3.amsl.com>; Thu, 19 Aug 2010 12:18:12 -0700 (PDT)
Received: from mail-wy0-f172.google.com (mail-wy0-f172.google.com [74.125.82.172]) by core3.amsl.com (Postfix) with ESMTP id DA49B3A688F for <hybi@ietf.org>; Thu, 19 Aug 2010 12:18:11 -0700 (PDT)
Received: by wyb40 with SMTP id 40so2687840wyb.31 for <hybi@ietf.org>; Thu, 19 Aug 2010 12:18:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=RKHcwl366+IQvzJKM/nMTjiTAEalkKESzvbmv0TZA3s=; b=G2/SPrHAEidfn5llBXP9WYK9sl0H1KVlBSKuaVIE1V28xwl1ysBKar/5acAxV0nEDM lU0+KCxOqc82hp9da+hdQBi94b4t8lg3wAgcdHij4iaFnRb5/RvR2b2SLyqUeQidHmpq FiMSQrzqLmIpz5Jby+6Z0Oqkw0QYBGLzU1Pus=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=uhuU9E52WSbvHbfg8WHjDOiThYsIKPkfu9T7RZMlugnowycfMTHiVIb/Rp/wHSdcZs wIUkrZSKumkTjbLON8GrZGn9Lc5zHxBkLL41EluDs95DgN9tJrbaoUQ9mz8G7d3VUe+h r2ioDjiD+NC3MyZcWLF4EZe0s6a29V7tqacbU=
MIME-Version: 1.0
Received: by 10.216.233.234 with SMTP id p84mr238629weq.38.1282245526102; Thu, 19 Aug 2010 12:18:46 -0700 (PDT)
Received: by 10.216.172.139 with HTTP; Thu, 19 Aug 2010 12:18:45 -0700 (PDT)
In-Reply-To: <AANLkTinu+3AYRuQJXXoUa6mw4UAuGxO1Wu5pOfs7NFCP@mail.gmail.com>
References: <AANLkTineuhvGsC_vca6AiAX8OmHdkE-7s7rA1DQtjtMm@mail.gmail.com> <1282231803.22142.649.camel@vulcan.aspl.local> <AANLkTim44=x0BRpF3BYMqS9GNzHA+icG818JgfRRaFPT@mail.gmail.com> <AANLkTi=tw7PPQzn4U0qEO7dDKncWUt0J8eUK2QBoHq90@mail.gmail.com> <AANLkTinu+3AYRuQJXXoUa6mw4UAuGxO1Wu5pOfs7NFCP@mail.gmail.com>
Date: Thu, 19 Aug 2010 21:18:45 +0200
Message-ID: <AANLkTimVM2cGtx0zB1X8_5EKMnG590w6nbRuO39ae-SO@mail.gmail.com>
From: gustav trede <gustav.trede@gmail.com>
To: John Tamplin <jat@google.com>
Content-Type: multipart/alternative; boundary="000e0cd51cf01922b5048e320d86"
Cc: Hybi <hybi@ietf.org>
Subject: Re: [hybi] how do we move forward on agreeing on framing?
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: Thu, 19 Aug 2010 19:18:13 -0000

On 19 August 2010 19:28, John Tamplin <jat@google.com> wrote:

> On Thu, Aug 19, 2010 at 1:02 PM, gustav trede <gustav.trede@gmail.com>wrote:
>
>> Only one thing that i fail to understand, regarding the payload length
>> encoding:
>> What technical reason makes it so much better then the original binary
>> frame length encoding( if (byte[i]&0x80)==0x80) to detect the length bytes)
>> that its rather massive waste of bandwidth is justified ?.
>>
>
> There are a couple of problems with it:
>
>    - you can have an arbitrary number of leading 0x80 bytes, so there is
>    no single representation of a length
>
> you have to parse yes, like you must do regardless while interpreting the
bits and bytes the protocol is. whats the _real_ problem here ?.

>
>    - you can have an arbitrary number of length bytes, which means to
>    properly support the spec you have to implement multi-precision arithmetic.
>     In practice, implementations will likely use 32 or 64-bit ints, and then
>    some attacker will exploit those implementations.  With this proposal, every
>    implementor knows they must support 64-bit lengths
>
>
What is the real world gain regarding guarantied super frame lengths ?.
Servers are supposed to do exactly what with valid but impossible to handle
frames lengths ?.

Whacking connection is what IMO will be done with the spec "valid" evil
clients, unless we add standardized max frame length negotiation like TCP
does for its various limits (yay! for complex protocol..),
That brings us back to square 1 again:
The supported length will for a few decades be, just like with unlimited
frame lengths something that is limited below the application implementation
layer.

If we are to guarantee a frame length in the spec, it must be something that
servers can handle today,
and then we can add negotiation that client can initiate if it wants more.
Or no limit at all and always do negotiation.


>
>
you now have 9 steps in the length, and I don't think they are justified.  I
> think the 8 bytes of length is not significant for a larger message, so in
> the worst case you have 127 payload bytes, so the overall message length is
> 137 bytes (2 byte fixed header, 8 byte extended length, payload) -- giving
> an overhead of 7.3%.  More typical payload sizes will result in overheads of
> the extra length bytes of well under half a percent.
>
> The two length encoding mechanisms compare like this (ignoring the
> opcode/flags byte, and any TCP/IP headers), with overall overhead
> percentages for each:
>
>    - 0-126 octets - both take one additional byte
>    - 127 octets - v76 takes 1 byte, this proposal takes 9 (1.6%, 7.3%)
>    - 128-16383 octets - v76 takes 2 bytes, this proposal takes 9
>    (2.3%-.02%, 7.2%-.06%)
>    - 16384-2097152 octets - v76 takes 3 bytes, this proposal takes 9
>    (.03%-.0002%, .06%-.0005%)
>    - ...
>
> You can already see that there is no significant difference in overhead for
> the larger packet sizes, yet we have the complexity of all these different
> size length values for little benefit.  When you consider TCP/IP headers as
> well, the difference in overhead is negligible.
>
>
Yes, it is more efficient to have a 2-byte length format for small packets
> just above 127 bytes, but is that worth the additional complexity of extra
> length steps?  Profiling of real-world WebSocket apps (admittedly, there are
> few currently) suggests that there will be lots of very small packets
> (especially once compression is supported), and a few larger packets.  So I
> think that matches well with the proposal to provide exactly two steps of
> length sizes.
>
>
Compression algorithms choice that is optimized for each specific usage case
is possible once binary frames are allowed.
That will still be something to do even if there is algorithm x added to the
standard protocol, because x is not the universal best choice.
With the current development of jscript performance its viable to let it do
some compression, at least for chat text and game state data.