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

Fix CSMA accuracy #23

Merged
merged 2 commits into from
Apr 30, 2024
Merged

Fix CSMA accuracy #23

merged 2 commits into from
Apr 30, 2024

Conversation

SamClercky
Copy link
Contributor

Previously, the CSMA implementation did not perform well under circumstances where an ACK does not arrive. In that case, all other frames would be ignored until the timer for waiting on an ACK would run out, or an ACK would arrive. Before this PR, the timer for waiting on an ACK could take up to 24ms (for a full blown 127 byte frame).

The section in the IEEE specification speaks about waiting for an ACK to arrive in the 'expected time'. When looking at the diagrams in that section, they expect that from when the last frame is transmitted, the transmitting device should wait for the AIFS + time of sending an ACK + SIFS. Both AIFS and SIFS seem to be 1ms and sending an ACK (3 bytes) at 250kbps, seems to translate to 24us. This PR then sets the new waiting time to 2024us.

Additionally, the AIFS should be used on the receiving side to go from receiving mode to transmitting mode. As timers with Rust futures work in an at least this long-way, the time to wait before transmitting the ACK on the receiving side is halved. When testing this on an nRF52840 with Embassy and sniffing the traffic in Wireshark, the ACKs arrived between 1 and 2ms after the previous data frame had been sent.

Lastly, due to how join is implemented, the order of sending an ACK and sending the received frame to the network layer is reversed in order. This has as goal to transmit an ACK with a slightly higher priority over further processing the received frame.

Copy link

codecov bot commented Apr 28, 2024

Codecov Report

Attention: Patch coverage is 94.87179% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 73.99%. Comparing base (c5dcb71) to head (53ade83).

Files Patch % Lines
dot15d4/src/csma/mod.rs 94.87% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
+ Coverage   73.96%   73.99%   +0.02%     
==========================================
  Files          36       36              
  Lines        5436     5442       +6     
==========================================
+ Hits         4021     4027       +6     
  Misses       1415     1415              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thvdveld thvdveld merged commit 07994ec into thvdveld:main Apr 30, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants