← Back to the chapter · Previous detail

Technical detail · CoAP Messages: Parsing and Validation

Delayed CoAP responses: acknowledgment, correlation and loss

A delayed response to the sensor read separates receipt from the application reply. Follow the Message ID and Token independently so that waiting for data is not mistaken for waiting for an acknowledgment.

For the CON GET request with Message ID 0x7A10 and Token A1 B2, an empty acknowledgment can repeat Message ID 0x7A10 without carrying the application response. A later, separate response carries Token A1 B2 and uses a new message exchange. Match the acknowledgment by Message ID; match the response by Token together with the peer. A different response Message ID is not, by itself, evidence of a mismatch.

The peer is the remote endpoint. Keep its identity beside the outstanding request, because the Token is interpreted within the exchange with that peer. The Message ID continues to serve acknowledgment matching and duplicate handling.

UDP can lose, reorder, or duplicate datagrams. CoAP handles selected cases, while the application defines acceptable consequences. For this GET request, distinguish a timeout caused by a missing ACK from one caused by a missing response. If a response arrives, check its Token before accepting the data.

A matching Token identifies the request within the exchange with that peer. It does not authenticate the sender, establish freshness, or prove that a physical reading is correct. Choosing CON or NON cannot establish those properties either; message handling and acceptance of the result remain separate decisions. In the flat, a well-formed temperature response still needs its acceptance conditions checked, and a lamp command still needs evidence of its physical effect.

← Back to the chapter · Previous detail