cooja
cooja copied to clipboard
Wrongly calcutated packet size in CoojaRadio
Hi all,
Recently, I have been experiencing a weird situation when a Cooja mote sends a packet to a z1 one. Upon reception, the z1 mote was always measuring a RSSI of -100 dBm, even if the motes were close (using the UDGM radio medium).
I found out that z1 mote defined in apps/mspsim/src/org/contikios/cooja/mspmote/Z1Mote.java
uses the Msp802154Radio
radio type, which simulates the reception of a packet by delivering it byte by byte in the method setReceivedPacket
.
However, before sending the bytes to the radio object, the packet received from a Cooja mote is converted using the class CC2420RadioPacketConverter
, which adds 6 additional bytes of header (preamble + synch + length).
Now, if we take a look at the code for a new transmission in a java/org/contikios/cooja/contikimote/interfaces/CoojaRadio.java
, we can see that 2 additional footer bytes (lines 373 & 374
) are not taken into account in the size.
Hence, the variable size
in CoojaRadio does not count 8 bytes received by the simulated mote. Since size
is used to determine the time needed for a Cooja mote to sleep before advertising the end of a transmission, the transmission is announced as finished earlier.
When it happens, the RSSI is resetted to -100 dBm by the UDGM.updateSignalStrengths
method, while the z1 mote's radio is still receiving 8 bytes, which is sufficient enough to have a falsy computed value by Msp802154Radio.setCurrentSignalStrength
.