TheThingsNetwork / lorawan-stack

The Things Stack, an Open Source LoRaWAN Network Server
https://www.thethingsindustries.com/stack/
Apache License 2.0
932 stars 301 forks source link

Large device frame counter gaps may trigger device default channels to be re-enabled #6110

Open adriansmares opened 1 year ago

adriansmares commented 1 year ago

Summary

As part of the L2 1.0.4 specification, the backoff procedure of the ADR algorithm mentions that once the default data rate has been reached, and the Network Server has not responded to ADRACKReq, the end device will re-enable all of its default channels, and reset the transmission power index and number of transmissions:

image

Our stack does not recognize that this event occurs, and it will not correct the end device channel mask when it occurs.

Steps to Reproduce

  1. Join an end device on SF10 in US915.
  2. Unplug the gateway.
  3. Allow the end device to send ~96 uplinks.
  4. Re-plug the gateway.

Current Result

The LNS does not correct the end device channel mask, even though the end device has reset it.

Expected Result

The LNS should realize that the end device may have re-enabled all of the default channels, and re-patch the channel mask.

Relevant Logs

No response

URL

No response

Deployment

The Things Stack Enterprise (self-hosted)

The Things Stack Version

v3.24.2

Client Name and Version

No response

Other Information

No response

Proposed Fix

  1. We need to keep the last FCntUp which has been observed without the ADRACKReq bit set. This allows us to compute the theoretical gap in which the end device has not received a downlink that confirms that the connectivity is available.
  2. If the end device is on the default / minimal data rate (note that this is a set, because some regions have two default data rates depending on the join considerations), and the gap is larger than ADR_ACK_DELAY, mark all of the default end device channels as enabled.

Contributing

Code of Conduct

adriansmares commented 1 month ago

I've hit this while moving the test setup to the office. It is possible to hit this with default firmware of the Generic Node.