[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/collection TreeRoutingEngineP.nc, 1.1.2.2, 1.1.2.3

Rodrigo Fonseca rfonseca76 at users.sourceforge.net
Tue May 16 15:51:36 PDT 2006


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

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	TreeRoutingEngineP.nc 
Log Message:
A number of small fixes.

Index: TreeRoutingEngineP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/TreeRoutingEngineP.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
*** TreeRoutingEngineP.nc	15 May 2006 16:46:35 -0000	1.1.2.2
--- TreeRoutingEngineP.nc	16 May 2006 22:51:33 -0000	1.1.2.3
***************
*** 1,4 ****
--- 1,5 ----
  #include <Timer.h>
  #include <TreeRouting.h>
+ #define TEST_INSERT
  /* $Id$ */
  /*
***************
*** 85,88 ****
--- 86,93 ----
      error_t routingTableUpdateEntry(am_addr_t, am_addr_t , uint8_t, uint16_t);
      error_t routingTableEvict(am_addr_t neighbor);
+ #ifdef TEST_INSERT
+     error_t routingTableInsert(am_addr_t from);
+     uint8_t victim;
+ #endif
  
  
***************
*** 97,100 ****
--- 102,108 ----
          beaconMsg = call BeaconSend.getPayload(&beaconMsgBuffer);
          dbg("TreeRoutingCtl","TreeRouting initialized!\n");
+ #ifdef TEST_INSERT
+         victim = 0;
+ #endif
          return SUCCESS;
      }
***************
*** 144,147 ****
--- 152,156 ----
       * 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);
      }
***************
*** 170,174 ****
          for (i = 0; i < routingTableActive; i++) {
              entry = &routingTable[i];
!             dbg("TreeRouting", "routingTable[%d]: neighbor: [parent: %d hopcount: %d metric:%d ]\n", 
                           i, entry->neighbor, entry->info.parent, entry->info.hopcount,
                              entry->info.metric);
--- 179,183 ----
          for (i = 0; i < routingTableActive; i++) {
              entry = &routingTable[i];
!             dbg("TreeRouting", "routingTable[%d]: neighbor: [id: %d parent: %d hopcount: %d metric:%d ]\n", 
                           i, entry->neighbor, entry->info.parent, entry->info.hopcount,
                              entry->info.metric);
***************
*** 233,237 ****
          } else {
              beaconMsg->metric = routeInfo.metric +
!                                 call LinkEstimator.getLinkQuality(routeInfo.parent); 
          }
  
--- 242,246 ----
          } else {
              beaconMsg->metric = routeInfo.metric +
!                                 evaluateMetric(call LinkEstimator.getLinkQuality(routeInfo.parent)); 
          }
  
***************
*** 286,290 ****
              rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->metric);
          //update neighbor table
!         routingTableUpdateEntry(from, rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->metric);
          
          //post updateRouteTask();
--- 295,307 ----
              rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->metric);
          //update neighbor table
!         if (rcvBeacon->parent != INVALID_ADDR) {
! #ifdef TEST_INSERT
!         if (rcvBeacon->hopcount == 0) {
!             dbg("TreeRouting","from a root, inserting if not in table\n");
!             routingTableInsert(from);
!         }
! #endif
!             routingTableUpdateEntry(from, rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->metric);
!         }
          
          //post updateRouteTask();
***************
*** 380,383 ****
--- 397,434 ----
      }
  
+ 
+ #ifdef TEST_INSERT
+     /* Temporary function mostly for testing. this should be implemented
+      * in the link estimator table */
+     error_t routingTableInsert(am_addr_t from) {
+         uint8_t idx, i;
+         //static uint8_t victim = 0;
+         idx = routingTableFind(from);
+         if (idx == routingTableSize) {
+             //table is full: replace someone not root and not parent
+             for (i = 0; i < routingTableActive; i++) {
+                 idx = (victim + 1) % routingTableActive;
+                 if (routingTable[idx].info.parent == INVALID_ADDR ||
+                     (routingTable[idx].info.hopcount != 0 &&
+                      routeInfo.parent != routingTable[idx].neighbor))
+                     break;
+             }
+             if (i == routingTableActive) 
+                 return FAIL;
+             victim = (victim + i) % routingTableActive;
+             idx = victim;
+             dbg("TreeRouting", "%s table full replacing idx %d\n", __FUNCTION__,idx);
+         } else if (idx == routingTableActive) {
+             //not found and there is space
+             dbg("TreeRouting", "%s table not full inserting at idx %d\n", __FUNCTION__,idx);
+             routingTableActive++;
+         }
+         //replace victim
+         routingTable[idx].neighbor = from;
+         routeInfoInit(&routingTable[idx].info);
+         return SUCCESS;
+     }
+ #endif
+ 
      error_t routingTableUpdateEntry(am_addr_t from, am_addr_t parent, 
                              uint8_t hopcount, uint16_t metric)



More information about the Tinyos-2-commits mailing list