dtls
dtls copied to clipboard
Handshaker doesn't handle "Read retransmit" event
Your environment.
- Version: v2.1.5
- Other Information - stacktraces, related issues, suggestions how to fix, links for us to have context
What did you do?
- Run server:
PION_LOG_TRACE=all go run ./examples/listen/psk/main.gofrom https://github.com/mniestroj/pion-dtls/tree/read-retransmit-reproduction - Run client:
PION_LOG_TRACE=all go run ./examples/dial/psk/main.gofrom https://github.com/pion/dtls/tree/v2.1.5
There is no valid handling of "Read retransmit" messages. Some additional logs here:
client.log
server.log
What did you expect?
According to "DTLS Timeout and Retransmission State Machine" in https://datatracker.ietf.org/doc/html/rfc6347#section-4.2.4 whenever a message is read that is a retransmit, it should make state machine to switch from "WAITING" to "SENDING" phase. This does not happen. In other words, "Read retransmit" from the following diagram is ignored:
+-----------+
| PREPARING |
+---> | | <--------------------+
| | | |
| +-----------+ |
| | |
| | Buffer next flight |
| | |
| \|/ |
| +-----------+ |
| | | |
| | SENDING |<------------------+ |
| | | | | Send
| +-----------+ | | HelloRequest
Receive | | | |
next | | Send flight | | or
flight | +--------+ | |
| | | Set retransmit timer | | Receive
| | \|/ | | HelloRequest
| | +-----------+ | | Send
| | | | | | ClientHello
+--)--| WAITING |-------------------+ |
| | | | Timer expires | |
| | +-----------+ | |
| | | | |
| | | | |
| | +------------------------+ |
| | Read retransmit |
Receive | | |
last | | |
flight | | |
| | |
\|/\|/ |
|
+-----------+ |
| | |
| FINISHED | -------------------------------+
| |
+-----------+
| /|\
| |
| |
+---+
Read retransmit
Retransmit last flight
Figure 3. DTLS Timeout and Retransmission State Machine
What happened?
Handshaker's state machine only relies on "Timer expires", which is suboptimal for handling lossy communication with low-power and/or low-bandwidth nodes.
I can pick this one up! Thanks for the detailed report @mniestroj!