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

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

?? ctpforwardingenginep.nc

?? tinyos-2.x.rar
?? NC
?? 第 1 頁 / 共 3 頁
字號:
/* $Id: CtpForwardingEngineP.nc,v 1.23 2009/08/15 18:11:30 gnawali Exp $ */
/*
 * Copyright (c) 2008-9 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.
 */

/**
 *  This component contains the forwarding path of CTP Noe, the
 *  standard CTP implementation packaged with TinyOS 2.x. The CTP
 *  specification can be found in TEP 123.  The paper entitled
 *  "Collection Tree Protocol," by Omprakash Gnawali et al., in SenSys
 *  2009, describes the implementation and provides detailed
 *  performance results of CTP Noe.</p>
 *
 *  <p>The CTP ForwardingEngine is responsible for queueing and
 *  scheduling outgoing packets. It maintains a pool of forwarding
 *  messages and a packet send queue. A ForwardingEngine with a
 *  forwarding message pool of size <i>F</i> and <i>C</i>
 *  CollectionSenderC clients has a send queue of size <i>F +
 *  C</i>. This implementation several configuration constants, which
 *  can be found in <code>ForwardingEngine.h</code>.</p>
 *
 *  <p>Packets in the send queue are sent in FIFO order, with
 *  head-of-line blocking. Because this is a tree collection protocol,
 *  all packets are going to the same destination, and so the
 *  ForwardingEngine does not distinguish packets from one
 *  another. Packets from CollectionSenderC clients are sent
 *  identically to forwarded packets: only their buffer handling is
 *  different.</p>
 *
 *  <p>If ForwardingEngine is on top of a link layer that supports
 *  synchronous acknowledgments, it enables them and retransmits packets
 *  when they are not acked. It transmits a packet up to MAX_RETRIES times
 *  before giving up and dropping the packet. MAX_RETRIES is typically a
 *  large number (e.g., >20), as this implementation assumes there is
 *  link layer feedback on failed packets, such that link costs will go
 *  up and cause the routing layer to pick a next hop. If the underlying
 *  link layer does not support acknowledgments, ForwardingEngine sends
 *  a packet only once.</p> 
 *
 *  <p>The ForwardingEngine detects routing loops and tries to correct
 *  them. Routing is in terms of a cost gradient, where the collection
 *  root has a cost of zero and a node's cost is the cost of its next
 *  hop plus the cost of the link to that next hop.  If there are no
 *  loops, then this gradient value decreases monotonically along a
 *  route. When the ForwardingEngine sends a packet to the next hop,
 *  it puts the local gradient value in the packet header. If a node
 *  receives a packet to forward whose gradient value is less than its
 *  own, then the gradient is not monotonically decreasing and there
 *  may be a routing loop. When the ForwardingEngine receives such a
 *  packet, it tells the RoutingEngine to advertise its gradient value
 *  soon, with the hope that the advertisement will update the node
 *  who just sent a packet and break the loop. It also pauses the
 *  before the next packet transmission, in hopes of giving the
 *  routing layer's packet a priority.</p>
 *  
 *  <p>ForwardingEngine times its packet transmissions. It
 *  differentiates between four transmission cases: forwarding,
 *  success, ack failure, and loop detection. In each case, the
 *  ForwardingEngine waits a randomized period of time before sending
 *  the next packet. This approach assumes that the network is
 *  operating at low utilization; its goal is to prevent correlated
 *  traffic -- such as nodes along a route forwarding packets -- from
 *  interfering with itself.</p>
 *
 *  <p>While this implementation can work on top of a variety of link
 *  estimators, it is designed to work with a 4-bit link estimator
 *  (4B). Details on 4B can be found in the HotNets paper "Four Bit
 *  Link Estimation" by Rodrigo Fonseca et al. The forwarder provides
 *  the "ack" bit for each sent packet, telling the estimator whether
 *  the packet was acknowledged.</p>
 *
 *  @author Philip Levis
 *  @author Kyle Jamieson
 *  @date   $Date: 2009/08/15 18:11:30 $
 */

#include <CtpForwardingEngine.h>
#include <CtpDebugMsg.h>
   
generic module CtpForwardingEngineP() {
  provides {
    interface Init;
    interface StdControl;
    interface Send[uint8_t client];
    interface Receive[collection_id_t id];
    interface Receive as Snoop[collection_id_t id];
    interface Intercept[collection_id_t id];
    interface Packet;
    interface CollectionPacket;
    interface CtpPacket;
    interface CtpCongestion;
  }
  uses {
    // These five interfaces are used in the forwarding path
    //   SubSend is for sending packets
    //   PacketAcknowledgements is for enabling layer 2 acknowledgments
    //   RetxmitTimer is for timing packet sends for improved performance
    //   LinkEstimator is for providing the ack bit to a link estimator
    interface AMSend as SubSend;
    interface PacketAcknowledgements;
    interface Timer<TMilli> as RetxmitTimer;
    interface LinkEstimator; 
    interface UnicastNameFreeRouting;
    interface Packet as SubPacket;

    // These four data structures are used to manage packets to forward.
    // SendQueue and QEntryPool are the forwarding queue.
    // MessagePool is the buffer pool for messages to forward.
    // SentCache is for suppressing duplicate packet transmissions.
    interface Queue<fe_queue_entry_t*> as SendQueue;
    interface Pool<fe_queue_entry_t> as QEntryPool;
    interface Pool<message_t> as MessagePool;
    interface Cache<message_t*> as SentCache;
    
    interface Receive as SubReceive;
    interface Receive as SubSnoop;
    interface CtpInfo;
    interface RootControl;
    interface CollectionId[uint8_t client];
    interface AMPacket;
    interface Leds;
    interface Random;

    // This implementation has extensive debugging instrumentation.
    // Wiring up the CollectionDebug interface provides information
    // on important events, such as transmissions, receptions,
    // and cache checks. The TinyOS release includes scripts for
    // parsing these messages.
    interface CollectionDebug;

    
    // The ForwardingEngine monitors whether the underlying
    // radio is on or not in order to start/stop forwarding
    // as appropriate.
    interface SplitControl as RadioControl;
  }
}
implementation {
  /* Helper functions to start the given timer with a random number
   * masked by the given mask and added to the given offset.
   */
  static void startRetxmitTimer(uint16_t mask, uint16_t offset);
  void clearState(uint8_t state);
  bool hasState(uint8_t state);
  void setState(uint8_t state);

  // CTP state variables.
  enum {
    QUEUE_CONGESTED  = 0x1, // Need to set C bit?
    ROUTING_ON       = 0x2, // Forwarding running?
    RADIO_ON         = 0x4, // Radio is on?
    ACK_PENDING      = 0x8, // Have an ACK pending?
    SENDING          = 0x10 // Am sending a packet?
  };

  // Start with all states false
  uint8_t forwardingState = 0; 
  
  /* Keep track of the last parent address we sent to, so that
     unacked packets to an old parent are not incorrectly attributed
     to a new parent. */
  am_addr_t lastParent;
  
  /* Network-level sequence number, so that receivers
   * can distinguish retransmissions from different packets. */
  uint8_t seqno;

  enum {
    CLIENT_COUNT = uniqueCount(UQ_CTP_CLIENT)
  };

  /* Each sending client has its own reserved queue entry.
     If the client has a packet pending, its queue entry is in the 
     queue, and its clientPtr is NULL. If the client is idle,
     its queue entry is pointed to by clientPtrs. */

  fe_queue_entry_t clientEntries[CLIENT_COUNT];
  fe_queue_entry_t* ONE_NOK clientPtrs[CLIENT_COUNT];

  /* The loopback message is for when a collection roots calls
     Send.send. Since Send passes a pointer but Receive allows
     buffer swaps, the forwarder copies the sent packet into 
     the loopbackMsgPtr and performs a buffer swap with it.
     See sendTask(). */
     
  message_t loopbackMsg;
  message_t* ONE_NOK loopbackMsgPtr;

  command error_t Init.init() {
    int i;
    for (i = 0; i < CLIENT_COUNT; i++) {
      clientPtrs[i] = clientEntries + i;
      dbg("Forwarder", "clientPtrs[%hhu] = %p\n", i, clientPtrs[i]);
    }
    loopbackMsgPtr = &loopbackMsg;
    lastParent = call AMPacket.address();
    seqno = 0;
    return SUCCESS;
  }

  command error_t StdControl.start() {
    setState(ROUTING_ON);
    return SUCCESS;
  }

  command error_t StdControl.stop() {
    clearState(ROUTING_ON);
    return SUCCESS;
  }

  /* sendTask is where the first phase of all send logic
   * exists (the second phase is in SubSend.sendDone()). */
  task void sendTask();
  
  /* ForwardingEngine keeps track of whether the underlying
     radio is powered on. If not, it enqueues packets;
     when it turns on, it then starts sending packets. */ 
  event void RadioControl.startDone(error_t err) {
    if (err == SUCCESS) {
      setState(RADIO_ON);
      if (!call SendQueue.empty()) {
	dbg("FHangBug", "%s posted sendTask.\n", __FUNCTION__);
        post sendTask();
      }
    }
  }

  static void startRetxmitTimer(uint16_t window, uint16_t offset) {
    uint16_t r = call Random.rand16();
    r %= window;
    r += offset;
    call RetxmitTimer.startOneShot(r);
    dbg("Forwarder", "Rexmit timer will fire in %hu ms\n", r);
  }
  
  /* 
   * If the ForwardingEngine has stopped sending packets because
   * these has been no route, then as soon as one is found, start
   * sending packets.
   */ 
  event void UnicastNameFreeRouting.routeFound() {
    dbg("FHangBug", "%s posted sendTask.\n", __FUNCTION__);
    post sendTask();
  }

  event void UnicastNameFreeRouting.noRoute() {
    // Depend on the sendTask to take care of this case;
    // if there is no route the component will just resume
    // operation on the routeFound event
  }
  
  event void RadioControl.stopDone(error_t err) {
    if (err == SUCCESS) {
      clearState(RADIO_ON);
    }
  }

  ctp_data_header_t* getHeader(message_t* m) {
    return (ctp_data_header_t*)call SubPacket.getPayload(m, sizeof(ctp_data_header_t));
  }
 
  /*
   * The send call from a client. Return EBUSY if the client is busy
   * (clientPtrs is NULL), otherwise configure its queue entry
   * and put it in the send queue. If the ForwardingEngine is not
   * already sending packets (the RetxmitTimer isn't running), post
   * sendTask. It could be that the engine is running and sendTask
   * has already been posted, but the post-once semantics make this
   * not matter. What's important is that you don't post sendTask
   * if the retransmit timer is running; this would circumvent the
   * timer and send a packet before it fires.
   */ 
  command error_t Send.send[uint8_t client](message_t* msg, uint8_t len) {
    ctp_data_header_t* hdr;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一区久久| 欧美96一区二区免费视频| 一区二区三区资源| 亚州成人在线电影| 国产综合久久久久影院| 东方欧美亚洲色图在线| 91女神在线视频| 日韩理论在线观看| 亚洲人成精品久久久久久| 亚洲国产人成综合网站| 久久精品国产99久久6| 日本 国产 欧美色综合| 精品中文字幕一区二区小辣椒| 国产成人精品一区二区三区网站观看| 久久综合色天天久久综合图片| 国产亚洲成aⅴ人片在线观看| 国产精品每日更新| 一区二区三区成人| 麻豆专区一区二区三区四区五区| 美美哒免费高清在线观看视频一区二区| 国产一区二区三区精品视频| aaa国产一区| 69p69国产精品| 国产精品色哟哟网站| 午夜欧美在线一二页| 久久亚洲精华国产精华液| 亚洲天堂a在线| 日av在线不卡| 一本大道久久a久久精品综合| 欧美成人一级视频| 一区二区三区在线播放| 国产一区二区免费在线| 欧洲一区二区三区免费视频| 国产亚洲美州欧州综合国| 视频一区中文字幕国产| 不卡一区二区三区四区| 欧美哺乳videos| 亚洲伊人色欲综合网| 国产经典欧美精品| 欧美一区午夜视频在线观看| 综合久久久久久久| 国产麻豆一精品一av一免费| 欧美日产国产精品| 成人欧美一区二区三区小说 | 日韩精品一级中文字幕精品视频免费观看 | 久久超碰97中文字幕| 91美女福利视频| 久久久不卡网国产精品二区| 日韩国产精品大片| 欧美日韩在线播放一区| 亚洲人吸女人奶水| 国产白丝精品91爽爽久久| 欧美电影免费提供在线观看| 香蕉影视欧美成人| 91精品办公室少妇高潮对白| 国产精品午夜电影| 欧美videofree性高清杂交| 亚洲一区二区美女| 色欧美日韩亚洲| 中文字幕一区二区三区不卡| 国产另类ts人妖一区二区| 99久久99久久免费精品蜜臀| 日韩一区欧美小说| 日韩一卡二卡三卡四卡| 国产在线视频一区二区三区| 精品av久久707| 国产一区二区精品久久99 | av激情成人网| 亚洲人一二三区| 欧美丝袜丝nylons| 美日韩一区二区三区| 精品美女一区二区| 日韩一级完整毛片| 日韩av在线免费观看不卡| 欧美影院午夜播放| 一区二区在线观看免费| 色女孩综合影院| 亚洲视频一二三区| 色综合一个色综合| 亚洲精品自拍动漫在线| 中文字幕免费不卡在线| 成人av在线资源网站| 国产精品丝袜久久久久久app| 成人动漫一区二区在线| 日韩一区欧美一区| 欧美在线你懂得| 亚洲成人黄色影院| 91精品国产综合久久福利| 久久99最新地址| 久久久久久久久一| 成人18视频在线播放| 亚洲免费观看在线观看| 欧美亚洲国产一区在线观看网站 | av色综合久久天堂av综合| 亚洲蜜臀av乱码久久精品| 在线中文字幕一区二区| 亚洲18影院在线观看| 欧美电影免费观看完整版| 国产精品伊人色| 亚洲欧洲韩国日本视频| 在线观看亚洲精品| 麻豆精品一二三| 国产亚洲欧洲一区高清在线观看| 97久久超碰精品国产| 亚洲福利视频导航| 精品国免费一区二区三区| 高清成人免费视频| 一区二区三区毛片| 日韩视频一区二区三区在线播放| 国产精品自拍三区| 亚洲免费在线视频一区 二区| 欧美欧美午夜aⅴ在线观看| 久久er99精品| 亚洲少妇30p| 91麻豆精品91久久久久同性| 国产毛片精品国产一区二区三区| 综合久久给合久久狠狠狠97色| 欧美另类变人与禽xxxxx| 国产一区二区三区免费观看| 一区二区三区国产精品| www.亚洲色图.com| 成人av资源网站| 国产性色一区二区| 亚洲日本免费电影| 天堂久久久久va久久久久| 国产999精品久久久久久绿帽| 国产成人在线观看| 大胆欧美人体老妇| 欧洲视频一区二区| 日韩三级在线观看| 国产无遮挡一区二区三区毛片日本| 久久久高清一区二区三区| 亚洲欧美一区二区不卡| 中文av字幕一区| 欧美男同性恋视频网站| 国产aⅴ综合色| 三级欧美韩日大片在线看| 国产精品网站在线观看| 91麻豆精品91久久久久久清纯| 成人黄色在线看| 美女一区二区在线观看| 亚洲综合一区二区| 国产拍揄自揄精品视频麻豆 | 国产精品成人在线观看| 777午夜精品视频在线播放| caoporen国产精品视频| 琪琪久久久久日韩精品| 一区二区三区高清| 国产精品国产精品国产专区不蜜 | 激情综合一区二区三区| 亚洲一区二区在线观看视频| 国产日产欧美精品一区二区三区| 欧美另类z0zxhd电影| 日本丰满少妇一区二区三区| 高清不卡一区二区| 国产综合成人久久大片91| 免费的成人av| 亚洲777理论| 亚洲精品国久久99热| 中文字幕巨乱亚洲| 亚洲精品在线一区二区| 欧美精品国产精品| 欧美色综合久久| 99久久国产综合精品女不卡| 国产福利一区二区三区视频在线 | 欧美巨大另类极品videosbest| 91免费观看视频在线| 国产69精品久久777的优势| 久久精品久久综合| 丝袜脚交一区二区| 亚洲国产精品久久不卡毛片| 亚洲免费在线视频| 亚洲人123区| 亚洲女同女同女同女同女同69| 日本一区二区三区国色天香| 亚洲精品一线二线三线| 精品av久久707| 26uuu亚洲综合色欧美| 日韩精品一区二区三区蜜臀| 国产视频一区二区在线观看| 日本特黄久久久高潮| 国产精品久久久久影院色老大| 欧美三级中文字| 日韩福利电影在线| 一区二区三区欧美激情| 国产**成人网毛片九色| 国产精品大尺度| 91国模大尺度私拍在线视频| 亚洲最新视频在线观看| 欧美日韩午夜在线视频| 天天av天天翘天天综合网| 欧美丰满高潮xxxx喷水动漫| 91在线视频在线| 毛片av一区二区| 一区二区三区四区精品在线视频| 亚洲婷婷综合色高清在线| 亚洲男人的天堂一区二区| 一区二区三区免费| 丝袜美腿亚洲色图| 精品一区二区三区在线播放|