<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.6.26 (Ruby 3.1.3) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-seemann-quic-reliable-stream-reset-02" category="std" consensus="true" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.17.0 -->
  <front>
    <title abbrev="QUIC Reliable Stream Reset">Reliable QUIC Stream Resets</title>
    <seriesInfo name="Internet-Draft" value="draft-seemann-quic-reliable-stream-reset-02"/>
    <author initials="M." surname="Seemann" fullname="Marten Seemann">
      <organization>Protocol Labs</organization>
      <address>
        <email>martenseemann@gmail.com</email>
      </address>
    </author>
    <date year="2023" month="March" day="26"/>
    <area>Transport</area>
    <workgroup>QUIC</workgroup>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <t>QUIC (<xref target="RFC9000"/>) defines a RESET_STREAM frame to reset a stream. When a
sender resets a stream, it stops retransmitting STREAM frames for this stream.
On the receiver side, there is no guarantee that any of the data sent on that
stream is delivered to the application.
This document defines a new QUIC frame, the RELIABLE_RESET_STREAM frame, that
resets a stream, while guaranteeing reliable delivery of stream data up to a
certain byte offset.</t>
    </abstract>
    <note removeInRFC="true">
      <name>Discussion Venues</name>
      <t>Discussion of this document takes place on the
    QUIC Working Group mailing list (quic@ietf.org),
    which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/quic/"/>.</t>
      <t>Source for this draft and an issue tracker can be found at
    <eref target="https://github.com/marten-seemann/draft-seemann-quic-reliable-stream-reset"/>.</t>
    </note>
  </front>
  <middle>
    <section anchor="introduction">
      <name>Introduction</name>
      <t>QUIC v1 (<xref target="RFC9000"/>) allows streams to be reset.  When a stream is
reset, the sender doesn't retransmit stream data for the respective stream.
On the receiver side, the QUIC stack is free to surface the stream reset to the
application immediately, even if it has already received stream data for that
stream.</t>
      <t>Applications running on top of QUIC might need to send an identifier at the
beginning of the stream in order to associate that stream with a specific
subpart of the application. For example, WebTransport
(<xref target="WEBTRANSPORT"/>) uses a variable-length-encoded
integer (as defined in QUIC v1) to transmit the ID of the WebTransport session to
the receiver. It is desirable that the receiver is able to associate incoming
streams with their respective subpart of the application, even if the QUIC stream
is reset before the identifier at the beginning of the stream was read.</t>
      <t>Another use-case is relaying data from an external data source. When a relay
is sending data being read from an external source and encounters an error, it
might want to use a stream reset to signal that error, at the same time making
sure that all data being read previously is delivered to the peer.</t>
      <t>This document describes a QUIC extension defining a new frame type, the
RELIABLE_RESET_STREAM frame. This frame allows an endpoint to mark a portion at
the beginning of the stream which will then be guaranteed to be delivered to
receiver's application, even if the stream was reset.</t>
    </section>
    <section anchor="conventions-and-definitions">
      <name>Conventions and Definitions</name>
      <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
"<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
appear in all capitals, as shown here.</t>
    </section>
    <section anchor="negotiating-extension-use">
      <name>Negotiating Extension Use</name>
      <t>Endpoints advertise their support of the extension described in this document by
sending the reliable_reset_stream (0x727273) transport parameter
(Section 7.4 of <xref target="RFC9000"/>) with an empty value. An implementation that
understands this transport parameter <bcp14>MUST</bcp14> treat the receipt of a non-empty
value as a connection error of type TRANSPORT_PARAMETER_ERROR.</t>
      <t>In order to allow reliable stream resets in 0-RTT packets, the client <bcp14>MUST</bcp14>
remember the value of this transport parameter.  If 0-RTT data is accepted by
the server, the server <bcp14>MUST</bcp14> not disable this extension on the resumed
connection.</t>
    </section>
    <section anchor="reliableresetstream-frame">
      <name>RELIABLE_RESET_STREAM Frame</name>
      <t>Conceptually, the RELIABLE_RESET_STREAM frame is a RESET_STREAM frame with an
added Reliable Size field.</t>
      <artwork><![CDATA[
RELIABLE_RESET_STREAM Frame {
  Type (i) = 0x72,
  Stream ID (i),
  Application Protocol Error Code (i),
  Final Size (i),
  Reliable Size (i),
}
]]></artwork>
      <t>RELIABLE_RESET_STREAM frames contain the following fields:</t>
      <t>Stream ID:  A variable-length integer encoding of the stream ID of
      the stream being terminated.</t>
      <t>Application Protocol Error Code:  A variable-length integer
    containing the application protocol error code (see Section 20.2)
    that indicates why the stream is being closed.</t>
      <t>Final Size:  A variable-length integer indicating the final size of
    the stream by the RESET_STREAM sender, in units of bytes; see
    (Section 4.5 of <xref target="RFC9000"/>).</t>
      <t>Reliable Size:  A variable-length integer indicating the amount of
    data that needs to be delivered to the application even though
    the stream is reset.</t>
      <t>If the Reliable Size is larger than the Final Size, the receiver <bcp14>MUST</bcp14> close the
connection with a connection error of type FRAME_ENCODING_ERROR.</t>
      <t>Semantically, a RESET_STREAM frame is equivalent to a RELIABLE_RESET_STREAM
frame with the Reliable Size set to 0.</t>
      <t>RELIABLE_RESET_STREAM frames are ack-eliciting. When lost, they <bcp14>MUST</bcp14> be
retransmitted, unless a RESET_STREAM frame or another RELIABLE_RESET_STREAM
frame was sent for the same stream (see <xref target="multiple-frames"/>).</t>
    </section>
    <section anchor="resetting-streams">
      <name>Resetting Streams</name>
      <t>When resetting a stream, the node has the choice between using a RESET_STREAM
frame and a RELIABLE_RESET_STREAM frame. When using a RESET_STREAM frame, the
behavior is unchanged from the behavior described in (<xref target="RFC9000"/>).</t>
      <t>The initiator <bcp14>MUST</bcp14> guarantee reliable delivery of stream data of at least
Reliable Size bytes.  If STREAM frames containing data up to that byte offset
are lost, the initiator <bcp14>MUST</bcp14> retransmit this data,  as described in
(Section 13.3 of <xref target="RFC9000"/>). Data sent beyond that byte offset <bcp14>SHOULD NOT</bcp14> be
retransmitted.</t>
      <t>As described in (Section 3.2 of <xref target="RFC9000"/>), it <bcp14>MAY</bcp14> deliver data beyond that
offset to the application.</t>
      <section anchor="multiple-frames">
        <name>Multiple RELIABLE_RESET_STREAM / RESET_STREAM frames</name>
        <t>The initiator <bcp14>MAY</bcp14> send multiple RELIABLE_RESET_STREAM frames for the same
stream in order to reduce the Reliable Size.  It <bcp14>MAY</bcp14> also send a RESET_STREAM
frame, which is equivalent to sending a RELIABLE_RESET_STREAM frame with a
Reliable Size of 0.</t>
        <t>When sending multiple frames for the same stream, the initiator <bcp14>MUST NOT</bcp14> increase
the Reliable Size.  When receiving a RELIABLE_RESET_STREAM frame with a lower
Reliable Size, the receiver only needs to deliver data up the lower Reliable
Size to the application. It <bcp14>MUST NOT</bcp14> expect the delivery of any data beyond that
byte offset.</t>
        <t>Reordering of packets might lead to a RELIABLE_RESET_STREAM frame with a higher
Reliable Size being received after a RELIABLE_RESET_STREAM frame with a lower
Reliable Size.  The receiver <bcp14>MUST</bcp14> ignore any RELIABLE_RESET_STREAM frame that
increases the Reliable Size.</t>
        <t>When sending another RELIABLE_RESET_STREAM or RESET_STREAM frame for the same
stream, the initiator <bcp14>MUST NOT</bcp14> change the Application Error Code or the Final
Size. If the receiver detects a change in those fields, it <bcp14>MUST</bcp14> close the
connection with a connection error of type STREAM_STATE_ERROR.</t>
      </section>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>TODO Security</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>This document has no IANA actions.</t>
    </section>
  </middle>
  <back>
    <references>
      <name>Normative References</name>
      <reference anchor="RFC9000">
        <front>
          <title>QUIC: A UDP-Based Multiplexed and Secure Transport</title>
          <author fullname="J. Iyengar" initials="J." role="editor" surname="Iyengar">
            <organization/>
          </author>
          <author fullname="M. Thomson" initials="M." role="editor" surname="Thomson">
            <organization/>
          </author>
          <date month="May" year="2021"/>
          <abstract>
            <t>This document defines the core of the QUIC transport protocol.  QUIC provides applications with flow-controlled streams for structured communication, low-latency connection establishment, and network path migration. QUIC includes security measures that ensure confidentiality, integrity, and availability in a range of deployment circumstances.  Accompanying documents describe the integration of TLS for key negotiation, loss detection, and an exemplary congestion control algorithm.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="9000"/>
        <seriesInfo name="DOI" value="10.17487/RFC9000"/>
      </reference>
      <reference anchor="WEBTRANSPORT">
        <front>
          <title>WebTransport over HTTP/3</title>
          <author fullname="Alan Frindell" initials="A." surname="Frindell">
            <organization>Facebook</organization>
          </author>
          <author fullname="Eric Kinnear" initials="E." surname="Kinnear">
            <organization>Apple Inc.</organization>
          </author>
          <author fullname="Victor Vasiliev" initials="V." surname="Vasiliev">
            <organization>Google</organization>
          </author>
          <date day="13" month="March" year="2023"/>
          <abstract>
            <t>   WebTransport [OVERVIEW] is a protocol framework that enables clients
   constrained by the Web security model to communicate with a remote
   server using a secure multiplexed transport.  This document describes
   a WebTransport protocol that is based on HTTP/3 [HTTP3] and provides
   support for unidirectional streams, bidirectional streams and
   datagrams, all multiplexed within the same HTTP/3 connection.

            </t>
          </abstract>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-ietf-webtrans-http3-05"/>
      </reference>
      <reference anchor="RFC2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author fullname="S. Bradner" initials="S." surname="Bradner">
            <organization/>
          </author>
          <date month="March" year="1997"/>
          <abstract>
            <t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="2119"/>
        <seriesInfo name="DOI" value="10.17487/RFC2119"/>
      </reference>
      <reference anchor="RFC8174">
        <front>
          <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
          <author fullname="B. Leiba" initials="B." surname="Leiba">
            <organization/>
          </author>
          <date month="May" year="2017"/>
          <abstract>
            <t>RFC 2119 specifies common key words that may be used in protocol  specifications.  This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the  defined special meanings.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="8174"/>
        <seriesInfo name="DOI" value="10.17487/RFC8174"/>
      </reference>
    </references>
    <section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>TODO acknowledge.</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA51YbW8buRH+zl/B2h/OKSTVdlKkUZuiOlvpCbCtVFYQHA4H
g9qlJMK75IbkWtEZzm/pb+kv68yQu9qV1k57CZCs+DKcl4czz7Df7zOvfCaH
/GgmMyUWmeT/+jS54LfeSpHzmXTSuyMmFgsrH2AVTdZLm6uOWGoSLXKQlVqx
9H0nZS607n8pVdK3cUvf0Rb4DVv6p+csEV6ujN0OufMpY6qwQ+5t6fz56ek7
mBewfMjnVmhXGOvZxtj7lTVlMSRF2b3cwlA65BPtpdUg9BJPZ8x5odM7kRkN
Gm2lYy4X1t99KY2Xbsi1YYUa8l+8SXrcgWQrlw6+tjl+/MqYKP3a2CHjfcbh
j9Kw6XrAb4NVNBasvQaxUrcmjF0JrX4TXhk95B+tgVNMxq/EwtE8rFTZkOe0
M/rpHyscHCQmZ0wbm8PmBzkEj+hl4xfr9/scxHgrEjCSwnHy+PiH2YeLd6en
p09Pr3gql0pLxwWfjW/H87vb+Ww8uuZLC9pybzi5HmZDJAb88xq0F8xJnUob
Zl093ePKw6cpHMx4jEKuvFd6xZtiHQcduV8rV0llUw2/JWxKJGhuuVOp7OGQ
lRyWacNXpQB5XoJSawEK6S03S9qUCg/nS+250TTJglTcmAKQQJ5M0RRcLIoi
U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