Topics

ieee802154: csma-ca: random backoff factor looks wrong

Franco Saworski <franco.saworski@...>
 

The calculation for the random backoff factor looks wrong [1]:
u8_t bo_n = sys_rand32_get() & (2 << (be + 1));

This generates either a power-of-two number or zero for bo_n, because it only overlaps a single bit with the random number. This is very rare and results in the backoff time being zero most of the time, if I'm not completely mistaken.

The standard defines the value to be random between zero and 2^be-1. The implementation should be:
u8_t bo_n = sys_rand32_get() & ((1 << be) - 1);

Has anyone had experience with this? I noticed this going over the implementation.

Kind regards,
Franco

--

Embedded Engineer

blik GmbH
transparent real-time data

Leonrodstraße 68 | 80636 München
HRB: 233881 | Amtsgericht München
Geschäftsführer: Bastian Burger, Philip Eller, Victoria Hauzeneder

Information in this email - including any attachments - may be privileged, confidential and is intended exclusively for the addressee(s). If you are not the intended recipient, please notify the sender and delete all copies from your system. You should not reproduce, distribute, store, retransmit, use or disclose its contents to anyone.