Re: [hybi] frame length encoding

gustav trede <gustav.trede@gmail.com> Fri, 20 August 2010 19:22 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 CC03A3A694D for <hybi@core3.amsl.com>; Fri, 20 Aug 2010 12:22:31 -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 xs8sZR+YFxF2 for <hybi@core3.amsl.com>; Fri, 20 Aug 2010 12:22:29 -0700 (PDT)
Received: from mail-ew0-f44.google.com (mail-ew0-f44.google.com [209.85.215.44]) by core3.amsl.com (Postfix) with ESMTP id 12EC23A67B2 for <hybi@ietf.org>; Fri, 20 Aug 2010 12:22:27 -0700 (PDT)
Received: by ewy22 with SMTP id 22so2571060ewy.31 for <hybi@ietf.org>; Fri, 20 Aug 2010 12:23:02 -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=vJzLBizToqQ57FEFn1bgGG9Rpe4l5YmY4TZ/xBnrxZU=; b=QsS4vtLvmDgpDlvoUIEksfSUo1dobw869L68qBbxdpP9DkKdarDxvcbVlsXv3G2gcw 6AJTqUh2k5RsNlSva3CQGBukdbBwSZ6o6jufFnjuUxgQ6gNrxHKFlQj8BAljPuAPKYtb jX3k90Hd+En1Qp99p7aPU6F/yZ7Cd3HaytVU4=
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=o0rNd2/F4k8Knpiqk9awyHzyO7dYDdT8DhXZj4tJrr6QaFmAwi32yJCo9D71Mrm8lx nQmc5jG/ybujt3CVxtLrHUi+/caTcct/o9Ok27y1QwuB1+sjGG1h8ryZ+So9QBm3p+GV NU3CNIHvYibkUxLuinISAEFXFr74g6NbhqKuM=
MIME-Version: 1.0
Received: by 10.216.47.80 with SMTP id s58mr1669205web.15.1282332181895; Fri, 20 Aug 2010 12:23:01 -0700 (PDT)
Received: by 10.216.172.139 with HTTP; Fri, 20 Aug 2010 12:23:01 -0700 (PDT)
In-Reply-To: <AANLkTimKbmcpgx8k0uXUWvCO=8w9pPrtV=3y4qh6363k@mail.gmail.com>
References: <AANLkTimKbmcpgx8k0uXUWvCO=8w9pPrtV=3y4qh6363k@mail.gmail.com>
Date: Fri, 20 Aug 2010 21:23:01 +0200
Message-ID: <AANLkTin-xr5X1feBrNpjDOvOX4c1GHaSsTPCNhiNE4Q+@mail.gmail.com>
From: gustav trede <gustav.trede@gmail.com>
To: John Tamplin <jat@google.com>
Content-Type: multipart/alternative; boundary="001485f280102f9b56048e463a50"
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: Fri, 20 Aug 2010 19:22:32 -0000

On 20 August 2010 21:08, John Tamplin <jat@google.com> wrote:

> From the discussions related to my previous proposal, it seems like how we
> encode the length is the remaining contentious issue (at least there were no
> other comments on the rest of the 4 issues I outlined).  It is hard to get a
> sense of who prefers what to what extent.  Also, in a comment not intended
> as a serious proposal I mentioned a 1/2/8 option, I had a couple of people
> reply to me privately that they liked the idea.  So, I thought I would ask
> for a "show of hands" about three possibilities.  If you feel strongly for
> or against a particular option, please reply and say so.  If you are fine
> with any of the three, then there is no need to reply.
>
> A sample code snippet (not suggesting this is optimal for any of the cases)
> is included to make sure what is intended is clear.
>
> Option 1
> ========
> Use 7 bits in the frame header, and if the value is 0-126, that is the
> length.  If the value is 127, the next 8 bytes are a 63-bit length (the high
> bit must be zero).
>
> long long len = readByte();
> if (len == 127) {
>   len = readLongLong();
> }
>
Strong negative feeling against option 1


> Option 2
> ========
> Use 7 bits in the frame header, and if the value is 0-125, that is the
> length.  If the value is 126, then the next 2 bytes are a 16-bit length.  If
> the value is 127, the next 8 bytes are a 63-bit length (the high bit must be
> zero).
>
> long long len = readByte();
> switch (len) {
>   case 126:
>     len = readUnsignedShort();
>     break;
>   case 127:
>     len = readLongLong();
>     break;
> }
>
Strong positive feeling for option 2.


>
> Option 3
> ========
> Use 8 bits in the frame header (assigning RSV2 in the most recent proposal
> to be part of the length field).  If the high bit is set in that byte, shift
> the current length seven bits and read the next byte.  Leading 0x80 bytes
> are disallowed, and at most 9 length bytes may be included
>
> int byte = readByte();
> if (byte == 0x80) // fail
> long long len = byte;
> for (int i = 1; (byte & 0x80) && i < 9; ++i) {
>   byte = readByte();
>   len = (len << 7) | (byte & 0x7f);
> }
> if (byte & 0x80) // fail
>
>
>
> I would be willing to live with any of the three personally.  My preference
> is roughly even for #1 or #2 over #3 because #3 uses one of our reserved
> bits (reducing expansion options) and has error states which must be
> checked.  Also, most of the lengths don't buy you much in terms of reducing
> overhead, as the overall frame is much longer than the header at that point
> anyway.
>
> --
> John A. Tamplin
> Software Engineer (GWT), Google
>
> _______________________________________________
> hybi mailing list
> hybi@ietf.org
> https://www.ietf.org/mailman/listinfo/hybi
>
>