TheThingsNetwork / lorawan-stack

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

Relay Forwarding Limitation sets unlimited values instead of default values #7333

Open StevenCellist opened 2 weeks ago

StevenCellist commented 2 weeks ago

Summary

Upon configuring the Forwarding Limitations through the CLI, the NS sends ConfigureFwdLimitReq to the relay. The contents of this MAC command reveal that TTS by default sets the 'unlimited' Reload Rate instead of the specified default values in TS011-1.0.0 section 8.8

Steps to Reproduce

  1. Register a 1.0.4 device
  2. Enable this device to act as a relay: ttn-lw-cli relays create <app-id> <device-id> --mode.serving
  3. Configure one of the Forwarding Limitation rules: ttn-lw-cli relays update <app-id> <device-id> --mode.serving.limits.join-requests.reload-rate 60
  4. Send an uplink from the relay
  5. Observe the MAC output of ConfigureFwdLimitReq

Current Result

The payload of ConfigureFwdLimitReq looks like this:

17:32:25.621 > [MAC] 45
17:32:25.622 > [Pay] ff ff 9f 07 00

The translation of this payload is as follows: ResetLimitCounter: 0 JoinReq bucket: (Rate: 60, Size: 60), Notify bucket: (Rate: 127, Size: 127), GlobalUplink bucket: (Rate: 127, Size: 127), Overall bucket: (Rate: 127, Size: 127),

Expected Result

The NS should set all buckets for which no ReloadRate is configured to the default value as specified in TS011-1.0.0, which in the same format as in 'current result' should look like this: JoinReq bucket: (Rate: 4, Size: 8), Notify bucket: (Rate: 4, Size: 8), GlobalUplink bucket: (Rate: 8, Size: 16), Overall bucket: (Rate: 8, Size: 16),

Relevant Logs

No response

URL

No response

Deployment

The Things Stack Community Edition

The Things Stack Version

3.32.1

Client Name and Version

The Things Network Command-line Interface: ttn-lw-cli
Version:             3.31.1
Build date:          2024-08-01T15:00:26Z
Git commit:          e351ea62e
Go version:          go1.21.12
OS/Arch:             windows/amd64

Other Information

No response

Proposed Fix

Set the default values as specified in TS011-1.0.0.

Contributing

Validation

Code of Conduct

StevenCellist commented 2 weeks ago

As an additional comment, the ResetLimitCounter should not be set to 0 by default. The meaning of 0 is that the token counters are set to 0, effectively muting the relay until the next bucket reload occurs. IMO, this is not a good default value, I would propose setting this to 1 (Set token counter to Reload Rate) or 3 (Do not change token counter).

StevenCellist commented 2 weeks ago

Upon further investigation, the 'unlimited' values are not even user-configurable. The CLI does not allow setting the ReloadRate to 127 for all Relay buckets nor to 63 for the EndDevice buckets, which are the 'unlimited' values for these buckets. According to 10.4 and 10.7 however, these appear to be accepted values.