Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTLS flights re-sending delay is incorrect #7301

Closed
Shaienn opened this issue May 25, 2023 · 1 comment
Closed

DTLS flights re-sending delay is incorrect #7301

Shaienn opened this issue May 25, 2023 · 1 comment
Assignees
Labels
bug Issue is reported as a bug team:PS Assigned to OTP team PS
Milestone

Comments

@Shaienn
Copy link
Contributor

Shaienn commented May 25, 2023

Describe the bug
DTLS flights re-sending delay is incorrect. DTLS doubles flight retransmission timer value each time when DTLS state machine entering next state despite there is no retransmission occurred.

To Reproduce
Some flight (except the first one) content should be lost after sending (UDP packet lost). Then it need to wait until the lost flight content will be re-sent and measure the time between first and second sending. Measured time will be greater than 1 second. On flight4 it can be 8 seconds.

Expected behavior
According to RFC I expect that timer value will not be increased without retransmission.

https://datatracker.ietf.org/doc/html/rfc9147#section-5.8.1-7.1

The retransmit timer expires: the implementation transitions to the SENDING state, where it retransmits the flight, adjusts and re-arms the retransmit timer

https://datatracker.ietf.org/doc/html/rfc9147#section-5.8.2-2

...implementations SHOULD use an initial timer value of 1000 ms and double the value at each retransmission...

https://datatracker.ietf.org/doc/html/rfc9147#section-5.8.2-5

Implementations SHOULD retain the current timer value until a message is transmitted and acknowledged without having to be retransmitted

Affected versions
Erlang/OTP 26.

Additional context

There is some code which changes DTLS statem states and shows that retransmit value is increased after each state transition.

-module(test).
-include_lib("ssl/src/ssl_connection.hrl").
-compile(export_all).

close(_) -> ok.

start() ->
 application:start(crypto),
 application:start(asn1),
 application:start(public_key),
 application:start(ssl),
 Role = client,
 SslOpts0 = [{protocol, dtls}, {cb_info, {?MODULE,udp,udp_closed,udp_error,udp_passive}},
   {handshake, hello}, {verify_peer, none}],
 {ok, SslConfig} = ssl:handle_options(SslOpts0, Role, dummy),
 #config{ssl = SslOpts, transport_info = CbInfo} = SslConfig,

 DtlsStatem = proc_lib:spawn_link(dtls_connection, init, [[Role, host, port, {{peer, port}, #{role => Role}}, {SslOpts, #socket_options{}, []}, user, CbInfo]]),
 {initial_hello, #state{protocol_specific = #{flight_state := {retransmit, 1000}}} = State1} = sys:get_state(DtlsStatem),
 exit(DtlsStatem, normal),

 {keep_state, State2, _} = dtls_connection:hello(enter, dummy, State1),
 #state{protocol_specific = #{flight_state := {retransmit, 2000}}} = State2,

 {keep_state, State3, _} = dtls_connection:hello(enter, dummy, State2),
 #state{protocol_specific = #{flight_state := {retransmit, 4000}}} = State3,

 {keep_state, State4, _} = dtls_connection:certify(enter, dummy, State3),
 #state{protocol_specific = #{flight_state := {retransmit, 8000}}} = State4,

 {keep_state, State5, _} = dtls_connection:cipher(enter, dummy, State4),
 #state{protocol_specific = #{flight_state := {retransmit, 16000}}} = State5,

 ok.

I have created pull request for the issue: #7300

@Shaienn Shaienn added the bug Issue is reported as a bug label May 25, 2023
@IngelaAndin IngelaAndin added the team:PS Assigned to OTP team PS label May 26, 2023
@IngelaAndin IngelaAndin added this to the OTP-26.0.1 milestone Jun 7, 2023
@IngelaAndin IngelaAndin self-assigned this Jun 7, 2023
@IngelaAndin
Copy link
Contributor

OTP-26.0.1 has been released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:PS Assigned to OTP team PS
Projects
None yet
Development

No branches or pull requests

2 participants