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

nanocoap sock: stop retransmissions after empty ACK #20697

Conversation

fabian18
Copy link
Contributor

@fabian18 fabian18 commented May 27, 2024

Contribution description

The nanocoap_sock_request_cb() function does a synchronous CoAP request.
This PR fixes that further retransmissions are done, even though a matching empty ACK was received.
The behavior is mandatory for CoAP and should also be done when no response callback is set, because the ACK is not the actual response.

Testing procedure

Run examples/nanocoap_server and tests/net/nanocoap_cli and increase the timeout for the /separate resource.
Without this fix, the client keeps retransmitting even after the empty ACK.

Test when I set the server separate response delay to 10 seconds.

client get fe80::4d3:11ff:fe35:6a43 5683 /well-known/core
client get fe80::4d3:11ff:fe35:6a43 5683 /well-known/core
nanocli: sending msg ID 1, 22 bytes
nanocli: msg send failed: -6
> client get fe80::4d3:11ff:fe35:6a43 5683 /.well-known/core
client get fe80::4d3:11ff:fe35:6a43 5683 /.well-known/core
nanocli: sending msg ID 1, 23 bytes
nanocli: response Success, code 2.05, 16 bytes
</vfs>,</separat
> client get fe80::4d3:11ff:fe35:6a43 5683 /separate
client get fe80::4d3:11ff:fe35:6a43 5683 /separate
nanocli: sending msg ID 1, 15 bytes
nanocli: response Success, code 2.05, 28 bytes
00000000  54  68  69  73  20  69  73  20  61  20  64  65  6C  61  79  65
00000010  64  20  72  65  73  70  6F  6E  73  65  2E  00

bug: Look at </vfs>,</separat no bug just blockwise transfer

When I disable the ACK on the server side I can see retransmissions in wireshark:

Screenshot from 2024-05-27 11-46-07

But another bug: The serveice unavailable ACK is treated as the response. :(

Issues/PRs references

first split out of #20696

@github-actions github-actions bot added Area: network Area: Networking Area: CoAP Area: Constrained Application Protocol implementations Area: sys Area: System labels May 27, 2024
@fabian18
Copy link
Contributor Author

need to think if the state handling is done correct here.state = STATE_RESPONSE_RCVD; for everything that is received

@fabian18
Copy link
Contributor Author

fabian18 commented May 27, 2024

But another bug: The serveice unavailable ACK is treated as the response.

If the separate response is pending for a different request.

if (event_timeout_is_pending(&event_timeout)) {
puts("_separate_handler(): response already scheduled");
return coap_build_reply(pkt, COAP_CODE_SERVICE_UNAVAILABLE, buf, len, 0);
}

Can I fix it right here in this PR?

@benpicco
Copy link
Contributor

Can I fix it right here in this PR?

Sure!

@github-actions github-actions bot added the Area: examples Area: Example Applications label May 27, 2024
@fabian18 fabian18 added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 27, 2024
@maribu maribu changed the title nanocoap sock: stop retransmissions after empty aACK nanocoap sock: stop retransmissions after empty ACK May 27, 2024
@riot-ci
Copy link

riot-ci commented May 27, 2024

Murdock results

✔️ PASSED

9dfdf2b examples/nanocoap_server: 5.03 only for different requests to /separate

Success Failures Total Runtime
10143 0 10143 12m:36s

Artifacts

@fabian18 fabian18 force-pushed the pr/nanocoap_sock_stop_retransmissions_after_empty_ack branch from b173aec to 9090984 Compare May 27, 2024 15:48
@fabian18 fabian18 force-pushed the pr/nanocoap_sock_stop_retransmissions_after_empty_ack branch from 9090984 to 9dfdf2b Compare May 27, 2024 15:59
@fabian18
Copy link
Contributor Author

Given that the request contains a no response option to suppresses certain response classes, this must be communicated to the function somehow. Even if there is no callback, maybe the program must wait for a response.

I think before the assumption was, if the no-response option is included, the caller does not provide a callback.

@fabian18
Copy link
Contributor Author

fabian18 commented May 27, 2024

When you send a request in which you suppress 2.xx replies you still have to wait to maybe get a 4.xx or 5.xx reply.
No response could be handled like: When the request with a no-response option times out, you expect it timed out because the response got suppressed. But this should be known to the caller of nanocoap_sock_request_cb.

Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you suggest we should differentiate between

  • ACK received but no separate response (because it was suppressed or lost)
  • no ACK received

But I think this is a separate issue.

@benpicco benpicco added this pull request to the merge queue May 27, 2024
@fabian18
Copy link
Contributor Author

Thanks for approval.

Luckily we only add a no-response option for NON without buffer to write the response to. This case is still catched.

- ACK received but no separate response (because it was suppressed or lost)
- no ACK received

That I did not event think of. But yes, if there is a timeout it could be due to no ACK or no response, which means different things.

But I think this is a separate issue.

Yes

Merged via the queue into RIOT-OS:master with commit 27b06aa May 27, 2024
26 checks passed
@mguetschow mguetschow added this to the Release 2024.07 milestone Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: CoAP Area: Constrained Application Protocol implementations Area: examples Area: Example Applications Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants