1

Again I came across a doubt. I inserted in my implementation the use of ACK.

In the function:

AMSend.sendDone (message_t * bufPtr, error_t error) {
    if (call PacketAcknowledgements.wasAcked (bufPtr)) {
         dbg ("test", "SEND_ACK \ n");
    }
}

And it's apparently working correctly, depending on the output log.

Already in function:

AMControl.startDone (error_t err) {
    radio = TRUE;
    dbg ("test", "SLOT_ACTIVE \ n");
    if (err == SUCCESS) {
        if ((call Clock.get ()> (ultpkdados + 5000)) && (TOS_NODE_ID! = 0)) {
            test_msg_t * rcm = (test_msg_t *) call Packet.getPayload (& pkt, sizeof (test_msg_t));
            rcm-> type = 1;
            rcm-> nodeid = TOS_NODE_ID;
            rcm-> proxsalto = syncwith;
            call PacketAcknowledgements.requestAck (& pkt);
            if (call AMSend.send (syncwith, & pkt, sizeof (test_msg_t)) == SUCCESS) {
                Dbg ("test", "SEND_PKT_DATA \ n"));
                locked = TRUE;
                ultpkdados call Clock.get = ();
            }
        }
    }
}

This function startDone is sending this packet of "data" normally, and I made a call PacketAcknowledgements.requestAck to request the ACK.

My question is whether at this point, if the ACK is not confirmed, the original message is retransmitted. If this is not happening, could you suggest me the appropriate changes for this to happen?

Chad Nouis
  • 6,861
  • 1
  • 27
  • 28
ARSaraiva
  • 21
  • 2

1 Answers1

0

My question is whether at this point, if the ACK is not confirmed, the original message is retransmitted.

No, the message will not be retransmitted.

If this is not happening, could you suggest me the appropriate changes for this to happen?

What you are doing is just requesting acknowledgments and not enabling retransmissions. Retransmissions are sent by the Packet link layer which is used as specified HERE.

In order to enable re-transmissions you need to:

1) add the PACKETLINK preprocessor variable to your makefile. This can be done by simply adding "-DPACKETLINK" to PFlags in your makefile i.e

PFLAGS = -DPACKETLINK

2) Specify the maximum number of retries that your device can transmit and the delay between each retry. This is done by appropriately calling the setRetries and setRetryDelay functions in the Packet link interface (These are found on a instantiation of a PacketLink interface so you will need a uses interface PacketLink statement in the wiring section of your module). You need to set the number of retries before calling AMSend.send. i.e you would need to have something that goes along the lines of:

#if defined(PACKET_LINK)
          maxRetries = 100;  //max retries
          myDelay = 10;    //delay between retries
          call PacketLink.setRetries(&pkt, maxRetries); //set retries
          call PacketLink.setRetryDelay(&pkt, myDelay); //set delay
#endif  

3. In your configuration file you need to provide a Packetlink implementation instantiated and link it to your module. For instance if you are using a node with a CC2420 transceiver (such as the TelosB node) you would have the following in the implementation section of your configuration file.

 components CC2420ActiveMessageC, myModuleP as App; 
 App.PacketLink -> CC2420ActiveMessageC.PacketLink;

What the above will do is compile the Packet Link Layer along with the rest the the Communication stack. You can look the PacketLinkP.nc file to see how the values you are passing to the PacketLink interface are being used.

If you are using the PacketLink interface and PacketAcknowledgements.wasAcked returns FALSE in your AMSend.sendDone method then it means transmission has still failed despite all the retries. You can at this point try a fresh retransmit again (which the device will again try to retransmit up to a total of maxRetries times).

KillaKem
  • 995
  • 1
  • 13
  • 29