CoAP Option Offsets and Shifted Boundaries
CoAP Option Offsets and Shifted Boundaries
Predict where the next CoAP option begins.
CoAPOriginal datagram
- Byte pointer
- Next prefix · offset 5
- Previous complete option number
- 0
Original datagram
b7 · delta 11 · length 7 → offsets 6–12: sensors
- Byte pointer
- Next prefix · offset 13
- Previous complete option number
- 11
Original datagram
b7 · delta 11 · length 7 → offsets 6–12: sensors
04 · delta 0 · length 4 → offsets 14–17: 74 65 6d 70 → temp
Decoded path: /sensors/temp · No payload marker
- Byte pointer
- End of datagram · offset 18
- Previous complete option number
- 11
Original datagram
b7 · delta 11 · length 7 → offsets 6–12: sensors
04 · delta 0 · length 4 → offsets 14–17: 74 65 6d 70 → temp
Decoded path: /sensors/temp · No payload marker
- Byte pointer
- End of datagram · offset 18
- Previous complete option number
- 11
Shifted datagram · b8 replaces b7
b8 · delta 11 · length 8 → offsets 6–13. The byte 04 now belongs to the first value.
- Byte pointer
- Next prefix · offset 14
- Previous complete option number
- 11
Original datagram
b7 · delta 11 · length 7 → offsets 6–12: sensors
04 · delta 0 · length 4 → offsets 14–17: 74 65 6d 70 → temp
Decoded path: /sensors/temp · No payload marker
- Byte pointer
- End of datagram · offset 18
- Previous complete option number
- 11
Shifted datagram · b8 replaces b7
b8 · delta 11 · length 8 → offsets 6–13. The byte 04 now belongs to the first value.
74 · delta 7 · length 4. The declared value needs offsets 15–18. Only 65 6d 70 are available.
- Byte pointer
- Candidate value starts at offset 15
- Previous complete option number
- 11
- Candidate number
- 18
Find the first option prefix
The fixed header and token are accounted for. After reading b7 and its value, where should the next option prefix begin?
Technical boundaries. The byte strips isolate a single prefix change in a fixed datagram with no payload marker. The replay stops at the incomplete candidate when the declared span runs past the available bytes. Other shifted traces can decode into unintended options.