anroOfCode / linux-cc2520-driver

A kernel module that will (one day) power the CC2520 802.15.4 radio in Linux.
19 stars 11 forks source link

Weird Behavior with No Ack Requested #3

Closed bradjc closed 11 years ago

bradjc commented 11 years ago

When I change the packet of the write test to:

char test_msg[] = {0x0D, 0x41, 0x88, (char) i, 0x22, 0x00, 0x01, 0x00, 0x01, 0x00, 0x72, (char) i};

(no longer requesting an ack, as is the default for ActiveMessage apps in TinyOS like RadioCountToLeds), the driver seems to retransmit the packet a bunch of times.

https://www.dropbox.com/s/0zua0my5ycliro2/write_no_ack.logicdata

I'm not sure why it's doing that.

anroOfCode commented 11 years ago

That actually is the low-power listening implementation. It will send for a value calculated using the algorithm in the LPL implementation in rfxlink TinyOS radio stack, and the parameters defined in cc2520.h. When not requesting an ACK it doesn't know to prematurely terminate, so it will transmit for the entire LPL interval, broadcasting ensuring all LPL duty-cycled motes will receive it.

Here's the parameters that control LPL in cc2520.h:

#define CC2520_DEF_LPL_WAKEUP_INTERVAL 512000
#define CC2520_DEF_LPL_LISTEN_WINDOW 5120

To be done: ability to disable/enable this. right now it's compile-time.

bradjc commented 11 years ago

Ah that makes sense. But yeah it would be cool if LPL was disabled at the start and only enabled if the LPL tinyos was compiled in. Actually, that probably won't work, but instead the dummylpl should be able to disable lpl at boot.

anroOfCode commented 11 years ago

FYI I added a bunch of (untested) ioctls this morning that allow you to turn these things on and off.

Also take a look at cc2520.h:

// Defaults for Radio Operation
#define CC2520_DEF_CHANNEL 26
#define CC2520_DEF_RFPOWER 0x32 // 0 dBm
#define CC2520_DEF_PAN 0x22
#define CC2520_DEF_SHORT_ADDR 0x01
#define CC2520_DEF_EXT_ADDR 0x01

// All these timing parameters are in microseconds.
#define CC2520_DEF_ACK_TIMEOUT 2500 
#define CC2520_DEF_MIN_BACKOFF 320
#define CC2520_DEF_INIT_BACKOFF 4960
#define CC2520_DEF_CONG_BACKOFF 2240
#define CC2520_DEF_CSMA_ENABLED true

// We go for around a 1% duty cycle of the radio
// for LPL stuff. 
#define CC2520_DEF_LPL_WAKEUP_INTERVAL 512000
#define CC2520_DEF_LPL_LISTEN_WINDOW 5120
#define CC2520_DEF_LPL_ENABLED true

You can adjust the default values for all the parameters now, including whether LPL and CSMA are enabled, at compile time.

For the record I would recommend leaving CSMA enabled, unless you're trying to push really high data rates (>200 pkts/s). It does a lot more good than harm in all other cases. Disable LPL if you feel it's unnecessary, but keep in mind you'll only see it ever kick in when your motes are LPL enabled, or when you're sending to a broadcast address.