[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/le LinkEstimator.h, 1.1.2.1, 1.1.2.2 LinkEstimator.nc, 1.1.2.1, 1.1.2.2 LinkEstimatorP.nc, 1.1.2.1, 1.1.2.2

Omprakash Gnawali gnawali at users.sourceforge.net
Thu Oct 5 01:08:20 PDT 2006


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

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	LinkEstimator.h LinkEstimator.nc LinkEstimatorP.nc 
Log Message:
changes in the linkestimator so that we use data transmission success/failure information to estimate the etx as well as beacons

Index: LinkEstimator.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/le/Attic/LinkEstimator.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
*** LinkEstimator.h	29 Aug 2006 17:24:41 -0000	1.1.2.1
--- LinkEstimator.h	5 Oct 2006 08:08:18 -0000	1.1.2.2
***************
*** 100,103 ****
--- 100,106 ----
    uint8_t inquality;
    uint8_t outquality;
+   uint16_t etx;
+   uint8_t data_success;
+   uint8_t data_total;
  } neighbor_table_entry_t;
  

Index: LinkEstimator.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/le/Attic/LinkEstimator.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
*** LinkEstimator.nc	29 Aug 2006 17:24:41 -0000	1.1.2.1
--- LinkEstimator.nc	5 Oct 2006 08:08:18 -0000	1.1.2.2
***************
*** 53,56 ****
--- 53,67 ----
    command error_t unpinNeighbor(am_addr_t neighbor);
  
+   /* called when an acknowledgement is received; sign of a successful
+      data transmission; to update forward link quality */
+   command error_t txAck(am_addr_t neighbor);
+ 
+   /* called when an acknowledgement is not received; could be due to
+      data pkt or acknowledgement loss; to update forward link quality */
+   command error_t txNoAck(am_addr_t neighbor);
+ 
+   /* called when the parent changes; clear state about data-driven link quality  */
+   command error_t clearDLQ(am_addr_t neighbor);
+ 
    /* signal when this neighbor is evicted from the neighbor table */
    event void evicted(am_addr_t neighbor);

Index: LinkEstimatorP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/le/Attic/LinkEstimatorP.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
*** LinkEstimatorP.nc	29 Aug 2006 17:24:41 -0000	1.1.2.1
--- LinkEstimatorP.nc	5 Oct 2006 08:08:18 -0000	1.1.2.2
***************
*** 79,83 ****
      // decay the link estimate using this alpha
      // we use a denominator of 10, so this corresponds to 0.2
!     ALPHA = 2 
    };
  
--- 79,86 ----
      // decay the link estimate using this alpha
      // we use a denominator of 10, so this corresponds to 0.2
!     ALPHA = 2,
!     // number of packets to wait before computing a new
!     // DLQ (Data-driven Link Quality)
!     DLQ_PKT_WINDOW = 5
    };
  
***************
*** 281,284 ****
--- 284,336 ----
    }
  
+   // update the ETX estimator
+   // called when new beacon estimate is done
+   // also called when new DETX estimate is done
+   void updateETX(neighbor_table_entry_t *ne, uint16_t newEst) {
+     ne->etx = (ALPHA * ne->etx + (10 - ALPHA) * newEst)/10;
+   }
+ 
+ 
+   // update data driven ETX
+   void updateDETX(neighbor_table_entry_t *ne) {
+     uint16_t estETX= (10 * ne->data_success) / ne->data_total - 10;
+     updateETX(ne, estETX);
+     ne->data_success = 0;
+     ne->data_total = 0;
+   }
+ 
+ 
+   // 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;
+     }
+   }
+ 
+   // BidirETX = 1 / (q1*q2)
+   // BidirEETX = BidirETX - 1
+   // computeBidirEETX return BidirEETX*10
+   uint8_t computeBidirEETX(uint8_t q1, uint8_t q2) {
+     uint16_t q;
+     if ((q1 > 0) && (q2 > 0)) {
+       q =  65025u / q1;
+       q = (10*q) / q2 - 10;
+       if (q > 255) {
+ 	q = INFINITY;
+       }
+       return (uint8_t)q;
+     } else {
+       return INFINITY;
+     }
+   }
  
    // update the inbound link quality by
***************
*** 302,305 ****
--- 354,358 ----
  	if ((ne->inage == 0) && (ne->outage == 0)) {
  	  ne->flags ^= VALID_ENTRY;
+ 	  ne->inquality = ne->outquality = 0;
  	} else {
  	  dbg("LI", "Making link: %d mature\n", i);
***************
*** 320,323 ****
--- 373,377 ----
  	  ne->failcnt = 0;
  	}
+ 	updateETX(ne, computeBidirEETX(ne->inquality, ne->outquality));
        }
        else {
***************
*** 423,459 ****
    }
  
-   // 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;
-     }
-   }
- 
-   // BidirETX = 1 / (q1*q2)
-   // BidirEETX = BidirETX - 1
-   // computeBidirEETX return BidirEETX*10
-   uint8_t computeBidirEETX(uint8_t q1, uint8_t q2) {
-     uint16_t q;
-     if ((q1 > 0) && (q2 > 0)) {
-       q =  65025u / q1;
-       q = (10*q) / q2 - 10;
-       if (q > 255) {
- 	q = INFINITY;
-       }
-       return (uint8_t)q;
-     } else {
-       return INFINITY;
-     }
-   }
- 
    // return bi-directional link quality to the neighbor
    command uint8_t LinkEstimator.getLinkQuality(am_addr_t neighbor) {
--- 477,480 ----
***************
*** 463,468 ****
--- 484,492 ----
        return INFINITY;
      } else {
+       /*
        return computeBidirEETX(NeighborTable[idx].inquality,
  			      NeighborTable[idx].outquality);
+       */
+       return NeighborTable[idx].etx - 10;
      };
    }
***************
*** 540,543 ****
--- 564,614 ----
  
  
+   // called when an acknowledgement is received; sign of a successful
+   // data transmission; to update forward link quality
+   command error_t LinkEstimator.txAck(am_addr_t neighbor) {
+     neighbor_table_entry_t *ne;
+     uint8_t nidx = findIdx(neighbor);
+     if (nidx == INVALID_RVAL) {
+       return FAIL;
+     }
+     ne = &NeighborTable[nidx];
+     ne->data_success++;
+     ne->data_total++;
+     if (ne->data_total >= DLQ_PKT_WINDOW) {
+       updateDETX(ne);
+     }
+     return SUCCESS;
+   }
+ 
+   // called when an acknowledgement is not received; could be due to
+   // data pkt or acknowledgement loss; to update forward link quality
+   command error_t LinkEstimator.txNoAck(am_addr_t neighbor) {
+     neighbor_table_entry_t *ne;
+     uint8_t nidx = findIdx(neighbor);
+     if (nidx == INVALID_RVAL) {
+       return FAIL;
+     }
+ 
+     ne = &NeighborTable[nidx];
+     ne->data_total++;
+     if (ne->data_total >= DLQ_PKT_WINDOW) {
+       updateDETX(ne);
+     }
+     return SUCCESS;
+   }
+ 
+   /* called when the parent changes; clear state about data-driven link quality  */
+   command error_t LinkEstimator.clearDLQ(am_addr_t neighbor) {
+     neighbor_table_entry_t *ne;
+     uint8_t nidx = findIdx(neighbor);
+     if (nidx == INVALID_RVAL) {
+       return FAIL;
+     }
+     ne = &NeighborTable[nidx];
+     ne->data_total = 0;
+     ne->data_success = 0;
+   }
+ 
+ 
    // get the link layer source address for the incoming packet
    command am_addr_t LinkSrcPacket.getSrc(message_t* msg) {



More information about the Tinyos-2-commits mailing list