CoAP blockwise transfer

Block-Wise Transfers in the Constrained Application Protocol (CoAP)
https://www.rfc-editor.org/rfc/rfc7959.html

In summary, this specification adds a pair of Block options to CoAP
that can be used for block-wise transfers. Benefits of using these
options include:
o Transfers larger than what can be accommodated in constrained-
network link-layer packets can be performed in smaller blocks.
o No hard-to-manage conversation state is created at the adaptation
layer or IP layer for fragmentation.
o The transfer of each block is acknowledged, enabling individual
retransmission if required.
o Both sides have a say in the block size that actually will be
used.
o The resulting exchanges are easy to understand using packet
analyzer tools, and thus quite accessible to debugging.
o If needed, the Block options can also be used (without changes) to
provide random access to power-of-two sized blocks within a
resource representation.

As discussed in the introduction, there are good reasons to limit the
size of datagrams in constrained networks: o by the maximum datagram size (~ 64 KiB for UDP)

o by the desire to avoid IP fragmentation (MTU of 1280 for IPv6)

o by the desire to avoid adaptation-layer fragmentation (60-80 bytes
for 6LoWPAN [RFC4919])

we use the number 1 ("Block1", "Size1") to refer to the transfer of the resource representation that pertains to the request,
and the number 2 ("Block2", "Size2") to refer to the transfer of the
resource representation for the response

put uses block1, get uses block2

Structure of a Block Option Three items of information may need to be transferred in a Block
(Block1 or Block2) option:

o the size of the block (SZX);

o whether more blocks are following (M);

o the relative number of the block (NUM) within a sequence of blocks
with the given size.

SZX: Block Size. The block size is represented as a three-bit
unsigned integer indicating the size of a block to the power of
two. Thus, block size = 2(SZX + 4). The allowed values of SZX
are 0 to 6, i.e., the minimum block size is 2
(0+4) = 16 and the
maximum is 2**(6+4) = 1024. The value 7 for SZX (which would
indicate a block size of 2048) is reserved, i.e., MUST NOT be sent
and MUST lead to a 4.00 Bad Request response code upon reception
in a request.

posted @ 2021-09-25 20:30  feiwatson  阅读(100)  评论(0编辑  收藏  举报