Skip to main content

Module block

Module block 

Source
Expand description

CoAP block-wise transfer per RFC 7959.

EST payloads frequently exceed the CoAP datagram size limit, especially with post-quantum certificates (ML-DSA-87 certificates can exceed 7KB). Block-wise transfer splits large payloads into numbered blocks that are individually acknowledged.

§Block Options

  • Block1 (option 27): Controls request payload transfer (client to server). The client sends the request body in numbered chunks; the server acknowledges each chunk before the next is sent.

  • Block2 (option 23): Controls response payload transfer (server to client). The server splits its response into numbered chunks; the client requests successive chunks.

§SZX Encoding

Block sizes are encoded as szx where actual size = 2^(szx + 4):

  • szx=0 → 16 bytes
  • szx=1 → 32 bytes
  • szx=2 → 64 bytes
  • szx=3 → 128 bytes
  • szx=4 → 256 bytes
  • szx=5 → 512 bytes (default)
  • szx=6 → 1024 bytes (maximum)

Structs§

BlockAssembler
Reassembles Block1 fragments into a complete request payload.
BlockDisassembler
Splits a response payload into Block2 chunks for incremental delivery.
BlockOption
A decoded Block1 or Block2 option value.

Constants§

DEFAULT_SZX
Default block size exponent (szx=5 → 512 bytes).
MAX_SZX
Maximum block size exponent (szx=6 → 1024 bytes).

Functions§

block_size_from_szx
Converts an SZX exponent to the actual block size in bytes.
szx_from_block_size
Converts a block size in bytes to the corresponding SZX exponent.