CoAP · Study deck
CoAP Block and Discovery Contracts
A constrained node cannot always carry a firmware image in one CoAP message, and a new client cannot use a resource it cannot discover.
Broker Bex is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Choose Block1 or Block2 and record block size, retry, resume, and hash-verification evidence for a large CoAP transfer.
- Decode Block option NUM, M, and SZX fields and check them against byte offsets in a trace.
- Describe /.well-known/core discovery, CoRE Link Format attributes, filtered discovery queries, and Content-Format 40.
- Review Max-Age, ETag revalidation, and proxy caching decisions for constrained CoAP resources.
Major section
Reassemble the Image the Server Actually Sent
It selects the firmware resource and requests a block.
- Four full blocks carry (4\times1{,}024=4{,}096) bytes, leaving (5{,}000-4{,}096=904) bytes in the fifth block.
- The client should expect exactly 5,000 assembled bytes before checking the image hash and signature.
- Discovery has its own precision.
Major section
Reassemble the Image the Server Actually Sent (continued)
A lost response does not mean the server should advance state blindly.
- The client can request the same block number again, and the server should return the matching portion of the same representation.
- Mixing old and new blocks could produce 5,000 bytes that are still unsafe.
- A link-format record can name a resource path, content type, interface, resource type, and observability.
- Authorization remains separate from knowing that a URI exists.
Major section
Start With the Broken Firmware Download
One block is missing, and a nearby cache may describe an old file.
- The device needs proof before it resumes or installs anything.
- A protocol means the shared rules for a message exchange.
- CoAP means Constrained Application Protocol, a compact message system for small devices.
- Firmware means the software stored on a device.
Major section
Start With the Broken Firmware Download (continued)
A block is one numbered piece of a larger transfer.
- This runway does not prove every proxy or update route.
- The device asks for a firmware image, receives several blocks, loses one packet, then wakes later behind a proxy that may still have cached metadata.
- A working demo is not enough; the transfer needs block size, numbering, retry, resume, hash, discovery, and freshness evidence.
Major section
Overview: Block-wise Transfer Moves Big Payloads Through Small Datagrams
The key benefit is failure isolation.
- Each block is carried in its own request/response exchange with its own Message ID, so a lost block is retransmitted alone rather than forcing the entire payload to restart.
- In a real maintenance window, that isolation changes the rollout plan.
Major section
Overview: Block-wise Transfer Moves Big Payloads Through Small Datagrams (continued)
The transfer has 384 numbered blocks.
- The review evidence should record the chosen block size, retry cap, resume point, hash check, and the condition that triggers rollback to the previous profile.
- That ordered contract turns the pump-controller example into a testable transfer rather than assuming that smaller datagrams alone make delivery safe.
- Failure isolation Each block is its own exchange, so loss costs one block, not the whole transfer.
Major section
Practitioner: The Block Option Encodes NUM, More, and a Size Exponent
With SZX 4 the client sends 256-byte Block1 chunks, so it needs ceil(18,432 / 256) = 72 blocks.
- NUM is the block number within the transfer.
- M (the More flag) is 1 while further blocks follow and 0 on the last block.
- Fewest exchanges; needs the largest buffer/MTU.
Major section
Under the Hood: Discovery via CoRE Link Format, and Caching Through Proxies
Here rt is the resource type, if is the interface description, ct is the content-format the resource speaks (50 = JSON), and obs marks it observable.
- A client can narrow the query — GET /.well-known/core?rt=temperature returns only temperature links — which keeps discovery cheap on a large node.
- Every response carries an implicit or explicit Max-Age (option 14, default 60 seconds) stating how long it stays fresh.
- The evidence record should show the discovery query, Link Format body, Max-Age value, ETag revalidation result, and which resources are excluded from shared caching.
Major section
Under the Hood: Discovery via CoRE Link Format, and Caching Through Proxies (continued)
A caching CoAP proxy — forward or reverse — can store a response and serve it to other clients until Max-Age expires, so ten dashboards observing one sensor need not each wake the device.
- When freshness lapses, an ETag (option 4) lets the proxy revalidate: it repeats the ETag, and if nothing changed the origin answers 2.03 Valid with no body, saving the payload entirely.
- Max-Age caching A proxy reuses a stored response until Max-Age expires, sparing the origin device.
- Once resources are known, caching reduces how often a sleepy node is disturbed.
Deck summary
Key takeaways
It selects the firmware resource and requests a block.
- A lost response does not mean the server should advance state blindly.
- One block is missing, and a nearby cache may describe an old file.
- A block is one numbered piece of a larger transfer.
- The key benefit is failure isolation.
Retrieval practice
Recall check 1 of 3

Broker Bex says: answer from memory, then check your reasoning.
Q1Why does CoAP use block-wise transfer instead of relying on IP fragmentation for a large firmware image?
Show answer
Answer: B Block-wise transfer isolates failures to a single block, which is far more robust than IP fragmentation on lossy constrained links.
Retrieval practice
Recall check 2 of 3

Broker Bex says: answer from memory, then check your reasoning.
Q2In a CoAP block-wise option, a block has SZX = 6 and the More (M) flag set to 0. What does that mean?
Show answer
Answer: B Block size is 2^(SZX+4) = 2^10 = 1024 bytes, and M = 0 marks the last block, so the transfer ends here.
Retrieval practice
Recall check 3 of 3

Broker Bex says: answer from memory, then check your reasoning.
Q3A CoAP caching proxy holds a sensor response whose Max-Age has just expired. It revalidates and the value is unchanged. What response makes this efficient?
Show answer
Answer: A ETag-based revalidation lets the origin answer 2.03 Valid without resending the body, refreshing the cache cheaply.
Print reference
Answers
Answer key.
- B · Block-wise transfer isolates failures to a single block, which is far more robust than IP fragmentation on lossy constrained links.
- B · Block size is 2^(SZX+4) = 2^10 = 1024 bytes, and M = 0 marks the last block, so the transfer ends here.
- A · ETag-based revalidation lets the origin answer 2.03 Valid without resending the body, refreshing the cache cheaply.