The Byte Budget

Ada audits the byte budget — offsets, option nibbles, and payload boundaries

foundations
math-foundations
coap
wire-format
advanced
Ada ADA · CALCULATION AUDIT

The Byte Budget

This chapter traces a complete GET /temp request and shows it fits in just 13 CoAP bytes — header 4 plus token 4 plus option prefix 1 plus option value 4 — before any UDP/IP overhead. Every byte carries exact meaning, from the delta-11 Uri-Path option to the 0xFF payload marker. This audit walks that byte budget to show each field is countable, not approximate.

Companion to the chapter CoAP Wire Format and Option Encoding — every number here comes from that chapter.

CoAP · optional mathematics and physics — offsets, option nibbles, and payload boundaries, ~4 minutes

A packet decoder is a small physics budget: every bit consumes a position on the wire, so the parser must prove where the next field begins before it interprets the value.

Ada audits the byte budget

Check Arithmetic Parser consequence
Request option start Fixed header 4 bytes + TKL 4 token bytes = offset 8. The first option prefix is byte 8, so token bytes cannot be decoded as options.
Uri-Path prefix 0xB4 splits into delta nibble 0xB = 11 and length nibble 0x4 = 4. Previous option 0 + delta 11 = option 11, Uri-Path; four following bytes spell temp.
Request size shown Header 4 + Token 4 + option prefix 1 + option value 4 = 13 bytes. The complete GET /temp trace fits in 13 CoAP bytes before any UDP/IP link overhead.
Response code byte 0x45 = 69; class = floor(69 / 32) = 2; detail = 69 - 64 = 5. The response is 2.05 Content, not a raw decimal code.
Payload marker boundary ASCII reading 32 32 2E 35 is 4 payload bytes, and it is only payload after 0xFF. Without the marker, those bytes would still be read as option-prefix material until the datagram ended.

Round only at presentation boundaries: the code-byte split uses exact integer division, while byte offsets stay exact counts from the datagram start.

Every number above is taken from the chapter’s own CoAP wire-format example and re-derived step by step.