← Back to the chapter · Previous detail

Technical detail · CoAP Lab: Stack and Trace Contracts

Application-byte arithmetic and its assumptions

Two simplified CoAP and HTTP exchange models count application bytes while excluding the rest of a real network exchange.

The /temp model counts a request as a 4-byte header, 2-byte token and 5-byte Uri-Path option carrying the resource path: 11 bytes. The response is a 4-byte header, 2-byte token, 1-byte marker and 4-byte payload: another 11 bytes. The total is 22 application bytes. The stated literal HTTP request and response total 78 bytes, about 3.55 times the CoAP total. HTTP means Hypertext Transfer Protocol.

At the assumed 250 kbps, those application bytes give ideal transmission times of 0.704 ms and 2.496 ms. The constant 20 mA transmit model treats both request and response bytes at the same current and rate. It excludes transport framing, handshakes, losses and idle listening; it cannot establish the endpoint’s battery life.

The message calculator’s default longer temperature path gives 29 CoAP bytes and 85 HTTP bytes in its simplified exchange. Its response still omits Content-Format. The charge calculator instead uses the smaller 22/78-byte model. Keep path, token length, options and both directions aligned before diagnosing a count mismatch. Turning off HTTP headers explores the model but does not produce a valid HTTP/1.1 request.

← Back to the chapter · Previous detail