[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/ctp CtpForwardingEngineP.nc, 1.1.2.7, 1.1.2.8 CtpInfo.nc, 1.1.2.2, 1.1.2.3 CtpP.nc, 1.1.2.4, 1.1.2.5 CtpRoutingEngineP.nc, 1.1.2.5, 1.1.2.6 CtpRoutingPacket.nc, 1.1.2.1, 1.1.2.2 TreeRouting.h, 1.1.2.1, 1.1.2.2

Phil Levis scipio at users.sourceforge.net
Tue Sep 12 18:41:59 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/ctp
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv23835/ctp

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	CtpForwardingEngineP.nc CtpInfo.nc CtpP.nc 
	CtpRoutingEngineP.nc CtpRoutingPacket.nc TreeRouting.h 
Log Message:
Updated for working trickle timers.


Index: CtpForwardingEngineP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/ctp/Attic/CtpForwardingEngineP.nc,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** CtpForwardingEngineP.nc	11 Sep 2006 12:11:59 -0000	1.1.2.7
--- CtpForwardingEngineP.nc	13 Sep 2006 01:41:57 -0000	1.1.2.8
***************
*** 433,437 ****
        
        // Loop-detection functionality:
!       if (call CtpInfo.getMetric(&gradient) != SUCCESS) {
          // If we have no metric, set our gradient conservatively so
          // that other nodes don't automatically drop our packets.
--- 433,437 ----
        
        // Loop-detection functionality:
!       if (call CtpInfo.getEtx(&gradient) != SUCCESS) {
          // If we have no metric, set our gradient conservatively so
          // that other nodes don't automatically drop our packets.
***************
*** 443,447 ****
  
        // Set or clear the congestion bit on *outgoing* packets.
!       if (congested)
          call CtpPacket.setOption(qe->msg, CTP_OPT_ECN);
        else
--- 443,447 ----
  
        // Set or clear the congestion bit on *outgoing* packets.
!       if (congested())
          call CtpPacket.setOption(qe->msg, CTP_OPT_ECN);
        else
***************
*** 642,646 ****
          dbg("Forwarder,Route", "%s forwarding packet %p with queue size %hhu\n", __FUNCTION__, m, call SendQueue.size());
          // Loop-detection code:
!         if (call CtpInfo.getMetric(&gradient) == SUCCESS) {
            // We only check for loops if we know our own metric
            if (call CtpPacket.getEtx(m) < gradient) {
--- 642,646 ----
          dbg("Forwarder,Route", "%s forwarding packet %p with queue size %hhu\n", __FUNCTION__, m, call SendQueue.size());
          // Loop-detection code:
!         if (call CtpInfo.getEtx(&gradient) == SUCCESS) {
            // We only check for loops if we know our own metric
            if (call CtpPacket.getEtx(m) < gradient) {

Index: CtpInfo.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/ctp/Attic/CtpInfo.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
*** CtpInfo.nc	25 Aug 2006 00:41:28 -0000	1.1.2.2
--- CtpInfo.nc	13 Sep 2006 01:41:57 -0000	1.1.2.3
***************
*** 41,52 ****
    
    /**
-    * Get the depth (hopcount) of the node in the tree.  The pointer is
-    * allocated by the caller.  If the parent is invalid, return FAIL
-    * (no info).  The caller MUST NOT use the value in parent if the
-    * return is not SUCCESS.
-    */
-   command error_t getHopcount(uint8_t* hopcount);
-   
-   /**
     * Get the path quality metric for the current path to the root
     * through the current parent.  The pointer is allocated by the
--- 41,44 ----
***************
*** 56,60 ****
     */
    
!   command error_t getMetric(uint16_t* metric);
  
    /**
--- 48,52 ----
     */
    
!   command error_t getEtx(uint16_t* etx);
  
    /**

Index: CtpP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/ctp/Attic/CtpP.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** CtpP.nc	12 Sep 2006 12:45:02 -0000	1.1.2.4
--- CtpP.nc	13 Sep 2006 01:41:57 -0000	1.1.2.5
***************
*** 121,124 ****
--- 121,125 ----
  
    components new TimerMilliC() as RoutingBeaconTimer;
+   components new TimerMilliC() as RouteUpdateTimer;
    components LinkEstimatorP as Estimator;
  
***************
*** 127,131 ****
    components new AMSnooperC(AM_CTP_DATA);
    
!   components new CtpRoutingEngineP(TREE_ROUTING_TABLE_SIZE, 2, 60) as Router;
    StdControl = Router;
    StdControl = Estimator;
--- 128,132 ----
    components new AMSnooperC(AM_CTP_DATA);
    
!   components new CtpRoutingEngineP(TREE_ROUTING_TABLE_SIZE, 8, 8) as Router;
    StdControl = Router;
    StdControl = Estimator;
***************
*** 139,142 ****
--- 140,144 ----
    Router.RadioControl -> ActiveMessageC;
    Router.BeaconTimer -> RoutingBeaconTimer;
+   Router.RouteTimer -> RouteUpdateTimer;
    Router.CollectionDebug = CollectionDebug;
    Forwarder.CollectionDebug = CollectionDebug;

Index: CtpRoutingEngineP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/ctp/Attic/CtpRoutingEngineP.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
*** CtpRoutingEngineP.nc	11 Sep 2006 12:17:07 -0000	1.1.2.5
--- CtpRoutingEngineP.nc	13 Sep 2006 01:41:57 -0000	1.1.2.6
***************
*** 102,105 ****
--- 102,106 ----
          interface CtpInfo;
          interface StdControl;
+ 	interface CtpRoutingPacket;
          interface Init;
      } 
***************
*** 112,115 ****
--- 113,117 ----
          interface SplitControl as RadioControl;
          interface Timer<TMilli> as BeaconTimer;
+ 	interface Timer<TMilli> as RouteTimer;
          interface Random;
          interface CollectionDebug;
***************
*** 138,142 ****
  
      message_t beaconMsgBuffer;
!     beacon_msg_t* beaconMsg;
  
      /* routing table -- routing info about neighbors */
--- 140,144 ----
  
      message_t beaconMsgBuffer;
!     ctp_routing_header_t* beaconMsg;
  
      /* routing table -- routing info about neighbors */
***************
*** 151,155 ****
      void routingTableInit();
      uint8_t routingTableFind(am_addr_t);
!     error_t routingTableUpdateEntry(am_addr_t, am_addr_t , uint8_t, uint16_t);
      error_t routingTableEvict(am_addr_t neighbor);
  
--- 153,157 ----
      void routingTableInit();
      uint8_t routingTableFind(am_addr_t);
!     error_t routingTableUpdateEntry(am_addr_t, am_addr_t , uint16_t);
      error_t routingTableEvict(am_addr_t neighbor);
  
***************
*** 171,177 ****
  
      void decayInterval() {
!       currentInterval *= 2;
!       if (currentInterval > maxInterval) {
!         currentInterval = maxInterval;
        }
        chooseAdvertiseTime();
--- 173,181 ----
  
      void decayInterval() {
!       if (!state_is_root) {
! 	currentInterval *= 2;
! 	if (currentInterval > maxInterval) {
! 	  currentInterval = maxInterval;
! 	}
        }
        chooseAdvertiseTime();
***************
*** 205,211 ****
          if (!running) {
              running = TRUE;
!             nextInt = call Random.rand16() % BEACON_INTERVAL;
!             nextInt += BEACON_INTERVAL >> 1;
!             call BeaconTimer.startOneShot(nextInt);
              dbg("TreeRoutingCtl","%s running: %d radioOn: %d\n", __FUNCTION__, running, radioOn);
          }     
--- 209,214 ----
          if (!running) {
              running = TRUE;
! 	    resetInterval();
! 	    call RouteTimer.startPeriodic(BEACON_INTERVAL);
              dbg("TreeRoutingCtl","%s running: %d radioOn: %d\n", __FUNCTION__, running, radioOn);
          }     
***************
*** 237,247 ****
      /* Is this quality measure better than the minimum threshold? */
      // Implemented assuming quality is EETX
!     bool passLinkMetricThreshold(uint16_t metric) {
!         return (metric < ETX_THRESHOLD);
      }
  
      /* Converts the output of the link estimator to path metric
       * units, that can be *added* to form path metric measures */
!     uint16_t evaluateMetric(uint8_t quality) {
          //dbg("TreeRouting","%s %d -> %d\n",__FUNCTION__,quality, quality+10);
          return (quality + 10);
--- 240,250 ----
      /* Is this quality measure better than the minimum threshold? */
      // Implemented assuming quality is EETX
!     bool passLinkEtxThreshold(uint16_t etx) {
!         return (etx < ETX_THRESHOLD);
      }
  
      /* Converts the output of the link estimator to path metric
       * units, that can be *added* to form path metric measures */
!     uint16_t evaluateEtx(uint8_t quality) {
          //dbg("TreeRouting","%s %d -> %d\n",__FUNCTION__,quality, quality+10);
          return (quality + 10);
***************
*** 255,261 ****
          routing_table_entry* entry;
          routing_table_entry* best;
!         uint16_t minMetric;
!         uint16_t currentMetric;
!         uint16_t linkMetric, pathMetric;
  
          if (state_is_root)
--- 258,264 ----
          routing_table_entry* entry;
          routing_table_entry* best;
!         uint16_t minEtx;
!         uint16_t currentEtx;
!         uint16_t linkEtx, pathEtx;
  
          if (state_is_root)
***************
*** 263,270 ****
          
          best = NULL;
!         /* Minimum metric found among neighbors, initially infinity */
!         minMetric = MAX_METRIC;
          /* Metric through current parent, initially infinity */
!         currentMetric = MAX_METRIC;
  
          dbg("TreeRouting","%s\n",__FUNCTION__);
--- 266,273 ----
          
          best = NULL;
!         /* Minimum etx found among neighbors, initially infinity */
!         minEtx = MAX_METRIC;
          /* Metric through current parent, initially infinity */
!         currentEtx = MAX_METRIC;
  
          dbg("TreeRouting","%s\n",__FUNCTION__);
***************
*** 277,312 ****
              if (entry->info.parent == INVALID_ADDR || entry->info.parent == my_ll_addr) {
                dbg("TreeRouting", 
!                   "routingTable[%d]: neighbor: [id: %d parent: %d hopcount: %d metric: NO ROUTE]\n",  
!                   i, entry->neighbor, entry->info.parent, entry->info.hopcount);
                continue;
              }
- 	    if (TOS_NODE_ID > 10 && entry->neighbor == 0) {
- 	      continue;
- 	    }
              /* Compute this neighbor's path metric */
!             linkMetric = evaluateMetric(call LinkEstimator.getLinkQuality(entry->neighbor));
              dbg("TreeRouting", 
!                 "routingTable[%d]: neighbor: [id: %d parent: %d hopcount: %d metric: %d]\n",  
!                 i, entry->neighbor, entry->info.parent, entry->info.hopcount, linkMetric);
!             pathMetric = linkMetric + entry->info.metric;
              /* Operations specific to the current parent */
              if (entry->neighbor == routeInfo.parent) {
                  dbg("TreeRouting", "   already parent.\n");
!                 currentMetric = pathMetric;
                  /* update routeInfo with parent's current info */
                  atomic {
!                     routeInfo.metric = entry->info.metric;
!                     routeInfo.hopcount = entry->info.hopcount + 1;
                  }
                  continue;
              }
              /* Ignore links that are bad */
!             if (!passLinkMetricThreshold(linkMetric)) {
                dbg("TreeRouting", "   did not pass threshold.\n");
                continue;
              }
              
!             if (pathMetric < minMetric) {
!                 minMetric = pathMetric;
                  best = entry;
              }  
--- 280,311 ----
              if (entry->info.parent == INVALID_ADDR || entry->info.parent == my_ll_addr) {
                dbg("TreeRouting", 
!                   "routingTable[%d]: neighbor: [id: %d parent: %d  etx: NO ROUTE]\n",  
!                   i, entry->neighbor, entry->info.parent);
                continue;
              }
              /* Compute this neighbor's path metric */
!             linkEtx = evaluateEtx(call LinkEstimator.getLinkQuality(entry->neighbor));
              dbg("TreeRouting", 
!                 "routingTable[%d]: neighbor: [id: %d parent: %d etx: %d]\n",  
!                 i, entry->neighbor, entry->info.parent, linkEtx);
!             pathEtx = linkEtx + entry->info.etx;
              /* Operations specific to the current parent */
              if (entry->neighbor == routeInfo.parent) {
                  dbg("TreeRouting", "   already parent.\n");
!                 currentEtx = pathEtx;
                  /* update routeInfo with parent's current info */
                  atomic {
!                     routeInfo.etx = entry->info.etx;
                  }
                  continue;
              }
              /* Ignore links that are bad */
!             if (!passLinkEtxThreshold(linkEtx)) {
                dbg("TreeRouting", "   did not pass threshold.\n");
                continue;
              }
              
!             if (pathEtx < minEtx) {
!                 minEtx = pathEtx;
                  best = entry;
              }  
***************
*** 314,320 ****
  
          /* Now choose between the current parent and the best neighbor */
!         if (minMetric != MAX_METRIC) {
!             if (currentMetric == MAX_METRIC ||
!                 minMetric + PARENT_SWITCH_THRESHOLD < currentMetric) {
                  // routeInfo.metric will not store the composed metric.
                  // since the linkMetric may change, we will compose whenever
--- 313,319 ----
  
          /* Now choose between the current parent and the best neighbor */
!         if (minEtx != MAX_METRIC) {
!             if (currentEtx == MAX_METRIC ||
!                 minEtx + PARENT_SWITCH_THRESHOLD < currentEtx) {
                  // routeInfo.metric will not store the composed metric.
                  // since the linkMetric may change, we will compose whenever
***************
*** 324,334 ****
                  resetInterval();
                  dbg("TreeRouting","Changed parent. from %d to %d\n", routeInfo.parent, best->neighbor);
!                 call CollectionDebug.logEventRoute(NET_C_TREE_NEW_PARENT, best->neighbor, best->info.hopcount + 1, best->info.metric); 
                  call LinkEstimator.unpinNeighbor(routeInfo.parent);
                  call LinkEstimator.pinNeighbor(best->neighbor);
                  atomic {
                      routeInfo.parent = best->neighbor;
!                     routeInfo.metric = best->info.metric;
!                     routeInfo.hopcount = best->info.hopcount + 1; 
                  }
              }
--- 323,332 ----
                  resetInterval();
                  dbg("TreeRouting","Changed parent. from %d to %d\n", routeInfo.parent, best->neighbor);
!                 call CollectionDebug.logEventRoute(NET_C_TREE_NEW_PARENT, best->neighbor, 0, best->info.etx); 
                  call LinkEstimator.unpinNeighbor(routeInfo.parent);
                  call LinkEstimator.pinNeighbor(best->neighbor);
                  atomic {
                      routeInfo.parent = best->neighbor;
!                     routeInfo.etx = best->info.etx;
                  }
              }
***************
*** 340,350 ****
          if (justEvicted && routeInfo.parent == INVALID_ADDR) 
              signal Routing.noRoute();
!         /* On the other hand, if we didn't have a parent (no currentMetric) and now we
           * do, then we signal route found. The exception is if we just evicted the 
           * parent and immediately found a replacement route: we don't signal in this 
           * case */
          else if (!justEvicted && 
!                   currentMetric == MAX_METRIC &&
!                   minMetric != MAX_METRIC)
              signal Routing.routeFound();
          justEvicted = FALSE; 
--- 338,348 ----
          if (justEvicted && routeInfo.parent == INVALID_ADDR) 
              signal Routing.noRoute();
!         /* On the other hand, if we didn't have a parent (no currentEtx) and now we
           * do, then we signal route found. The exception is if we just evicted the 
           * parent and immediately found a replacement route: we don't signal in this 
           * case */
          else if (!justEvicted && 
!                   currentEtx == MAX_METRIC &&
!                   minEtx != MAX_METRIC)
              signal Routing.routeFound();
          justEvicted = FALSE; 
***************
*** 361,383 ****
          }
          beaconMsg->parent = routeInfo.parent;
!         beaconMsg->hopcount = routeInfo.hopcount;
! 
!         if (state_is_root || routeInfo.parent == INVALID_ADDR) {
!             beaconMsg->metric = routeInfo.metric;
          } else {
!             beaconMsg->metric = routeInfo.metric +
!                                 evaluateMetric(call LinkEstimator.getLinkQuality(routeInfo.parent)); 
          }
  
!         dbg("TreeRouting", "%s parent: %d hopcount: %d metric: %d\n",
                    __FUNCTION__,
                    beaconMsg->parent, 
!                   beaconMsg->hopcount, 
!                   beaconMsg->metric);
!         call CollectionDebug.logEventRoute(NET_C_TREE_SENT_BEACON, beaconMsg->parent, beaconMsg->hopcount, beaconMsg->metric);
  
          eval = call BeaconSend.send(AM_BROADCAST_ADDR, 
                                      &beaconMsgBuffer, 
!                                     sizeof(beacon_msg_t));
          if (eval == SUCCESS) {
              sending = TRUE;
--- 359,384 ----
          }
          beaconMsg->parent = routeInfo.parent;
!         if (state_is_root) {
!             beaconMsg->etx = routeInfo.etx;
! 	    beaconMsg->options = 0;
! 	}
! 	else if (routeInfo.parent == INVALID_ADDR) {
!             beaconMsg->etx = routeInfo.etx;
! 	    beaconMsg->options = CTP_OPT_PULL;
          } else {
! 	  beaconMsg->etx = routeInfo.etx +
!                                 evaluateEtx(call LinkEstimator.getLinkQuality(routeInfo.parent));
! 	    beaconMsg->options = 0;
          }
  
!         dbg("TreeRouting", "%s parent: %d etx: %d\n",
                    __FUNCTION__,
                    beaconMsg->parent, 
! 	    beaconMsg->etx);
!         call CollectionDebug.logEventRoute(NET_C_TREE_SENT_BEACON, beaconMsg->parent, 0, beaconMsg->etx);
  
          eval = call BeaconSend.send(AM_BROADCAST_ADDR, 
                                      &beaconMsgBuffer, 
!                                     sizeof(ctp_routing_header_t));
          if (eval == SUCCESS) {
              sending = TRUE;
***************
*** 396,404 ****
      }
  
! 
      event void BeaconTimer.fired() {
        if (radioOn && running) {
          if (!tHasPassed) {
-           post updateRouteTask();
            post sendBeaconTask();
            remainingInterval();
--- 397,408 ----
      }
  
!     event void RouteTimer.fired() {
!       if (radioOn && running) 
! 	post updateRouteTask();
!     }
!     
      event void BeaconTimer.fired() {
        if (radioOn && running) {
          if (!tHasPassed) {
            post sendBeaconTask();
            remainingInterval();
***************
*** 411,423 ****
  
  
      /* Handle the receiving of beacon messages from the neighbors. We update the
       * table, but wait for the next route update to choose a new parent */
      event message_t* BeaconReceive.receive(message_t* msg, void* payload, uint8_t len) {
          am_addr_t from;
!         beacon_msg_t* rcvBeacon;
  
          // Received a beacon, but it's not from us.
!         if (len != sizeof(beacon_msg_t)) {
!           dbg("LITest", "%s, received beacon of size %hhu, expected %i\n", __FUNCTION__, len, (int)sizeof(beacon_msg_t));
                
            return msg;
--- 415,432 ----
  
  
+     ctp_routing_header_t* getHeader(message_t* m) {
+       return (ctp_routing_header_t*)call BeaconReceive.getPayload(m, NULL);
+     }
+     
+     
      /* Handle the receiving of beacon messages from the neighbors. We update the
       * table, but wait for the next route update to choose a new parent */
      event message_t* BeaconReceive.receive(message_t* msg, void* payload, uint8_t len) {
          am_addr_t from;
!         ctp_routing_header_t* rcvBeacon;
  
          // Received a beacon, but it's not from us.
!         if (len != sizeof(ctp_routing_header_t)) {
!           dbg("LITest", "%s, received beacon of size %hhu, expected %i\n", __FUNCTION__, len, (int)sizeof(ctp_routing_header_t));
                
            return msg;
***************
*** 426,435 ****
          //need to get the am_addr_t of the source
          from = call LinkSrcPacket.getSrc(msg);
!         rcvBeacon = (beacon_msg_t*)payload;
  
!         dbg("TreeRouting","%s from: %d  [ parent: %d hopcount: %d metric: %d]\n",
              __FUNCTION__, from, 
!             rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->metric);
!         //call CollectionDebug.logEventRoute(NET_C_TREE_RCV_BEACON, rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->metric);
  
          //update neighbor table
--- 435,444 ----
          //need to get the am_addr_t of the source
          from = call LinkSrcPacket.getSrc(msg);
!         rcvBeacon = (ctp_routing_header_t*)payload;
  
!         dbg("TreeRouting","%s from: %d  [ parent: %d etx: %d]\n",
              __FUNCTION__, from, 
!             rcvBeacon->parent, rcvBeacon->etx);
!         //call CollectionDebug.logEventRoute(NET_C_TREE_RCV_BEACON, rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->etx);
  
          //update neighbor table
***************
*** 438,451 ****
              /* If this node is a root, request a forced insert in the link
               * estimator table and pin the node. */
!             if (rcvBeacon->hopcount == 0) {
                  dbg("TreeRouting","from a root, inserting if not in table\n");
                  call LinkEstimator.insertNeighbor(from);
                  call LinkEstimator.pinNeighbor(from);
              }
!             //TODO: also, if better than my current parent's path metric, insert
  
!             routingTableUpdateEntry(from, rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->metric);
          }
!         
          //post updateRouteTask();
          return msg;
--- 447,463 ----
              /* If this node is a root, request a forced insert in the link
               * estimator table and pin the node. */
!             if (rcvBeacon->etx == 0) {
                  dbg("TreeRouting","from a root, inserting if not in table\n");
                  call LinkEstimator.insertNeighbor(from);
                  call LinkEstimator.pinNeighbor(from);
              }
!             //TODO: also, if better than my current parent's path etx, insert
  
!             routingTableUpdateEntry(from, rcvBeacon->parent, rcvBeacon->etx);
          }
! 
! 	if (call CtpRoutingPacket.getOptions(msg) & CTP_OPT_PULL) {
! 	  resetInterval();
! 	}
          //post updateRouteTask();
          return msg;
***************
*** 482,499 ****
          return SUCCESS;
      }
!     command error_t CtpInfo.getHopcount(uint8_t* hopcount) {
!         if (hopcount == NULL) 
!             return FAIL;
!         if (routeInfo.parent == INVALID_ADDR)    
!             return FAIL;
!         *hopcount= routeInfo.hopcount;
!         return SUCCESS;
!     }
!     command error_t CtpInfo.getMetric(uint16_t* metric) {
!         if (metric == NULL) 
              return FAIL;
          if (routeInfo.parent == INVALID_ADDR)    
              return FAIL;
!         *metric = routeInfo.metric;
          return SUCCESS;
      }
--- 494,504 ----
          return SUCCESS;
      }
! 
!     command error_t CtpInfo.getEtx(uint16_t* etx) {
!         if (etx == NULL) 
              return FAIL;
          if (routeInfo.parent == INVALID_ADDR)    
              return FAIL;
!         *etx = routeInfo.etx;
          return SUCCESS;
      }
***************
*** 520,530 ****
              state_is_root = 1;
              routeInfo.parent = my_ll_addr; //myself
!             routeInfo.hopcount = 0;
!             routeInfo.metric = 0;
          }
          if (route_found) 
              signal Routing.routeFound();
          dbg("TreeRouting","%s I'm a root now!\n",__FUNCTION__);
!         call CollectionDebug.logEventRoute(NET_C_TREE_NEW_PARENT, routeInfo.parent, routeInfo.hopcount, routeInfo.metric);
          return SUCCESS;
      }
--- 525,534 ----
              state_is_root = 1;
              routeInfo.parent = my_ll_addr; //myself
!             routeInfo.etx = 0;
          }
          if (route_found) 
              signal Routing.routeFound();
          dbg("TreeRouting","%s I'm a root now!\n",__FUNCTION__);
!         call CollectionDebug.logEventRoute(NET_C_TREE_NEW_PARENT, routeInfo.parent, 0, routeInfo.etx);
          return SUCCESS;
      }
***************
*** 580,594 ****
  
  
!     error_t routingTableUpdateEntry(am_addr_t from, am_addr_t parent, 
!                             uint8_t hopcount, uint16_t metric)
!     {
          uint8_t idx;
!         uint16_t  linkMetric;
!         linkMetric = evaluateMetric(call LinkEstimator.getLinkQuality(from));
  
          idx = routingTableFind(from);
          if (idx == routingTableSize) {
              //not found and table is full
!             //if (passLinkMetricThreshold(linkMetric))
                  //TODO: add replacement here, replace the worst
              //}
--- 584,596 ----
  
  
!     error_t routingTableUpdateEntry(am_addr_t from, am_addr_t parent, uint16_t etx)    {
          uint8_t idx;
!         uint16_t  linkEtx;
!         linkEtx = evaluateEtx(call LinkEstimator.getLinkQuality(from));
  
          idx = routingTableFind(from);
          if (idx == routingTableSize) {
              //not found and table is full
!             //if (passLinkEtxThreshold(linkEtx))
                  //TODO: add replacement here, replace the worst
              //}
***************
*** 598,612 ****
          else if (idx == routingTableActive) {
              //not found and there is space
!             if (passLinkMetricThreshold(linkMetric)) {
                  atomic {
                      routingTable[idx].neighbor = from;
                      routingTable[idx].info.parent = parent;
!                     routingTable[idx].info.hopcount = hopcount;
!                     routingTable[idx].info.metric = metric;
                      routingTableActive++;
                  }
                  dbg("TreeRouting", "%s OK, new entry\n", __FUNCTION__);
              } else {
!                 dbg("TreeRouting", "%s Fail, link quality (%hu) below threshold\n", __FUNCTION__, linkMetric);
              }
          } else {
--- 600,613 ----
          else if (idx == routingTableActive) {
              //not found and there is space
!             if (passLinkEtxThreshold(linkEtx)) {
                  atomic {
                      routingTable[idx].neighbor = from;
                      routingTable[idx].info.parent = parent;
!                     routingTable[idx].info.etx = etx;
                      routingTableActive++;
                  }
                  dbg("TreeRouting", "%s OK, new entry\n", __FUNCTION__);
              } else {
!                 dbg("TreeRouting", "%s Fail, link quality (%hu) below threshold\n", __FUNCTION__, linkEtx);
              }
          } else {
***************
*** 615,620 ****
                  routingTable[idx].neighbor = from;
                  routingTable[idx].info.parent = parent;
!                 routingTable[idx].info.hopcount = hopcount;
!                 routingTable[idx].info.metric = metric;
              }
              dbg("TreeRouting", "%s OK, updated entry\n", __FUNCTION__);
--- 616,620 ----
                  routingTable[idx].neighbor = from;
                  routingTable[idx].info.parent = parent;
!                 routingTable[idx].info.etx = etx;
              }
              dbg("TreeRouting", "%s OK, updated entry\n", __FUNCTION__);
***************
*** 653,659 ****
          return SUCCESS;
      }
!     default command error_t CollectionDebug.logEventRoute(uint8_t type, am_addr_t parent, uint8_t hopcount, uint16_t metric) {
          return SUCCESS;
      }
!  
  } 
--- 653,679 ----
          return SUCCESS;
      }
!     default command error_t CollectionDebug.logEventRoute(uint8_t type, am_addr_t parent, uint8_t hopcount, uint16_t etx) {
          return SUCCESS;
      }
! 
!     command ctp_options_t CtpRoutingPacket.getOptions(message_t* msg) {
!       return getHeader(msg)->options;
!     }
!     command void          CtpRoutingPacket.setOptions(message_t* msg, ctp_options_t options) {
!       getHeader(msg)->options = options;
!     }
!     
!     command am_addr_t     CtpRoutingPacket.getParent(message_t* msg) {
!       return getHeader(msg)->parent;
!     }
!     command void          CtpRoutingPacket.setParent(message_t* msg, am_addr_t addr) {
!       getHeader(msg)->parent = addr;
!     }
!     
!     command uint16_t      CtpRoutingPacket.getEtx(message_t* msg) {
!       return getHeader(msg)->etx;
!     }
!     command void          CtpRoutingPacket.setEtx(message_t* msg, uint8_t etx) {
!       getHeader(msg)->etx = etx;
!     }
  } 

Index: CtpRoutingPacket.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/ctp/Attic/CtpRoutingPacket.nc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** CtpRoutingPacket.nc	25 Aug 2006 00:41:28 -0000	1.1.2.1
--- CtpRoutingPacket.nc	13 Sep 2006 01:41:57 -0000	1.1.2.2
***************
*** 50,53 ****
  
    command uint16_t      getEtx(message_t* msg);
!   command void          setEtx(message_t* msg, uint8_t seqno);
  }
--- 50,53 ----
  
    command uint16_t      getEtx(message_t* msg);
!   command void          setEtx(message_t* msg, uint8_t etx);
  }

Index: TreeRouting.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/ctp/Attic/TreeRouting.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** TreeRouting.h	29 Aug 2006 17:24:41 -0000	1.1.2.1
--- TreeRouting.h	13 Sep 2006 01:41:57 -0000	1.1.2.2
***************
*** 14,19 ****
  typedef struct {
      am_addr_t parent;
!     uint8_t hopcount;
!     uint16_t metric;
  } route_info_t;
  
--- 14,18 ----
  typedef struct {
      am_addr_t parent;
!     uint16_t etx;
  } route_info_t;
  
***************
*** 25,37 ****
  inline void routeInfoInit(route_info_t *ri) {
      ri->parent = INVALID_ADDR;
!     ri->hopcount = 0;
!     ri->metric = 0;
  }
  
- typedef nx_struct beacon_msg_t {
-     nx_am_addr_t parent;
-     nx_uint8_t hopcount;
-     nx_uint16_t metric;
- } beacon_msg_t;
- 
  #endif
--- 24,29 ----
  inline void routeInfoInit(route_info_t *ri) {
      ri->parent = INVALID_ADDR;
!     ri->etx = 0;
  }
  
  #endif



More information about the Tinyos-2-commits mailing list