Re: Implicitly opened streams and exposing stream IDs

Martin Thomson <> Tue, 03 April 2018 07:28 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 4AFDC1201FA for <>; Tue, 3 Apr 2018 00:28:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -0.999
X-Spam-Status: No, score=-0.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Authentication-Results: (amavisd-new); dkim=pass (2048-bit key)
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id DiugX78Bbriz for <>; Tue, 3 Apr 2018 00:28:29 -0700 (PDT)
Received: from ( [IPv6:2607:f8b0:4003:c0f::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by (Postfix) with ESMTPS id D3A27124205 for <>; Tue, 3 Apr 2018 00:28:22 -0700 (PDT)
Received: by with SMTP id j8-v6so10783989ota.7 for <>; Tue, 03 Apr 2018 00:28:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=eWBdAXIRKAcoco0OEWQOu+mD1h2ZkYufyYXupJJjWRk=; b=j4qa2npu3M7i0wOscazKn0pdJVvBl1vsl0INgiy7QSUIx1gwjkCY8w55UTaCPdWP39 L1THlX5cjKgzhv5mfa6Ery1zZCfI06AlWUuMP+YjW7rZiaGjZ1K9hN4TOrze8aLR4aov 5KLqbeVqgLGiADJloMxVgvj7f8eZl3t/hlUxnSSMzvFYm5J5feuNzRp6owXHiLravqC8 Ew777jk62nV6XVytKg3HrMnQ3H5w1SDcXwxwKaHA/WIoWYzaC/aamI7LZL//Tvk6CjVO FVzUciyo4QlEOCUj51yzG9tQAnJUwsvx0ip0Y+BV3rh788HhRf6vqLsDjUpIafmUNzQj RJNw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=eWBdAXIRKAcoco0OEWQOu+mD1h2ZkYufyYXupJJjWRk=; b=fMcJbkY0gk/E0vsWVs3cnhqpFDToUASGN5yXpv6vT0oT0CZfAa7iUTa/LNzV/2WdTh BUiX56aZLnft+LUCk6KHE0JtzBJqcjMyo6nP5oNMAyNzpG2B0VBmmZjd+F+VX3ezHKzz sLL6tHUx6p+VMJNPomJZY3o1qYjc/dnc6s+BTYc60UuhhhoLsJwe3YWkL3HXyiseeEPk v1ZotSXUEdTyqHx4XJvAXenQr6wXfs1/1qwcYkX6vG764tqeD/aBMm+AIsN9zQtUWQa5 8L9yFMNHsmUU+Ows5ir+ADklxdyqEVnqaAdGSSUn16L5I9vp6ropg+Ad8mlRyhERq5RQ PTBw==
X-Gm-Message-State: ALQs6tAsP+slIJ4XNvtlGWmKVnXZDXTrqFwk2TYDrjjlGgWGtP9RGwOe 5WGXQyG8fcgW510d7uGUl/bEROu5uo34ucLJeG4=
X-Google-Smtp-Source: AIpwx49C30a4PiqqNUZaH//DfkqnHeJGo4oLD63MTd263oLCeexI5Od9dG4qSvxM3hMXQrD9RxJ8aQ4zyWhfNNIXl9U=
X-Received: by 2002:a9d:6001:: with SMTP id h1-v6mr6947507otj.283.1522740501989; Tue, 03 Apr 2018 00:28:21 -0700 (PDT)
MIME-Version: 1.0
Received: by 2002:a9d:ac7:0:0:0:0:0 with HTTP; Tue, 3 Apr 2018 00:28:21 -0700 (PDT)
In-Reply-To: <>
References: <> <7CF7F94CB496BF4FAB1676F375F9666A3BB0D858@bgb01xud1012> <>
From: Martin Thomson <>
Date: Tue, 03 Apr 2018 17:28:21 +1000
Message-ID: <>
Subject: Re: Implicitly opened streams and exposing stream IDs
To: Marten Seemann <>
Cc: Lucas Pardue <>, QUIC WG <>
Content-Type: text/plain; charset="UTF-8"
Archived-At: <>
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Main mailing list of the IETF QUIC working group <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Tue, 03 Apr 2018 07:28:31 -0000

Requiring in-order opening is harder than it sounds.  Say you have a
multithreaded application that is initiating requests.  The usual
process is something like:

s = connection.OpenStream()

That is, there is time between acquisition of the stream and its use.
Do that with enough concurrency and you end up having to add late
binding of stream identifiers to streams, which complicates the design
of the stack considerably.  It also complicates usage because now
there is a period where s.Id() returns an undefined result.

Alternatively, you could track the highest stream ID on which data has
been sent and send an empty, offset 0 STREAM frame rather than create
a gap.

Or, you could decide that a MUST here is unenforceable (even more so
than the flow control limits one) and just wantonly ignore that
requirement if this race condition happens.  While it is in theory
possible to catch someone in a violation, it requires some interesting
conditions (like zero packet loss).

BTW, I also wish to make it possible to avoid relying on specific
stream IDs for special functions.  I hadn't considered opening order
as a way to do that though and had assumed that we'd use an in-stream
header for that.  I don't think that makes the complexity worse, or at
least no worse than having to deal with different frame types for
different functions.

On Tue, Apr 3, 2018 at 5:10 PM, Marten Seemann <> wrote:
> Hello,
> Sure, the application could deal with it by starting every stream with some
> kind of header, to signal what kind of stream type this is. I'm not sure if
> I like this solution, since it creates additional complexity, and it is only
> necessary because we removed a useful feature from the spec.
> What did we actually gain from removing implicit stream opening from the
> protocol? As far as I can see, we were able to relax the requirement
> "endpoints MUST open the send side of streams for each type in order" to
> "endpoints SHOULD open the send side of streams for each type in order".
> This might seem nice from a conceptual viewpoint, but honestly, I don't
> really see why anyone would actually want to do this. I think the main
> argument against the MUST was that it's not enforceable anyway, but this
> applies to a lot of other MUSTs in the spec as well (e.g. that flow control
> limits can't be decreased).
> The fix for this is straightforward: We should REQUIRE a peer to open
> streams in order. How the receiver handles out of order streams then is an
> implementation and API decision. I see two ways that an implementation could
> reasonably deal with this:
> Return streams in the order they are received, e.g. return N+4 before N, if
> packets are reordered.
> Return streams ordered by stream ID, i.e. return first N and then N+4 if a
> frame for N+4 is received.
> This way, we wouldn't need to reintroduce implicitly opened streams, but
> leave this up to implementations. I should have named this thread
> differently, if only I had realized this earlier ;)
> Regards,
> Marten
> On Mon, Apr 2, 2018 at 7:05 PM Lucas Pardue <> wrote:
>> Hi Marten,
>> Would Stream headers fix this problem? I.e. anything that requires special
>> behaviour other than "bulk data" has some bytes of of magic at the start of
>> the stream.
>> Regards
>> Lucas
>> ________________________________________
>> From: QUIC [] on behalf of Marten Seemann
>> []
>> Sent: 02 April 2018 12:43
>> To: QUIC WG
>> Subject: Implicitly opened streams and exposing stream IDs
>> Recently, the implicit opening of streams (i.e. that when a receiver
>> receives a frame for stream N+4, it can assume that stream N was already
>> opened, but the packet might have been reordered) was removed from the
>> draft. I think this change has some consequences that we haven't discussed
>> so far.
>> For the purpose of writing some pseudocode, I'm assuming a QUIC API that
>> provides an AcceptStream() method, but the conclusions will be the same for
>> a callback-based API.
>>   *   If QUIC has implicit stream opening, AcceptStream() would return the
>> streams in order (and if a frame opening stream N+4 is received before
>> stream n is opened, AcceptStream() will first return stream N and then
>> stream N+4).
>>   *   Without implicit stream opening, AcceptStream() just returns
>> whatever stream is received first. Streams might be returned in arbitrary
>> order, if the peer doesn't open streams consecutively or if packets are
>> reordered.
>> Now imagine an application protocol where the first unidirectional stream
>> opened by the client is a control stream, and all higher unidirectional
>> streams are data streams. The application on the server side needs to find
>> out which stream is the control stream, because it needs to be handled
>> separately.
>> With implicit stream opening, the server code would be:
>>     control_stream = AcceptStream() // is guaranteed to open the first
>> stream
>>     // handle the control stream
>>      while true:
>>          stream = AcceptStream()
>>          // handle the data stream
>> and without implicit stream opening:
>>     while true:
>>         stream = AcceptStream()
>>         if stream.ID() == kControlStreamID:
>>             // handle the control stream
>>         else:
>>             // handle the data stream
>> In this case, after accepting a stream, we first have to check the stream
>> ID, since there's no guarantee if the control stream will actually be
>> received first.
>> For this stream mapping, it seems like the removal of implicitly opened
>> streams implies that QUIC has to expose stream IDs to the application layer.
>> I'm not sure if this was intended when making the change, especially since
>> we're considering to change HQ such that it doesn't rely on QUIC stream IDs
>> any more.
>> We only manage to avoid the problem described here in our HTTP mapping,
>> because the HTTP control streams are unidirectional and the request streams
>> are bidirectional, and can therefore be told apart by their directionality.
>> However, as a general transport protocol, other applications built on top of
>> QUIC will have to find some way to deal with it.
>> -----------------------------
>> This e-mail (and any attachments) is confidential and
>> may contain personal views which are not the views of the BBC unless
>> specifically stated.
>> If you have received it in
>> error, please delete it from your system.
>> Do not use, copy or disclose the
>> information in any way nor act in reliance on it and notify the sender
>> immediately.
>> Please note that the BBC monitors e-mails
>> sent or received.
>> Further communication will signify your consent to
>> this.
>> -----------------------------