Re: [hybi] frame length encoding

John Tamplin <jat@google.com> Sun, 22 August 2010 16:39 UTC

Return-Path: <jat@google.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 A42713A688B for <hybi@core3.amsl.com>; Sun, 22 Aug 2010 09:39:02 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -105.255
X-Spam-Level:
X-Spam-Status: No, score=-105.255 tagged_above=-999 required=5 tests=[AWL=0.721, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-4, USER_IN_WHITELIST=-100]
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 LK9MrNgBEKSv for <hybi@core3.amsl.com>; Sun, 22 Aug 2010 09:39:01 -0700 (PDT)
Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.35]) by core3.amsl.com (Postfix) with ESMTP id E50623A68DF for <hybi@ietf.org>; Sun, 22 Aug 2010 09:39:00 -0700 (PDT)
Received: from wpaz5.hot.corp.google.com (wpaz5.hot.corp.google.com [172.24.198.69]) by smtp-out.google.com with ESMTP id o7MGdXOh003615 for <hybi@ietf.org>; Sun, 22 Aug 2010 09:39:33 -0700
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1282495174; bh=r6czsxg9IZv/5177KgEMFXmAvx8=; h=MIME-Version:In-Reply-To:References:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=E4QBrKlUSx2Ghsk0/OLYvN2O+Ry0cYPOa7kgwO1GrbZZOuXK+6/Re499mkgSbW8Cd pFntAAee0YKMBofgV3vdQ==
DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:in-reply-to:references:from:date:message-id: subject:to:cc:content-type:x-system-of-record; b=eS/eLiN3X4vDu2moEp3FvUMBP9XaKiNvfMWXFlXl5jEDwTq3NOHCv7PomKXlqu/CZ KB0BYc+QNFvJOp9S7KYQA==
Received: from ywt2 (ywt2.prod.google.com [10.192.20.2]) by wpaz5.hot.corp.google.com with ESMTP id o7MGdW28006160 for <hybi@ietf.org>; Sun, 22 Aug 2010 09:39:32 -0700
Received: by ywt2 with SMTP id 2so508162ywt.27 for <hybi@ietf.org>; Sun, 22 Aug 2010 09:39:32 -0700 (PDT)
Received: by 10.151.78.6 with SMTP id f6mr4035336ybl.68.1282495172196; Sun, 22 Aug 2010 09:39:32 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.151.60.3 with HTTP; Sun, 22 Aug 2010 09:39:12 -0700 (PDT)
In-Reply-To: <AANLkTimo0MwZEMn1t1vrASfwC1bx82Q9Z_Ls3wVb-zUS@mail.gmail.com>
References: <AANLkTimKbmcpgx8k0uXUWvCO=8w9pPrtV=3y4qh6363k@mail.gmail.com> <alpine.DEB.2.00.1008212037190.27211@tvnag.unkk.fr> <AANLkTinrsT+wV48nHvVW_1ChGYffkq7jisU2-PZnMyKg@mail.gmail.com> <alpine.DEB.2.00.1008212123460.27211@tvnag.unkk.fr> <20ef7ed5e135c57c1ee5a741658b9d98.squirrel@sm.webmail.pair.com> <1282423311.2014.6.camel@tng> <224b9ed365bd78fd5e316b8cb5f3f837.squirrel@sm.webmail.pair.com> <1282435214.2014.14.camel@tng> <AANLkTimo0MwZEMn1t1vrASfwC1bx82Q9Z_Ls3wVb-zUS@mail.gmail.com>
From: John Tamplin <jat@google.com>
Date: Sun, 22 Aug 2010 12:39:12 -0400
Message-ID: <AANLkTimQxo0d9TW+ApKLfWrSwutMYL4MJBVRWtxP1sC5@mail.gmail.com>
To: Brian <theturtle32@gmail.com>
Content-Type: multipart/alternative; boundary="0015174bed782a39ad048e6c2dbe"
X-System-Of-Record: true
Cc: Hybi <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 16:39:02 -0000

On Sun, Aug 22, 2010 at 3:57 AM, Brian <theturtle32@gmail.com> wrote:

> As much as I feel that 63-bits is ridiculously large for the frame length,
> I'd be happy to accept it and just move on to the next item of discussion --
> though the WS server I'm writing right now will consider any frame with a
> non-zero bit in the high 31-bits of the long long length field to be an
> error condition, and immediately drop the rogue/attacking/misbehaving
> client.  I don't want to be bound to treat absurdly large frames as
> potentially legitimate by an overzealous specification.  Furthermore, I'm
> writing my server with Node.js, which, being a JavaScript-based environment
> itself, doesn't even have a 64-bit integer type of any sort.  I *can't*
> correctly handle a 63-bit frame.  Ah, the irony of a protocol meant for
> JavaScript applications that's impossible to fully implemented in JavaScript
> (at least efficiently -- no bignum libraries allowed.)  And who knows what
> would happen with the actual frame data in, say, a JavaScript String, with a
> frame of a few terabytes?  Assuming anyone had that much RAM?   We're
> talking about JavaScript clients here, so no streaming to disk, etc....
>
> In my not-so-humble opinion, trying to accommodate sending large files
> through WebSockets is a complete and utter misdirection.  The protocol
> exists to provide real-time interactivity support to browsers.  That's what
> it's meant for.  If someone wants to send large chunks of data (>4GB) in one
> frame, they should find another protocol, because they're clearly not
> planning to process it in JavaScript in a web-browser client.  And if
> they're not running in the browser, there's no reason they have to use WS.
>  Making abusers of the protocol chunk at 4GB boundaries is more than
> reasonable when you consider that the vast majority of users won't begin to
> consider sending fragments anywhere near even a fraction of that size.  This
> is not and should not be an all-things to all-people protocol.  We shouldn't
> be designing for these edge cases just because the protocol could
> theoretically enable any number of diverse applications.
>

Just because the JS API today passes the messages totally in RAM, there is
no reason that it can be extended to support a stream-like API if processing
larger messages becomes justified.  However, at the framing level, we have
to have something in place such that v1.0 implementations written against
this spec can interoperate with later extensions, so it seems prudent to
make sure the protocol is sufficient for any reasonably forseeable needs.
 There were several strong arguments that 32-bits isn't enough, and the next
logical step up is 63/64-bits.

Personally, I would be perfectly happy with a 32-bit maximum frame length,
and let senders fragment larger messages.  However, there were significant
objections (see the discussions link from
http://www.ietf.org/mail-archive/web/hybi/current/msg03399.html for details)
about being required to fragment a message when its size was known, and the
fact that it made "fire and forget" of sending the message contents with a
single sendfile() call impossible (when larger than 4G).  Thus, it seemed
likely the only way to gain consensus was to support a maximum frame length
much larger than 32 bits.

I agree in the spec we need to clarify behavior regarding frame size.  I
suspect we will wind up adding some way of declaring maximum acceptable
frame size during the handshake, but we have yet to start working on trying
to nail that down.

-- 
John A. Tamplin
Software Engineer (GWT), Google