<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" docName="draft-bosh-core-new-block-03" ipr="trust200902">
  <front>
    <title abbrev="New Block-Wise Transfer Options">Constrained Application
    Protocol (CoAP) Block-Wise Transfer Options for Faster
    Transmission</title>

    <author fullname="Mohamed Boucadair" initials="M." surname="Boucadair">
      <organization>Orange</organization>

      <address>
        <postal>
          <street></street>

          <city>Rennes</city>

          <region></region>

          <code>35000</code>

          <country>France</country>
        </postal>

        <email>mohamed.boucadair@orange.com</email>
      </address>
    </author>

    <author fullname="Jon Shallow" initials="J." surname="Shallow">
      <organization></organization>

      <address>
        <postal>
          <street></street>

          <city></city>

          <region></region>

          <code></code>

          <country>United Kingdom</country>
        </postal>

        <email>supjps-ietf@jpshallow.com</email>
      </address>
    </author>

    <date />

    <workgroup>CORE</workgroup>

    <keyword>security</keyword>

    <keyword>mitigation</keyword>

    <keyword>service delivery</keyword>

    <keyword>connectivity</keyword>

    <keyword>anti-DDoS</keyword>

    <keyword>automation</keyword>

    <keyword>cooperation</keyword>

    <keyword>Resilience</keyword>

    <keyword>Filtering</keyword>

    <keyword>Security Center</keyword>

    <keyword>Mitigator</keyword>

    <keyword>Scrubbing</keyword>

    <keyword>dynamic service protection</keyword>

    <keyword>dynamic mitigation</keyword>

    <abstract>
      <t>This document specifies new Constrained Application Protocol (CoAP)
      Block-Wise transfer options: Block3 and Block4 Options.</t>

      <t>These options are similar to the CoAP Block1 and Block2 Options, but
      enable faster transmission rates for large amounts of data with less
      packet interchanges as well as supporting faster recovery should any of
      the blocks get lost in transmission.</t>
    </abstract>
  </front>

  <middle>
    <section anchor="introduction" title="Introduction">
      <section title="Existing CoAP Block-Wise Transfer Options">
        <t>The Constrained Application Protocol (CoAP) <xref
        target="RFC7252"></xref>, although inspired by HTTP, was designed to
        use UDP instead of TCP. The message layer of CoAP over UDP includes
        support for reliable delivery, simple congestion control, and flow
        control. <xref target="RFC7959"></xref> introduced the CoAP Block1 and
        Block2 Options to handle data records that cannot fit in a single IP
        packet, so not having to rely on IP fragmentation and further updated
        by <xref target="RFC8323"></xref> for use over TCP, TLS, and
        Websockets.</t>

        <t>The CoAP Block1 and Block2 Options work well in environments where
        there are no or minimal packet losses. These options operate
        synchronously where each block has to be requested and can only ask
        for (or send) the next block when the request for the previous block
        has completed. Packet, and hence block transmission rate, is
        controlled by Round Trip Times (RTTs).</t>

        <t>There is a requirement for these blocks of data to be transmitted
        at higher rates under network conditions where there may be transient
        packet loss. An example is when a network is subject to a Distributed
        Denial of Service (DDoS) attack and there is a need for DDoS
        mitigation agents relying upon CoAP to communicate with each other
        (e.g., <xref target="I-D.ietf-dots-telemetry"></xref>). As a reminder,
        <xref target="RFC7959"></xref> recommends use of Confirmable (CON)
        responses to handle potential packet loss; which does not work with a
        flooded pipe DDoS situation.</t>
      </section>

      <section title="New CoAP Block-Wise Transfer Options">
        <t>This document introduces the CoAP Block3 and Block4 Options. These
        options are similar in operation to the CoAP Block1 and Block2 Options
        respectively, but enable faster transmissions of sets of blocks of
        data with less packet interchanges as well as supporting faster
        recovery should any of the Blocks get lost in transmission.</t>

        <t>Using Non-confirmable (NON) messages, the faster transmissions
        occur as all the Blocks can be transmitted serially (as are IP
        fragmented packets) without having to wait for an acknowledgement or
        next request from the remote CoAP peer. Recovery of missing Blocks is
        faster in that multiple missing Blocks can be requested in a single
        CoAP packet.</t>

        <t>Note that the same performance benefits can be applied to
        Confirmable messages if the value of NSTART is increased from 1
        (Section 4.7 of <xref target="RFC7252"></xref>). Some sample examples
        with Confirmable messages are provided in <xref
        target="CON"></xref>.</t>

        <t>There is little, if any, benefit of using these options with CoAP
        running over a reliable connection <xref target="RFC8323"></xref>. In
        this case, there is no differentiation between Confirmable and NON as
        they are not used.</t>

        <t>A CoAP endpoint can acknowledge all or a subset of the blocks.
        Concretely, the receiving CoAP endpoint informs the CoAP endpoint
        sender either successful receipt or reports on all blocks in the body
        that have been not yet been received. The CoAP endpoint sender will
        then retransmit only the blocks that have been lost in
        transmission.</t>

        <t>Block3 and Block4 Options are used instead of Block1 and Block2
        Options respectively because the transmission semantics and usage have
        changed.</t>

        <t>The deviations from Block1 and Block2 Options are specified in
        <xref target="spec"></xref>. Pointers to appropriate <xref
        target="RFC7959"></xref> sections are provided.</t>

        <t>The specification refers to the base CoAP methods defined in
        Section 5.8 of <xref target="RFC7252"></xref> and the new CoAP
        methods, FETCH, PATCH, and iPATCH introduced in <xref
        target="RFC8132"></xref>.</t>
      </section>

      <section title="New CoAP Response Code">
        <t>This document defines a new CoAP Response Code (Section 5.9 of
        <xref target="RFC7252"></xref>), called TBA3 (Missing payloads), to
        report on payloads using the Block3 Option that are not received by
        the server.</t>

        <t>See <xref target="code"></xref> for more details.</t>
      </section>

      <section title="Applicability Scope">
        <t>The mechanism specified in the document includes guards to prevent
        a CoAP agent from overloading the network by adopting an aggressive
        sending rate. These guards MUST be followed in addition to the
        existing CoAP congestion control as specified in Section 4.7 of <xref
        target="RFC7252"></xref>.</t>

        <t>This mechanism primarily targets applications such as DDoS Open
        Threat Signaling (DOTS) that can't use Confirmable (CON) responses to
        handle potential packet loss and that support application-specific
        mechanisms to assess whether the remote peer is able to handle the
        messages sent by a CoAP endpoint (e.g., DOTS heartbeats in Section 4.7
        of <xref target="RFC8782"></xref>).</t>
      </section>
    </section>

    <section anchor="notation" title="Terminology">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
      "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
      "OPTIONAL" in this document are to be interpreted as described in BCP 14
      <xref target="RFC2119"></xref><xref target="RFC8174"></xref> when, and
      only when, they appear in all capitals, as shown here.</t>

      <t>Readers should be familiar with the terms and concepts defined in
      <xref target="RFC7252"></xref>.</t>

      <t>The terms "payload" and "body" are defined in <xref
      target="RFC7959"></xref>. The term "payload" is thus used for the
      content of a single CoAP message (i.e., a single block being
      transferred), while the term "body" is used for the entire resource
      representation that is being transferred in a block-wise fashion.</t>
    </section>

    <section anchor="spec" title="The Block3 and Block4 Options">
      <section title="Properties of Block3 and Block4 Options">
        <t>The properties of Block3 and Block4 Options are shown in Table 1.
        The formatting of this table follows the one used in Table 4 of <xref
        target="RFC7252"></xref> (Section 5.10). The C, U, N, and R columns
        indicate the properties Critical, Unsafe, NoCacheKey, and Repeatable
        defined in Section 5.4 of <xref target="RFC7252"></xref>. Only C
        column is marked for the Block3 Option. Only C and R columns are
        marked for the Block4 Option.</t>

        <t><figure align="center">
            <artwork align="center"><![CDATA[+--------+---+---+---+---+-----------+--------+--------+---------+
| Number | C | U | N | R | Name      | Format | Length | Default |
+========+===+===+===+===+===========+========+========+=========+
|  TBA1  | x |   |   |   | Block3    | uint   |  0-7   | (none)  |
|  TBA2  | x |   |   | x | Block4    | uint   |  0-7   | (none)  |
+--------+---+---+---+---+-----------+--------+--------+---------+

        Table 1: CoAP Block3 and Block4 Option Properties
]]></artwork>
          </figure></t>

        <t>The Block3 and Block4 Options can be present in both the request
        and response messages. The Block3 Option pertains to the request
        payload and the Block4 Option pertains to the response payload. The
        Content-Format Option applies to the body, not to the payload (i.e.,
        it must be the same for all payloads of the same body).</t>

        <t>Block3 is useful with the payload-bearing POST, PUT, PATCH, and
        iPATCH requests and their responses (2.01 and 2.04). Block4 Option is
        useful with GET, POST, PUT, FETCH, PATCH, and iPATCH requests and
        their payload-bearing responses (2.01, 2.03, 2.04, and 2.05) (Section
        5.5 of <xref target="RFC7252"></xref>).</t>

        <t>To indicate support for Block4 responses, the CoAP client MUST
        include the Block4 Option in a GET or similar requests so that the
        server knows that the client supports this Block4 functionality should
        it needs to send back a body that spans multiple payloads. Otherwise,
        the server would use the Block2 Option (if supported) to send back a
        message body that is too large to fit into a single IP packet <xref
        target="RFC7959"></xref>.</t>

        <t>If Block3 Option is present in a request or Block4 Option in a
        response (i.e., in that message to the payload of which it pertains),
        it indicates a block-wise transfer and describes how this specific
        block-wise payload forms part of the entire body being transferred. If
        it is present in the opposite direction, it provides additional
        control on how that payload will be formed or was processed.</t>

        <t>Implementation of Block3 (or Block4) Option is intended to be
        optional. However, when it is present in a CoAP message, it MUST be
        processed (or the message rejected). Therefore, Block3 and Block4
        Options are identified as Critical options.</t>

        <t>The Block3 and Block4 Options are safe to forward. That is, a CoAP
        proxy that does not understand the Block3 (or Block4) Option should
        forward the option on.</t>

        <t>The Block4 Option is repeatable when requesting re-transmission of
        missing Blocks, but not otherwise. Except that case, any request
        carrying multiple Block3 (or Block4) Options MUST be handled following
        the procedure specified in Section 5.4.5 of <xref
        target="RFC7252"></xref>.</t>

        <t>PROBING_RATE parameter in CoAP indicates the average data rate that
        must not be exceeded by a CoAP endpoint in sending to a peer endpoint
        that does not respond. The body of blocks will be subjected to
        PROBING_RATE (Section 4.7 of <xref target="RFC7252"></xref>).</t>

        <t>The Block3 and Block4 Options, like the Block1 and Block2 Options,
        are both a class E and a class U in terms of OSCORE processing (see
        Section 4.1 of <xref target="RFC8613"></xref>): The Block3 (or Block4)
        Option MAY be an Inner or Outer option. The Inner and Outer values are
        therefore independent of each other. The Inner option is encrypted and
        integrity protected between clients and servers, and provides message
        body identification in case of end-to-end fragmentation of requests.
        The Outer option is visible to proxies and labels message bodies in
        case of hop-by-hop fragmentation of requests. </t>
      </section>

      <section title="Structure of Block3 and Block4 Options">
        <t>The structure of Block3 and Block4 Options follows the structure
        defined in Section 2.2 of <xref target="RFC7959"></xref>.</t>

        <t>There is no default value for the Block3 and Block4 Options.
        Absence of one of these options is equivalent to an option value of 0
        with respect to the value of block number (NUM) and more bit (M) that
        could be given in the option, i.e., it indicates that the current
        block is the first and only block of the transfer (block number is set
        to 0, M is unset). However, in contrast to the explicit value 0, which
        would indicate a size of the block (SZX) of 0, and thus a size value
        of 16 bytes, there is no specific explicit size implied by the absence
        of the option -- the size is left unspecified. (As for any uint, the
        explicit value 0 is efficiently indicated by a zero-length option;
        this, therefore, is different in semantics from the absence of the
        option).</t>
      </section>

      <section title="Using the Block3 Option ">
        <t>The Block3 Option is used when the client wants to send a large
        amount of data to the server using the POST, PUT, PATCH, or iPATCH
        methods where the data and headers do not fit into a single
        packet.</t>

        <t>When Block3 Option is used, the client MUST include Request-Tag
        Option <xref target="I-D.ietf-core-echo-request-tag"></xref>. The
        Request-Tag value MUST be the same for all of the blocks in the body
        of data that is being transferred. It is also used to identify a
        particular block that needs to be re-transmitted. The Request-Tag is
        opaque in nature, but it is RECOMMENDED that the client treats it as
        an unsigned integer of 8 bytes in length. An implementation may want
        to consider limiting this to 4 bytes to reduce packet overhead size.
        The server still treats it as an opaque entity. The Request-Tag value
        MUST be different for distinct bodies or sets of blocks of data and
        SHOULD be incremented whenever a new body of data is being transmitted
        for a CoAP session between peers. The initial Request-Tag value SHOULD
        be randomly generated by the client. </t>

        <t>The client sends all the individual payloads of the body using
        Block3 and Request-Tag Options, only expecting a response when all the
        payloads have been sent. It is RECOMMENDED that after transmission of
        every set of MAX_PAYLOADS payloads of a single body, a delay is
        introduced of ACK_TIMEOUT (Section 4.8.2 of <xref
        target="RFC7252"></xref>) before the next set of payload transmissions
        to manage potential congestion issues. MAX_PAYLOADS should be
        configurable with a default value of 10.<list style="empty">
            <t>Note: The default value is chosen for reasons similar to those
            discussed in Section 5 of <xref target="RFC6928"></xref>.</t>
          </list></t>

        <t>For NON transmissions, it is permissible, but not required, to send
        the ultimate payload of a MAX_PAYLOADS set as a Confirmable packet. If
        a Confirmable packet is used, then the client MUST wait for the ACK to
        be returned before sending the next set of payloads, which can be in
        time terms less than the ACK_TIMEOUT delay.</t>

        <t>Also, for NON transmissions, it is permissible, but not required,
        to send a Confirmable packet for the final payload of a body (that is,
        M bit unset). If a Confirmable packet is used, then the client MUST
        wait for the 2.01 (Created) or 2.04 (Changed) Response Codes to be
        returned for successful transmission, or TBA3 (Missing Payloads)
        Response Code to then resend the missing blocks (if any).</t>

        <t>With NON transmission, the server acknowledges receipt of all of
        the payloads that make up the body or can respond at any time during
        the receipt of the payloads to acknowledge that some of the payloads
        have arrived, but others are missing. It is RECOMMENDED that, unless
        there are receipt issues, the server only responds when the final
        payload (i.e., M bit unset) is received.</t>

        <t>For Confirmable transmission, the server MUST continue to
        acknowledge each packet. NSTART will also need to be increased from
        the default (1) to get faster transmission rates.</t>

        <t>Tokens MUST be included. Each individual payload of the body MUST
        have a different Token value. </t>

        <t>A 2.01 (Created) or 2.04 (Changed) Response Code indicates
        successful receipt of the entire body. The 2.31 (Continue) Response
        Code MUST NOT be used.</t>

        <t>A 4.00 (Bad Request) Response Code MUST be returned if the request
        does not include a Request-Tag Option but does include a Block3
        option. </t>

        <t>A 4.02 (Bad Option) Response Code MUST be returned if the server
        does not support the Block3 Option.</t>

        <t>Use of 4.08 (Request Entity Incomplete) Response Code is
        discouraged when using Block3 Option because packets may arrive out of
        sequence; TBA3 (Missing Payloads) Response Code (<xref
        target="code"></xref>) SHOULD be used instead. However, 4.08 (Request
        Entity Incomplete) Response Code is still valid to reject a
        Content-Format mismatch.</t>

        <t>A 4.13 (Request Entity Too Large) Response Code can be returned
        under similar conditions to those discussed in Section 2.9.3 of <xref
        target="RFC7959"></xref>.</t>

        <t>A TBA3 (Missing Payloads) Response Code indicates that some of the
        payloads are missing and need to be resent. The client then
        re-transmits the missing payloads using the Request-Tag and Block3 to
        specify the block number, SZX, and M bit as appropriate. The
        Request-Tag value to use is determined from the payload of the TBA3
        (Missing Payloads) Response Code. If the client dos not recognize the
        Request-Tag, the client can ignore this response. As discussed above,
        the sending of the list of missing blocks is subject to MAX_PAYLOADS.
        </t>

        <t>If the server has not received the final payload (i.e., a block
        with M bit unset), but one or other payloads have been received, it
        SHOULD wait for up to MAX_TRANSMIT_SPAN (Section 4.8.2 of <xref
        target="RFC7252"></xref>) before sending the TBA3 (Missing Payloads)
        Response Code. However, this timer MAY be reduced to two times
        ACK_TIMEOUT before sending a TBA3 (Missing Payloads) Response Code to
        cover the situation where MAX_PAYLOADS has been triggered by the
        client causing a break in transmission.</t>

        <t>In all cases, multiple TBA3 (Missing Payloads) Response Codes are
        traffic limited by PROBING_RATE.</t>

        <t>If the client transmits a new body of data with a new Request-Tag
        to the same server, the server MUST remove any partially received body
        held for a previous Request-Tag for that resource.</t>

        <t>If the server receives a duplicate block with the same Request-Tag,
        it SHOULD silently ignore the packet.</t>

        <t>A server SHOULD only maintain a partial body (missing payloads) for
        up to EXCHANGE_LIFETIME (Section 4.8.2 of <xref
        target="RFC7252"></xref>).</t>
      </section>

      <section title="Using the Block 4 Option">
        <t>Support for the receipt of Block4 Option by the client is indicated
        by using the Block4 Option in the GET, POST, PUT, FETCH, PATCH or
        iPATCH request. If the Block4 Option is not included in the request,
        the server MUST NOT send data using the Block4 Option, but can use
        Block2 if supported instead. </t>

        <t>In a request, the Block4 MUST always have the M bit set to 0.</t>

        <t>The payloads sent back from the server as a response MUST all have
        the same ETag (Section 5.10.6 of <xref target="RFC7252"></xref>) for
        the same body. The server MUST NOT use the same ETag value for
        different representations of a resource.</t>

        <t>The sending of the payloads is subject to MAX_PAYLOADS. If
        MAX_PAYLOADS is exceeded, the server MUST introduce an ACK_TIMEOUT
        delay before transmitting the next set of payloads.</t>

        <t>The ETag is opaque in nature, but it is RECOMMENDED that the server
        treats it as an unsigned integer of 8 bytes in length. An
        implementation may want to consider limiting this to 4 bytes to reduce
        packet overhead size. The client still treats it as an opaque entity.
        The ETag value MUST be different for distinct bodies or sets of blocks
        of data and SHOULD be incremented whenever a new body of data is being
        transmitted for a CoAP session between peers. The initial ETag value
        SHOULD be randomly generated by the server. </t>

        <t>For NON transmission, it is permissible, but not required, to send
        the ultimate payload of a MAX_PAYLOADS set as a Confirmable packet. If
        a Confirmable packet is used, then the server MUST wait for the ACK to
        be received before sending the next set of payloads, which can be in
        time terms less than the ACK_TIMEOUT delay.</t>

        <t>Also, for NON transmission, it is permissible, but not required, to
        send a Confirmable packet for the final payload of a body (i.e., M bit
        unset). If a Confirmable packet is used, the server MUST wait for the
        ACK to be returned for successful transmission.</t>

        <t>If the client detects that some of the payloads are missing, the
        missing payloads are requested by issuing a new GET, POST, PUT, FETCH,
        PATCH, or iPATCH request that contains one or more Block4 Options that
        define the missing blocks. A new Token value MUST be used for this
        request. The rate of requests for missing blocks is subject to
        PROBING_RATE. The ETag Option MUST NOT be used in the request as the
        server could respond with a 2.03 (Valid Response) with no payload. If
        the server responds with a different ETag Option value (as the
        resource representation has changed), then the client SHOULD drop all
        the payloads for the current body that are no longer valid. </t>

        <t>The client may elect to request the missing blocks or just ignore
        the partial body.</t>

        <t>All the payload responses to a specific GET, POST, PUT, FETCH,
        PATCH, or iPATCH request MUST have the same Token value as in the
        request. </t>

        <t>With NON transmission, the client only needs to indicate that some
        of the payloads are missing by issuing a GET, POST, PUT, FETCH, PATCH,
        or iPATCH request for the missing blocks. </t>

        <t>For Confirmable transmission, the client SHOULD continue to
        acknowledge each packet as well as issuing a separate GET, POST, PUT,
        FETCH, PATCH, or iPATCH for the missing blocks. NSTART will also need
        to be increased from the default (1) to get faster transmission rates.
        </t>

        <t>If the server transmits a new body of data (e.g., a triggered
        Observe) with a new ETag to the same client with the same Token value,
        the client MUST remove any partially received body held for a previous
        ETag for that Token. </t>

        <t>If the client receives a duplicate block with the same ETag, it
        SHOULD silently ignore the packet.</t>

        <t>A client SHOULD only maintain a partial body (missing payloads) for
        up to EXCHANGE_LIFETIME (Section 4.8.2 of <xref
        target="RFC7252"></xref>) or as defined by the Max-Age Option
        whichever is the less.</t>
      </section>

      <section title="Working with Observe and Block4 Options">
        <t>As the blocks of the body are sent without waiting for
        acknowledgement of the individual blocks, the Observe value <xref
        target="RFC7641"></xref> MUST be the same for all the blocks of the
        same body.</t>

        <t>Likewise, the Tokens MUST all have the same value for all the
        blocks of the same body. This is so that if any of the blocks get lost
        during transmission (including the first one), the receiving CoAP
        endpoint can take the appropriate decisions as to how to continue
        (implementation specific).</t>

        <t>If the client requests missing blocks, the client MUST use a
        different Token; all repeated missing blocks for that new request MUST
        use the new Token.</t>
      </section>

      <section title="Working with Size1 and Size2 Options">
        <t>Section 4 of <xref target="RFC7959"></xref> defines two CoAP
        options: Size1 for indicating the size of the representation
        transferred in requests and Size2 for indicating the size of the
        representation transferred in responses.</t>

        <t>It is RECOMMENDED that the Size1 Option is used with the Block3
        Option. It is also RECOMMENDED that the Size2 Option is used with the
        Block4 Option.</t>

        <t>If Size1 or Size2 Options are used, they MUST be used in all
        payloads of the body and MUST have the same value.</t>
      </section>

      <section title="Use of Block3 and Block4 Options Together">
        <t>The behavior is similar to the one defined in Section 3.3 of <xref
        target="RFC7959"></xref> with Block3 substituted for Block1 and Block4
        for Block2.</t>
      </section>
    </section>

    <section anchor="code" title="TBA3 (Missing Payloads) Response Code">
      <t>TBA3 (Missing Payloads) Response Code is a new client error status
      code (Section 5.9.2 of <xref target="RFC7252"></xref>) used to indicate
      that the server has not received all of the blocks of the request body
      that it needs to proceed.</t>

      <t>Likely causes are the client has not sent all blocks, some blocks
      were dropped during transmission, or the client has sent them
      sufficiently long ago that the server has already discarded them. </t>

      <t>The data payload of the TBA3 (Missing Payloads) Response Code is
      encoded as a CBOR Sequence <xref target="RFC8742"></xref>. First is CBOR
      encoded Request-Tag followed by 1 or more missing CBOR encoded missing
      block numbers. The missing block numbers MUST be unique per TBA3
      (Missing Payloads) when created by the server; the client SHOULD drop
      any duplicates in the same TBA3 (Missing Payloads) message. </t>

      <t>The Content-Format Option (Section 5.10.3 of <xref
      target="RFC7252"></xref>) MUST be used in the TBA3 (Missing Payloads)
      Response Code. It MUST be set to "application/cbor-seq+block" (see <xref
      target="new-format"></xref>).</t>

      <t>The Concise Data Definition Language <xref target="RFC8610"></xref>
      for the data describing these missing blocks is as follows:<figure
          align="center" anchor="cddl"
          title="Structure of the Missing Blocks Payload">
          <artwork align="center"><![CDATA[TBA3-payload = (request-tag, missing-block-list)
; A copy of the opaque Request-Tag value
request-tag = bstr 
missing-block-list = [1 * missing-block-number]
; A unique block number not received
missing-block-number = uint      
]]></artwork>
        </figure></t>

      <t>If the size of the TBA3 (Missing Payloads) response packet is larger
      than that defined by Section 4.6 <xref target="RFC7252"></xref>, then
      the number of missing blocks MUST be limited so that the response can
      fit into a single packet. If necessary, multiple TBA3 (Missing Payloads)
      Response Codes can be sent back; each covering a Request-Tag and a
      unique set of missing blocks. The same Token can be used for the
      multiple TBA3 (missing Payloads) if this is the case. </t>
    </section>

    <section title="Caching Considerations">
      <t>The Block3 and Block4 Options are part of the cache key. As such, a
      CoAP proxy that does not understand the Block3 and Block4 Options must
      follow the recommendations in Section 5.7.1 of <xref
      target="RFC7252"></xref> for caching.</t>

      <t>This specification does not require a proxy to obtain the complete
      representation before it serves parts of it to the client. Otherwise,
      the considerations discussed in Section 2.10 of <xref
      target="RFC7959"></xref> apply for the Block3 and Block4 Options (with
      Block3 substituted for Block1 and Block4 substituted for Block2) for
      proxies that support Block3 and Block4 Options.</t>

      <t>A proxy that supports Block4 Option MUST be prepared to receive a GET
      or similar message indicating one or more missing blocks. The proxy can
      serve from its cache missing blocks that are available in its cache in a
      set as a server would send all the Block4s. If one or more requested
      blocks are not available in the cache, the proxy SHOULD update the GET
      request by removing the blocks that it can serve from the cache, and
      then forward on the request to the next hop.</t>

      <t>Alternatively, the original request unmodified (from the missing
      block perspective) MAY be forwarded on to the server. All the responses
      are then passed back to the client with the cache getting updated.</t>

      <t>How long a CoAP endpoint (or proxy) keeps the body in its cache is
      implementation specific (e.g., it may be based on Max-Age).</t>
    </section>

    <section title="HTTP-Mapping Considerations">
      <t>As a reminder, the basic normative requirements on HTTP/CoAP mappings
      are defined in Section 10 of <xref target="RFC7252"></xref>. The
      implementation guidelines for HTTP/CoAP mappings are elaborated in <xref
      target="RFC8075"></xref>.</t>

      <t>The rules defined in Section 5 of <xref target="RFC7959"></xref> are
      to be followed.</t>
    </section>

    <section title="Examples of Selective Block Recovery">
      <t>This section provides some sample flows to illustrate the use of
      Block3 and Block4 Options. <xref target="legend"></xref> lists the
      conventions that are used in the following subsections.</t>

      <t><figure align="center" anchor="legend"
          title="Notations Used in the Figures">
          <artwork><![CDATA[   T: Token value
   O: Observe Option value
   M: Message ID
  RT: Request-Tag
  ET: ETag
  B3: Block3 Option values NUM/More/SZX
  B4: Block3 Option values NUM/More/SZX
   \: Trimming long lines
[[]]: Comments
-->X: Message loss
X<--: Message loss

]]></artwork>
        </figure></t>

      <section title="Block3 Option: Non-Confirmable Example">
        <t><xref target="B3non"></xref> depicts an example of a NON PUT
        request conveying Block3 Option. All the blocks are received by the
        server.</t>

        <t><figure anchor="B3non"
            title="Example of NON Request with Block3 Option (Without Loss)">
            <artwork><![CDATA[        CoAP        CoAP
       Client      Server
         |          |
         +--------->| NON PUT /path M:0x01 T:0xf0 RT=10 B3:0/1/1024
         +--------->| NON PUT /path M:0x02 T:0xf1 RT=10 B3:1/1/1024
         +--------->| NON PUT /path M:0x03 T:0xf2 RT=10 B3:2/1/1024
         +--------->| NON PUT /path M:0x04 T:0xf3 RT=10 B3:3/0/1024
         |<---------+ NON 2.04 M:0xf1 T:0xf3
             ...
]]></artwork>
          </figure></t>

        <t>Consider now a scenario where a new body of data is to be sent by
        the client, but some blocks are dropped in transmission as illustrated
        in <xref target="B3non1"></xref>.</t>

        <t><figure anchor="B3non1"
            title="Example of NON Request with Block3 Option (With Loss)">
            <artwork><![CDATA[        CoAP        CoAP
       Client      Server
         |          |
         +--------->| NON PUT /path M:0x05 T:0xe0 RT=11 B3:0/1/1024
         +--->X     | NON PUT /path M:0x06 T:0xe1 RT=11 B3:1/1/1024
         +--->X     | NON PUT /path M:0x07 T:0xe2 RT=11 B3:2/1/1024
         +--------->| NON PUT /path M:0x08 T:0xe3 RT=11 B3:3/0/1024
         |          |
             ...
]]></artwork>
          </figure></t>

        <t>The server realizes that some blocks are missing and asks for the
        missing ones in one go (<xref target="B3non2"></xref>). It does so by
        indicating which blocks have been received in the data portion of the
        response.</t>

        <t><figure anchor="B3non2"
            title="Example of NON Request with Block3 Option (Blocks Recovery)">
            <artwork><![CDATA[        CoAP        CoAP
       Client      Server
         |          |
             ...
         |<---------+ NON TBA3 M:0xf2 T:0xe3 [Missing 1,2 for RT=11] 
         +--------->| NON PUT /path M:0x09 T:0xe4 RT=11 B3:1/1/1024
         +--->X     | NON PUT /path M:0x0a T:0xe5 RT=11 B3:2/1/1024
         |          |
         |<---------+ NON TBA3 M:0xf3 T:0xe4 [Missing 2 for RT=11]
         +--------->| NON PUT /path M:0x0b T:0xe6 RT=11 B3:2/1/1024
         |<---------+ NON 2.04 M:0xf4 T:0xe6 
         |          |
             ...
]]></artwork>
          </figure></t>

        <t>Under high levels of traffic loss, the client can elect not to
        retry sending missing blocks of data. This decision is implementation
        specific.</t>
      </section>

      <section title="Block4 Option: Non-Confirmable Example">
        <t><xref target="nonb4"></xref> illustrates the example of Block4
        Option. The client sends a NON GET carrying an Observe and a Block4
        Options. The Block4 Option indicates a size hint (1024 bytes). This
        request is replied by the server using four (4) blocks that are
        transmitted to the client without any loss. Each of these blocks
        carries a Block4 Option. The same process is repeated when an Observe
        is triggered, but no loss is experienced by any of the notification
        blocks.</t>

        <t><figure anchor="nonb4"
            title="Example of NON Notifications with Block4 Option (Without Loss)">
            <artwork><![CDATA[        CoAP        CoAP
       Client      Server
         |          |
         +--------->| NON GET /path M:0x01 T:0xf0 O:0 B4:0/0/1024
         |<---------+ NON 2.05 M:0xf1 T:0xf0 O:1234 ET=21 B4:0/1/1024
         |<---------+ NON 2.05 M:0xf2 T:0xf0 O:1234 ET=21 B4:1/1/1024
         |<---------+ NON 2.05 M:0xf3 T:0xf0 O:1234 ET=21 B4:2/1/1024
         |<---------+ NON 2.05 M:0xf4 T:0xf0 O:1234 ET=21 B4:3/0/1024
              ...
           [[Observe triggered]]
         |<---------+ NON 2.05 M:0xf5 T:0xf0 O:1235 ET=22 B4:0/1/1024
         |<---------+ NON 2.05 M:0xf6 T:0xf0 O:1235 ET=22 B4:1/1/1024
         |<---------+ NON 2.05 M:0xf7 T:0xf0 O:1235 ET=22 B4:2/1/1024
         |<---------+ NON 2.05 M:0xf8 T:0xf0 O:1235 ET=22 B4:3/0/1024
             ...

]]></artwork>
          </figure></t>

        <t><xref target="nonb41"></xref> shows the example of an Observe that
        is triggered but for which some notification blocks are lost. The
        client detects the missing blocks and request their retransmission. It
        does so by indicating the blocks that were successfully received.</t>

        <t><figure anchor="nonb41"
            title="Example of NON Notifications with Block4 Option (Blocks Recovery)">
            <artwork><![CDATA[        CoAP        CoAP
       Client      Server
         |          |
             ...
            [[Observe triggered]]
         |<---------+ NON 2.05 M:0xf9 T:0xf0 O:1236 ET=23 B4:0/1/1024
         |     X<---+ NON 2.05 M:0xfa T:0xf0 O:1236 ET=23 B4:1/1/1024
         |     X<---+ NON 2.05 M:0xfb T:0xf0 O:1236 ET=23 B4:2/1/1024
         |<---------+ NON 2.05 M:0xfc T:0xf0 O:1236 ET=23 B4:3/0/1024
         |          |
      [[Client realizes blocks are missing and asks for the missing
        ones in one go]]
         +--------->| NON GET /path M:0x02 T:0xf1 B4:1/0/1024\
         |          |                             B4:2/0/1024
         |     X<---+ NON 2.05 M:0xfd T:0xf1 ET=23 B4:1/1/1024
         |<---------+ NON 2.05 M:0xfe T:0xf1 ET=23 B4:2/1/1024
         |          |
      [[Get the final missing block]]
         +--------->| NON GET /path M:0x03 T:0xf2 B4:1/0/1024
         |<---------+ NON 2.05 M:0xff T:0xf2 ET=23 B4:1/1/1024
             ...
]]></artwork>
          </figure></t>

        <t>Under high levels of traffic loss, the client can elect not to
        retry getting missing blocks of data. This decision is implementation
        specific.</t>
      </section>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <section title="New CoAP Options">
        <t>IANA is requested to add the following entries to the "CoAP Option
        Numbers" sub-registry available at
        https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#option-numbers:</t>

        <t><figure align="center">
            <artwork align="center"><![CDATA[+--------+------------------+-----------+
| Number | Name             | Reference |
+========+==================+===========+
|  TBA1  | Block3           | [RFCXXXX] |
|  TBA2  | Block4           | [RFCXXXX] |
+--------+------------------+-----------+

Table 2: CoAP Block3 and Block4 Option Numbers]]></artwork>
          </figure></t>

        <t>This document suggests 21 (TBA1) and 25 (TBA2) as a values to be
        assigned for the new option numbers.</t>
      </section>

      <section title="New CoAP Response Code">
        <t>IANA is requested to add the following entry to the "CoAP Response
        Codes" sub-registry available at
        https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#response-codes:</t>

        <t><figure align="center">
            <artwork align="center"><![CDATA[+------+------------------+-----------+
| Code | Description      | Reference |
+======+==================+===========+
| TBA3 | Missing Payloads | [RFCXXXX] |
+------+------------------+-----------+

Table 3: New CoAP Response Code]]></artwork>
          </figure></t>

        <t>This document suggests 4.19 (TBA3) as a value to be assigned for
        the new Response Code.</t>
      </section>

      <section anchor="new-format" title="New Content Format">
        <t>This document requests IANA to register the CoAP Content-Format ID
        for the "application/cbor-seq+block" media type in the "CoAP
        Content-Formats" registry available at
        https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#content-formats:</t>

        <figure>
          <artwork><![CDATA[o  Media Type: application/cbor-seq+block
o  Encoding: -
o  Id: TBD4
o  Reference: [RFCXXXX]]]></artwork>
        </figure>

        <t></t>
      </section>
    </section>

    <section anchor="security" title="Security Considerations">
      <t>Security considerations discussed in Section 9 of <xref
      target="RFC7959"></xref> should be taken into account.</t>

      <t>Security considerations related to the use of Request-Tag are
      discussed in Section 5 of <xref
      target="I-D.ietf-core-echo-request-tag"></xref>.</t>
    </section>

    <section anchor="ack" title="Acknowledgements">
      <t>Thanks to Achim Kraus and Jim Schaad for the comments on the mailing
      list.</t>

      <t>Special thanks to Christian Ams&uuml;ss and Carsten Bormann for their
      suggestions and several reviews, which improved this specification
      significantly.</t>

      <t>Some text from <xref target="RFC7959"></xref> is reused for readers
      convenience.</t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?>

      <?rfc include="reference.RFC.7252"?>

      <?rfc include='reference.RFC.8174'?>

      <?rfc include='reference.RFC.8075'?>

      <?rfc include='reference.RFC.7959'?>

      <?rfc include='reference.RFC.7641'?>

      <?rfc include='reference.RFC.8132'?>

      <?rfc include='reference.RFC.8323'?>

      <?rfc include='reference.RFC.8613'?>

      <?rfc include='reference.RFC.8742'?>

      <?rfc include='reference.I-D.ietf-core-echo-request-tag'?>
    </references>

    <references title="Informative References">
      <?rfc include="reference.I-D.ietf-dots-telemetry"?>

      <?rfc include='reference.RFC.6928'?>

      <?rfc include='reference.RFC.8782'?>

      <?rfc include='reference.RFC.8610'?>
    </references>

    <section anchor="CON" title="Examples with Confirmable Messages">
      <t>These examples assume NSTART has been increased to at least 4. </t>

      <t>The notations provided in <xref target="legend"></xref> are used in
      the following subsections. </t>

      <section title="Block3 Option">
        <t>Let's now consider the use Block3 Option with a CON request as
        shown in <xref target="con3"></xref>. All the blocks are acknowledged
        (ACK).</t>

        <t><figure anchor="con3"
            title="Example of CON Request with Block3 Option (Without Loss)">
            <artwork><![CDATA[        CoAP        CoAP
       Client      Server
         |          |
         +--------->| CON PUT /path M:0x01 T:0xf0 RT=10 B3:0/1/1024
         +--------->| CON PUT /path M:0x02 T:0xf1 RT=10 B3:1/1/1024
         +--------->| CON PUT /path M:0x03 T:0xf2 RT=10 B3:2/1/1024
         +--------->| CON PUT /path M:0x04 T:0xf3 RT=10 B3:3/0/1024
         |<---------+ ACK 0.00 M:0x01
         |<---------+ ACK 0.00 M:0x02
         |<---------+ ACK 0.00 M:0x03
         |<---------+ ACK 0.00 M:0x04

]]></artwork>
          </figure></t>

        <t>Now, suppose that a new body of data is to sent but with some
        blocks dropped in transmission as illustrated in <xref
        target="con32"></xref>. The client will retry sending blocks for which
        no ACK was received.</t>

        <t><figure anchor="con32"
            title="Example of CON Request with Block3 Option (Blocks Recovery)">
            <artwork><![CDATA[        CoAP        CoAP
       Client      Server
         |          |
         +--------->| CON PUT /path M:0x05 T:0xf4 RT=11 B3:0/1/1024
         +--->X     | CON PUT /path M:0x06 T:0xf5 RT=11 B3:1/1/1024
         +--->X     | CON PUT /path M:0x07 T:0xf6 RT=11 B3:2/1/1024
         +--------->| CON PUT /path M:0x08 T:0xf7 RT=11 B3:3/1/1024
         |<---------+ ACK 0.00 M:0x05
         |<---------+ ACK 0.00 M:0x08
         |          |
       [[The client retries sending packets not acknowledged]]
         +--------->| CON PUT /path M:0x06 T:0xf5 RT=11 B3:1/1/1024
         +--->X     | CON PUT /path M:0x07 T:0xf6 RT=11 B3:2/1/1024
         |<---------+ ACK 0.00 M:0x06
         |          |
       [[The client retransmits messages not acknowledged
        (exponential backoff)]]
         +--->?     | CON PUT /path M:0x07 T:0xf6 RT=11 B3:2/1/1024
         |          |
       [[Either transmission failure (acknowledge retry timeout)
         or successfully transmitted.]]
]]></artwork>
          </figure>It is implementation dependent as to whether a CoAP session
        is terminated following acknowledge retry timeout, or whether the CoAP
        session continues to be used under such adverse traffic
        conditions.</t>

        <t>If there is likely to be the possibility of network transient
        losses, then the use of Non-confirmable traffic should be
        considered.</t>
      </section>

      <section title="Block4 Option">
        <t>An example of the use of Block4 Option with Confirmable messages is
        shown in <xref target="b4con"></xref>.</t>

        <t><figure align="center" anchor="b4con"
            title="Example of CON Notifications with Block4 Option">
            <artwork align="center"><![CDATA[       Client      Server
         |          |
         +--------->| CON GET /path M:0x01 T:0xf0 O:0 B4:0/0/1024
         |<---------+ ACK 2.05 M:0x01 T:0xf0 O:1234 ET=21 B4:0/1/1024
         |<---------+ ACK 2.05 M:0xe1 T:0xf0 O:1234 ET=21 B4:1/1/1024
         |<---------+ ACK 2.05 M:0xe2 T:0xf0 O:1234 ET=21 B4:2/1/1024
         |<---------+ ACK 2.05 M:0xe3 T:0xf0 O:1234 ET=21 B4:3/0/1024
             ...
                 [[Observe triggered]]
         |<---------+ CON 2.05 M:0xe4 T:0xf0 O:1235 ET=22 B4:0/1/1024
         |<---------+ CON 2.05 M:0xe5 T:0xf0 O:1235 ET=22 B4:1/1/1024
         |<---------+ CON 2.05 M:0xe6 T:0xf0 O:1235 ET=22 B4:2/1/1024
         |<---------+ CON 2.05 M:0xe7 T:0xf0 O:1235 ET=22 B4:3/0/1024
         |--------->+ ACK 0.00 M:0xe4
         |--------->+ ACK 0.00 M:0xe5
         |--------->+ ACK 0.00 M:0xe6
         |--------->+ ACK 0.00 M:0xe7
              ...
                 [[Observe triggered]]
         |<---------+ CON 2.05 M:0xe8 T:0xf0 O:1236 ET=23 B4:0/1/1024
         |     X<---+ CON 2.05 M:0xe9 T:0xf0 O:1236 ET=23 B4:1/1/1024
         |     X<---+ CON 2.05 M:0xea T:0xf0 O:1236 ET=23 B4:2/1/1024
         |<---------+ CON 2.05 M:0xeb T:0xf0 O:1236 ET=23 B4:3/0/1024
         |--------->+ ACK 0.00 M:0xe8
         |--------->+ ACK 0.00 M:0xeb
         |          |
                 [[Server retransmits messages not acknowledged]]
         |<---------+ CON 2.05 M:0xe9 T:0xf0 O:1236 ET=23 B4:1/1/1024
         |     X<---+ CON 2.05 M:0xea T:0xf0 O:1236 ET=23 B4:2/1/1024
         |--------->+ ACK 0.00 M:0xe9
         |          |
                 [[Server retransmits messages not acknowledged
                  (exponential backoff)]]
         |     X<---+ CON 2.05 M:0xea T:0xf0 O:1236 ET=23 B4:2/1/1024
         |          |
           [[Either transmission failure (acknowledge retry timeout)
             or successfully transmitted.]]
]]></artwork>
          </figure></t>

        <t>It is implementation-dependent as to whether a CoAP session is
        terminated following acknowledge retry timeout, or whether the CoAP
        session continues to be used under such adverse traffic
        conditions.</t>

        <t>If there is likely to be the possibility of network transient
        losses, then the use of Non-confirmable traffic should be
        considered.</t>
      </section>
    </section>
  </back>
</rfc>
