contiki-os / contiki

The official git repository for Contiki, the open source OS for the Internet of Things
http://www.contiki-os.org/
Other
3.69k stars 2.58k forks source link

802.15.4 CSMA: incrementing backoff exponent in case of NOACK #2142

Open gmichelo opened 7 years ago

gmichelo commented 7 years ago

I had been working with broadcast at layer 2 and I've got a problem with L2 retransmission in case of no received ACK.

The scenario is described as follows. When two nodes, not in the hearing area of the other, receive a broadcast message simultaneously, they try together to reply back using L2 unicast towards the originating node, resulting in a non-detected collision. However, they don't receive any ACK from the destination node, since it wasn't able to read the message correctly. What is strange is that both nodes try to retransmit the same message several times, failing each one because they access the wireless channel exactly at the same time.

Taking a look at the file core/net/mac/csma.c I've found out that in case of not receiving an ACK message, the CSMA layer doesn't increment the backoff exponent, in fact it keeps that value ad the minimum one: CSMA_MIN_BE. Which its default value is 0, leading to no random access at all.

Here is the code I'm referring to : n->collisions = CSMA_MIN_BE in function noack(). Shouldn't it increment the collisions counter also in this situation?

I hope that the problem is clear.

niziak commented 6 years ago

I agree. In mentioned scenario burst of 7 frames is TXed (no chance to get ACK) and radio channel is occupied without sense (because another node is performing the same). Solution for this is to use CSMA_MIN_BE: 3 as pointed in #2255 With CSMA_MIN_BE=3 every TX will be always delayed by random time between 0 and 2^BE-1 backoff periods.