Question

Iam using telosB motes for implementation. I have come across one of the way for acknowledging the packets,

task void send() {
    call PacketAcknowledgements.requestAck(&myMsg);
    if(call AMSend.send(1, &myMsg, 0) != SUCCESS) {
      post send();
    }
  }
 event void AMSend.sendDone(message_t *msg, error_t error) {
    if(call PacketAcknowledgements.wasAcked(msg))
      // do something if packet was acked
    else
      // do something else if packet was not acked (possibly resend)
  }

Actually my doubt is, the receiving mote should have to acknowledge the packet or it should have PacketAcknowledgements interface in its application in order to send ACKs. How this type of acknowledgement works?

And I have checked with my own type of acknowledgement, it works like after receiving the packet the mote acknowledge the packets, if source mote does not receive positive ack in certain time frame then re transmit the packet .

So which is better way of doing?

Please guide & thanks,

Était-ce utile?

La solution

In TinyOS acknowledgements are implemented on the lowest communication abstraction level - active message[1]. This means that any component that operates with active messages has a built in support for synchronous acknowledgements.

Actually my doubt is, the receiving mote should have to acknowledge the packet or it should have PacketAcknowledgements interface in its application in order to send ACKs.

If you used PacketAcknowledgements.requestAck(&myMsg) to request acknowledgement, then you don't have to write extra code in Receive.receive event handler to process acks as this is done for you by underlying communication layer. All you need to do is wire PacketAcknowledgements interface that your component/module uses to one of the providers (AMSenderC or ActiveMessageC).

How this type of acknowledgement works?

The high level idea is following - calling PacketAcknowledgements.requestAck(&myMsg) sets a flag in a packet header and tells sender component not to signal sendDone event until ack was received (or timed out). When receiver component handles the packet on the other end it reads the flag and sends and ack if requested.

Having said all that, description of your way of acknowledging packets seems very similar to what PacketAcknowledgements offers, so personally I would avoid writing extra code for handling acknowledgements myself and stick with the tools provided.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top