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

gnawali gnawali at users.sourceforge.net
Mon May 1 18:37:12 PDT 2006


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

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	LinkEstimatorP.nc 
Log Message:
return eetx, exp decay link quality

Index: LinkEstimatorP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/LinkEstimatorP.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
*** LinkEstimatorP.nc	1 May 2006 06:35:21 -0000	1.1.2.3
--- LinkEstimatorP.nc	2 May 2006 01:37:10 -0000	1.1.2.4
***************
*** 55,59 ****
  
  #define NEIGHBOR_TABLE_SIZE 10
! #define NEIGHBOR_AGE_TIMER 4096
  
    enum {
--- 55,59 ----
  
  #define NEIGHBOR_TABLE_SIZE 10
! #define NEIGHBOR_AGE_TIMER 8192
  
    enum {
***************
*** 64,68 ****
      MAX_QUALITY = 0xff,
      INVALID_RVAL = 0xff,
!     INVALID_NEIGHBOR_ADDR = 0xff
    };
  
--- 64,70 ----
      MAX_QUALITY = 0xff,
      INVALID_RVAL = 0xff,
!     INVALID_NEIGHBOR_ADDR = 0xff,
!     INFINITY = 0xff,
!     ALPHA = 2 // (out of 10, thus 0.2)
    };
  
***************
*** 151,156 ****
  
    uint8_t computeBidirLinkQuality(uint8_t inQuality, uint8_t outQuality) {
!     // estimator specific function to compute bi-directional quality
!     return ((inQuality + outQuality) >> 1);
    }
  
--- 153,157 ----
  
    uint8_t computeBidirLinkQuality(uint8_t inQuality, uint8_t outQuality) {
!     return ((inQuality * outQuality) >> 8);
    }
  
***************
*** 245,248 ****
--- 246,250 ----
      uint8_t i, totalPkt;
      neighbor_table_entry_t *ne;
+     uint8_t newEst;
      
      for (i = 0; i < NEIGHBOR_TABLE_SIZE; i++) {
***************
*** 259,265 ****
  	  totalPkt = ne->rcvcnt + ne->failcnt;
  	  if (totalPkt == 0) {
! 	    ne->inquality = 0;
  	  } else {
! 	    ne->inquality = (255 * ne->rcvcnt) / totalPkt;
  	  }
  	  ne->rcvcnt = 0;
--- 261,268 ----
  	  totalPkt = ne->rcvcnt + ne->failcnt;
  	  if (totalPkt == 0) {
! 	    ne->inquality = (ALPHA * ne->inquality) / 10;
  	  } else {
! 	    newEst = (255 * ne->rcvcnt) / totalPkt;
! 	    ne->inquality = (ALPHA * ne->inquality + (10-ALPHA) * newEst)/10;
  	  }
  	  ne->rcvcnt = 0;
***************
*** 306,317 ****
    }
  
    command uint8_t LinkEstimator.getLinkQuality(uint16_t neighbor) {
      uint8_t idx;
      idx = findIdx(neighbor);
      if (idx == INVALID_RVAL) {
!       return 0;
      } else {
!       return computeBidirLinkQuality(NeighborTable[idx].inquality,
! 				     NeighborTable[idx].outquality);
      };
    }
--- 309,352 ----
    }
  
+   // EETX (Extra Expected number of Transmission)
+   // EETX = ETX - 1
+   // computeEETX returns EETX*10
+ 
+   uint8_t computeEETX(uint8_t q1) {
+     uint16_t q;
+     if (q1 > 0) {
+       q =  2550 / q1 - 10;
+       if (q > 255) {
+ 	q = INFINITY;
+       }
+       return (uint8_t)q;
+     } else {
+       return INFINITY;
+     }
+   }
+ 
+   uint8_t computeBidirEETX(uint8_t q1, uint8_t q2) {
+     uint16_t q;
+     if ((q1 > 0) && (q2 > 0)) {
+       q =  65025 / q1;
+       q = (10*q) / q2 - 10;
+       if (q > 255) {
+ 	q = INFINITY;
+       }
+       return (uint8_t)q;
+     } else {
+       return INFINITY;
+     }
+   }
+ 
+ 
    command uint8_t LinkEstimator.getLinkQuality(uint16_t neighbor) {
      uint8_t idx;
      idx = findIdx(neighbor);
      if (idx == INVALID_RVAL) {
!       return INFINITY;
      } else {
!       return computeBidirEETX(NeighborTable[idx].inquality,
! 			      NeighborTable[idx].outquality);
      };
    }
***************
*** 321,327 ****
      idx = findIdx(neighbor);
      if (idx == INVALID_RVAL) {
!       return 0;
      } else {
!       return NeighborTable[idx].inquality;
      };
    }
--- 356,362 ----
      idx = findIdx(neighbor);
      if (idx == INVALID_RVAL) {
!       return INFINITY;
      } else {
!       return computeEETX(NeighborTable[idx].inquality);
      };
    }
***************
*** 329,337 ****
    command uint8_t LinkEstimator.getForwardQuality(uint16_t neighbor) {
      uint8_t idx;
      idx = findIdx(neighbor);
      if (idx == INVALID_RVAL) {
!       return 0;
      } else {
!       return NeighborTable[idx].outquality;
      };
    }
--- 364,373 ----
    command uint8_t LinkEstimator.getForwardQuality(uint16_t neighbor) {
      uint8_t idx;
+     uint16_t q;
      idx = findIdx(neighbor);
      if (idx == INVALID_RVAL) {
!       return INFINITY;
      } else {
!       return computeEETX(NeighborTable[idx].outquality);
      };
    }
***************
*** 365,372 ****
    }
  
- 
-   printOutboundQualities(linkest_footer_t* f) {
-   }
- 
    event message_t* SubReceive.receive(message_t* msg,
  				      void* payload,
--- 401,404 ----
***************
*** 380,384 ****
        print_neighbor_table();
  
-       atomic {
        // update neighbor table with this information
        nidx = findIdx(hdr->ll_addr);
--- 412,415 ----
***************
*** 398,402 ****
  	updateNeighborEntryIdx(nidx, hdr->seq);
        }
-       }
  
        if (hdr->linkest_footer_offset > 0) {
--- 429,432 ----



More information about the Tinyos-2-commits mailing list