X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Flib%2Fnet%2F4bitle%2FLinkEstimatorP.nc;h=3939424ec65f9a8c9ce5d3c048abc3247c1635bc;hb=55fa947e16b3e3841c76672149ab386e6f10be5e;hp=d993678c92107f785ac6eb9283dc81b15b37a7c3;hpb=0fad559edd06738bdccc1bfec25259db3c3bb258;p=tinyos-2.x.git diff --git a/tos/lib/net/4bitle/LinkEstimatorP.nc b/tos/lib/net/4bitle/LinkEstimatorP.nc index d993678c..3939424e 100644 --- a/tos/lib/net/4bitle/LinkEstimatorP.nc +++ b/tos/lib/net/4bitle/LinkEstimatorP.nc @@ -67,10 +67,12 @@ implementation { BEST_EETX = 0, INVALID_RVAL = 0xff, INVALID_NEIGHBOR_ADDR = 0xff, - INFINITY = 0xff, + // if we don't know the link quality, we need to return a value so + // large that it will not be used to form paths + VERY_LARGE_EETX_VALUE = 0xff, // decay the link estimate using this alpha // we use a denominator of 10, so this corresponds to 0.2 - ALPHA = 2, + ALPHA = 9, // number of packets to wait before computing a new // DLQ (Data-driven Link Quality) DLQ_PKT_WINDOW = 5, @@ -130,7 +132,8 @@ implementation { newPrevSentIdx = 0; for (i = 0; i < NEIGHBOR_TABLE_SIZE && j < maxEntries; i++) { k = (prevSentIdx + i + 1) % NEIGHBOR_TABLE_SIZE; - if (NeighborTable[k].flags & VALID_ENTRY) { + if ((NeighborTable[k].flags & VALID_ENTRY) && + (NeighborTable[k].flags & MATURE_ENTRY)) { footer->neighborList[j].ll_addr = NeighborTable[k].ll_addr; footer->neighborList[j].inquality = NeighborTable[k].inquality; newPrevSentIdx = k; @@ -295,11 +298,11 @@ implementation { if (q1 > 0) { q = 2550 / q1 - 10; if (q > 255) { - q = INFINITY; + q = VERY_LARGE_EETX_VALUE; } return (uint8_t)q; } else { - return INFINITY; + return VERY_LARGE_EETX_VALUE; } } @@ -393,9 +396,9 @@ implementation { for (i = 0; i < NEIGHBOR_TABLE_SIZE; i++) { 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, computeBidirEETX(ne->inquality, ne->outquality)); + dbg("LI,LITest", "%d:%d inQ=%d, inA=%d, rcv=%d, fail=%d, Q=%d\n", + i, ne->ll_addr, ne->inquality, ne->inage, + ne->rcvcnt, ne->failcnt, computeEETX(ne->inquality)); } } } @@ -437,14 +440,18 @@ implementation { } // return bi-directional link quality to the neighbor - command uint8_t LinkEstimator.getLinkQuality(am_addr_t neighbor) { + command uint16_t LinkEstimator.getLinkQuality(am_addr_t neighbor) { uint8_t idx; idx = findIdx(neighbor); if (idx == INVALID_RVAL) { - return INFINITY; + return VERY_LARGE_EETX_VALUE; } else { - return NeighborTable[idx].eetx; - }; + if (NeighborTable[idx].flags & MATURE_ENTRY) { + return NeighborTable[idx].eetx; + } else { + return VERY_LARGE_EETX_VALUE; + } + } } // insert the neighbor at any cost (if there is a room for it) @@ -690,9 +697,7 @@ implementation { // application payload pointer is just past the link estimation header command void* Packet.getPayload(message_t* msg, uint8_t len) { - linkest_header_t *hdr = getHeader(msg); - uint8_t footerLen = (hdr->flags & NUM_ENTRIES_FLAG) * sizeof(linkest_header_t); - void* payload = call SubPacket.getPayload(msg, len + footerLen); + void* payload = call SubPacket.getPayload(msg, len + sizeof(linkest_header_t)); if (payload != NULL) { payload += sizeof(linkest_header_t); }