CoAP Retransmission Timeouts: Distinguish Congestion Protection from Product Deadlines
An application may stop waiting before CoAP exhausts its retransmissions, but that choice needs an explicit cancellation and late-result policy. Do not shorten the protocol’s congestion-control timers merely to make a user interface return sooner. A caller deadline and a message retransmission schedule answer different questions.
This procedure covers Confirmable unicast messages over the UDP binding in RFC 7252. It excludes multicast, reliable-transport bindings, and the separate-response waiting period after an empty ACK. Pin the stack version, transmission parameters, cancellation API, and callback ownership model. A setting called “request timeout” may combine several phases; inspect its actual implementation before using it as a product guarantee.
1. Put the clocks on the same timeline
Record application creation time, queue admission, first transmission, each retransmission, ACK or Reset arrival, response arrival, and final callback. Start the product deadline at the event promised to the caller. Starting it only after socket transmission hides time spent waiting for a request slot.
RFC 7252 defaults are ACK_TIMEOUT of 2 seconds, ACK_RANDOM_FACTOR of 1.5, MAX_RETRANSMIT of 4, and NSTART of 1. The initial timeout is randomized, then doubles between retransmissions. Parameter changes must preserve congestion-control safety. See sections 4.2, 4.7, and 4.8.
The default NSTART limit can therefore matter before the first packet is sent. Measure admission delay separately from on-wire waiting. A user-facing budget that expires in the queue should not later launch an obsolete operation just because a slot becomes available.

2. Calculate the ideal schedule without calling it a measurement
For an illustrative initial timeout of 2.5 seconds and four retransmissions, the ideal no-response schedule is:
| Event | Seconds after first transmission |
|---|---|
| Initial transmission. | 0 |
| First retransmission. | 2.5 |
| Second retransmission. | 7.5 |
| Third retransmission. | 17.5 |
| Fourth, final retransmission. | 37.5 |
| Final ACK wait expires. | 77.5 |
The distinction between the last send and the final wait matters. RFC 7252 section 4.8.2 gives default upper values of 45 seconds for MAX_TRANSMIT_SPAN and 93 seconds for MAX_TRANSMIT_WAIT. Neither is a promise that an application operation completes within that duration, nor a permission to retire all exchange identity immediately afterward.
The table’s arithmetic was checked with an original Python 3.12.14 host-only model. The model also checked initial timeouts of 2 and 3 seconds, five total sends when four retransmissions are allowed, and the zero-retransmission boundary. It used no CoAP library, sockets, scheduler, or real clock. The source, runner instructions, output, and limits accompany the offline test evidence.
A target trace can differ because of valid implementation timing behavior, queueing, sleep, and incoming messages. Compare that trace with the applicable RFC envelope and library behavior rather than treating the ideal table as an exact packet timestamp requirement.
3. Define what the caller deadline actually cancels
RFC 7252 section 4.2 permits an endpoint to give up seeking an ACK before the retransmission limit, including when the application cancels. This permits a policy; it does not establish what a particular library’s cancellation function does. See early termination of Confirmable transmission.
Choose and document the product behavior for each phase:
| Deadline location | Required decision |
|---|---|
| Still waiting in an application queue. | Remove or invalidate the queued work so it cannot start later. |
| Message sent, ACK still pending. | Stop caller waiting and use the supported API to end retransmissions if policy requires it. |
| Send already handed to the network. | Do not claim that cancellation retracts the packet or undoes remote processing. |
| ACK or response races with cancellation. | Choose one terminal caller result and retain safe ownership for any later callback. |
| Application no longer accepts the result. | Keep required protocol cleanup distinct from delivery to the expired caller. |
A strict hypothetical 3-second caller deadline would allow the ideal sends at 0 and 2.5 seconds, but suppress later sends if cancellation completes as specified. The host model checks that decision arithmetic only. It cannot prove that a real stack stops a timer, removes a queued packet, or avoids a callback race.
4. Avoid creating a second retry engine accidentally
When the UI times out, immediately creating a new CoAP request can overlap the old exchange. If the old request caused a remote action but its response was lost, the second request may cause that action again. Message deduplication within one exchange does not provide an application operation identifier across arbitrary new requests.
For operations with consequences, define an application reconciliation method before enabling automatic reissue. A harmless status query, a documented operation identifier, or a domain-specific idempotent action can be appropriate when supported by the service contract. Do not infer any of them from a successful ACK.
Rate-limit reissues and keep congestion accounting intact. Repeatedly canceling and restarting with fresh identifiers must not become a way to evade the intended backoff or outstanding-interaction limit. Increasing responsiveness at the caller boundary should not increase uncontrolled network load.
5. Qualify cancellation and late traffic
- Withhold all fixture responses and record the actual retransmission schedule and final failure.
- Expire the caller while its request is queued, then release the queue and verify no obsolete work starts.
- Expire it between retransmissions and observe whether further packets are emitted.
- Deliver an ACK or response immediately before, during, and after cancellation. Require one terminal application result and no invalid memory access.
- Return a response after a new unrelated request starts. Confirm it cannot complete the wrong operation.
- Repeat under the supported sleep and scheduler-load conditions, preserving the applicable congestion-control limits.
These target tests are proposed, not executed here. A hypothetical control panel that needs a three-second decision can report “result unknown within deadline” and reconcile later. It should not report that the device definitely rejected the operation, and it should not turn every caller timeout into an immediate new command.
Release with separate admission, caller-deadline, retransmission, and cleanup evidence. That gives the product a responsive boundary while preserving the protocol’s responsibility to the network.