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: re-try if wrong block was received #20952

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Nov 5, 2024

Contribution description

Our go-coap server sometimes responds with block 0 to a block2 request. This breaks SUIT updates.

An easy fix is to just try again when an unexpected block was received, we then get the expected block.

Testing procedure

master

2024-11-05 17:26:32,695 # nanocoap: fetching block 29
2024-11-05 17:26:32,696 # nanocoap: send 20 bytes (4 tries left)
2024-11-05 17:26:32,712 # nanocoap: waiting for response (timeout: 1283696 µs)
2024-11-05 17:26:32,776 # nanocoap: response code=203
2024-11-05 17:26:32,777 # nanocoap got block 29 (offset 29696)
2024-11-05 17:26:32,777 # nanocoap: fetching block 30
2024-11-05 17:26:32,792 # nanocoap: send 20 bytes (4 tries left)
2024-11-05 17:26:32,795 # nanocoap: waiting for response (timeout: 1466309 µs)
2024-11-05 17:26:34,263 # nanocoap: timeout waiting for response
2024-11-05 17:26:34,264 # nanocoap: send 20 bytes (3 tries left)
2024-11-05 17:26:34,279 # nanocoap: waiting for response (timeout: 2937618 µs)
2024-11-05 17:26:34,343 # nanocoap: response code=203
2024-11-05 17:26:34,343 # nanocoap got block 30 (ffset 30720)
2024-11-05 17:26:34,349 # nanocoap: fetching block 31
2024-11-05 17:26:34,359 # nanocoap: send 20 bytes (4 tries left)
2024-11-05 17:26:34,360 # nanocoap: waiting for response (timeout: 1441263 µs)
2024-11-05 17:26:34,423 # nanocoap: response code=203
2024-11-05 17:26:34,424 # nanocoap got block 0 (offset 0)
2024-11-05 17:26:34,424 # Unexpected offset: 4 - expected: 31744
2024-11-05 17:26:34,439 # nanocoap: error fetching block 31: -50

this PR

2024-11-05 17:48:35,054 # nanocoap: fetching block 19
2024-11-05 17:48:35,054 # nanocoap: send 20 bytes (4 tries left)
2024-11-05 17:48:35,070 # nanocoap: waiting for response (timeout: 1168273 µs)
2024-11-05 17:48:35,135 # nanocoap: response code=203
2024-11-05 17:48:35,137 # nanocoap: got block 19 (offset 19456)
2024-11-05 17:48:35,140 # nanocoap: fetching block 20
2024-11-05 17:48:35,150 # nanocoap: send 20 bytes (4 tries left)
2024-11-05 17:48:35,153 # nanocoap: waiting for response (timeout: 1198003 µs)
2024-11-05 17:48:36,351 # nanocoap: timeout waiting for response
2024-11-05 17:48:36,353 # nanocoap: send 20 bytes (3 tries left)
2024-11-05 17:48:36,369 # nanocoap: waiting for response (timeout: 2402006 µs)
2024-11-05 17:48:36,432 # nanocoap: response code=203
2024-11-05 17:48:36,434 # nanocoap: got block 20 (offset 20480)
2024-11-05 17:48:36,436 # nanocoap: fetching block 21
2024-11-05 17:48:36,446 # nanocoap: send 20 bytes (4 tries left)
2024-11-05 17:48:36,449 # nanocoap: waiting for response (timeout: 1430197 µs)
2024-11-05 17:48:36,511 # nanocoap: response code=203
2024-11-05 17:48:36,513 # nanocoap: got block 0 (offset 0)
2024-11-05 17:48:36,514 # nanocoap: fetching block 21
2024-11-05 17:48:36,526 # nanocoap: send 20 bytes (4 tries left)
2024-11-05 17:48:36,527 # nanocoap: waiting for response (timeout: 1429462 µs)
2024-11-05 17:48:37,967 # nanocoap: timeout waiting for response
2024-11-05 17:48:37,968 # nanocoap: send 20 bytes (3 tries left)
2024-11-05 17:48:37,982 # nanocoap: waiting for response (timeout: 2862924 µs)
2024-11-05 17:48:38,031 # nanocoap: response code=203
2024-11-05 17:48:38,047 # nanocoap: got block 21 (offset 21504)
2024-11-05 17:48:38,049 # nanocoap: fetching block 22
2024-11-05 17:48:38,057 # nanocoap: send 20 bytes (4 tries left)
2024-11-05 17:48:38,066 # nanocoap: waiting for response (timeout: 1365115 µs)
2024-11-05 17:48:38,128 # nanocoap: response code=203
2024-11-05 17:48:38,137 # nanocoap: got block 22 (offset 22528)
2024-11-05 17:48:38,139 # nanocoap: fetching block 23
2024-11-05 17:48:38,142 # nanocoap: send 20 bytes (4 tries left)
2024-11-05 17:48:38,148 # nanocoap: waiting for response (timeout: 1033951 µs)
2024-11-05 17:48:38,206 # nanocoap: response code=203
2024-11-05 17:48:38,209 # nanocoap: got block 23 (offset 23552)

Issues/PRs references

@github-actions github-actions bot added Area: network Area: Networking Area: CoAP Area: Constrained Application Protocol implementations Area: sys Area: System labels Nov 5, 2024
@benpicco benpicco force-pushed the nanocoap-block_robust branch from f8f3e21 to 08c62b4 Compare November 5, 2024 16:58
@benpicco benpicco requested a review from maribu November 5, 2024 16:59
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 5, 2024
@riot-ci
Copy link

riot-ci commented Nov 5, 2024

Murdock results

✔️ PASSED

9b25c03 nanocoap/sock: re-try if wrong block was received

Success Failures Total Runtime
10214 0 10215 17m:31s

Artifacts

@benpicco benpicco force-pushed the nanocoap-block_robust branch from 08c62b4 to 9b25c03 Compare November 5, 2024 17:06
@maribu maribu enabled auto-merge November 5, 2024 17:08
@maribu
Copy link
Member

maribu commented Nov 5, 2024

Our go-coap server sometimes responds with block 0 to a block2 request.

That's not the best motivation.

But networks are not always order preserving and consistent in their latency. I think we are supposed to be prepared that an no longer expected block can arrive out of order even with a correct CoAP server, so this makes sense even for non go-coap users.

@maribu maribu added this pull request to the merge queue Nov 5, 2024
@benpicco
Copy link
Contributor Author

benpicco commented Nov 5, 2024

networks are not always order preserving and consistent in their latency. I think we are supposed to be prepared that an no longer expected block can arrive out of order

Usually that would be caught by _id_or_token_missmatch() since we use a new ID for each block that we request.
Here we get a response with the right ID but the wrong block.

@maribu
Copy link
Member

maribu commented Nov 5, 2024

Ah, indeed, we do implement duplicate detection on client side.

Merged via the queue into RIOT-OS:master with commit d10ab41 Nov 5, 2024
26 checks passed
@benpicco benpicco deleted the nanocoap-block_robust branch November 6, 2024 10:41
@MrKevinWeiss MrKevinWeiss added this to the Release 2025.01 milestone Jan 20, 2025
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: 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants