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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? multihopewma.nc

?? MultiHopEngineM多跳路由鄰居表3
?? NC
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
// $Id: MultiHopEWMA.nc,v 1.1 2003/11/21 19:47:24 jlhill Exp $

/*									tab:4
 * "Copyright (c) 2000-2003 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 * Copyright (c) 2002-2003 Intel Corporation
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached INTEL-LICENSE     
 * file. If you do not find these files, copies can be found by writing to
 * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
 * 94704.  Attention:  Intel License Inquiry.
 */


includes AM;
includes MultiHop;


#define MULTI_HOP_DEBUG 1

module MultiHopEWMA {

  provides {
    interface StdControl;
    interface RouteSelect;
    interface RouteControl;
  }

  uses {
    interface Timer;
    interface ReceiveMsg;
    interface Intercept as Snoop[uint8_t id];
    interface SendMsg;
    interface Send as DebugSendMsg;
  }
}

implementation {

  enum {
    NBRFLAG_VALID    = 0x01,
    NBRFLAG_NEW      = 0x02,
    NBRFLAG_EST_INIT = 0x04
  };

  enum {
    BASE_STATION_ADDRESS        = 0,
    ROUTE_TABLE_SIZE            = 16,
    ESTIMATE_TO_ROUTE_RATIO     = 5,
    ACCEPTABLE_MISSED           = -20,
    DATA_TO_ROUTE_RATIO         = 2,
    DATA_FREQ                   = 10000,
    SWITCH_THRESHOLD     	= 192,
    MAX_ALLOWABLE_LINK_COST     = 256*6,
    LIVELINESS              	= 2,
    MAX_DESCENDANT		= 5

  };

  enum {
    ROUTE_INVALID    = 0xff
  };

  struct SortEntry {
    uint16_t id;
    uint8_t  receiveEst;
  };

  struct SortDbgEntry {
    uint16_t id;
    uint8_t  sendEst;
    uint8_t  hopcount; 
  };

  typedef struct RPEstEntry {
    uint16_t id;
    uint8_t receiveEst;
  } __attribute__ ((packed)) RPEstEntry;

  typedef struct RoutePacket {
    uint16_t parent;
    uint16_t cost;
    uint8_t estEntries;
    RPEstEntry estList[1];
  } __attribute__ ((packed)) RoutePacket;

  typedef struct TableEntry {
    uint16_t id;  // Node Address
    uint16_t parent;
    uint16_t cost;
    uint8_t childLiveliness;
    uint16_t missed;
    uint16_t received;
    int16_t lastSeqno;
    uint8_t flags;
    uint8_t liveliness;
    uint8_t hop;
    uint8_t receiveEst;
    uint8_t sendEst;
  } TableEntry;

  TOS_Msg debugMsg; 
  TOS_Msg routeMsg; 
  bool gfSendRouteBusy;

  TableEntry BaseStation;
  TableEntry NeighborTbl[ROUTE_TABLE_SIZE];
  TableEntry *gpCurrentParent;
  uint8_t gbCurrentHopCount;
  uint16_t gbCurrentCost;
  int16_t gCurrentSeqNo;
  uint16_t gwEstTicks;
  uint32_t gUpdateInterval;


  /*////////////////////////////////////////////////////////*/
  /**
   * Return index into neighbor table of the given node addr
   * @author terence
   * @param id
   * @return index, if not found return ROUTE_INVALID
   */

  uint8_t findEntry(uint8_t id) {
    uint8_t i = 0;
    for (i = 0; i < ROUTE_TABLE_SIZE; i++) {
      if ((NeighborTbl[i].flags & NBRFLAG_VALID) && NeighborTbl[i].id == id) {
        return i;
      }
    }
    return ROUTE_INVALID;
  }
  /*////////////////////////////////////////////////////////*/
  /**
   * This function determines which entry should be replace
   * in this case, we find the one with the lease send estimate
   * @author terence
   * @param void
   * @return index of the table
   */

  uint8_t findEntryToBeReplaced() {
    uint8_t i = 0;
    uint8_t minSendEst = -1;
    uint8_t minSendEstIndex = ROUTE_INVALID;
    for (i = 0; i < ROUTE_TABLE_SIZE; i++) {
      if ((NeighborTbl[i].flags & NBRFLAG_VALID) == 0) {
        return i;
      }
      if (minSendEst >= NeighborTbl[i].sendEst) {
        minSendEst = NeighborTbl[i].sendEst;
        minSendEstIndex = i;
      }
    }
    return minSendEstIndex;
  }
  /*////////////////////////////////////////////////////////*/
  /**
   * This is going to make a new entry give an index and a id
   * @author terence
   * @param index, the index of the table
   * @param id, the node id 
   * @return void
   */

  void newEntry(uint8_t indes, uint16_t id) {
    NeighborTbl[indes].id = id;
    NeighborTbl[indes].flags = (NBRFLAG_VALID | NBRFLAG_NEW);
    NeighborTbl[indes].liveliness = 0;
    NeighborTbl[indes].parent = ROUTE_INVALID;
    NeighborTbl[indes].cost = ROUTE_INVALID;
    NeighborTbl[indes].childLiveliness = 0;
    NeighborTbl[indes].hop = ROUTE_INVALID;
    NeighborTbl[indes].missed = 0;
    NeighborTbl[indes].received = 0;
    NeighborTbl[indes].receiveEst = 0;
    NeighborTbl[indes].sendEst = 0;
    //call Estimator.clearTrackInfo(NeighborTbl[indes].trackInfo);
  }


  /*////////////////////////////////////////////////////////*/
  /**
   * Get neighbor table entry corresponding to the given address.
   * If current entry doesn't exist, then create one, possibly
   * evicting a previous entry. 
   * XXX - what if it evicts the parent???
   *
   * @author terence
   * @param id, node id
   * @return index
   */

  uint8_t findPreparedIndex(uint16_t id) {
    uint8_t indes = findEntry(id);
    if (indes == (uint8_t) ROUTE_INVALID) {
      indes = findEntryToBeReplaced();
      newEntry(indes, id);
    }
    return indes;
  }


  int sortByReceiveEstFcn(const void *x, const void *y) {
    struct SortEntry *nx = (struct SortEntry *) x;
    struct SortEntry *ny = (struct SortEntry *) y;
    uint8_t xReceiveEst = nx->receiveEst, yReceiveEst = ny->receiveEst;
    if (xReceiveEst > yReceiveEst) return -1;
    if (xReceiveEst == yReceiveEst) return 0;
    if (xReceiveEst < yReceiveEst) return 1;
    return 0; // shouldn't reach here becasue it covers all the cases
  }

  int sortDebugEstFcn(const void *x, const void *y) {
    struct SortDbgEntry *nx = (struct SortDbgEntry *) x;
    struct SortDbgEntry *ny = (struct SortDbgEntry *) y;
    uint8_t xReceiveEst = nx->sendEst, yReceiveEst = ny->sendEst;
    if (xReceiveEst > yReceiveEst) return -1;
    if (xReceiveEst == yReceiveEst) return 0;
    if (xReceiveEst < yReceiveEst) return 1;
    return 0; // shouldn't reach here becasue it covers all the cases
  }

  uint32_t evaluateCost(uint16_t cost, uint8_t sendEst, uint8_t receiveEst) {
    uint32_t transEst = (uint32_t) sendEst * (uint32_t) receiveEst;
    uint32_t immed = ((uint32_t) 1 << 24);

    if (transEst == 0) return ((uint32_t) 1 << (uint32_t) 16);
    // DO NOT change this LINE! mica compiler is WEIRD!
    immed = immed / transEst;
    immed += ((uint32_t) cost << 6);
    return immed;
  }


  void updateEst(TableEntry *Nbr) {
    uint16_t usExpTotal, usActTotal, newAve;

    if (Nbr->flags & NBRFLAG_NEW)
      return;
    
    usExpTotal = ESTIMATE_TO_ROUTE_RATIO;
    //if (pNbr->hop != 0) {
    //  usExpTotal *= (1 + DATA_TO_ROUTE_RATIO);
    //}
    dbg(DBG_ROUTE,"MultiHopEWMA: Updating Nbr %d. ExpTotl = %d, rcvd= %d, missed = %d\n",
        Nbr->id, usExpTotal, Nbr->received, Nbr->missed);

    atomic {
      usActTotal = Nbr->received + Nbr->missed;
      
      if (usActTotal < usExpTotal) {
        usActTotal = usExpTotal;
      }
      
      newAve = ((uint16_t) 255 * (uint16_t)Nbr->received) / (uint16_t)usActTotal;
      Nbr->missed = 0;
      Nbr->received = 0;

      // If we haven't seen a recieveEst for us from our neighbor, decay our sendEst
      // exponentially
      if (Nbr->liveliness  == 0) {
        Nbr->sendEst >>= 1;
      }else{
      	Nbr->liveliness --;
      }
    
    }
 

    if (Nbr->flags & NBRFLAG_EST_INIT) {
      uint16_t tmp;
      tmp = ((2 * ((uint16_t)Nbr->receiveEst) + (uint16_t)newAve * 6) / 8);
      Nbr->receiveEst = (uint8_t)tmp;
    }
    else {
      Nbr->receiveEst = (uint8_t) newAve;
      Nbr->flags ^= NBRFLAG_EST_INIT;
    }

     if(Nbr->childLiveliness > 0) Nbr->childLiveliness --;
  }

  void updateTable() {
    TableEntry *pNbr;
    uint8_t i = 0;

    gwEstTicks++;
    gwEstTicks %= ESTIMATE_TO_ROUTE_RATIO;

    for(i = 0; i < ROUTE_TABLE_SIZE; i++) {
      pNbr = &NeighborTbl[i];
      if (pNbr->flags & NBRFLAG_VALID) {
        if (gwEstTicks == 0) 
          updateEst(pNbr);
      }
    }
  }

  bool updateNbrCounters(uint16_t saddr, int16_t seqno, uint8_t *NbrIndex) {
    TableEntry *pNbr;
    int16_t sDelta;
    uint8_t iNbr;
    bool Result = FALSE;  // Result is TRUE if message is a duplicate

    iNbr = findPreparedIndex(saddr);
    pNbr = &NeighborTbl[iNbr];

    sDelta = (seqno - NeighborTbl[iNbr].lastSeqno - 1);

    if (pNbr->flags & NBRFLAG_NEW) {
      pNbr->received++;
      pNbr->lastSeqno = seqno;
      pNbr->flags ^= NBRFLAG_NEW;
    }
    else if (sDelta >= 0) {
      pNbr->missed += sDelta;
      pNbr->received++;
      pNbr->lastSeqno = seqno;
    }
    else if (sDelta < ACCEPTABLE_MISSED) {
      // Something happend to this node.  Reinitialize it's state
      newEntry(iNbr,saddr);
      pNbr->received++;
      pNbr->lastSeqno = seqno;
      pNbr->flags ^= NBRFLAG_NEW;
    }
    else {
      Result = TRUE;
    }

    *NbrIndex = iNbr;
    return Result;

  }

  void chooseParent() {
    TableEntry *pNbr;
    uint32_t ulNbrLinkCost = (uint32_t) -1;
    uint32_t ulNbrTotalCost = (uint32_t) -1;
    uint32_t oldParentCost = (uint32_t) -1;
    uint32_t oldParentLinkCost = (uint32_t) -1;
    uint32_t ulMinTotalCost = (uint32_t) -1;
    TableEntry* pNewParent = NULL;
    TableEntry* pOldParent = NULL;
    uint8_t i;

    if (TOS_LOCAL_ADDRESS == BASE_STATION_ADDRESS) return;

    // Choose the parent based on minimal hopcount and cost.  
    // There is a special case for choosing a base-station as it's 
    // receiveEst may be zero (it's not sending any packets)

    for (i = 0;i < ROUTE_TABLE_SIZE;i++) {
      pNbr = &NeighborTbl[i];


      if (!(pNbr->flags & NBRFLAG_VALID)) continue;
      if (pNbr->parent == TOS_LOCAL_ADDRESS) continue;
      if (pNbr->parent == ROUTE_INVALID) continue;
      if (pNbr->hop == ROUTE_INVALID) continue;
      if (pNbr->cost == (uint16_t) ROUTE_INVALID) continue;
      if (pNbr->sendEst < 25 || pNbr->receiveEst < 25) continue;
      if (pNbr->childLiveliness > 0) continue;

      ulNbrLinkCost = evaluateCost(0, pNbr->sendEst,pNbr->receiveEst);
      ulNbrTotalCost = evaluateCost(pNbr->cost, pNbr->sendEst,pNbr->receiveEst);


      if (ulNbrLinkCost > MAX_ALLOWABLE_LINK_COST) continue;
      dbg(DBG_ROUTE,"MultiHopEWMA node: %d, Cost %d, link Cost, %d\n", pNbr->id, ulNbrTotalCost, ulNbrLinkCost);
      if (pNbr == gpCurrentParent) {
	pOldParent = pNbr;
  	oldParentCost = ulNbrTotalCost;
  	oldParentLinkCost = ulNbrLinkCost;
  	continue;
      }
      
      if (ulMinTotalCost > ulNbrTotalCost) {
        ulMinTotalCost = ulNbrTotalCost;
        pNewParent = pNbr;
      }

    }

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99久久精品欧美| 亚洲成人黄色小说| 2欧美一区二区三区在线观看视频| 欧美日韩不卡一区| 欧美日本在线观看| 欧美成人欧美edvon| 久久久久久久久久久久久女国产乱 | 国产suv精品一区二区6| 一区二区三区免费在线观看| 青青草97国产精品免费观看| 亚洲国产成人91porn| 亚洲女厕所小便bbb| 国产精品五月天| 国产欧美日韩视频在线观看| 欧美高清dvd| 欧美一区二区在线免费播放| 欧美一区二区三区免费在线看| 欧美电视剧在线看免费| 亚洲人成伊人成综合网小说| 亚洲一区二区在线观看视频 | 久久精品亚洲麻豆av一区二区| 日韩精品自拍偷拍| 亚洲美女视频一区| 国产乱码精品一区二区三| 91久久一区二区| 欧美国产激情二区三区 | 国v精品久久久网| 欧美精品一区二区三区蜜臀| 日本免费新一区视频 | 91蝌蚪国产九色| 日韩免费高清视频| 亚洲综合一区在线| av亚洲精华国产精华精华| 日韩视频免费观看高清完整版在线观看 | 中日韩av电影| 韩国av一区二区| 久久综合久久综合亚洲| 五月天精品一区二区三区| 91老师国产黑色丝袜在线| 国产精品免费av| 韩国av一区二区| 激情成人综合网| 91老师片黄在线观看| 色综合久久88色综合天天6| 欧美成人艳星乳罩| 亚洲午夜电影在线| 91欧美一区二区| 国产网红主播福利一区二区| 丝袜诱惑制服诱惑色一区在线观看| 波多野结衣91| 久久久99精品免费观看| 美女mm1313爽爽久久久蜜臀| 一道本成人在线| 中文字幕日韩av资源站| 国产高清精品久久久久| 精品国产免费一区二区三区四区| 亚洲成精国产精品女| 色94色欧美sute亚洲线路一久| 国产欧美一区二区三区在线老狼| 青青国产91久久久久久| 欧美日韩免费一区二区三区| 亚洲黄色性网站| 91香蕉视频在线| 中文字幕一区二区在线播放| 成人性生交大片| 国产欧美精品一区| 国产91丝袜在线播放0| 国产香蕉久久精品综合网| 久草中文综合在线| 2024国产精品视频| 激情综合网最新| 久久新电视剧免费观看| 国产精品一区免费视频| 国产欧美日韩综合精品一区二区| 国产精品综合一区二区| 久久精品一区二区三区不卡 | 久久女同精品一区二区| 紧缚捆绑精品一区二区| 久久视频一区二区| 国产精品乡下勾搭老头1| 欧美国产日韩精品免费观看| 99久久精品免费精品国产| 亚洲欧美经典视频| 欧美日本韩国一区二区三区视频| 亚洲国产精品久久不卡毛片| 欧美三级蜜桃2在线观看| 日本vs亚洲vs韩国一区三区| 欧美一卡2卡3卡4卡| 精品一区二区三区在线视频| 久久综合九色综合久久久精品综合| 国产乱码字幕精品高清av | av激情综合网| 亚洲美女在线国产| 欧美乱熟臀69xxxxxx| 久久aⅴ国产欧美74aaa| 国产亚洲精品福利| 99久久国产综合精品女不卡| 一区二区国产视频| 91精品国产欧美一区二区18| 国内欧美视频一区二区| 国产精品视频线看| 欧美性一级生活| 日本va欧美va精品发布| 久久久精品天堂| 97久久超碰国产精品| 午夜视频一区在线观看| 精品国产髙清在线看国产毛片| 国产成人av影院| 一区二区不卡在线视频 午夜欧美不卡在| 欧美日韩国产一二三| 国产米奇在线777精品观看| 亚洲婷婷综合色高清在线| 91精品国产综合久久久久久久| 国产精品99久久久久久有的能看 | 欧美日韩卡一卡二| 麻豆精品久久精品色综合| 国产精品久久福利| 欧美日韩国产一级| 成人综合日日夜夜| 日韩中文字幕1| 中文字幕av一区二区三区免费看| 色av一区二区| 精品一区二区精品| 亚洲免费大片在线观看| 亚洲精品一区二区精华| 91香蕉视频mp4| 极品瑜伽女神91| 亚洲一卡二卡三卡四卡五卡| 久久综合九色综合欧美98| 色美美综合视频| 国产成人一级电影| 成人午夜视频在线| 人人狠狠综合久久亚洲| 中文字幕欧美日韩一区| 日韩欧美综合一区| 国产乱码精品一区二区三区av | 日本网站在线观看一区二区三区| 国产亚洲精品中文字幕| 在线综合视频播放| 91香蕉视频mp4| 国产99久久久国产精品| 午夜免费久久看| 亚洲色图在线视频| 久久久久久久综合| 日韩欧美综合一区| 欧美性一二三区| 91视频免费看| 成人免费av资源| 久久97超碰国产精品超碰| 亚洲国产sm捆绑调教视频| 国产精品久久久久久久裸模 | 国产ts人妖一区二区| 奇米影视一区二区三区小说| 亚洲午夜在线电影| ㊣最新国产の精品bt伙计久久| 2023国产精华国产精品| 欧美精品在线一区二区| 在线亚洲一区二区| 99久久综合国产精品| 国产精品原创巨作av| 精品一区二区成人精品| 日本成人在线视频网站| 亚洲成人av中文| 一区二区欧美在线观看| 亚洲欧美视频一区| 中文字幕一区免费在线观看| 欧美国产日产图区| 国产欧美视频在线观看| 国产婷婷色一区二区三区在线| 日韩一区二区三区视频在线 | 激情五月婷婷综合网| 蜜桃久久av一区| 免费成人美女在线观看.| 日本成人在线不卡视频| 婷婷国产在线综合| 日韩成人伦理电影在线观看| 天天综合色天天综合| 午夜精品福利视频网站| 亚洲国产日韩一级| 午夜av区久久| 青青草精品视频| 免费在线视频一区| 久久精品国内一区二区三区| 免费国产亚洲视频| 狠狠狠色丁香婷婷综合激情 | 国产精品伦理一区二区| 中文字幕高清不卡| 亚洲同性同志一二三专区| 亚洲色图欧美激情| 亚洲乱码中文字幕综合| 成人欧美一区二区三区黑人麻豆 | 欧美视频一二三区| 欧美顶级少妇做爰| 欧美大片拔萝卜| 国产欧美日韩麻豆91| 成人欧美一区二区三区在线播放| 亚洲六月丁香色婷婷综合久久| 一区二区三区四区中文字幕| 亚洲国产cao| 久久成人精品无人区|