Re: [hybi] Is it important to know frame length at the start of frame? (was: Re: Discontinuation of mux ...)

Takeshi Yoshino <tyoshino@google.com> Thu, 13 February 2014 04:38 UTC

Return-Path: <tyoshino@google.com>
X-Original-To: hybi@ietfa.amsl.com
Delivered-To: hybi@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id EA01C1A00E9 for <hybi@ietfa.amsl.com>; Wed, 12 Feb 2014 20:38:47 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.926
X-Spam-Level:
X-Spam-Status: No, score=-1.926 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RP_MATCHES_RCVD=-0.548, SPF_PASS=-0.001] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yZx_UBbeIigG for <hybi@ietfa.amsl.com>; Wed, 12 Feb 2014 20:38:44 -0800 (PST)
Received: from mail-wi0-x22b.google.com (mail-wi0-x22b.google.com [IPv6:2a00:1450:400c:c05::22b]) by ietfa.amsl.com (Postfix) with ESMTP id 6D0361A00EB for <hybi@ietf.org>; Wed, 12 Feb 2014 20:38:43 -0800 (PST)
Received: by mail-wi0-f171.google.com with SMTP id cc10so7983902wib.16 for <hybi@ietf.org>; Wed, 12 Feb 2014 20:38:41 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=RYIB61UZ0UCld+V/iPX/WNH/dv91umbIVE70pldQgy8=; b=fvMW7sZpcjT+TxExIMhiM5a0hmdHPIrQ3zsM+ljHmsiYhMBCWRPZPHx/tGOQaVvYuz S/3sRBEVfCg/KjGkOogTdxi3ZgDIkkXNHZhDT5MvgOTxCSIgoZ33N89ZI7V1PTclfPz9 M/Iw4x8o7feN9DsmLjf5pXBJnm6m8Hj+8CfTVx667/94wR1IplhN4XGOgwvk5YeNzUrB ttHRj69aArfxRO/rPkWCqcsWFLU2qLp93IQvTA4DleOaZCRoH2Z2Lj0hcbENI6xo651S 2+4NNlYmT62ZsGQZFg/cjKxMg6OHjBBs5w+cgScDd7JoZ7cG4wP25sNX/xFOrkmoZCWN CqLw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=RYIB61UZ0UCld+V/iPX/WNH/dv91umbIVE70pldQgy8=; b=a9lcgmBUk5IO2iejfDh0dGdhjVe5E5gX+/ev9CnqFI4FhX6siDUzEiuV9NjeWNqYxP bKBaAcvHLDsfkTXC0OS5s/2G9krtRum/cUbj1WKUakuHm7xBOcnL0TkSnMLnXBj0V5+n VKJ9rdnzqoDesResW3msElNoLQyhR2/73hlyCel9ntpSK/xvCFUXCsTb9W20yLAktjD4 OYuepBVOrj9qo7TbmD2ED8/5l37ph09xXbYsn9VhgaKO2JTELQqSJMYkVkC6Kgi4Z4Wj xT9ivx8h1ZTaTSblmQVuRN0Kilu70BwpsynaJ3e+O/ptnxw9UhOHlrwpiDnULYKy41W8 +Auw==
X-Gm-Message-State: ALoCoQmJkpKRRJ8hvw7w09EQltcIabaIpUzwHQalPE8doWOcARiulISe4EJlHVWjsckdYxcLk8nz8nKJ48LMPTPupnk3i3ZOorjpls9sEcOpxtoQfZ2EsyCRIT/B6V/1KTwAVcPpAD+TI7Bape+IKDD2jOntb8zKyjM5Lf9XjvGsVIfyJ2daXM6EAvq3OZTvVdZfxNuAsBVj
X-Received: by 10.194.110.41 with SMTP id hx9mr4205658wjb.28.1392266321516; Wed, 12 Feb 2014 20:38:41 -0800 (PST)
MIME-Version: 1.0
Received: by 10.194.8.231 with HTTP; Wed, 12 Feb 2014 20:38:21 -0800 (PST)
In-Reply-To: <CAG4zZZA4WR50Ea2e36XEgTgpJURwiMFn+DXeYuxHFfZatYzDOQ@mail.gmail.com>
References: <CAH9hSJbf_ABT7ECL9eS=_ADrncX8qBtxZv=uLcdu9_6GUv23Uw@mail.gmail.com> <CACuKZqEcA1Pv8RpWfmThMjTzi2BbVMMKXqujs6BxVfxRPZJ9NQ@mail.gmail.com> <CAG4zZZCr4aTfVpw2coX2g0qw++4kdgNCFVze6tHKZ+fJNqb0aQ@mail.gmail.com> <CAG4zZZA4WR50Ea2e36XEgTgpJURwiMFn+DXeYuxHFfZatYzDOQ@mail.gmail.com>
From: Takeshi Yoshino <tyoshino@google.com>
Date: Thu, 13 Feb 2014 13:38:21 +0900
Message-ID: <CAH9hSJYv5VXGjS7AfG12-ArEvE6Uj_eE6pPxAiQcchcgV8vHcg@mail.gmail.com>
To: Joakim Erdfelt <joakim@intalio.com>
Content-Type: multipart/alternative; boundary="089e010d89e0871e2904f24243e9"
Cc: "hybi@ietf.org" <hybi@ietf.org>
Subject: Re: [hybi] Is it important to know frame length at the start of frame? (was: Re: Discontinuation of mux ...)
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/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, 13 Feb 2014 04:38:48 -0000

Joakim,

In my post, I was doubting necessity of frame length header IN THE CONTEXT
OF WebSocket over HTTP/2.0 discussion as the HTTP/2.0 DATA frame also has a
frame length that is immediately decodable and you can choose to send a big
one DATA frame to send a big message to tell the peer that it's a big frame
at the start of arrival of the frame. Not doubting necessity of frame
length in general.

However, I noticed that I didn't consider that the size of the frame length
field of the current HTTP/2.0 spec is very small. It's 14 bit. Old SPDYs
used 24 bits (and the latest SPDY/4 uses 16 bits).

So, without help by WebSocket level length field, even by using an
un-fragmented WebSocket frame (at WebSocket semantics level), we cannot
tell the peer that "we're sending a message which is N (N > 16k) bytes
long" on the first DATA frame. Sorry that I didn't notice this point.


On Thu, Feb 13, 2014 at 1:19 AM, Joakim Erdfelt <joakim@intalio.com> wrote:

> Eliminating the size from the frame also eliminates the ability to
> fast-fail on excessive messages.
>
> Scenario (with current RFC6455 / WS+HTTP/1.1):
>   Sending side starts to write out a single message of 100MB.
>   Receiving side, using a whole message delivery based API is configured
> for max messages of 20MB.
>   Receiving side sees the 100MB frame size and automatically closes the
> connection with 1009 and doesn't bother reading past the current network
> buffer.
>
> Scenario (without frame sizes):
>   Sending side starts to write out a single message of 100MB.
>   Receiving side, using a whole message delivery based API is configured
> for max messages of 20MB.
>   Receiving side reads till the 20MB mark, then fails the connection with
> 1009.  Wasting time, memory, and resources for no good reason.
>
> I really don't see how a discussion of a protocol without sizes is even
> going on.
> I mean, even the IP layer and TCP layer have sizes for their frames.
>
>
>
> --
> Joakim Erdfelt <joakim@intalio.com>
> webtide.com <http://www.webtide.com/> - intalio.com/jetty
> Expert advice, services and support from from the Jetty & CometD experts
> eclipse.org/jetty - cometd.org
>
>
> On Wed, Feb 12, 2014 at 9:13 AM, Joakim Erdfelt <joakim@intalio.com>wrote:
>
>> Scenario:
>>   Sending side uses a message stream based API to write out 1 websocket
>> message.
>>   The sending side's API is configured/implemented to buffer only 16k at
>> a time, writing out a frame of 16k for each buffer filled.
>>   The sending side writes out a 600k message.
>>   The receiving side is using a different API, one that is based on
>> complete messages.
>>   The receiving side is configured to not accept messages over 100k.
>>   The receiving side's API/implementation tosses a close code 1009 to the
>> sending side, per API.
>>   The receiving side's endpoint receives an error and close notification
>> indicating a protocol closure due to excessive message size from sending
>> side.
>>
>>
>>
>> --
>> Joakim Erdfelt <joakim@intalio.com>
>>  webtide.com <http://www.webtide.com/> - intalio.com/jetty
>> Expert advice, services and support from from the Jetty & CometD experts
>> eclipse.org/jetty - cometd.org
>>
>>
>> On Wed, Feb 12, 2014 at 9:00 AM, Zhong Yu <zhong.j.yu@gmail.com> wrote:
>>
>>> Why not send the message in one frame? The frame length is then the
>>> message length.
>>>
>>> One argument for fragmentation is to insert control frames while
>>> transmitting a long message. However that reasoning is not very
>>> convincing:
>>>
>>> PONG - as long as we are writing data, any data, the peer should see
>>> that the connection is alive. It's unreasonable for the peer to think
>>> that our end is unresponsive while it is receiving data from us.
>>>
>>> PING - not necessary while we are writing data. If peer is
>>> unresponsive, we'll learn that from TCP layer.
>>>
>>> CLOSE - closing the connection in the middle of a message is abnormal
>>> anyway, it's probably not important to do the close handshake.
>>>
>>> Zhong Yu
>>>
>>>
>>> On Fri, Feb 7, 2014 at 1:30 AM, Takeshi Yoshino <tyoshino@google.com>
>>> wrote:
>>> > I remember that in early days of the standardization, somebody was
>>> proposing
>>> > (*) that we should have a message length field in the first fragment to
>>> > allow for allocating buffer for full message at the beginning.
>>> >
>>> > On Thu, Jan 16, 2014 at 3:27 PM, "Martin J. Dürst" <
>>> duerst@it.aoyama.ac.jp>
>>> > wrote:
>>> >>
>>> >> On 2014/01/16 15:05, Yutaka Hirano wrote:
>>> >>>
>>> >>> Hi Joakim,
>>> >>>
>>> >>> Thanks for the comment.
>>> >>>
>>> >>> Knowing the size of a frame at the start of the frame, traditional
>>> >>>>
>>> >>>> websocket behavior, is desired, as it allows us to fast fail for the
>>> >>>> 1009
>>> >>>> (message too big) use case.
>>> >>>
>>> >>>
>>> >>> Do you know how effective it is?
>>> >>>
>>> >>> Having no prior knowledge of frame size is undesirable to us.
>>> >>>
>>> >>> On the other hand, the frame sender have more freedom because they
>>> don't
>>> >>> have to know the size of the frame in front.
>>> >>
>>> >>
>>> >> My understanding of why messages are split into frames was that this
>>> would
>>> >> allow to start a message without knowing its length. But if you don't
>>> know
>>> >> the size of a frame before sending it, then the right solution is to
>>> make it
>>> >> smaller. Frames are just arbitrary pieces of a message.
>>> >
>>> >
>>> > We should be clear if we want to make it able to
>>> > (a) know the length of WebSocket frame on receiving the header of each
>>> > fragment
>>> > (b) know the length of WebSocket message on receiving the first
>>> fragment
>>> >
>>> > As the proposal (*) has been rejected and not in the RFC6455 header,
>>> (b) is
>>> > not true even in RFC6455. What Joakim said should be to keep (a) which
>>> is
>>> > true now in RFC6455.
>>> >
>>> > But if a message is fragmented into smaller frames, we cannot reject
>>> (and
>>> > send 1009) the message on receiving the first frame. "Whether we can
>>> > fast-reject a big message on receiving some non-final frame" depends
>>> on how
>>> > the peer fragments a message.
>>> >
>>> > In some plans discussed in the main thread, it's planned to drop frame
>>> > length info for efficiency. But something else such as the length
>>> field of
>>> > HTTP/2.0 DATA frame tells how much data the fragment (when multiple
>>> DATAs
>>> > convey a WebSocket frame, each DATA would be called fragments of a
>>> frame)
>>> > contains. So, we won't be able to know the length of fragments
>>> > (original/encapsulated WebSocket frames) on receiving each of them, but
>>> > still be able to know the length of sub-fragments (e.g. HTTP/2.0 data
>>> > frames).
>>> >
>>> > I think this change is acceptable and shouldn't be considered as
>>> breaking of
>>> > RFC6455 semantics. Even in the mux extension I was editing
>>> > (http://tools.ietf.org/html/draft-ietf-hybi-websocket-multiplexing-11),
>>> I
>>> > made the same change. The length of the encapsulated frame is unknown
>>> until
>>> > receiving all the fragments of the encapsulating message. No one was
>>> > objecting to that when we were discussing the spec, IIRC.
>>> >
>>> >
>>> > _______________________________________________
>>> > hybi mailing list
>>> > hybi@ietf.org
>>> > https://www.ietf.org/mailman/listinfo/hybi
>>> >
>>>
>>> _______________________________________________
>>> hybi mailing list
>>> hybi@ietf.org
>>> https://www.ietf.org/mailman/listinfo/hybi
>>>
>>
>>
>