亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? multihopewma.nc

?? MultiHopEngineM多跳路由鄰居表3
?? NC
?? 第 1 頁 / 共 2 頁
字號:

    //now pick between old and new.
    if(pNewParent == NULL) {
	//use the old parent unless it is null;
	pNewParent = pOldParent;
        ulMinTotalCost = oldParentCost;
    } else if((pOldParent != NULL) &&
              (oldParentCost < (SWITCH_THRESHOLD + ulMinTotalCost))){
	//both valid, but use the old parent 
	pNewParent = pOldParent;
        ulMinTotalCost = oldParentCost;
    }

    if (pNewParent) {
      atomic {
        gpCurrentParent = pNewParent;
        gbCurrentHopCount = pNewParent->hop + 1;
        gbCurrentCost = ulMinTotalCost >> 6;
      }
    } else {
      atomic {
        gpCurrentParent = NULL;
        gbCurrentHopCount = ROUTE_INVALID;
        gbCurrentCost = ROUTE_INVALID;
      }

    }
  }

  uint8_t last_entry_sent;

  task void SendRouteTask() {
    TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *) &routeMsg.data[0];
    RoutePacket *pRP = (RoutePacket *)&pMHMsg->data[0];
    struct SortEntry sortTbl[ROUTE_TABLE_SIZE];
    uint8_t length = offsetof(TOS_MHopMsg,data) + offsetof(RoutePacket,estList);
    uint8_t maxEstEntries;
    uint8_t i,j;
    uint8_t last_index_added = 0;

    if (gfSendRouteBusy) {
      return;
    }

    dbg(DBG_ROUTE,"MultiHopEWMA Sending route update msg.\n");
    dbg(DBG_ROUTE,"Current cost: %d.\n", gbCurrentCost);

    maxEstEntries = TOSH_DATA_LENGTH - length;
    maxEstEntries = maxEstEntries / sizeof(RPEstEntry);


    pRP->parent = (gpCurrentParent) ? gpCurrentParent->id : ROUTE_INVALID;
    pRP->cost = gbCurrentCost; 

    for (i = 0,j = 0;i < ROUTE_TABLE_SIZE && j < maxEstEntries; i++) {
      uint8_t table_index = i + last_entry_sent + 1;
      if(table_index >= ROUTE_TABLE_SIZE) table_index -=ROUTE_TABLE_SIZE;
      if (NeighborTbl[table_index].flags & NBRFLAG_VALID && NeighborTbl[table_index].receiveEst > 100) {
        pRP->estList[j].id = NeighborTbl[table_index].id;
        pRP->estList[j].receiveEst = NeighborTbl[table_index].receiveEst;
	j ++;
        length += sizeof(RPEstEntry);
	last_index_added = table_index;
        dbg(DBG_ROUTE,"Adding %d to route msg.\n", pRP->estList[j].id);
      }
    }
    last_entry_sent = last_index_added;
    dbg(DBG_ROUTE,"Added total of %d entries to route msg.\n", j);
    pRP->estEntries = j;
    pMHMsg->sourceaddr = pMHMsg->originaddr = TOS_LOCAL_ADDRESS;
    pMHMsg->hopcount = gbCurrentHopCount;
    pMHMsg->seqno = gCurrentSeqNo++;

    if (call SendMsg.send(TOS_BCAST_ADDR, length, &routeMsg) == SUCCESS) {
      gfSendRouteBusy = TRUE;
    }

  }


  task void SendDebugTask() {
    struct SortDbgEntry sortTbl[ROUTE_TABLE_SIZE];
    uint16_t max_length;
    uint8_t length = offsetof(DebugPacket,estList);
    DebugPacket *pRP = (DebugPacket *)call DebugSendMsg.getBuffer(&debugMsg,&max_length);
    uint8_t maxEstEntries;
    uint16_t parent;
    uint8_t i,j;

    dbg(DBG_ROUTE,"MultiHopEWMA Sending route debug msg.\n");

    maxEstEntries = max_length / sizeof(DBGEstEntry);
    maxEstEntries --;
    parent = (gpCurrentParent) ? gpCurrentParent->id : ROUTE_INVALID;

    for (i = 0,j = 0;i < ROUTE_TABLE_SIZE; i++) {
      if (NeighborTbl[i].flags & NBRFLAG_VALID && NeighborTbl[i].id != parent) {
        sortTbl[j].id = NeighborTbl[i].id;
        sortTbl[j].sendEst = NeighborTbl[i].sendEst;
        sortTbl[j].hopcount = NeighborTbl[i].hop;
        j++;
      }
    }
    qsort (sortTbl,j,sizeof(struct SortDbgEntry),sortDebugEstFcn);

    pRP->estEntries = (j > maxEstEntries) ? maxEstEntries : j;
    pRP->estList[0].id = parent;
    if(gpCurrentParent){
	pRP->estList[0].sendEst = gpCurrentParent->sendEst;
	pRP->estList[0].hopcount = gpCurrentParent->hop;
    }
    length += sizeof(DBGEstEntry);

    for (i = 0; i < pRP->estEntries; i++) {
      pRP->estList[i+1].id = sortTbl[i].id;
      pRP->estList[i+1].sendEst = sortTbl[i].sendEst;
      pRP->estList[i+1].hopcount = sortTbl[i].hopcount;
      length += sizeof(DBGEstEntry);
    }
    pRP->estEntries ++;
    call DebugSendMsg.send(&debugMsg, length);

  }

  int debugCounter;

  task void TimerTask() {
    
    dbg(DBG_ROUTE,"MultiHopEWMA timer task.\n");
    updateTable();

#ifndef NDEBUG
    {
      int i;
      dbg(DBG_ROUTE,"\taddr\tprnt\tcost\tmisd\trcvd\tlstS\thop\trEst\tsEst\tDesc\n");
      for (i = 0;i < ROUTE_TABLE_SIZE;i++) {
        if (NeighborTbl[i].flags) {
          dbg(DBG_ROUTE,"\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
              NeighborTbl[i].id,
              NeighborTbl[i].parent,
              NeighborTbl[i].cost,
              NeighborTbl[i].missed,
              NeighborTbl[i].received,
              NeighborTbl[i].lastSeqno,
              NeighborTbl[i].hop,
              NeighborTbl[i].receiveEst,
              NeighborTbl[i].sendEst,
              NeighborTbl[i].childLiveliness);
        }
      }
      if (gpCurrentParent) {
        dbg(DBG_ROUTE,"MultiHopEWMA: Parent = %d\n",gpCurrentParent->id);
      }
    }
#endif
    chooseParent();
#ifdef MULTI_HOP_DEBUG
    if(TOS_LOCAL_ADDRESS != BASE_STATION_ADDRESS) debugCounter ++;
    if(debugCounter > 1){
	post SendDebugTask();
	debugCounter = 0;
    }else{
#endif //MULTI_HOP_DEBUG
    	post SendRouteTask();
#ifdef MULTI_HOP_DEBUG
    }
#endif //MULTI_HOP_DEBUG

  }


  command result_t StdControl.init() {

    memset((void *)NeighborTbl,0,(sizeof(TableEntry) * ROUTE_TABLE_SIZE));
    BaseStation.id = TOS_UART_ADDR;
    BaseStation.parent = TOS_UART_ADDR;
    BaseStation.flags = NBRFLAG_VALID;
    BaseStation.hop = 0;
    gpCurrentParent = NULL;
    gbCurrentHopCount = ROUTE_INVALID;
    gCurrentSeqNo = 0;
    gwEstTicks = 0;
    gUpdateInterval = DATA_TO_ROUTE_RATIO * DATA_FREQ;
    gfSendRouteBusy = FALSE;

    if (TOS_LOCAL_ADDRESS == BASE_STATION_ADDRESS) {

      gpCurrentParent = &BaseStation;
      gbCurrentHopCount = 0;
      gbCurrentCost = 0;

    }

    return SUCCESS;
  }

  command result_t StdControl.start() {
    post TimerTask();
    call Timer.start(TIMER_REPEAT,gUpdateInterval);
    return SUCCESS;
  }

  command result_t StdControl.stop() {
    call Timer.stop();
    return SUCCESS;
  }

  command bool RouteSelect.isActive() {
#if 0
    bool Result = FALSE;

    if (gpCurrentParent != NULL) {
      Result = TRUE;
    }

    return Result;
#endif

    return TRUE;
  }


  void updateDescendant(uint16_t id){
	uint8_t indes = findEntry(id);
	if (indes == (uint8_t) ROUTE_INVALID) { return;}
	else{
		NeighborTbl[indes].childLiveliness = MAX_DESCENDANT;
	}
  }

  command result_t RouteSelect.selectRoute(TOS_MsgPtr Msg, uint8_t id) {
    TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];

    uint8_t iNbr;
    bool fIsDuplicate;
    result_t Result = SUCCESS;


    if (gpCurrentParent == NULL) {
      // If the msg is locally generated, then send it to the broadcast address
      // This is necessary to seed the network.
      if ((pMHMsg->sourceaddr == TOS_LOCAL_ADDRESS) &&
          (pMHMsg->originaddr == TOS_LOCAL_ADDRESS)) {
        pMHMsg->sourceaddr = TOS_LOCAL_ADDRESS;
        pMHMsg->hopcount = gbCurrentHopCount;
        pMHMsg->seqno = gCurrentSeqNo++;
        Msg->addr = TOS_BCAST_ADDR;
        return SUCCESS;
      }
      else {
        return FAIL;
      }
    }

    if (gbCurrentHopCount >= pMHMsg->hopcount) {
      // Possible cycle??
      return FAIL;
    }
    
    if ((pMHMsg->sourceaddr == TOS_LOCAL_ADDRESS) &&
        (pMHMsg->originaddr == TOS_LOCAL_ADDRESS)) {
      fIsDuplicate = FALSE;
    }
    else {
      fIsDuplicate = updateNbrCounters(pMHMsg->sourceaddr,pMHMsg->seqno,&iNbr);
    }

    if (!fIsDuplicate) {
      pMHMsg->sourceaddr = TOS_LOCAL_ADDRESS;
      pMHMsg->hopcount = gbCurrentHopCount;
      if (gpCurrentParent->id != TOS_UART_ADDR) {
        pMHMsg->seqno = gCurrentSeqNo++;
      }
      Msg->addr = gpCurrentParent->id;
      if(pMHMsg->originaddr != TOS_LOCAL_ADDRESS){
	  updateDescendant(pMHMsg->originaddr);
      }
    }
    else {
      Result = FAIL;
    }
    dbg(DBG_ROUTE,"MultiHopEWMA: Sequence Number: %d\n", pMHMsg->seqno);

    return Result;

  }

  command result_t RouteSelect.initializeFields(TOS_MsgPtr Msg, uint8_t id) {
    TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];

    pMHMsg->sourceaddr = pMHMsg->originaddr = TOS_LOCAL_ADDRESS;
    pMHMsg->hopcount = ROUTE_INVALID;

    return SUCCESS;
  }

  command uint8_t* RouteSelect.getBuffer(TOS_MsgPtr Msg, uint16_t* Len) {

  }

  command uint16_t RouteControl.getParent() {

    uint16_t addr;

    addr = (gpCurrentParent != NULL) ? gpCurrentParent->id : 0xffff;

    return addr;
  }

  command uint8_t RouteControl.getQuality() {
    uint8_t val;

    val = (gpCurrentParent != NULL) ? gpCurrentParent->sendEst : 0x00;

    return val;
  }

  command uint8_t RouteControl.getDepth() {
    return gbCurrentHopCount;
  }

  command uint8_t RouteControl.getOccupancy() {
    return 0;
  }

  command uint16_t RouteControl.getSender(TOS_MsgPtr msg) {
    TOS_MHopMsg		*pMHMsg = (TOS_MHopMsg *)msg->data;
    return pMHMsg->sourceaddr;
  }

  command result_t RouteControl.setUpdateInterval(uint16_t Interval) {
    result_t Result;

    call Timer.stop();
    gUpdateInterval = (Interval * 1024);  // * 1024 to make the math simpler
    Result = call Timer.start(TIMER_REPEAT,gUpdateInterval);

    return Result;
  }

  command result_t RouteControl.manualUpdate() {
    result_t Result;

    Result = post TimerTask();
    return Result;
  }



  event result_t Timer.fired() {
    post TimerTask();
    return SUCCESS;
  }

  event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr Msg) {
    TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];
    RoutePacket *pRP = (RoutePacket *)&pMHMsg->data[0];
    uint16_t saddr;
    uint8_t i, iNbr;

    saddr = pMHMsg->sourceaddr;

    updateNbrCounters(saddr,pMHMsg->seqno,&iNbr);
    //    iNbr = findPreparedIndex(saddr);

    NeighborTbl[iNbr].parent = pRP->parent;
    NeighborTbl[iNbr].hop = pMHMsg->hopcount;
    NeighborTbl[iNbr].cost = pRP->cost;

    // find out my address, extract the estimation
    for (i = 0; i < pRP->estEntries; i++) {
      if (pRP->estList[i].id == TOS_LOCAL_ADDRESS) {
        NeighborTbl[iNbr].sendEst = pRP->estList[i].receiveEst;
        NeighborTbl[iNbr].liveliness = LIVELINESS;
      }
    }

    return Msg;
  }

  event result_t Snoop.intercept[uint8_t id](TOS_MsgPtr Msg, void *Payload, uint16_t Len) {
    TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];
    uint8_t iNbr;

    updateNbrCounters(pMHMsg->sourceaddr,pMHMsg->seqno,&iNbr);

    return SUCCESS;
  }


  event result_t SendMsg.sendDone(TOS_MsgPtr pMsg, result_t success) {
    gfSendRouteBusy = FALSE;

    return SUCCESS;
  }
  event result_t DebugSendMsg.sendDone(TOS_MsgPtr pMsg, result_t success) {
    return SUCCESS;
  }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精彩视频在线观看| 激情文学综合插| 欧美性猛交xxxx乱大交退制版| 中文字幕一区二区三区蜜月| 色综合色狠狠综合色| 亚洲精品欧美激情| 99久久综合精品| 亚洲成a人在线观看| 国产亚洲污的网站| 欧美日韩一区二区三区免费看| 亚洲日本va午夜在线影院| 色综合天天视频在线观看| 亚洲在线一区二区三区| 91精品中文字幕一区二区三区| 国产成人午夜精品5599 | 欧美私人免费视频| 美女脱光内衣内裤视频久久影院| 久久久99免费| 91社区在线播放| 蜜桃av一区二区三区电影| 国产精品久久久久久妇女6080 | 狠狠v欧美v日韩v亚洲ⅴ| 一区二区激情小说| 亚洲欧美色图小说| 国产亚洲午夜高清国产拍精品| 欧美在线短视频| 一本大道久久a久久精二百| av不卡免费在线观看| 粉嫩欧美一区二区三区高清影视| 国产成人免费视频网站 | 99热99精品| 99久久精品国产一区| 一本到不卡精品视频在线观看| 成人91在线观看| 欧美写真视频网站| 精品国产乱码久久| 亚洲免费av高清| 日本sm残虐另类| 99久久精品国产一区二区三区| av成人免费在线观看| 在线视频一区二区三| 日韩欧美国产午夜精品| 精品噜噜噜噜久久久久久久久试看| 久久精品一区四区| 亚洲人成7777| 久久疯狂做爰流白浆xx| 国产成人午夜电影网| 欧美日韩国产一区| 久久久精品国产99久久精品芒果 | 日韩欧美亚洲另类制服综合在线| 国产女人水真多18毛片18精品视频| 国产精品麻豆欧美日韩ww| 久久久久久久久久久久久夜| 亚洲黄色免费网站| 国产精品一区二区黑丝| 欧美日韩中文字幕精品| 欧美国产精品劲爆| 久久国产人妖系列| 欧美视频一区在线观看| 亚洲欧美一区二区三区久本道91| 国产在线精品一区二区夜色| 一本一道波多野结衣一区二区| 精品国产乱码久久久久久久| 天堂蜜桃91精品| 欧美日韩精品一区二区三区四区| 国产精品午夜免费| 高清免费成人av| 国产日韩欧美精品综合| 精品亚洲成a人| 欧美精品一区二区三区久久久| 日韩成人免费在线| 日韩女优av电影在线观看| 美女脱光内衣内裤视频久久网站| 欧美剧情片在线观看| 久久精品99国产精品| 麻豆专区一区二区三区四区五区| 高清不卡一区二区在线| 69av一区二区三区| 日韩成人免费在线| 久久久久成人黄色影片| 国产精品夜夜嗨| 亚洲免费电影在线| 国产亚洲综合av| 欧美视频中文字幕| 国产一区久久久| 自拍偷自拍亚洲精品播放| 在线一区二区视频| 日韩高清一区二区| 国产精品女人毛片| 日韩欧美激情在线| 欧美日韩第一区日日骚| 国产一区二区三区在线观看免费| 亚洲欧美在线观看| 2024国产精品| 欧美日韩国产综合久久| aaa欧美大片| 国产在线视频不卡二| 亚洲猫色日本管| 欧美变态tickling挠脚心| 日本道精品一区二区三区| 国模无码大尺度一区二区三区| 亚洲免费av在线| 亚洲国产精品av| 精品91自产拍在线观看一区| 91麻豆精品国产综合久久久久久 | 国产综合久久久久久久久久久久| 一区二区三区四区乱视频| 国产精品久久久久久久久免费樱桃| 欧美成人一区二区三区在线观看 | 一本色道久久加勒比精品| 粉嫩av一区二区三区在线播放 | 国产丝袜美腿一区二区三区| 精品va天堂亚洲国产| 欧美一区二区三区不卡| 制服丝袜中文字幕一区| 欧美一区二区三区视频在线 | 亚洲伊人色欲综合网| 亚洲6080在线| 狠狠色伊人亚洲综合成人| 国产中文字幕精品| 国产99久久久国产精品潘金 | 高清不卡在线观看| 色婷婷综合激情| 91精品国产欧美一区二区18 | 51精品秘密在线观看| 2021国产精品久久精品| 中文字幕一区在线观看视频| 日韩久久一区二区| 亚洲小少妇裸体bbw| 久久久久9999亚洲精品| 91精品国产麻豆国产自产在线 | 精品视频一区二区三区免费| 日韩欧美123| 洋洋成人永久网站入口| 国产一区二区在线电影| 欧美久久久久免费| 《视频一区视频二区| 美女看a上一区| 在线观看不卡一区| 国产精品久久久久婷婷二区次| 亚洲自拍另类综合| 欧美精品一区视频| 久久一夜天堂av一区二区三区| 亚洲天堂av老司机| 国产伦理精品不卡| 欧美大片国产精品| 一区二区三区产品免费精品久久75| 一区二区三区中文免费| 不卡高清视频专区| 国产精品久久久久精k8| 国产mv日韩mv欧美| 久久久不卡网国产精品二区| 精品制服美女久久| 久久综合久久综合亚洲| 狠狠狠色丁香婷婷综合激情| 精品国产免费人成在线观看| 久草热8精品视频在线观看| 精品久久久久久久久久久院品网| 亚洲综合无码一区二区| 精品视频一区三区九区| 视频精品一区二区| 久久众筹精品私拍模特| 国产成人av电影在线播放| 欧美国产精品一区二区| 色94色欧美sute亚洲线路一ni| 亚洲欧美日韩系列| 欧美一区二区三区四区视频| 国产精品亚洲成人| 亚洲高清视频中文字幕| 欧美福利一区二区| 国产馆精品极品| 性感美女极品91精品| 国产精品网站一区| 欧美日韩你懂的| av电影在线观看一区| 美女视频免费一区| 亚洲一区影音先锋| 久久久精品日韩欧美| 欧美日韩dvd在线观看| 91麻豆福利精品推荐| 男人操女人的视频在线观看欧美| 国产精品视频yy9299一区| 欧美精品在线观看一区二区| 99国产精品一区| 99免费精品在线| 成人av网在线| 国产福利不卡视频| 天天综合色天天综合色h| 亚洲人被黑人高潮完整版| 国产精品天美传媒| 久久久久久久久99精品| 555www色欧美视频| 91精品国产aⅴ一区二区| 欧美日韩精品福利| 制服丝袜亚洲网站| 欧美日韩国产经典色站一区二区三区| 色哟哟国产精品免费观看| 99免费精品视频| 在线观看中文字幕不卡| 欧美在线一区二区三区|