Follow the CoAP Option Cursor
Follow the CoAP Option Cursor
Track the boundary and the option number
Wire formatUDP request
4410127d334a15b26c37d4b79731065116e1273136f147215730417741865196d2070Cursor → b7 at offset 8
Start at the first option
Token Length is 4 bytes.
Cumulative option number: 0.
UDP request
4410127d334a15b26c37d4b79731065116e1273136f147215730417741865196d2070Cursor → 04 at offset 16
Decode b7
Delta b → 11 (direct) · length 7 (direct).
0 + 11 = 11 → Uri-Path. Read 73 65 6e 73 6f 72 73 as sensors.
UDP request
4410127d334a15b26c37d4b79731065116e1273136f147215730417741865196d2070Cursor → datagram end, before offset 21
Decode 04
Delta 0 (direct) · length 4 (direct).
11 + 0 = 11 → Uri-Path. Read 74 65 6d 70 as temp.
Path: /sensors/temp · Payload absent.
UDP response
6414527d334a15b26c37d4c1932ff7b122213741465156d16701722183a19322032212e2235232c24222575266e276928742922303a312232433322347dCursor → ff at offset 10
Decode c1
Delta 12 (direct) · length 1 (direct).
0 + 12 = 12 → Content-Format. Value 0x32 is 50 (application/json).
UDP response
6414527d334a15b26c37d4c1932ff7b122213741465156d16701722183a19322032212e2235232c24222575266e276928742922303a312232433322347dCursor → payload marker at offset 10
Payload bytes through datagram end
Offsets 11–34 · 24 bytes
{"temp":22.5,"unit":"C"}
The uppercase C is 0x43. The option number stays 12.
Schematic · Cursor inside an option value
FFInside declared option value
Remaining value bytes
The cursor reads FF and the remaining bytes as value data. It checks for a payload marker at the next option boundary.
At an option boundary · RFC 7252 §3.1
Stop at datagram end. Otherwise check for FF first.
For FF, start the payload at the next byte. A missing payload is a format error.
Ordinary option header
Either nibble 15 → format error.
0–12 → direct.
13 → read one extension byte and add 13.
14 → read two extension bytes as an unsigned network-order integer and add 269.
Advance in field order
Header → delta extension, if present → length extension, if present → declared value → next boundary.
Add the decoded delta to the cumulative option number.
Use the header's token length to reach the first option, then start the option number at zero.
Technical boundaries. The byte strip follows one UDP request and one response with direct option deltas and lengths. Extension-byte and format-error rules appear in the final summary, outside the worked datagrams. The inset with FF inside an option value is a separate schematic that illustrates why byte position matters.