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

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

?? lqiforwardingenginep.nc

?? tinyos-2.x.rar
?? NC
?? 第 1 頁 / 共 2 頁
字號:
// $Id: LqiForwardingEngineP.nc,v 1.15 2008/06/11 00:46:25 razvanm Exp $

/* Copyright (c) 2007 Stanford University.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the
 *   distribution.
 * - Neither the name of the Stanford University nor the names of
 *   its contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD
 * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * "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.
 */

/* 
 * A simple module that handles multihop packet movement.  It accepts 
 * messages from both applications and the network and does the necessary
 * interception and forwarding.
 * It interfaces to an algorithmic componenet via RouteSelect. It also acts
 * as a front end for RouteControl
 */


/**
 * @author Philip Buonadonna
 * @auihor Alec Woo
 * @author Crossbow Inc.
 * @author Philip Levis (port from TinyOS 1.x)
 */

#include "AM.h"
#include "MultiHopLqi.h"
#include "CollectionDebugMsg.h"

module LqiForwardingEngineP {
  provides {
    interface Init;
    interface Send;
    interface Receive[collection_id_t id];
    interface Receive as Snoop[collection_id_t];
    interface Intercept[collection_id_t id];
    interface CollectionPacket;
    interface RouteControl;
    interface LqiRouteStats;
    interface Packet;
  }
  uses {
    interface SplitControl;
    interface Receive as SubReceive;
    interface AMSend as SubSend;
    interface AMSend as SubSendMine;
    interface RouteControl as RouteSelectCntl;
    interface RouteSelect;
    interface Leds;
    interface Packet as SubPacket;
    interface AMPacket;
    interface RootControl;
    interface Random;
    interface PacketAcknowledgements;
    interface CollectionDebug;
  }
}

implementation {

  enum {
    FWD_QUEUE_SIZE = MHOP_QUEUE_SIZE, // Forwarding Queue
    EMPTY = 0xff,
    MAX_RETRIES = 5
  };

  /* Internal storage and scheduling state */
  message_t FwdBuffers[FWD_QUEUE_SIZE];
  message_t *FwdBufList[FWD_QUEUE_SIZE];
  uint8_t FwdBufBusy[FWD_QUEUE_SIZE];
  uint8_t iFwdBufHead, iFwdBufTail;
  uint16_t sendFailures = 0;
  uint8_t fwd_fail_count = 0;
  uint8_t my_fail_count = 0;
  bool fwdbusy = FALSE;
  bool running = FALSE;
 
  lqi_header_t* getHeader(message_t* msg) {
    return (lqi_header_t*) call SubPacket.getPayload(msg, sizeof(lqi_header_t));
  }
  
  /***********************************************************************
   * Initialization 
   ***********************************************************************/


  static void initialize() {
    int n;

    for (n=0; n < FWD_QUEUE_SIZE; n++) {
      FwdBufList[n] = &FwdBuffers[n];
      FwdBufBusy[n] = 0;
    } 
    iFwdBufHead = iFwdBufTail = 0;

    sendFailures = 0;
  }

  command error_t Init.init() {
    initialize();
    return SUCCESS;
  }
 
  message_t* nextMsg();
  static void forward(message_t* msg);

  event void SplitControl.startDone(error_t err) {
    message_t* nextToSend;
    if (err != SUCCESS) {return;}
    nextToSend = nextMsg();
    running = TRUE;
    fwdbusy = FALSE;

    if (nextToSend != NULL) {
      forward(nextToSend);
    }
  }


  event void SplitControl.stopDone(error_t err) {
    if (err != SUCCESS) {return;}
    running = FALSE;
  }
  /***********************************************************************
   * Commands and events
   ***********************************************************************/
  command error_t Send.send(message_t* pMsg, uint8_t len) {
    len += sizeof(lqi_header_t);
    if (len > call SubPacket.maxPayloadLength()) {
      return ESIZE;
    }
    if (call RootControl.isRoot()) {
      return FAIL;
    }
    if (running == FALSE) {
      return EOFF;
    }
    call RouteSelect.initializeFields(pMsg);
    
    if (call RouteSelect.selectRoute(pMsg, 0) != SUCCESS) {
      return FAIL;
    }
    call PacketAcknowledgements.requestAck(pMsg);
    if (call SubSendMine.send(call AMPacket.destination(pMsg), pMsg, len) != SUCCESS) {
      sendFailures++;
      return FAIL;
    }

    return SUCCESS;
  } 
  
  int8_t get_buff(){
    uint8_t n;
    for (n=0; n < FWD_QUEUE_SIZE; n++) {
	uint8_t done = 0;
        atomic{
	  if(FwdBufBusy[n] == 0){
	    FwdBufBusy[n] = 1;
	    done = 1;
	  }
        }
	if(done == 1) return n;
      
    } 
    return -1;
  }

  int8_t is_ours(message_t* ptr){
    uint8_t n;
    for (n=0; n < FWD_QUEUE_SIZE; n++) {
       if(FwdBufList[n] == ptr){
		return n;
       }
    } 
    return -1;
  }

  static char* fields(message_t* msg) {
#ifdef TOSSIM
    static char mbuf[1024];
    lqi_header_t* hdr = getHeader(msg);
    sprintf(mbuf, "origin = %hu, seqno = %hu, oseqno = %hu, hopcount =%hu", hdr->originaddr, hdr->seqno, hdr->originseqno, hdr->hopcount);
    return mbuf;
#else
    return NULL;
#endif
  }

  static void forward(message_t* msg);
  
  static message_t* mForward(message_t* msg) {
    int8_t buf = get_buff();
    dbg("LQI", " Asked to forward packet @%s:\t%s\n", sim_time_string(), fields(msg));
    if (buf == -1) {
      dbg("LQI", "%s Dropped packet due to no space in queue.\n", __FUNCTION__);
      call CollectionDebug.logEvent(NET_C_FE_SEND_QUEUE_FULL);
      return msg;
    }
    if ((call RouteSelect.selectRoute(msg, 0)) != SUCCESS) {
      FwdBufBusy[(uint8_t)buf] = 0;
      call CollectionDebug.logEvent(NET_C_FE_NO_ROUTE);
      dbg("LQI", "%s Dropped packet due to no route.\n", __FUNCTION__);
      return msg;
    }
    else {
      message_t* newMsg = FwdBufList[(uint8_t)buf];
      FwdBufList[(uint8_t)buf] = msg;
      forward(msg);
      return newMsg;
    }
  }
  
  static void forward(message_t* msg) {
    // Failures at the send level do not cause the seq. number space to be 
    // rolled back properly.  This is somewhat broken.
    if (fwdbusy || running == FALSE) {
      dbg("LQI", "%s forwarding busy or off, wait for later.\n", __FUNCTION__);
      return;
    }
    else {
      call PacketAcknowledgements.requestAck(msg);
      if (call SubSend.send(call AMPacket.destination(msg),
			    msg,
			    call SubPacket.payloadLength(msg)) == SUCCESS) {
	call CollectionDebug.logEventMsg(NET_C_DBG_1, 
					 call CollectionPacket.getSequenceNumber(msg), 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91在线视频官网| 国产乱人伦偷精品视频不卡| 轻轻草成人在线| 不卡的av电影在线观看| 开心九九激情九九欧美日韩精美视频电影 | 亚洲欧美日韩成人高清在线一区| 亚洲永久免费av| 国产99一区视频免费| 欧美美女视频在线观看| 专区另类欧美日韩| 国产成人午夜精品影院观看视频 | 亚洲成人在线免费| av欧美精品.com| 久久这里只精品最新地址| 亚洲国产毛片aaaaa无费看| 不卡一区中文字幕| 久久久久99精品国产片| 日韩中文字幕1| 欧美亚洲自拍偷拍| 国产精品国产三级国产aⅴ中文| 奇米色一区二区三区四区| 欧洲国内综合视频| 亚洲精品日产精品乱码不卡| 成人午夜av在线| 久久久www成人免费毛片麻豆| 蜜桃视频一区二区三区在线观看| 在线观看视频一区二区| 一区二区三区日韩在线观看| 99久久精品国产麻豆演员表| 久久久久久久久久久99999| 久久99精品久久只有精品| 欧美精选在线播放| 同产精品九九九| 在线免费观看一区| 亚洲在线成人精品| 欧美妇女性影城| 日韩国产欧美三级| 91麻豆精品国产91久久久久久久久| 玉足女爽爽91| 欧美影片第一页| 日韩专区在线视频| 日韩午夜激情电影| 国产在线不卡一区| 国产日韩在线不卡| a美女胸又www黄视频久久| 综合久久一区二区三区| 色综合久久久网| 亚洲国产日韩综合久久精品| 欧美日韩免费不卡视频一区二区三区| 亚洲一线二线三线视频| 欧美精品一卡二卡| 久久av老司机精品网站导航| 精品国产免费人成在线观看| 国产成人综合在线播放| 日本一区二区三区国色天香| 91丨九色porny丨蝌蚪| 亚洲一级片在线观看| 欧美卡1卡2卡| 国内久久精品视频| 综合精品久久久| 欧美图区在线视频| 久久爱www久久做| 亚洲三级电影网站| 日韩三级精品电影久久久| 国产成人在线免费观看| 亚洲激情第一区| 日韩一区二区不卡| 99久久精品国产网站| 日本va欧美va精品| 国产精品国产成人国产三级| 欧美三级资源在线| 国产精品1024久久| 日韩成人一级片| 国产精品麻豆视频| 欧美一级生活片| 91视频免费播放| 狠狠色丁香婷综合久久| 一区二区三区四区国产精品| 欧美精品一区二区三区蜜桃视频| 色婷婷精品大视频在线蜜桃视频| 麻豆极品一区二区三区| 亚洲日本欧美天堂| 国产欧美视频一区二区三区| 3atv一区二区三区| 91久久香蕉国产日韩欧美9色| 精品一区二区三区视频| 亚洲国产精品久久艾草纯爱 | 国产精品不卡一区二区三区| 欧美一区二区福利在线| 91小视频在线免费看| 国产麻豆精品一区二区| 肉丝袜脚交视频一区二区| 亚洲欧洲日产国产综合网| 欧美精品一区二区三区在线播放| 欧美亚洲国产一区二区三区va| 高清视频一区二区| 久久精品国内一区二区三区| 亚洲电影在线免费观看| 亚洲欧美另类在线| 中文字幕一区二区三区在线观看 | 天堂午夜影视日韩欧美一区二区| 国产精品免费人成网站| 精品成人私密视频| 91精品欧美久久久久久动漫 | 国产欧美综合在线观看第十页| 欧美一区二区福利在线| 91麻豆精品国产自产在线| 欧美日韩亚洲不卡| 欧美在线免费观看视频| 一本色道久久综合亚洲91| 成人av综合在线| 成人av电影在线| 不卡的av电影在线观看| 成人精品视频.| av电影天堂一区二区在线| 成人黄色小视频在线观看| 成人永久免费视频| 成人精品视频一区二区三区尤物| 成人午夜电影小说| 色综合色综合色综合色综合色综合| 91丨九色丨尤物| 欧美日韩国产影片| 欧美精品自拍偷拍| 亚洲精品在线免费播放| 2020国产成人综合网| 国产婷婷一区二区| ●精品国产综合乱码久久久久| 亚洲人吸女人奶水| 亚洲图片欧美综合| 秋霞成人午夜伦在线观看| 国产一区二区剧情av在线| 国产**成人网毛片九色| 91丨porny丨国产入口| 欧美三级蜜桃2在线观看| 欧美精品xxxxbbbb| 久久视频一区二区| 国产精品久久久久久久久图文区| 亚洲人成网站色在线观看| 亚洲欧美偷拍卡通变态| 婷婷成人激情在线网| 国产精选一区二区三区| 91色porny| 91精品国产91综合久久蜜臀| 国产亚洲午夜高清国产拍精品| 日韩毛片视频在线看| 午夜电影一区二区| 国产成人午夜片在线观看高清观看| 色偷偷久久一区二区三区| 日韩区在线观看| 亚洲女厕所小便bbb| 男女男精品网站| eeuss鲁片一区二区三区在线看| 欧美日韩国产欧美日美国产精品| 欧美成人福利视频| 亚洲欧美国产三级| 国产在线麻豆精品观看| 91免费精品国自产拍在线不卡| 91精品国产综合久久小美女| 中文字幕免费一区| 日本在线不卡一区| 91影视在线播放| 国产偷国产偷亚洲高清人白洁| 午夜激情久久久| 一本色道久久综合狠狠躁的推荐| 久久这里都是精品| 日日夜夜精品视频天天综合网| 丁香六月综合激情| 欧美xxxxx牲另类人与| 亚洲国产中文字幕| 成人h动漫精品一区二区| 欧美成人aa大片| 午夜久久久久久久久| 色综合久久99| 国产精品久久久久三级| 青青草国产精品97视觉盛宴| 色综合久久久久久久| 国产精品无码永久免费888| 激情综合色丁香一区二区| 欧美三电影在线| 亚洲精品乱码久久久久| 国产成a人无v码亚洲福利| 精品免费国产二区三区| 婷婷六月综合网| 欧美精品久久久久久久多人混战 | 中文字幕综合网| 国产91精品一区二区麻豆网站| 日韩一级完整毛片| 天天亚洲美女在线视频| 欧美手机在线视频| 亚洲3atv精品一区二区三区| 色噜噜狠狠色综合欧洲selulu| 自拍偷在线精品自拍偷无码专区| 波多野洁衣一区| 国产精品久久三区| www.99精品| 日韩毛片精品高清免费| 色妹子一区二区| 午夜电影网一区| 日韩欧美中文字幕公布| 久久国产婷婷国产香蕉|