[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/collection
CollectionDebugMsg.h, 1.1.2.9, 1.1.2.10 CollectionPacket.nc,
1.1.2.3, 1.1.2.4 ForwardingEngineP.nc, 1.1.2.31,
1.1.2.32 Queue.nc, 1.1.2.2, 1.1.2.3 QueueC.nc, 1.1.2.5, 1.1.2.6
Rodrigo Fonseca
rfonseca76 at users.sourceforge.net
Thu Jun 22 06:43:31 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21336
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
CollectionDebugMsg.h CollectionPacket.nc ForwardingEngineP.nc
Queue.nc QueueC.nc
Log Message:
Index: CollectionDebugMsg.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/CollectionDebugMsg.h,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -C2 -d -r1.1.2.9 -r1.1.2.10
*** CollectionDebugMsg.h 21 Jun 2006 02:16:53 -0000 1.1.2.9
--- CollectionDebugMsg.h 22 Jun 2006 13:43:28 -0000 1.1.2.10
***************
*** 23,26 ****
--- 23,28 ----
NET_C_FE_SENDDONE_FAIL_ACK_SEND = 0x26,
NET_C_FE_SENDDONE_FAIL_ACK_FWD = 0x27,
+ NET_C_FE_DUPLICATE_CACHE = 0x28, //dropped duplicate packet seen in cache
+ NET_C_FE_DUPLICATE_QUEUE = 0x29, //dropped duplicate packet seen in queue
Index: CollectionPacket.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/CollectionPacket.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** CollectionPacket.nc 20 Jun 2006 21:16:28 -0000 1.1.2.3
--- CollectionPacket.nc 22 Jun 2006 13:43:28 -0000 1.1.2.4
***************
*** 40,42 ****
--- 40,49 ----
command uint8_t getControl(message_t* msg);
command void setControl(message_t* msg, uint8_t control);
+
+ command uint8_t getSequenceNumber(message_t* msg);
+ command void setSequenceNumber(message_t* msg, uint8_t seqno);
+
+ /* Returns a 32bit number which is a concatenation of
+ * the origin and the sequence number */
+ command uint32_t getPacketID(message_t* msg);
}
Index: ForwardingEngineP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/ForwardingEngineP.nc,v
retrieving revision 1.1.2.31
retrieving revision 1.1.2.32
diff -C2 -d -r1.1.2.31 -r1.1.2.32
*** ForwardingEngineP.nc 21 Jun 2006 02:16:53 -0000 1.1.2.31
--- ForwardingEngineP.nc 22 Jun 2006 13:43:28 -0000 1.1.2.32
***************
*** 54,57 ****
--- 54,58 ----
interface Pool<message_t> as MessagePool;
interface Timer<TMilli> as RetxmitTimer;
+ interface Cache<uint32_t> as SentCache;
interface PacketAcknowledgements;
interface Random;
***************
*** 89,92 ****
--- 90,95 ----
to a new parent. */
am_addr_t lastParent;
+
+ uint8_t seqno;
enum {
***************
*** 108,111 ****
--- 111,115 ----
loopbackMsgPtr = &loopbackMsg;
lastParent = call AMPacket.address();
+ seqno = 0;
return SUCCESS;
}
***************
*** 164,167 ****
--- 168,172 ----
hdr = getHeader(msg);
hdr->origin = TOS_NODE_ID;
+ hdr->seqno = seqno++;
hdr->collectid = call CollectionId.fetch[client]();
***************
*** 367,370 ****
--- 372,376 ----
call CollectionDebug.logEventRoute(NET_C_FE_FWD_MSG, error, TOS_NODE_ID,
call AMPacket.destination(msg));
+ call SentCache.insert(CollectionPacket.getPacketID(qe->msg));
call SendQueue.dequeue();
call MessagePool.put(qe->msg);
***************
*** 427,435 ****
--- 433,469 ----
uint8_t netlen;
collection_id_t collectid;
+
+ uint32_t msg_uid;
+ bool duplicate = FALSE;
+ fe_queue_entry_t* qe;
+
+
+ msg_uid = CollectionPacket.getPacketID(msg);
collectid = hdr->collectid;
+
call CollectionDebug.logEvent(NET_C_FE_RCV_MSG);
if (len > call SubSend.maxPayloadLength()) {
return msg;
}
+
+ //See if we remember having seen this packet
+ //We look in the sent cache ...
+ if (call SentCache.lookup(msg_uid)) {
+ call CollectionDebug.logEvent(NET_C_FE_DUPLICATE_CACHE);
+ return msg;
+ }
+ //... and in the queue for duplicates
+ for (i = call Queue.size(); --i ;) {
+ qe = call Queue.element(i);
+ if (call CollectionPacket.getPacketID(qe->msg) == msg_uid) {
+ duplicate = TRUE;
+ break;
+ }
+ }
+ if (duplicate) {
+ call CollectionDebug.logEvent(NET_C_FE_DUPLICATE_QUEUE);
+ return msg;
+ }
+
// If I'm the root, signal receive.
else if (call RootControl.isRoot())
***************
*** 507,511 ****
return getHeader(msg)->origin;
}
!
command void CollectionPacket.setOrigin(message_t* msg, am_addr_t addr) {
getHeader(msg)->origin = addr;
--- 541,545 ----
return getHeader(msg)->origin;
}
!
command void CollectionPacket.setOrigin(message_t* msg, am_addr_t addr) {
getHeader(msg)->origin = addr;
***************
*** 528,531 ****
--- 562,577 ----
}
+ command uint8_t getSequenceNumber(message_t* msg) {
+ return getHeader(msg)->seqno;
+ }
+
+ command void setSequenceNumber(message_t* msg, uint8_t seqno) {
+ getHeader(msg)->seqno = seqno;
+ }
+
+ command uint32_t CollectionPacket.getPacketID(message_t* msg) {
+ return ((uint32_t)(getHeader(msg)->origin) << 16) | (uint32_t)(getHeader(msg)->seqno);
+ }
+
default event void
Index: Queue.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/Queue.nc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** Queue.nc 1 May 2006 16:43:07 -0000 1.1.2.2
--- Queue.nc 22 Jun 2006 13:43:28 -0000 1.1.2.3
***************
*** 36,41 ****
--- 36,73 ----
command uint8_t maxSize();
+ /**
+ * Get the head of the queue without removing it. If the queue
+ * is empty, the return value is undefined.
+ *
+ * @return The head of the queue.
+ */
command t head();
+
+ /**
+ * Remove the head of the queue. If the queue is empty, the return
+ * value is undefined.
+ *
+ * @return The head of the queue.
+ */
command t dequeue();
+
+ /**
+ * Enqueue an element to the tail of the queue.
+ *
+ * @param newVal - the element to enqueue
+ * @return SUCCESS if the element was enqueued successfully, FAIL
+ * if it was not enqueued.
+ */
command error_t enqueue(t newVal);
+
+ /**
+ * Return the nth element of the queue without dequeueing it,
+ * where 0 is the head of the queue and (size - 1) is the tail.
+ * If the element requested is larger than the current queue size,
+ * the return value is undefined.
+ *
+ * @param index - the index of the element to return
+ * @return the requested element in the queue.
+ */
+ command t element(uint8_t index);
}
Index: QueueC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/QueueC.nc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** QueueC.nc 15 Jun 2006 17:22:57 -0000 1.1.2.5
--- QueueC.nc 22 Jun 2006 13:43:28 -0000 1.1.2.6
***************
*** 1,101 ****
! /* $Id$ */
! /*
! * "Copyright (c) 2006 Stanford University. All rights reserved.
! *
! * Permission to use, copy, modify, and distribute this software and
! * its documentation for any purpose, without fee, and without written
! * agreement is hereby granted, provided that the above copyright
! * notice, the following two paragraphs and the author appear in all
! * copies of this software.
! *
! * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR
! * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
! * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
! * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
! * DAMAGE.
! *
! * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
! * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
! * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
! * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY
! * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
! * ENHANCEMENTS, OR MODIFICATIONS."
! */
!
! /*
! * @author Philip Levis
! * @date $Date$
! */
!
!
! generic module QueueC(typedef queue_t, uint8_t QUEUE_SIZE) {
! provides interface Queue<queue_t>;
! }
!
! implementation {
!
! queue_t queue[QUEUE_SIZE];
! uint8_t head = 0;
! uint8_t tail = 0;
! uint8_t size = 0;
!
! command bool Queue.empty() {
! return size == 0;
! }
!
! command uint8_t Queue.size() {
! return size;
! }
!
! command uint8_t Queue.maxSize() {
! return QUEUE_SIZE;
! }
!
! command queue_t Queue.head() {
! return queue[head];
! }
!
! void printQueue() {
! #ifdef TOSSIM
! int i, j;
! dbg("QueueC", "head <-");
! for (i = head; i < head + size; i++) {
! dbg_clear("QueueC", "[");
! for (j = 0; j < sizeof(queue_t); j++) {
! uint8_t v = ((uint8_t*)&queue[i % QUEUE_SIZE])[j];
! dbg_clear("QueueC", "%0.2hhx", v);
! }
! dbg_clear("QueueC", "] ");
! }
! dbg_clear("QueueC", "<- tail\n");
! #endif
! }
!
! command queue_t Queue.dequeue() {
! queue_t t = call Queue.head();
! dbg("QueueC", "%s: size is %hhu\n", __FUNCTION__, size);
! if (!call Queue.empty()) {
! head++;
! head %= QUEUE_SIZE;
! size--;
! printQueue();
! }
! return t;
! }
!
! command error_t Queue.enqueue(queue_t newVal) {
! if (call Queue.size() < call Queue.maxSize()) {
! dbg("QueueC", "%s: size is %hhu\n", __FUNCTION__, size);
! queue[tail] = newVal;
! tail++;
! tail %= QUEUE_SIZE;
! size++;
! printQueue();
! return SUCCESS;
! }
! else {
! return FAIL;
! }
! }
!
! }
--- 1,107 ----
! /* $Id$ */
! /*
! * "Copyright (c) 2006 Stanford University. All rights reserved.
! *
! * Permission to use, copy, modify, and distribute this software and
! * its documentation for any purpose, without fee, and without written
! * agreement is hereby granted, provided that the above copyright
! * notice, the following two paragraphs and the author appear in all
! * copies of this software.
! *
! * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR
! * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
! * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
! * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
! * DAMAGE.
! *
! * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
! * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
! * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
! * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY
! * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
! * ENHANCEMENTS, OR MODIFICATIONS."
! */
!
! /*
! * @author Philip Levis
! * @date $Date$
! */
!
!
! generic module QueueC(typedef queue_t, uint8_t QUEUE_SIZE) {
! provides interface Queue<queue_t>;
! }
!
! implementation {
!
! queue_t queue[QUEUE_SIZE];
! uint8_t head = 0;
! uint8_t tail = 0;
! uint8_t size = 0;
!
! command bool Queue.empty() {
! return size == 0;
! }
!
! command uint8_t Queue.size() {
! return size;
! }
!
! command uint8_t Queue.maxSize() {
! return QUEUE_SIZE;
! }
!
! command queue_t Queue.head() {
! return queue[head];
! }
!
! void printQueue() {
! #ifdef TOSSIM
! int i, j;
! dbg("QueueC", "head <-");
! for (i = head; i < head + size; i++) {
! dbg_clear("QueueC", "[");
! for (j = 0; j < sizeof(queue_t); j++) {
! uint8_t v = ((uint8_t*)&queue[i % QUEUE_SIZE])[j];
! dbg_clear("QueueC", "%0.2hhx", v);
! }
! dbg_clear("QueueC", "] ");
! }
! dbg_clear("QueueC", "<- tail\n");
! #endif
! }
!
! command queue_t Queue.dequeue() {
! queue_t t = call Queue.head();
! dbg("QueueC", "%s: size is %hhu\n", __FUNCTION__, size);
! if (!call Queue.empty()) {
! head++;
! head %= QUEUE_SIZE;
! size--;
! printQueue();
! }
! return t;
! }
!
! command error_t Queue.enqueue(queue_t newVal) {
! if (call Queue.size() < call Queue.maxSize()) {
! dbg("QueueC", "%s: size is %hhu\n", __FUNCTION__, size);
! queue[tail] = newVal;
! tail++;
! tail %= QUEUE_SIZE;
! size++;
! printQueue();
! return SUCCESS;
! }
! else {
! return FAIL;
! }
! }
!
! command t Queue.element(uint8_t index) {
! index += head;
! index %= QUEUE_SIZE;
! return queue[index];
! }
!
! }
More information about the Tinyos-2-commits
mailing list