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

Multicast class B timing issue on ping slot calculation #255

Closed
Achichig opened this issue Aug 2, 2023 · 4 comments
Closed

Multicast class B timing issue on ping slot calculation #255

Achichig opened this issue Aug 2, 2023 · 4 comments

Comments

@Achichig
Copy link

Achichig commented Aug 2, 2023

In chirpstack v4.4.3, there appears to be a problem with estimating the opening of ping slots for multicast class B downlinks.
In the image below, you can see the consumption of my device at the top, with each peak corresponding to the opening of an Rx window.
At the bottom, you can see the downlinks sent by my gateway. The leftmost peak corresponds to the beacon, and the rightmost peak is a multicast class B downlink. We can observe that the downlink does not align with the Rx window opening on the modem side.

image

To verify whether the error originates from my device or the Network Server (NS), I took the liberty to calculate the ping slot offset:

Key: 0x00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Beacon Time: 0x80 BB F3 51
Group Addr: 0xE2 18 84 C7
Rand = aes_128_encrypt(00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, 80 BB F3 51 E2 18 84 C7 00 00 00 00 00 00 00 00 00) = 0xBE 9D D6 90 C9 D7 90 93 C1 59 3D 80 B8 DA 3E 57
PingOffset = (Rand[0] + Rand[1]*256) % PingPeriod = (190 + 157*256) % 128 = 62
First ping slot opening since starts of beacon = PingOffset * SlotLen + BeaconReserved = 3.98s

These calculations appear to confirm that my device is opening its ping slots at the correct timing since the first ping slot opening happens at exactly 3.98s after the beacon start.

I did the same work for unicast class B, and here I have no issues, and the calculations appear to be the same for both the device and the Network Server (NS).

image

@brocaar
Copy link
Contributor

brocaar commented Aug 4, 2023

Could you run the following DB query for me and share the output?

select mc_addr, class_b_ping_slot_period from multicast_group;

@Achichig
Copy link
Author

Achichig commented Aug 4, 2023

Hello Orne,

I get this:

chirpstack=# select mc_addr, class_b_ping_slot_period from multicast_group;  


   mc_addr   | class_b_ping_slot_period 
------------ +--------------------------
 \x084a35df  |                        4

The mc_addr is not the same than in my previous message, because this is part of a testing campaign, where the multicast group is dynamically created during the test execution (and then deleted afterward).

@brocaar
Copy link
Contributor

brocaar commented Aug 7, 2023

I think I have found your issue. I assume you are using the API. There is a difference between the device-profile value and multicast-group periodicity option values. I will align them (with a backwards compatibility option):

https://github.com/chirpstack/chirpstack/blob/master/ui/src/views/multicast-groups/MulticastGroupForm.tsx#L143

@brocaar
Copy link
Contributor

brocaar commented Mar 26, 2024

@Achichig the above commit aligns the Class-B ping-slot config with the device-profile where we configure the k value (0 - 7):

image

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

No branches or pull requests

2 participants