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

Takeshi Yoshino <tyoshino@google.com> Wed, 19 February 2014 03:59 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 22B9E1A0253 for <hybi@ietfa.amsl.com>; Tue, 18 Feb 2014 19:59:48 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.726
X-Spam-Level:
X-Spam-Status: No, score=-0.726 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, J_CHICKENPOX_64=0.6, J_CHICKENPOX_75=0.6, RP_MATCHES_RCVD=-0.548, SPF_PASS=-0.001] autolearn=no
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 IjDWadVRoTx3 for <hybi@ietfa.amsl.com>; Tue, 18 Feb 2014 19:59:45 -0800 (PST)
Received: from mail-wg0-x233.google.com (mail-wg0-x233.google.com [IPv6:2a00:1450:400c:c00::233]) by ietfa.amsl.com (Postfix) with ESMTP id 92F721A0329 for <hybi@ietf.org>; Tue, 18 Feb 2014 19:59:35 -0800 (PST)
Received: by mail-wg0-f51.google.com with SMTP id n12so4010627wgh.30 for <hybi@ietf.org>; Tue, 18 Feb 2014 19:59:32 -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=Pe9lPJnjWfj7yOwg+LOP5ipu0Zids8lgVT7959hAEjY=; b=U9cg3qNcudAXDspsIiAule0k0bYa/JZfqFYRyeL+7ACm0M7H+LYj5xxVrnB2ObOYpo EGKT/I/TrGXc7fU9G8yeayexwvRUQgbGIjmbC/6RWmX4I9RPWAslZCYlXiO5K140L/cW KN7Q6Vy4r5T91tntLrzCRKpXb6bdi7RD8RvgZ50RdIXA5CpmCyAGKB5xG5JogTYejyXq 9iK7gOFOUQnx1L1GjLvQpWxrmo/TpGh7cPYXUVbd97oYmCAbMgwVOlTHBcXTEY7ykwB4 eTzPBNVxMP5Q46EEPbbhIe90+ApvYPeCxiOFvh+2ezNVnYAftMBc7sLY9I3l7A7EIZsZ ot5w==
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=Pe9lPJnjWfj7yOwg+LOP5ipu0Zids8lgVT7959hAEjY=; b=ghyuAuiZEimGBS1CzaPzZufLHI5zj3VW6Ud7ih25HFN5KlqeecLzDqvFXA7oT35DpY RxLgbAWIm/nEz7GLXJtEjbGwA5CXc2Vx1NxDJZhO9rDUS74wQ27uvX4dMd4LsheP5VkE yaUFPzOfN0t3HYdufsL5MPbro1unxa1zO+Fr8WuDLooJCYvTd1XaKjjdqLcL8AvITDft WKaTzIT4xKJzk71wEnK4uLRi9c/ZDmbECiRdqlTBD5x0lc3zKuIpuEpNHPG9Jhg48jJs P/WCKhyxyJXZ6CZOnTPEMI6p8Y8vvO8Q7DWOtlzZMJYgNsW93T03b5A8TtfagRM2+XQm HGjA==
X-Gm-Message-State: ALoCoQkDHuKQBvanQAJyy/uzi3z8x4KgBeJFzPE5NeGht3o89vnYiZi6iUPLDM7E3EaK4krBD2JT2st7wPSVPsrFgHmse5eHiT1gR8/U99a3kl6lOn56UgvJ5vFgy+qjtvOc5nV6UykR6Z5yDOK7KAgigc+Gs4MWA0nfGSa08uNjwAPtAbJ3t8viLpwrjuln9jqRoGvZJZVJ
X-Received: by 10.180.107.136 with SMTP id hc8mr21228003wib.11.1392782372006; Tue, 18 Feb 2014 19:59:32 -0800 (PST)
MIME-Version: 1.0
Received: by 10.194.8.231 with HTTP; Tue, 18 Feb 2014 19:59:10 -0800 (PST)
In-Reply-To: <CAG4zZZB3h6TTFLUp-ucYQP7tMf-8=h5fh1UqufMh3w-0JN+hSw@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> <CAH9hSJYv5VXGjS7AfG12-ArEvE6Uj_eE6pPxAiQcchcgV8vHcg@mail.gmail.com> <CAH9hSJbzra7uz7yfKQwfZaP_jhnxwdZyx8JnwCmBGhiMk6rbtg@mail.gmail.com> <CAG4zZZC1cmaH36znAvVLZE_MyJ+ThNk1Ky7tQ-QnKf_qwiQNDw@mail.gmail.com> <CAG4zZZB3h6TTFLUp-ucYQP7tMf-8=h5fh1UqufMh3w-0JN+hSw@mail.gmail.com>
From: Takeshi Yoshino <tyoshino@google.com>
Date: Wed, 19 Feb 2014 12:59:10 +0900
Message-ID: <CAH9hSJaeCrLjkhHUzaaGDw-apiSv-eaPZeYGEHBuwRoF3yPCOA@mail.gmail.com>
To: Joakim Erdfelt <joakim@intalio.com>
Content-Type: multipart/alternative; boundary="e89a8f3bad4588840e04f2ba6aa7"
Archived-At: http://mailarchive.ietf.org/arch/msg/hybi/ESJb1B_7tDmqsl-HqWv18phK31A
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: Wed, 19 Feb 2014 03:59:48 -0000

Thanks, Joakim. So you're still be able to do the fail-fast without
WebSocket frame length header if we adopt HEADERS+DATA+END_SEGMENT approach
but with WebSocket frame length header eliminated. HTTP/2.0 DATA frame has
its own payload length field though it's small compared to the range
WebSocket header can express.

Takeshi


On Wed, Feb 19, 2014 at 3:12 AM, Joakim Erdfelt <joakim@intalio.com> wrote:

> Clicked too soon on that pseudo code.
> This is more clear. (i hope)
>
>    header = frame.parse_header(network_bytes)
>    if (header.size > system_memory_constraints) then
>       fail_protocol(1009)
>       // do not read payload
>       return
>    end
>    if (message.size + header.size > message.max_constraints) then
>       fail_protocol(1009)
>       // do not read payload
>       return
>    else
>       payload = frame.read_payload(network_bytes)
>       message.append(payload)
>    end
>    if (header.fin == true) then
>       message.deliver_to(local_endpoint)
>       // free up any message resources, reset message size to 0
>       message.reset
>    end
>
>
> --
> 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 Tue, Feb 18, 2014 at 11:08 AM, Joakim Erdfelt <joakim@intalio.com>wrote:
>
>> I'm not sure I was clear, as you seem to still have questions and are
>> hinting at alternatives.
>>
>> The most important thing I said:
>>    The size is important at the start of any payload about to be received.
>>
>> All other statements are based off of that.
>> The nuanced questions you are asking seems to indicate that you treat a
>> frame differently than a message is irrelevant.
>> If the frame happens to represent a complete message (eg:
>> opcode=(text|binary) + fin=true) vs being only 1 frame belonging to a
>> series of frames that make up a whole message makes no difference to the
>> statement.
>>
>> Since websocket is message based, not stream based, the above core
>> statement remains true.
>>
>> The fail-fast example applies for fragmented or whole messages.
>>
>>  some pseudo code:
>>
>>    header = frame.parse_header(network_bytes)
>>    if (header.size > system_memory_constraints) then
>>       fail_protocol(1009)
>>       return
>>    end
>>    // is message still being collected and not yet delivered to local
>> endpoint?
>>    if (message.delivered == false) then
>>       if (message.size + header.size > message.max_constraints) then
>>         fail_protocol(1009)
>>         return
>>       else
>>         payload = frame.read_payload(network_bytes)
>>         message.append(payload)
>>       end
>>    end
>>    if (header.fin == true) then
>>       message.deliver_to(local_endpoint)
>>       message.reset
>>    end
>>
>>
>>  --
>> 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 Mon, Feb 17, 2014 at 10:37 PM, Takeshi Yoshino <tyoshino@google.com>wrote:
>>
>>> So, to be clear, Joakim, you're not objecting to make it unable to know
>>> the size of each frame, but objecting to make it completely unable to know
>>> the size of big messages on receiving the head of it, right?
>>>
>>> Your use case (fail-fast) seems to require the sender to send messages
>>> unfragmented. So, it sounds like application (or kind of application)
>>> specific needs. You could do some application specific hack such as
>>> introducing "complete-message-size" header in the payload than depending on
>>> protocol level length header. If not, clients in the wild which are out of
>>> your control may do arbitrary fragmentation. FYI, Chromium's WebSocket
>>> stack is being refactored and after that it starts sending big messages as
>>> fragmented into small frames.
>>>
>>
>>
>