X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Flib%2Fnet%2F4bitle%2FLinkEstimatorP.nc;h=80360f26d4210280f26531b704b306db7ddab93b;hb=cc7acd52ff4da91bfa000fc670a2a8256d872174;hp=a90d0b1ebf9c9599d2916b089877dbaccd9ee6fe;hpb=391a8bf5861d4ee6074ad09164651abe4dc06671;p=tinyos-2.x.git diff --git a/tos/lib/net/4bitle/LinkEstimatorP.nc b/tos/lib/net/4bitle/LinkEstimatorP.nc index a90d0b1e..80360f26 100644 --- a/tos/lib/net/4bitle/LinkEstimatorP.nc +++ b/tos/lib/net/4bitle/LinkEstimatorP.nc @@ -328,16 +328,9 @@ implementation { ne->flags |= MATURE_ENTRY; totalPkt = ne->rcvcnt + ne->failcnt; dbg("LI", "MinPkt: %d, totalPkt: %d\n", minPkt, totalPkt); - if (totalPkt < minPkt) { - totalPkt = minPkt; - } - if (totalPkt == 0) { - ne->inquality = (ALPHA * ne->inquality) / 10; - } else { - newEst = (250UL * 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; - } + newEst = (250UL * 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; ne->rcvcnt = 0; ne->failcnt = 0; updateETX(ne, computeETX(ne->inquality)); @@ -357,7 +350,6 @@ implementation { if (NeighborTable[idx].flags & INIT_ENTRY) { dbg("LI", "Init entry update\n"); - NeighborTable[idx].lastseq = seq; NeighborTable[idx].flags &= ~INIT_ENTRY; } @@ -370,19 +362,15 @@ implementation { NeighborTable[idx].failcnt += packetGap - 1; } - // The or with packetGap >= BLQ_PKT_WINDOW is needed in case - // failcnt gets reset above - - if (((NeighborTable[idx].rcvcnt + NeighborTable[idx].failcnt) >= BLQ_PKT_WINDOW) - || (packetGap >= BLQ_PKT_WINDOW)) { - updateNeighborTableEst(NeighborTable[idx].ll_addr); - } - if (packetGap > MAX_PKT_GAP) { initNeighborIdx(idx, NeighborTable[idx].ll_addr); NeighborTable[idx].lastseq = seq; NeighborTable[idx].rcvcnt = 1; + } else if (((NeighborTable[idx].rcvcnt + NeighborTable[idx].failcnt) >= BLQ_PKT_WINDOW) + || (packetGap >= BLQ_PKT_WINDOW)) { + updateNeighborTableEst(NeighborTable[idx].ll_addr); } + }