Enabling ACKs in TinyOS 2.x


I’ve seen a lot of questions about how to enable ACKs in TinyOS and not too many responses. Unlike a lot of TinyOS problems I’ve had, this one isn’t too bad. Some sample code for enabling ACKs is available in $TOSROOT/apps/tests/cc2420/TestAcks. In your configuration .nc file, just wire the PacketAcknowledgements interface:

implementation {
...
MainC.PacketAcknowledgements -> ActiveMessageC;
}

Then, in your implementation file:

module TestAcksP {
uses {
interface PacketAcknowledgements;
...

Then, just before you call AMSend.send() for a message_t testMsg:

call PacketAcknowledgements.requestAck(&testMsg);

When a packet arrives with an ACK request, the ACK will be sent automatically. In the sender’s AMSend.sendDone(), you will want to make sure the packet was ACKed to determine if a retransmission is required:

if(!call PacketAcknowledgements.wasAcked(&testMsg))
retransmit();

And that’s pretty much it.

, , , ,

  1. #1 by Vikram on April 10, 2009 - 1:41 am

    Hi,
    Could you please tell the procedure to enable ACK in TinyOS1.x?

  2. #2 by Matt on April 10, 2009 - 1:22 pm

    I really don’t know how to enable ACKs in TinyOS 1.x — I never use it.

(will not be published)