[Tinyos-help] Is this a bug in Moteiv Boomerang MultiHop?

Adam shiyuan69 at gmail.com
Thu Jun 1 15:13:18 PDT 2006


In selectParent() function of MultihopLQIM.nc, is the following line a bug?
	if (parents[i].cost + parents[i].estimate < newparent) {

Should "newparent" be "parentestimate" ??
=======================

 void selectParent() {
    int i;
    int newparent = m_parent;
    uint16_t parentestimate = parents[m_parent].cost +
parents[m_parent].estimate;

    // if our parent is invalid, pick the best parent
    if (parents[m_parent].addr == MHOP_INVALID_PARENT) {
      for (i = 0; i < MHOP_PARENT_SIZE; i++) {
	if (parents[i].cost + parents[i].estimate < newparent) {
	  newparent = i;
	  parentestimate = parents[i].cost + parents[i].estimate;
	}
      }
    }
    // if we have a parent, don't switch unless they're worthwhile
    else {
      for (i = 0; i < MHOP_PARENT_SIZE; i++) {
	if (((uint32_t) parents[i].cost + (uint32_t) parents[i].estimate)
	    <
	    ((uint32_t) parentestimate) -
	    (((uint32_t) parentestimate) >> 2)) {
	  newparent = i;
	  parentestimate = parents[i].cost + parents[i].estimate;
	}
      }
    }
    m_parent = newparent;
  }



More information about the Tinyos-help mailing list