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

added functionality for LoRa Alliance TR-13 Enabling CSMA for LoRaWAN #859

Merged
merged 4 commits into from
Oct 29, 2023
Merged

added functionality for LoRa Alliance TR-13 Enabling CSMA for LoRaWAN #859

merged 4 commits into from
Oct 29, 2023

Conversation

amalinda
Copy link
Contributor

Thank you for making RadioLib available!

This pull request enables CSMA functionality for LoRaWAN in accordance with TR-13 [https://resources.lora-alliance.org/home/tr013-1-0-0-csma].

Conventionally, LoRaWAN utilizes the ALOHA mode for frame transmission. This can result in collisions when multiple nodes are in close proximity. E.g., when several nodes choose the same SF/CH combination, reception becomes suboptimal. To address this, the ultra-low-power CAD module available in all LoRa radios can be utilized for sensing. The power consumption for performing a CAD is in the range of nAh, which is very minimal. TR-13 emphasizes a CSMA protocol for LoRa which considers many other aspects. This pull request makes an effort to incorporate this protocol to Radiolib, aiming for enhanced spectral efficiency and energy conservation by reducing collisions.

Additionally, I've explored areas where the CAD performance can be optimized for the SX126X radio.

I welcome any feedback.

Disclosure: I am one of the authors of TR-13.

Thank you.

Copy link
Owner

@jgromes jgromes left a comment

Choose a reason for hiding this comment

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

This is very interesting - thank you very much! I left some comments in a review.

I'd also like to hear the thoughts of @StevenCellist and @HeadBoffin, as the LoRaWAN experts. One thing that's I'm not sure about is whether this should be enabled by default or not. I suspect that most users will be unlikely to change the default configuration in this regard unless they encounter issues.

src/modules/SX126x/SX126x.cpp Outdated Show resolved Hide resolved
src/protocols/LoRaWAN/LoRaWAN.cpp Outdated Show resolved Hide resolved
src/protocols/LoRaWAN/LoRaWAN.cpp Show resolved Hide resolved
src/protocols/LoRaWAN/LoRaWAN.h Outdated Show resolved Hide resolved
@amalinda
Copy link
Contributor Author

I'm happy to contribute and thanks for your suggestions!

Having this enabled by default provides efficient spectrum utilization and reliability to each frame at very minimal energy cost. It offers more advantages such as better overall network throughputs, PRRs and improved reliability for weak nodes due to fewer occurrences of strong nodes overriding low-snr frames. However, I understand that there could be other complications. I'll disable run-by-default in my next commit to this pull request. Perhaps after more testing, we can enable run-by-default.

As per CAD configuration, it's simple. We have only two options for the 125KHz CAD. We can either perform the most accurate CAD or the slightly less accurate one. In my experience and from what is stated in the Semtech AN1200.48, there isn't much difference. However, in either case, there are six different cadDetPeak values per SF. It would be challenging to set all to just one. CAD utilizing 2 symbols provides 90th percentile detection- also recommended by the TR-19. The only two settings for CADs under 125KHz in AN1200.48 are represented in Table-1 and Table-26. The most accurate CAD settings are presented in Table-1; however, I suggest not using them due to the larger trade-offs associated with higher sensing time and energy cost.

Yes, the new naming suggestions are better. I will incorporate them into my next pull request. I've also noted the suggestions regarding LoraWANNode::setCSMA(uint8_t backoffMax, uint8_t difsSlots) and the other minor changes

Thanks!

P.s., on an unrelated note to to Radiolib: Currently, TR-13 is integrated to LoRa Basic Modem on https://github.com/Lora-net/SWL2001 under branches feature/fuota or feature/relay. It can be enabled with LBM_CSMA ?= yes.

@amalinda
Copy link
Contributor Author

@jgromes , addressed the changes you requested.

@amalinda amalinda requested a review from jgromes October 29, 2023 02:02
@StevenCellist
Copy link
Collaborator

In response to @jgromes request I would like to add the following:

CSMA is definitely a nice-to-have feature, and I'd say we include it in the repo. But for now I'd strongly suggest keeping it off by default, as there's still work to do to get the must-haves running before adding nice-to-haves. Once the actual specification is (almost) complete and well tested, we can discuss if it's a good idea to enable by default.

And as always.. you can try and be the person to always wait for the traffic light to turn green before crossing, but that doesn't mean that the next person is actually just as nice. If they start transmitting after your transmission has started they still collide.

@amalinda
Copy link
Contributor Author

@StevenCellist Appreciate your input. Thanks! I've made the changes to keep CSMA off by default. I've also tested this pull request against the SX1262 radio. Channel hopping and collision detection works as expected.

@jgromes jgromes merged commit aca1d78 into jgromes:master Oct 29, 2023
29 checks passed
@jgromes
Copy link
Owner

jgromes commented Oct 29, 2023

@jgamage91 everything is resolved now. Merged, thank you very much for the contribution!

@amalinda
Copy link
Contributor Author

@jgamage91 everything is resolved now. Merged, thank you very much for the contribution!

Thank you for merging it!

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.

3 participants