Re: [hybi] Framing take IV

Ian Fette (イアンフェッティ) <ifette@google.com> Wed, 04 August 2010 00:57 UTC

Return-Path: <ifette@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 2B5D63A6B7C for <hybi@core3.amsl.com>; Tue, 3 Aug 2010 17:57:57 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -101.075
X-Spam-Level:
X-Spam-Status: No, score=-101.075 tagged_above=-999 required=5 tests=[AWL=0.001, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, J_CHICKENPOX_32=0.6, MIME_8BIT_HEADER=0.3, 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 mLPzr29CHLZr for <hybi@core3.amsl.com>; Tue, 3 Aug 2010 17:57:55 -0700 (PDT)
Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.35]) by core3.amsl.com (Postfix) with ESMTP id D1C973A68DE for <hybi@ietf.org>; Tue, 3 Aug 2010 17:57:54 -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 o740wM1C031388 for <hybi@ietf.org>; Tue, 3 Aug 2010 17:58:23 -0700
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1280883503; bh=+YkB3bjB2MhLFAlQ3xy5nbRibm4=; h=MIME-Version:Reply-To:In-Reply-To:References:Date:Message-ID: Subject:From:To:Cc:Content-Type; b=IWVePdlDbKjN0OSLeOKy4XCCIszIkP8vQOMfCh6u+U4O/rQncnihPT47ahzo3Y3vE LPzOxd0UswEz3+bDiDnUg==
DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:reply-to:in-reply-to:references:date: message-id:subject:from:to:cc:content-type:x-system-of-record; b=LLATVq5h+iuznEdmGOJWdx5NVYdvZcrn8LQ5rPo9I9+ocfG/wpKs5ByDHf45eQEdl ZzucPn5DiR2a2mQXRB8ow==
Received: from gwb10 (gwb10.prod.google.com [10.200.2.10]) by wpaz5.hot.corp.google.com with ESMTP id o740wLId017366 for <hybi@ietf.org>; Tue, 3 Aug 2010 17:58:21 -0700
Received: by gwb10 with SMTP id 10so1993302gwb.8 for <hybi@ietf.org>; Tue, 03 Aug 2010 17:58:21 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.151.63.26 with SMTP id q26mr9646637ybk.193.1280883500819; Tue, 03 Aug 2010 17:58:20 -0700 (PDT)
Received: by 10.150.67.19 with HTTP; Tue, 3 Aug 2010 17:58:20 -0700 (PDT)
In-Reply-To: <AANLkTinyrDoG5d_Ur6HVRy=SgMPjLzJtpJ++Ye=1DQdj@mail.gmail.com>
References: <AANLkTinyrDoG5d_Ur6HVRy=SgMPjLzJtpJ++Ye=1DQdj@mail.gmail.com>
Date: Tue, 03 Aug 2010 17:58:20 -0700
Message-ID: <AANLkTikPotideCqpBWQw1BqWLYjaPr7dT5vL1d3S5RBo@mail.gmail.com>
From: "Ian Fette (イアンフェッティ)" <ifette@google.com>
To: Greg Wilkins <gregw@webtide.com>
Content-Type: multipart/alternative; boundary="000e0cd5958e10a5e4048cf4ee22"
X-System-Of-Record: true
Cc: hybi@ietf.org
Subject: Re: [hybi] Framing take IV
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: ifette@google.com
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: Wed, 04 Aug 2010 00:57:57 -0000

On Tue, Aug 3, 2010 at 5:38 PM, Greg Wilkins <gregw@webtide.com> wrote:

>
> I'd like to refocus on what I believe we do have near-consensus on, so that
> we don't lose progress while we debate other possible features.
>
>
> I think that we have reasonable consensus on something like:
>
>   +--------------------------------------------------+
>   | frag(1) |unused(3) | opcode(4) |  Length(16)     |
>   +--------------------------------------------------+
>    |                      Data                        |
>   +--------------------------------------------------+
>
>     ws-frame            = frame-fragment
>                           frame-unused
>                           frame-opcode
>                           frame-length
>                           octet-data
>
>     frame-fragment      = %x0 ; 1 bit not a fragment
>                         | %x1 ; 1 bit fragment
>
>     frame-unused        = %x0 ; 3 bits
>
>     frame-opcode        = %x0 ; text data frame
>                         | %x1 ; binary data frame
>                         | %x2 ; ping
>                         | %x3 ; pong
>                         | %xf ; final frame
>
>     frame-length        = %x0000-FFFF
>
>     octet-data          = *( %x00-FF )
>
>
> I think there are no strong feelings either way on padding, but it is easy
> to add to any proposal, so let's sort the detail first and then consider
> padding at the very end.
>
> I do not think we have any consensus on compression, but the above framing
> can be easily extended at a later date (compressed opcodes, or add
> compressed bit, or just compress the stream).
>
> We are still a bit in the wilderness with regards to meta-data and
> multi-plexing.  However the above framing is at least extensible and would
> allow those and other extensions to be added by defining some new
> op-codes.
> But the problems with this style of extensibility are:
>
>    - The op-code space must be managed to avoid collisions, so that would
>    limit experimental and/or special purpose extensions
>    - Any extension data will be in it's own frame, and thus not directly
>    associated with a data frame, so extensions like multiplexing will be more
>    stateful and vulnerable to inserted frames.
>
> Neither of these problems are show stoppers, although they do combine
> badly.. ie multiplexing can be done with a channel switch and flow control
> frames, but only if op-codes are allocated to it and that will need
> centralized consensus on one true multiplexing algorithm.
>
>
>
> We have had many proposals about how to improve the extensibility of the
> framing, but so far I think only the proposal from roberto truly addresses
> the issue of non-centralized extensibility and extensions per frame.  His
> proposal was to optionally include meta-data with every frame - I refined
> that proposal to make the meta data easily ignorable:
>
>   +--------------------------------------------------------+
>   | frag(1) |opcode(3) | meta-length (12) |  Length(16)    |
>   +--------------------------------------------------------+
>   |                       Meta Data                        |
>   +--------------------------------------------------------+
>    |                          Data                          |
>   +--------------------------------------------------------+
>
>     ws-frame            = frame-fragment
>                           frame-opcode
>                           frame-meta-length
>                           frame-length
>                           +(meta-data)
>                           octet-data
>
>     frame-fragment      = %x0 ; not a fragment
>                         | %x1 ; fragment
>
>     frame-opcode        = %x0 ; text data frame
>                         | %x1 ; binary data frame
>                         | %x2 ; ping
>                         | %x3 ; pong
>                         | %xf ; final frame
>
>     frame-length        = %x0000-FFFF
>
>     meta-data           = ; length framed name value pairs
>
>     octet-data          = *( %x00-FF )
>
>
>
>
>
> The other proposal from Martin was that we add a  MIME frame op code:
>
>   +--------------------------------------------------+
>   | frag(1) |unused(3) | opcode(4) |  Length(16)     |
>   +--------------------------------------------------+
>    |                      Data                        |
>   +--------------------------------------------------+
>
>     ws-frame            = frame-fragment
>                           frame-unused
>                           frame-opcode
>                           frame-length
>                           octet-data
>
>     frame-fragment      = %x0 ; 1 bit not a fragment
>                         | %x1 ; 1 bit fragment
>
>     frame-unused        = %x0 ; 3 bits
>
>     frame-opcode        = %x0 ; text data frame
>                         | %x1 ; binary data frame
>                         | %x2 ; MIME data frame
>                         | %x4 ; ping
>                         | %x5 ; pong
>                         | %xf ; final frame
>
>     frame-length        = %x0000-FFFF
>
>     octet-data          = *( %x00-FF )
>
>
> I think Martin proposed it as standard CRLF separated Mime, but I think an
> argument could be made to put a length based encoding within that frame.
> This essentially would make the meta-data of robertos proposal available
> only for a single frame type.  An extension like multiplexing would be
> implemented by converting all binary/text frames to mime-frames.  (I'm not
> exactly sure mime is the right name for them, but let's go with it for now).
>
> Mime frames would allow arbitrary extensions to exchange arbitrary
> meta-data without centralized control.  It is a matter for either end
> how(if?) they would route any such messages to their APIs.
>
> There are many variations on these themes, but I think these are the 3
> basic approaches that have been identified, which I will call:
>
>    1. hixiesque - centralized extension via op-codes
>    2. robertoesque- per frame extension via meta-data
>    3. martinesque - extension via dedicated mime frame (meta-data plus
>    data)
>
> Any others?
>
> I think we really need to pick one of these approaches soon and get on with
> the detail.
>
> My own opinion is that my technical head is drawn to robertoesque solution,
> but my pragmatic head feels that martinesque is sufficient, simpler and more
> likely to get consensus.
>
>
> cheers
>
>
> PS. with a martinesque solution, who would ever use a %x1 binary data
> frame?
>
>
If I had to choose between Roberto's and Martin's, I would prefer Roberto's
simply because I worry that if you have metadata that changes between
messages, e.g. you are multiplexing a number of streams, you will end up
sending a control frame before each data frame, which sort of defeats the
purpose, makes it extra chatty, and opens us up to issues of frame injection
as well. So, I prefer to have whatever extension/meta-data associated with
the frame itself.

The one thing I don't like about Roberto's proposal is that I essentially
have to parse all the metadata to find the particular metadata I'm
interested in. I'm not sure if there are any ways to avoid this or make this
cheaper though if you have to support variable-length metadata, so maybe
it's just a price we pay.

I do think it would make a lot of sense to reserve a byte for stream ID
though. I know that for us (Google) to deploy, one way or another we will
need multiplexing, and I think it would be a lot more efficient if the
stream ID were at a known location than if we had to parse some metadata map
to get it out. I don't really buy the complexity arguments -- for us, the
main interest in WebSockets over JS hanging gets + posts is the ability to
pear down connections (two to one, better if we can multiplex) + more
efficiency. If we can't multiplex then there's not that much of a benefit to
the point where it becomes a lot less interesting to deploy (cost/benefit is
not so clear).