The Byte Budget
The Byte Budget
Ada audits the byte budget — offsets, option nibbles, and payload boundaries
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.
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. Calculate this case.
This audit walks that byte budget to show each field is countable, not approximate. Check shows this.
Round only at presentation boundaries: the code-byte split uses exact integer division, while byte offsets stay exact counts from the datagram start. Check confirms it.
See the relationship before changing it
The figure reads from left to right. The blue input is token length. The middle card names the page’s rule. The green output is get request size. The arrow matters: change the input, apply the rule once, then read the result with its unit.
Derive the baseline in four named moves
- 1
Name the input. The chapter baseline is 4 bytes.
- 2
Name the relationship. size = 4 header + token + 1 option prefix + 4 option value
- 3
Substitute with units. 4 + 4 + 1 + 4 = 13 bytes
- 4
Read the result. Keep the unit beside the value, then use the result only inside the technical boundary below.
Predict, then change token length
Try Predict how get request size responds when token length moves. Calculate token length; compare get request size with that prediction.
Observe Return to 4 bytes. Recheck get request size with token length at its chapter value.
Explain The token shifts every later byte boundary by its own length.
Check yourself
What should you do before trusting a moved-slider result?
What does this small model leave out?
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.