]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Copyrights and fixes
authorscipio <scipio>
Sat, 14 Apr 2007 00:40:57 +0000 (00:40 +0000)
committerscipio <scipio>
Sat, 14 Apr 2007 00:40:57 +0000 (00:40 +0000)
tos/lib/net/ctp/CollectionSenderC.nc
tos/lib/net/ctp/CollectionSenderP.nc
tos/lib/net/lqi/LqiForwardingEngineP.nc
tos/lib/net/lqi/LqiRoutingEngineP.nc

index 721f44e5829d3049389c2404170d2cb84f5914cf..bdb118aa2301f1d8eb7524b0db287c3f8ed628dc 100644 (file)
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 /**
  * The virtualized collection sender abstraction.
  *
index 9ca2279aaeffa21914749041e11478aa95aa40f2..9c854c7fb3fde4143fc491d74378332f61664d63 100644 (file)
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Stanford University nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #include "Collection.h"
 
 generic configuration 
index c1481d9eb7ba8f8184bcd705d200794c0c569eb0..9c448bc0167be5bd481ee8abcdefd3b84751a807 100644 (file)
@@ -248,6 +248,10 @@ implementation {
       if (call SubSend.send(call AMPacket.destination(msg),
                            msg,
                            call SubPacket.payloadLength(msg)) == SUCCESS) {
+       call CollectionDebug.logEventMsg(NET_C_DBG_1, 
+                                        call CollectionPacket.getSequenceNumber(msg), 
+                                        call CollectionPacket.getOrigin(msg), 
+                                        call AMPacket.destination(msg));
        dbg("LQI", "%s: Send to %hu success.\n", __FUNCTION__, call AMPacket.destination(msg));
       }
       fwdbusy = TRUE;
@@ -260,7 +264,7 @@ implementation {
     len -= sizeof(lqi_header_t);
 
     call CollectionDebug.logEventMsg(NET_C_FE_RCV_MSG, 
-                                    call CollectionPacket.getTestNetworkSeq(msg), 
+                                    call CollectionPacket.getSequenceNumber(msg), 
                                     call CollectionPacket.getOrigin(msg), 
                                     call AMPacket.destination(msg));
 
@@ -279,7 +283,7 @@ implementation {
   
   message_t* nextMsg() {
     int i;
-    int inc = call Random.rand16();
+    uint16_t inc = call Random.rand16() & 0xfff;
     for (i = 0; i < FWD_QUEUE_SIZE; i++) {
       int pindex = (i + inc) % FWD_QUEUE_SIZE;
       if (FwdBufBusy[pindex]) {
@@ -302,14 +306,14 @@ implementation {
                            call SubPacket.payloadLength(msg)) == SUCCESS) {
        dbg("LQI", "Packet not acked, retransmit @%s:\n\t%s\n", sim_time_string(), fields(msg));
         call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_WAITACK, 
-                                        call CollectionPacket.getTestNetworkSeq(msg), 
+                                        call CollectionPacket.getSequenceNumber(msg), 
                                         call CollectionPacket.getOrigin(msg), 
                                          call AMPacket.destination(msg));
        fail_count ++;
        return;
       } else {
        call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL, 
-                                        call CollectionPacket.getTestNetworkSeq(msg), 
+                                        call CollectionPacket.getSequenceNumber(msg), 
                                         call CollectionPacket.getOrigin(msg), 
                                          call AMPacket.destination(msg));
        dbg("LQI", "Packet not acked, retransmit fail @%s:\n\t%s\n", sim_time_string(), fields(msg));
@@ -319,7 +323,7 @@ implementation {
     }
     else if (fail_count >= 5) {
       call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL_ACK_FWD, 
-                                      call CollectionPacket.getTestNetworkSeq(msg), 
+                                      call CollectionPacket.getSequenceNumber(msg), 
                                       call CollectionPacket.getOrigin(msg), 
                                       call AMPacket.destination(msg));
       dbg("LQI", "Packet failed:\t%s\n", fields(msg));
@@ -327,7 +331,7 @@ implementation {
     else if (call PacketAcknowledgements.wasAcked(msg)) {
       dbg("LQI", "Packet acked:\t%s\n", fields(msg));
       call CollectionDebug.logEventMsg(NET_C_FE_FWD_MSG, 
-                                      call CollectionPacket.getTestNetworkSeq(msg), 
+                                      call CollectionPacket.getSequenceNumber(msg), 
                                       call CollectionPacket.getOrigin(msg), 
                                       call AMPacket.destination(msg));
     }
@@ -359,14 +363,14 @@ implementation {
                            call SubPacket.payloadLength(msg)) == SUCCESS) {
        dbg("LQI", "Packet not acked, retransmit (%hhu) @%s:\n\t%s\n", fail_count, sim_time_string(), fields(msg));
        call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_WAITACK, 
-                                        call CollectionPacket.getTestNetworkSeq(msg), 
+                                        call CollectionPacket.getSequenceNumber(msg), 
                                         call CollectionPacket.getOrigin(msg), 
                                          call AMPacket.destination(msg));
        fail_count ++;
        return;
       } else {
        call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL, 
-                                        call CollectionPacket.getTestNetworkSeq(msg), 
+                                        call CollectionPacket.getSequenceNumber(msg), 
                                         call CollectionPacket.getOrigin(msg), 
                                          call AMPacket.destination(msg));
        dbg("LQI", "Packet not acked, retransmit fail @%s:\n\t%s\n", sim_time_string(), fields(msg));
@@ -376,7 +380,7 @@ implementation {
     }
     else if (fail_count >= 5) {
       call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL_ACK_SEND, 
-                                      call CollectionPacket.getTestNetworkSeq(msg), 
+                                      call CollectionPacket.getSequenceNumber(msg), 
                                       call CollectionPacket.getOrigin(msg), 
                                       call AMPacket.destination(msg));
       dbg("LQI", "Packet failed:\t%s\n", fields(msg));
@@ -384,7 +388,7 @@ implementation {
     else if (call PacketAcknowledgements.wasAcked(msg)) {
       dbg("LQI", "Packet acked:\t%s\n", fields(msg));
       call CollectionDebug.logEventMsg(NET_C_FE_SENT_MSG, 
-                                      call CollectionPacket.getTestNetworkSeq(msg), 
+                                      call CollectionPacket.getSequenceNumber(msg), 
                                       call CollectionPacket.getOrigin(msg), 
                                       call AMPacket.destination(msg));
     }
@@ -504,11 +508,6 @@ implementation {
     hdr->originseqno = seqno;
   }
 
-  command uint16_t CollectionPacket.getTestNetworkSeq(message_t* msg) {
-    TestNetworkMsg *tn;
-    tn = (TestNetworkMsg *)call Packet.getPayload(msg, NULL);
-    return tn->seqno;
-  }
 
   
  default event void Send.sendDone(message_t* pMsg, error_t success) {}
index 4d99095792832422b037bbf35ba0732b3bab17a4..fdea7b4a06e439fc49118b1ae0d1bac31ff8ad56 100644 (file)
@@ -89,7 +89,8 @@ implementation {
   uint8_t gLastHeard;
 
   int16_t gCurrentSeqNo;
-
+  int16_t gOriginSeqNo;
+  
   uint16_t gUpdateInterval;
 
   uint8_t gRecentIndex;
@@ -137,7 +138,6 @@ implementation {
       bMsg->cost = 0;
       bMsg->originaddr = TOS_NODE_ID;
       bMsg->hopcount = 0;
-      bMsg->originseqno = gCurrentSeqNo;
       bMsg->seqno = gCurrentSeqNo++;
     }
     else {
@@ -145,7 +145,6 @@ implementation {
       bMsg->cost = gbCurrentParentCost + gbCurrentLinkEst;
       bMsg->originaddr = TOS_NODE_ID;
       bMsg->hopcount = gbCurrentHopCount;
-      bMsg->originseqno = gCurrentSeqNo;
       bMsg->seqno = gCurrentSeqNo++;
     }
     
@@ -189,6 +188,7 @@ implementation {
     gbCurrentHopCount = ROUTE_INVALID;
     gbCurrentCost = 0xfffe;
 
+    gOriginSeqNo = 0;
     gCurrentSeqNo = 0;
     gUpdateInterval = BEACON_PERIOD;
     msgBufBusy = FALSE;
@@ -280,7 +280,7 @@ implementation {
     lqi_header_t* header = (lqi_header_t*)call Packet.getPayload(msg, NULL);
 
     header->originaddr = TOS_NODE_ID;
-    header->originseqno = gCurrentSeqNo;
+    header->originseqno = gOriginSeqNo++;
     header->seqno = gCurrentSeqNo;
     
     if (isRoot) {