[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/collection ForwardingEngineP.nc, 1.1.2.12, 1.1.2.13 LinkEstimatorP.nc, 1.1.2.9, 1.1.2.10 TreeCollectionC.nc, 1.1.2.7, 1.1.2.8 TreeRoutingEngineP.nc, 1.1.2.6, 1.1.2.7

Phil Levis scipio at users.sourceforge.net
Thu Jun 1 19:10:21 PDT 2006


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

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	ForwardingEngineP.nc LinkEstimatorP.nc TreeCollectionC.nc 
	TreeRoutingEngineP.nc 
Log Message:
A bunch of bug fixes:

1) Sukun's send problem was due to ForwardingEngineP not freeing a send
queue entry when it sent a packet: the memory leak cause it to think that
its queue was full.

2) Found a bug in the interactions between the router and the link
estimator where the router could receive beacon packets it did not
originate. The current fix is a hack, but works. The estimator sends 
its own beacons if it thinks it needs to; as they are the same AM type,
received LE beacons are signaled to the router. But as the router did
not put a payload into them, if it looks for one it reads garbage. Also,
the Router's calculation of payload size was incorrect: should be
sizeof(beacon_msg_t), not sizeof(beacon_msg_t*).

Test the tree formation and link estimation with simple topology. Seems
to be working OK. Nodes prefer links with more hops if the metric is
smaller. It's tough to determine how good the ETX measure is, but it seems 
in the right ballpark.



Index: ForwardingEngineP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/ForwardingEngineP.nc,v
retrieving revision 1.1.2.12
retrieving revision 1.1.2.13
diff -C2 -d -r1.1.2.12 -r1.1.2.13
*** ForwardingEngineP.nc	23 May 2006 20:55:55 -0000	1.1.2.12
--- ForwardingEngineP.nc	2 Jun 2006 02:10:19 -0000	1.1.2.13
***************
*** 139,142 ****
--- 139,143 ----
  
      if (call QEntryPool.empty()) {
+       dbg("PhilTest", "Send failed as pool is empty.\n");
        // Queue pool is empty; fail the send.
        return EBUSY;
***************
*** 154,157 ****
--- 155,159 ----
      }
      else {
+       dbg("PhilTest", "Send failed as packet could not be enqueued.\n");
        return FAIL;
      }
***************
*** 195,198 ****
--- 197,201 ----
  	// Successfully submitted to the data-link layer.
  	sending = TRUE;
+         call QEntryPool.put(qe);
          return;
        }

Index: LinkEstimatorP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/LinkEstimatorP.nc,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -C2 -d -r1.1.2.9 -r1.1.2.10
*** LinkEstimatorP.nc	30 May 2006 06:32:34 -0000	1.1.2.9
--- LinkEstimatorP.nc	2 Jun 2006 02:10:19 -0000	1.1.2.10
***************
*** 340,344 ****
  	  } else {
  	    newEst = (255 * ne->rcvcnt) / totalPkt;
! 	    dbg("LI", "  %hu: %hhu -> %hhu", ne->ll_addr, ne->inquality, (ALPHA * ne->inquality + (10-ALPHA) * newEst)/10);
  	    ne->inquality = (ALPHA * ne->inquality + (10-ALPHA) * newEst)/10;
  	  }
--- 340,344 ----
  	  } else {
  	    newEst = (255 * ne->rcvcnt) / totalPkt;
! 	    dbg("LI,LITest", "  %hu: %hhu -> %hhu", ne->ll_addr, ne->inquality, (ALPHA * ne->inquality + (10-ALPHA) * newEst)/10);
  	    ne->inquality = (ALPHA * ne->inquality + (10-ALPHA) * newEst)/10;
  	  }
***************
*** 360,364 ****
        ne = &NeighborTable[i];
        if (ne->flags & VALID_ENTRY) {
! 	dbg("LI", "%d:%d inQ=%d, inA=%d, outQ=%d, outA=%d, rcv=%d, fail=%d, biQ=%d\n",
  	    i, ne->ll_addr, ne->inquality, ne->inage, ne->outquality, ne->outage,
  	    ne->rcvcnt, ne->failcnt, computeBidirLinkQuality(ne->inquality, ne->outquality));
--- 360,364 ----
        ne = &NeighborTable[i];
        if (ne->flags & VALID_ENTRY) {
! 	dbg("LI,LITest", "%d:%d inQ=%d, inA=%d, outQ=%d, outA=%d, rcv=%d, fail=%d, biQ=%d\n",
  	    i, ne->ll_addr, ne->inquality, ne->inage, ne->outquality, ne->outage,
  	    ne->rcvcnt, ne->failcnt, computeBidirLinkQuality(ne->inquality, ne->outquality));
***************
*** 428,432 ****
    // send beacon if it is time
    event void Timer.fired() {
!     dbg("LI", "Linkestimator timer fired\n");
  
      curEstInterval = (curEstInterval + 1) % TABLEUPDATE_INTERVAL;
--- 428,432 ----
    // send beacon if it is time
    event void Timer.fired() {
!     dbg("LI,LITest", "Linkestimator timer fired\n");
  
      curEstInterval = (curEstInterval + 1) % TABLEUPDATE_INTERVAL;
***************
*** 554,559 ****
  
      curBeaconInterval = 0;
- 
      newlen = addLinkEstHeaderAndFooter(msg, len);
      dbg("LI", "Sending seq: %d\n", linkEstSeq);
      print_packet(msg, newlen);
--- 554,559 ----
  
      curBeaconInterval = 0;
      newlen = addLinkEstHeaderAndFooter(msg, len);
+     dbg("LITest", "%s packet of length %hhu became %hhu\n", __FUNCTION__, len, newlen);
      dbg("LI", "Sending seq: %d\n", linkEstSeq);
      print_packet(msg, newlen);
***************
*** 571,575 ****
    }
  
!   // cascade the send call down
    command uint8_t Send.cancel(message_t* msg) {
      return call AMSend.cancel(msg);
--- 571,575 ----
    }
  
!   // cascade the send call down    if (call Packet.payloadLength
    command uint8_t Send.cancel(message_t* msg) {
      return call AMSend.cancel(msg);
***************
*** 661,665 ****
  
      }
!     
      return signal Receive.receive(msg,
  				  call Packet.getPayload(msg, NULL),
--- 661,665 ----
  
      }
! 
      return signal Receive.receive(msg,
  				  call Packet.getPayload(msg, NULL),

Index: TreeCollectionC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/TreeCollectionC.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
*** TreeCollectionC.nc	26 May 2006 00:25:55 -0000	1.1.2.7
--- TreeCollectionC.nc	2 Jun 2006 02:10:19 -0000	1.1.2.8
***************
*** 55,58 ****
--- 55,59 ----
    components new TreeRoutingEngineP(TREE_ROUTING_TABLE_SIZE) as Router;
    StdControl = Router;
+   StdControl = Estimator;
    RootControl = Router;
    MainC.SoftwareInit -> Router;

Index: TreeRoutingEngineP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/TreeRoutingEngineP.nc,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -d -r1.1.2.6 -r1.1.2.7
*** TreeRoutingEngineP.nc	26 May 2006 00:25:55 -0000	1.1.2.6
--- TreeRoutingEngineP.nc	2 Jun 2006 02:10:19 -0000	1.1.2.7
***************
*** 182,195 ****
          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);
- 
-             if (entry->info.parent == INVALID_ADDR) continue;
-             //avoid 1-hop loops    
-             if (entry->info.parent == my_ll_addr) continue;
  
              linkMetric = evaluateMetric(call LinkEstimator.getLinkQuality(entry->neighbor));
! 	    dbg("TreeRouting", "   metric: %hu.\n", linkMetric);
              pathMetric =linkMetric + entry->info.metric;
              //for current parent
--- 182,195 ----
          for (i = 0; i < routingTableActive; i++) {
              entry = &routingTable[i];
  
+ 	    // Avoid bad entries and 1-hop loops
+             if (entry->info.parent == INVALID_ADDR || entry->info.parent == my_ll_addr) {
+ 	      dbg("TreeRouting,LITest", "routingTable[%d]: neighbor: [id: %d parent: %d hopcount: %d metric: NO ROUTE]\n",  i, entry->neighbor, entry->info.parent, entry->info.hopcount);
+ 	      continue;
+ 	    }
+ 	    
              linkMetric = evaluateMetric(call LinkEstimator.getLinkQuality(entry->neighbor));
! 	    dbg("TreeRouting,LITest", "routingTable[%d]: neighbor: [id: %d parent: %d hopcount: %d metric: %d]\n",  i, entry->neighbor, entry->info.parent, entry->info.hopcount, linkMetric);
! 	    dbg_clear("TreeRouting,LITest", "   metric: %hu.\n", linkMetric);
              pathMetric =linkMetric + entry->info.metric;
              //for current parent
***************
*** 244,249 ****
              return;
          }
!         beaconMsg->parent = routeInfo.parent;
!         beaconMsg->hopcount = routeInfo.hopcount;
          if (state_is_root || routeInfo.parent == INVALID_ADDR) {
              beaconMsg->metric = routeInfo.metric;
--- 244,250 ----
              return;
          }
! 	beaconMsg->parent = routeInfo.parent;
! 	beaconMsg->hopcount = routeInfo.hopcount;
! 
          if (state_is_root || routeInfo.parent == INVALID_ADDR) {
              beaconMsg->metric = routeInfo.metric;
***************
*** 253,257 ****
          }
  
!         dbg("TreeRouting", "%s parent: %d hopcount: %d metric: %d\n",
                    __FUNCTION__,
                    beaconMsg->parent, 
--- 254,258 ----
          }
  
!         dbg("TreeRouting,LITest", "%s parent: %d hopcount: %d metric: %d\n",
                    __FUNCTION__,
                    beaconMsg->parent, 
***************
*** 261,265 ****
          eval = call BeaconSend.send(AM_BROADCAST_ADDR, 
                                      &beaconMsgBuffer, 
!                                     sizeof(beaconMsg));
          if (eval == SUCCESS) {
              sending = TRUE;
--- 262,266 ----
          eval = call BeaconSend.send(AM_BROADCAST_ADDR, 
                                      &beaconMsgBuffer, 
!                                     sizeof(beacon_msg_t));
          if (eval == SUCCESS) {
              sending = TRUE;
***************
*** 295,303 ****
          beacon_msg_t* rcvBeacon;
  
          //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);
--- 296,311 ----
          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;
+ 	}
+ 	
          //need to get the am_addr_t of the source
          from = call LinkSrcPacket.getSrc(msg);
          rcvBeacon = (beacon_msg_t*)payload;
  
!         dbg("TreeRouting,LITest","%s from: %d  [ parent: %d hopcount: %d metric: %d]\n",
              __FUNCTION__, from, 
              rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->metric);



More information about the Tinyos-2-commits mailing list