<?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.17 (Ruby 2.6.10) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-quic-reliable-stream-reset-00" category="std" consensus="true" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.17.1 -->
  <front>
    <title abbrev="QUIC Reliable Stream Reset">Reliable QUIC Stream Resets</title>
    <seriesInfo name="Internet-Draft" value="draft-ietf-quic-reliable-stream-reset-00"/>
    <author initials="M." surname="Seemann" fullname="Marten Seemann">
      <organization>Protocol Labs</organization>
      <address>
        <email>martenseemann@gmail.com</email>
      </address>
    </author>
    <author fullname="奥一穂" asciiFullname="Kazuho Oku">
      <organization>Fastly</organization>
      <address>
        <email>kazuhooku@gmail.com</email>
      </address>
    </author>
    <date year="2023" month="April" day="23"/>
    <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/quicwg/draft-ietf-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:
H4sIAEuKRWQAA51Y3W4buRW+51Ow9sXahaTKToo0alNUseWuUNtKZQXBYrEw
qBlKIjxDToYcK4rhYLFP0pu96Bv0us/Soq/Rcw45oxlp7LSbAImGP4fn5zvf
OWS322VOuUQO+MFUJkrME8n/+n58xm9cLkXKp9JKZw+YmM9zeQ+raLJaWl91
wGITaZGCrDgXC9dV0i26HwsVdfOwvmtpPXzD+m6/zyLh5NLkmwG3LmZMZfmA
u7yw7rTff90/ZQKWD/gsF9pmJndsbfK7ZW6KbEBasju5gaF4wMfayVyD0HM8
mjHrhI5vRWI0qLORltlU5O72Y2GctAOuDcvUgH/vTNThFiTncmHh1ybFHz8w
Jgq3MvmA8S7j8Edp2HTV4zdSpkJrGvOmXoFYqRsTJl8KrT4Lp4we8He5gVNM
wi/F3NI8rFTJgKe00/qNf1riYC8yaXnkokgSOoK+OB8M+L9//vlf//jxP3//
KQwJGymw4i/ic7EyfHJXlMcP+IWwLtnUj7ujVeauqB3FtMlT0PMeTmFKL2pf
rNvtctDY5SICf1LYjx4efjW9OHvd7/cfH495LBdKS8sFn45uRrPbm9l0NLzi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