[Bug]: DTLS 1.3: NO_ASN_TIME compiles out the only retransmission throttle; client loops on Finished/ACK over slow links
Found while benchmarking post-quantum DTLS 1.3 on Cortex-M devices over emulated narrowband links (Royal Military College of Canada). Reproduction scripts and logs are attached; happy to run further cases.
Summary
wolfSSL's only DTLS 1.3 resend throttle, DTLS13_MIN_RTX_INTERVAL in Dtls13RtxSendBuffered, sits inside #ifndef NO_ASN_TIME. It needs a millisecond clock, not ASN time. A client built with NO_ASN_TIME therefore has no throttle. That define is the usual one on an MCU without a wall clock: it is how certificate dates get switched off.
On a slow link that client answers every stale fragment of the server's resent flight with another resend. The server ACKs each copy, and the handshake can stay in that Finished/ACK loop until the link goes away. The default build, with the throttle, completes.
- Reproduction with stock wolfSSL only, on one host (below): v5.9.4-stable, the example client and server, DTLS 1.3, MTU 256, X25519MLKEM768, and a 9600 or 2400 bit/s link from a 100-line Python relay.
-DNO_ASN_TIMEclient: still inwolfSSL_connectwhen killed at 120 s, with 1700 Finished copies (one dropped server datagram) and 377 (no loss).- Same source without the define: completes in 4.6 s and 21.8 s, with 2 and 6 Finished copies.
- On a Cortex-M33 board (ML-KEM-768 hybrid with ML-DSA-44, a 38-fragment server flight, a 2400-9600 bit/s satellite pass):
- Throttle off: 28 of 206 handshakes failed with -308.
- Throttle on: all 120 handshakes at window 3 completed; on cell b, paired by trial, in 0.31-0.35 of the throttle-off time.
A lost HelloRetryRequest that is never recovered (cookie off) is a separate defect, independent of the throttle, and is reported separately.
Two secondary findings make the missing throttle worse; with the throttle, they cost little:
- A. The record-number window. A message keeps only the last
DTLS13_RETRANS_RN_SIZE= 3 record numbers, andDtls13RtxIsTrackedByRnsearches only up to the wrapping write index. An ACK for an older copy is ignored (RFC 9147 §7.2). With the throttle, window 3 against 255 is 2 % slower on the board (29 of 29 paired trials). Without it, the window decides whether the handshake completes. - B. One resend per old record. The client resends its flight for each record of a peer flight it has already processed, not once per retransmitted flight (RFC 9147 §5.8.1). With the throttle that is at most one resend a second, and still 38 Finished copies per handshake at the slowest part of the pass.
Versions checked
| Commit | Date | (1) ring of 3 | (2) search to rnIdx | (3) per-record resend, throttle under NO_ASN_TIME | |
|---|---|---|---|---|---|
| v5.9.4-stable (used for all measurements) | 3c5eead44904df64e6a5a1f4ebdce377d35a849a | 2026-09-25 | yes | yes | yes |
| master | 804ffb12375013714d699da1da4a27a69713cb9a | 2026-10-25 | yes, unchanged | yes, identical | yes, identical |
All 360 handshakes complete. The three failures are trial 21 in the three cell-b phase-0 runs: the handshake completes at 68 s and the application echo is lost three times in a loss burst (application timeout, not a DTLS error). Window 255 against 3 with the throttle on, cell b: -2.6 s at phase 0 (29 of 29 lower, sign p 3.7 × 10⁻⁹, ratio 0.980) and -0.2 s at 240 (30 of 30, 1.9 × 10⁻⁹, 0.988); window 3 still has 1,226 Finished copies sent while more than 3 newer copies were in flight, window 255 none.
The first reproduction, with our client
Our own client and link emulator live in a repository that will be public with our paper; the stock-wolfSSL reproduction above needs none of it, and this section is corroboration only.
Everything runs on one Linux host: the client (host build), wolfSSL's example server and the link emulator. The profile (wolfssl_ack_loop.yaml) is: 9600 bit/s, 8 ms one way, MTU 256, a 64 KiB queue, no random loss, and one deterministic loss, down frame 9 (the first encrypted record of the server's flight, holding the certificate). Cell (a) is X25519MLKEM768 with ECDSA P-256, one cipher suite, TLS13-AES256-GCM-SHA384.
bash scripts/e2_server.sh build # wolfSSL example server, out of tree in build/wolfssl-host/
make -C firmware/e2_client host THROTTLE=off # build/e2_client/host/e2_client_host_slip (NO_ASN_TIME)
python -m orchestrator.e2_host --cell a --profile docs/wolfssl_ack_loop.yaml --client build/e2_client/host/e2_client_host_slip \
--trials 1 --mtu 256 --timeout 120 --out runs/ack/stock/client.log
- Throttle off, window 3: exit status 3, the client still in
wolfSSL_connectat 120 s; 1709 frames up and 1702 down. After 60 s the link carries only Finished copies up (82 B, 898) and ACKs down (40 B, 897). - Control,
DTLS13_RETRANS_RN_SIZE=16on the client only:make -C firmware/e2_client host HOST_BUILD=$PWD/runs/ack/rn16 HOST_OPT="-O2 -DDTLS13_RETRANS_RN_SIZE=16"and the same command with--client runs/ack/rn16/e2_client_host_slip. The handshake completes in 4.04 s over 27 frames up and 24 down. - Without any loss: at 2400 bit/s the loop starts with no loss at all. The second ClientHello (1576 B) takes 5.3 s on the link, and the client's retransmissions queue behind it (626 frames up and 605 down in 180 s); the RN 16 build completes in 19.9 s.
The host client shares the board's user_settings.h; until 2026-10-25 its only build had NO_ASN_TIME (throttle off), and the runs above are that build. With make -C firmware/e2_client host THROTTLE=on (throttle on: ASN time from a counter, NO_ASN_TIME_CHECK), both cases complete at window 3: the frame-9 case in 4.04 s with 2 Finished copies (throttle off: still in wolfSSL_connect at 120 s, 1669 copies), the 2400 bit/s case (RTO 1 s) in 20.3 s with 6 copies (off: still looping at 180 s, 591 copies). The reproduction is therefore of a NO_ASN_TIME build.
Suggested changes (for discussion)
- The throttle: don't tie it to
NO_ASN_TIME; it needs a millisecond clock, not ASN time. This alone ends the loop in our measurements. - The resend trigger: resend once per retransmitted peer flight, as RFC 9147 §5.8.1 describes, rather than once per old record. Alternatively, rate-limit by the current retransmission timer rather than by a fixed 1 s.
- The record-number set: keep every record number a message was sent in, or at least search all
DTLS13_RETRANS_RN_SIZEentries after a wrap (separate the write index from the count), and widenrnIdxbeyond a byte. With the throttle this is worth 2 % here; without it, it decides whether the handshake completes. - The server's flight: consider sending large flights in parts, as RFC 9147 §5.8.3 suggests.
A second, independent issue (with the HRR cookie disabled, a lost HelloRetryRequest is never resent and the handshake fails after ~130 s) follows separately.
Hi @NordineQuadar,
My sincere apologies for the delay. I've pushed https://github.com/wolfSSL/wolfssl/pull/12205 to address this. Please review it and let me know what you think.
Hi @NordineQuadar,
My sincere apologies for the delay. I've pushed #12205 to address this. Please review it and let me know what you think.
Thanks Kareem, and no worries about the delay. I’ve read #12205: decoupling the rate limit from NO_ASN_TIME is the right fix. I’m running our reproduction against the PR head in a few build configurations (NO_ASN_TIME alone, with XTIME_MS, and with USER_TICKS) and will post the results on the PR in the next day or two.
Thanks Kareem again for the patch. I ran the #12022 reproduction against the PR head (7a3028e2) and its merge base (ed8d563a), varying only the client build.
Setup: DTLS 1.3, MTU 256, X25519MLKEM768, wolfSSL's example client and server through the slow-link script from #12022; 9600 bit/s with the 9th server datagram dropped, 120 s limit. The server is always the base default build.
| Client build | Rate limit compiled in | Outcome | 82-byte client datagrams (Finished) / 40-byte server datagrams (ACK) |
|---|---|---|---|
base, NO_ASN_TIME |
no | killed at 120 s | 1699 / 1693 |
head, NO_ASN_TIME |
no | killed at 120 s | 1699 / 1694 |
head, NO_ASN_TIME + XTIME_MS |
yes | ok in 4.6 s | 2 / 2 |
head, NO_ASN_TIME + USER_TICKS (own TimeNowInMilliseconds) |
no | killed at 120 s | 1699 / 1694 |
| head, default | yes | ok in 4.6 s | 2 / 2 |
So the decoupling works: with XTIME_MS the rate limit is active under NO_ASN_TIME and the handshake matches the default build. Two cases remain:
NO_ASN_TIMEwith no tick source still builds without the rate limit, silently. Would you consider an#error(or at least a#warning) whenWOLFSSL_DTLS13is built withoutWOLFSSL_HAVE_MILLI_TIME, unlessWOLFSSL_NO_MILLI_TIMEis set explicitly? The silent part is what made this hard to find.USER_TICKSports that provide their ownTimeNowInMilliseconds()are excluded after the second commit, so the function is never called. Is there an intended way for such a port to opt in?
Each row is a single run; only the client varies, and the RTOS macros in the list were not built. Happy to share the scripts and logs, or to re-run on a new revision.
A follow-up on my second question: I tested one more build at the PR head, NO_ASN_TIME + USER_TICKS + WOLFSSL_HAVE_MILLI_TIME defined by the user, with our own TimeNowInMilliseconds(). The rate limit is compiled in, our function is called, and the same case completes in 4.6 s (2 / 2).
So a USER_TICKS port can opt in by defining WOLFSSL_HAVE_MILLI_TIME itself. If that is the intended route, a line documenting it would help, including that the function's type must match (sword64, or word32 with WOLFSSL_32BIT_MILLI_TIME).
Thanks for the followup!
I've pushed an update which adds some documentation and #errors out with a message if WOLFSSL_DTLS13 is defined without WOLFSSL_HAVE_MILLI_TIME or WOLFSSL_NO_MILLI_TIME. You are correct that the intended route for USER_TICKS users with a custom TimeNowInMilliseconds is to define WOLFSSL_HAVE_MILLI_TIME or WOLFSSL_NO_MILLI_TIME, depending on their implementation.
Thanks Kareem, it's confirmed on 441d620b with the same reproduction: NO_ASN_TIME alone and NO_ASN_TIME + USER_TICKS now stop at the new #error; with XTIME_MS, or with USER_TICKS + WOLFSSL_HAVE_MILLI_TIME, the rate limit is active and the handshake completes in 4.6 s (2 / 2); WOLFSSL_NO_MILLI_TIME builds and reproduces the loop, by explicit choice. This resolves what I reported. Thanks again Kareem for the quick turnaround.