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

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

?? ctpforwardingenginep.nc

?? tinyos-2.x.rar
?? NC
?? 第 1 頁 / 共 3 頁
字號:
    fe_queue_entry_t *qe;
    dbg("Forwarder", "%s: sending packet from client %hhu: %x, len %hhu\n", __FUNCTION__, client, msg, len);
    if (!hasState(ROUTING_ON)) {return EOFF;}
    if (len > call Send.maxPayloadLength[client]()) {return ESIZE;}
    
    call Packet.setPayloadLength(msg, len);
    hdr = getHeader(msg);
    hdr->origin = TOS_NODE_ID;
    hdr->originSeqNo  = seqno++;
    hdr->type = call CollectionId.fetch[client]();
    hdr->thl = 0;

    if (clientPtrs[client] == NULL) {
      dbg("Forwarder", "%s: send failed as client is busy.\n", __FUNCTION__);
      return EBUSY;
    }

    qe = clientPtrs[client];
    qe->msg = msg;
    qe->client = client;
    qe->retries = MAX_RETRIES;
    dbg("Forwarder", "%s: queue entry for %hhu is %hhu deep\n", __FUNCTION__, client, call SendQueue.size());
    if (call SendQueue.enqueue(qe) == SUCCESS) {
      if (hasState(RADIO_ON) && !hasState(SENDING)) {
	dbg("FHangBug", "%s posted sendTask.\n", __FUNCTION__);
        post sendTask();
      }
      clientPtrs[client] = NULL;
      return SUCCESS;
    }
    else {
      dbg("Forwarder", 
          "%s: send failed as packet could not be enqueued.\n", 
          __FUNCTION__);
      
      // send a debug message to the uart
      call CollectionDebug.logEvent(NET_C_FE_SEND_QUEUE_FULL);

      // Return the pool entry, as it's not for me...
      return FAIL;
    }
  }

  command error_t Send.cancel[uint8_t client](message_t* msg) {
    // cancel not implemented. will require being able
    // to pull entries out of the queue.
    return FAIL;
  }

  command uint8_t Send.maxPayloadLength[uint8_t client]() {
    return call Packet.maxPayloadLength();
  }

  command void* Send.getPayload[uint8_t client](message_t* msg, uint8_t len) {
    return call Packet.getPayload(msg, len);
  }

  /*
   * These is where all of the send logic is. When the ForwardingEngine
   * wants to send a packet, it posts this task. The send logic is
   * independent of whether it is a forwarded packet or a packet from
   * a send clientL the two cases differ in how memory is managed in
   * sendDone.
   *
   * The task first checks that there is a packet to send and that
   * there is a valid route. It then marshals the relevant arguments
   * and prepares the packet for sending. If the node is a collection
   * root, it signals Receive with the loopback message. Otherwise,
   * it sets the packet to be acknowledged and sends it. It does not
   * remove the packet from the send queue: while sending, the 
   * packet being sent is at the head of the queue; a packet is dequeued
   * in the sendDone handler, either due to retransmission failure
   * or to a successful send.
   */

  task void sendTask() {
    uint16_t gradient;
    dbg("Forwarder", "%s: Trying to send a packet. Queue size is %hhu.\n", __FUNCTION__, call SendQueue.size());
    if (hasState(SENDING) || call SendQueue.empty()) {
      call CollectionDebug.logEvent(NET_C_FE_SENDQUEUE_EMPTY);
      return;
    }
    else if ((!call RootControl.isRoot() && 
	      !call UnicastNameFreeRouting.hasRoute()) ||
	     (call CtpInfo.getEtx(&gradient) != SUCCESS)) {
      /* This code path is for when we don't have a valid next
       * hop. We set a retry timer.
       *
       * Technically, this timer isn't necessary, as if a route
       * is found we'll get an event. But just in case such an event
       * is lost (e.g., a bug in the routing engine), we retry.
       * Otherwise the forwarder might hang indefinitely. As this test
       * doesn't require radio activity, the energy cost is minimal. */
      dbg("Forwarder", "%s: no route, don't send, try again in %i.\n", __FUNCTION__, NO_ROUTE_RETRY);
      call RetxmitTimer.startOneShot(NO_ROUTE_RETRY);
      call CollectionDebug.logEvent(NET_C_FE_NO_ROUTE);
      return;
    }
    else {
      /* We can send a packet.
	 First check if it's a duplicate;
	 if not, try to send/forward. */
      error_t subsendResult;
      fe_queue_entry_t* qe = call SendQueue.head();
      uint8_t payloadLen = call SubPacket.payloadLength(qe->msg);
      am_addr_t dest = call UnicastNameFreeRouting.nextHop();

      if (call SentCache.lookup(qe->msg)) {
	/* This packet is a duplicate, so suppress it: free memory and
	 * send next packet.  Duplicates are only possible for
	 * forwarded packets, so we can circumvent the client or
	 * forwarded branch for freeing the buffer. */
        call CollectionDebug.logEvent(NET_C_FE_DUPLICATE_CACHE_AT_SEND);
        call SendQueue.dequeue();
	if (call MessagePool.put(qe->msg) != SUCCESS) 
	  call CollectionDebug.logEvent(NET_C_FE_PUT_MSGPOOL_ERR); 
	if (call QEntryPool.put(qe) != SUCCESS) 
	  call CollectionDebug.logEvent(NET_C_FE_PUT_QEPOOL_ERR); 
	  
        post sendTask();
        return;
      }
      
      // Not a duplicate: we've decided we're going to send.
      dbg("Forwarder", "Sending queue entry %p\n", qe);

      if (call RootControl.isRoot()) {
	/* Code path for roots: copy the packet and signal receive. */
        collection_id_t collectid = getHeader(qe->msg)->type;
	uint8_t* payload;
	uint8_t payloadLength;

        memcpy(loopbackMsgPtr, qe->msg, sizeof(message_t));

	payload = call Packet.getPayload(loopbackMsgPtr, call Packet.payloadLength(loopbackMsgPtr));
	payloadLength =  call Packet.payloadLength(loopbackMsgPtr);
        dbg("Forwarder", "%s: I'm a root, so loopback and signal receive.\n", __FUNCTION__);
        loopbackMsgPtr = signal Receive.receive[collectid](loopbackMsgPtr,
							   payload,
							   payloadLength);
        signal SubSend.sendDone(qe->msg, SUCCESS);
      }
      else {
	/* The basic forwarding/sending case. */
	call CtpPacket.setEtx(qe->msg, gradient);
	call CtpPacket.clearOption(qe->msg, CTP_OPT_ECN | CTP_OPT_PULL);
	if (call PacketAcknowledgements.requestAck(qe->msg) == SUCCESS) {
	  setState(ACK_PENDING);
	}
	if (hasState(QUEUE_CONGESTED)) {
	  call CtpPacket.setOption(qe->msg, CTP_OPT_ECN); 
	  clearState(QUEUE_CONGESTED);
	}
	
	subsendResult = call SubSend.send(dest, qe->msg, payloadLen);
	if (subsendResult == SUCCESS) {
	  // Successfully submitted to the data-link layer.
	  setState(SENDING);
	  dbg("Forwarder", "%s: subsend succeeded with %p.\n", __FUNCTION__, qe->msg);
	  return;
	}
	// The packet is too big: truncate it and retry.
	else if (subsendResult == ESIZE) {
	  dbg("Forwarder", "%s: subsend failed from ESIZE: truncate packet.\n", __FUNCTION__);
	  call Packet.setPayloadLength(qe->msg, call Packet.maxPayloadLength());
	  post sendTask();
	  call CollectionDebug.logEvent(NET_C_FE_SUBSEND_SIZE);
	}
	else {
	  dbg("Forwarder", "%s: subsend failed from %i\n", __FUNCTION__, (int)subsendResult);
	}
      }
    }
  }


  /*
   * The second phase of a send operation; based on whether the transmission was
   * successful, the ForwardingEngine either stops sending or starts the
   * RetxmitTimer with an interval based on what has occured. If the send was
   * successful or the maximum number of retransmissions has been reached, then
   * the ForwardingEngine dequeues the current packet. If the packet is from a
   * client it signals Send.sendDone(); if it is a forwarded packet it returns
   * the packet and queue entry to their respective pools.
   * 
   */

  void packetComplete(fe_queue_entry_t* qe, message_t* msg, bool success) {
    // Four cases:
    // Local packet: success or failure
    // Forwarded packet: success or failure
    if (qe->client < CLIENT_COUNT) { 
      clientPtrs[qe->client] = qe;
      signal Send.sendDone[qe->client](msg, SUCCESS);
      if (success) {
	dbg("CtpForwarder", "%s: packet %hu.%hhu for client %hhu acknowledged.\n", __FUNCTION__, call CollectionPacket.getOrigin(msg), call CollectionPacket.getSequenceNumber(msg), qe->client);
	call CollectionDebug.logEventMsg(NET_C_FE_SENT_MSG, 
					 call CollectionPacket.getSequenceNumber(msg), 
					 call CollectionPacket.getOrigin(msg), 
                                         call AMPacket.destination(msg));
      } else {
	dbg("CtpForwarder", "%s: packet %hu.%hhu for client %hhu dropped.\n", __FUNCTION__, call CollectionPacket.getOrigin(msg), call CollectionPacket.getSequenceNumber(msg), qe->client);
	call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL_ACK_SEND, 
					 call CollectionPacket.getSequenceNumber(msg), 
					 call CollectionPacket.getOrigin(msg), 
					 call AMPacket.destination(msg));
      }
    }
    else { 
      if (success) {
	call SentCache.insert(qe->msg);
	dbg("CtpForwarder", "%s: forwarded packet %hu.%hhu acknowledged: insert in transmit queue.\n", __FUNCTION__, call CollectionPacket.getOrigin(msg), call CollectionPacket.getSequenceNumber(msg));
	call CollectionDebug.logEventMsg(NET_C_FE_FWD_MSG, 
					 call CollectionPacket.getSequenceNumber(msg), 
					 call CollectionPacket.getOrigin(msg), 
                                         call AMPacket.destination(msg));
      }
      else {
	dbg("CtpForwarder", "%s: forwarded packet %hu.%hhu dropped.\n", __FUNCTION__, call CollectionPacket.getOrigin(msg), call CollectionPacket.getSequenceNumber(msg));
	call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL_ACK_FWD, 
					 call CollectionPacket.getSequenceNumber(msg), 
					 call CollectionPacket.getOrigin(msg), 
					 call AMPacket.destination(msg));
      }
      if (call MessagePool.put(qe->msg) != SUCCESS)
	call CollectionDebug.logEvent(NET_C_FE_PUT_MSGPOOL_ERR);
      if (call QEntryPool.put(qe) != SUCCESS)
	call CollectionDebug.logEvent(NET_C_FE_PUT_QEPOOL_ERR);
    }
  }
  
  event void SubSend.sendDone(message_t* msg, error_t error) {
    fe_queue_entry_t *qe = call SendQueue.head();
    dbg("Forwarder", "%s to %hu and %hhu\n", __FUNCTION__, call AMPacket.destination(msg), error);

    if (error != SUCCESS) {
      /* The radio wasn't able to send the packet: retransmit it. */
      dbg("Forwarder", "%s: send failed\n", __FUNCTION__);
      call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL, 
				       call CollectionPacket.getSequenceNumber(msg), 
				       call CollectionPacket.getOrigin(msg), 
				       call AMPacket.destination(msg));
      startRetxmitTimer(SENDDONE_FAIL_WINDOW, SENDDONE_FAIL_OFFSET);
    }
    else if (hasState(ACK_PENDING) && !call PacketAcknowledgements.wasAcked(msg)) {
      /* No ack: if countdown is not 0, retransmit, else drop the packet. */
      call LinkEstimator.txNoAck(call AMPacket.destination(msg));
      call CtpInfo.recomputeRoutes();
      if (--qe->retries) { 
        dbg("Forwarder", "%s: not acked, retransmit\n", __FUNCTION__);
        call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_WAITACK, 
					 call CollectionPacket.getSequenceNumber(msg), 
					 call CollectionPacket.getOrigin(msg), 
                                         call AMPacket.destination(msg));
        startRetxmitTimer(SENDDONE_NOACK_WINDOW, SENDDONE_NOACK_OFFSET);
      } else {
	/* Hit max retransmit threshold: drop the packet. */
	call SendQueue.dequeue();
        clearState(SENDING);
        startRetxmitTimer(SENDDONE_OK_WINDOW, SENDDONE_OK_OFFSET);
	
	packetComplete(qe, msg, FALSE);
      }
    }
    else {
      /* Packet was acknowledged. Updated the link estimator,
	 free the buffer (pool or sendDone), start timer to
	 send next packet. */
      call SendQueue.dequeue();
      clearState(SENDING);
      startRetxmitTimer(SENDDONE_OK_WINDOW, SENDDONE_OK_OFFSET);
      call LinkEstimator.txAck(call AMPacket.destination(msg));
      packetComplete(qe, msg, TRUE);
    }
  }

  /*
   * Function for preparing a packet for forwarding. Performs
   * a buffer swap from the message pool. If there are no free
   * message in the pool, it returns the passed message and does not
   * put it on the send queue.
   */
  message_t* ONE forward(message_t* ONE m) {
    if (call MessagePool.empty()) {
      dbg("Route", "%s cannot forward, message pool empty.\n", __FUNCTION__);
      // send a debug message to the uart
      call CollectionDebug.logEvent(NET_C_FE_MSG_POOL_EMPTY);
    }
    else if (call QEntryPool.empty()) {
      dbg("Route", "%s cannot forward, queue entry pool empty.\n", 
          __FUNCTION__);
      // send a debug message to the uart
      call CollectionDebug.logEvent(NET_C_FE_QENTRY_POOL_EMPTY);
    }
    else {
      message_t* newMsg;
      fe_queue_entry_t *qe;
      uint16_t gradient;
      
      qe = call QEntryPool.get();
      if (qe == NULL) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91国偷自产一区二区开放时间| 成人爱爱电影网址| 国产精品妹子av| 欧美猛男男办公室激情| 国产一区二区三区四区五区美女 | 韩国在线一区二区| 依依成人综合视频| 中文字幕电影一区| 欧美mv日韩mv亚洲| 欧美日韩一二区| 成人免费三级在线| 蜜桃精品在线观看| 亚洲成a天堂v人片| 亚洲男女一区二区三区| 久久久久久99久久久精品网站| 欧美日本一区二区三区四区| 色综合久久综合| 国产成人精品网址| 久久成人麻豆午夜电影| 香蕉乱码成人久久天堂爱免费| 国产精品久久久久久久久图文区| 日韩女同互慰一区二区| 欧美自拍偷拍一区| 91丨九色porny丨蝌蚪| 国产精品影视天天线| 日本不卡1234视频| 性做久久久久久免费观看欧美| 1024成人网| 国产精品久久久久久久久动漫 | 欧美电影在哪看比较好| 成人sese在线| 国产成人在线视频免费播放| 久久成人av少妇免费| 免费成人在线影院| 美女被吸乳得到大胸91| 麻豆精品一区二区av白丝在线| 亚洲mv在线观看| 亚洲一区中文在线| 亚洲一级二级三级| 亚洲一区二区三区四区在线| 一区二区在线看| 依依成人综合视频| 亚洲国产sm捆绑调教视频| 亚洲男人的天堂网| 一区二区三区**美女毛片| 亚洲精品伦理在线| 一区二区三区中文免费| 一二三区精品福利视频| 又紧又大又爽精品一区二区| 亚洲午夜私人影院| 无码av免费一区二区三区试看| 亚洲国产成人av| 日韩成人精品在线| 老司机精品视频导航| 精品一区二区三区久久| 国产一区二区三区四区五区入口| 国产成人综合在线| 99精品欧美一区| 91色九色蝌蚪| 欧美精品日韩综合在线| 日韩欧美的一区| 久久久久久久电影| 亚洲视频一区在线| 亚洲国产一区二区a毛片| 日本欧美在线看| 国产成人夜色高潮福利影视| 99精品在线观看视频| 欧美怡红院视频| 欧美一卡二卡在线| 久久综合色之久久综合| 国产精品久久久久久久久久久免费看| 亚洲三级电影网站| 日韩精品一级中文字幕精品视频免费观看| 日本不卡123| 成人av在线资源网| 欧美日韩一本到| 国产亚洲欧洲997久久综合 | 久久久精品综合| 亚洲欧美自拍偷拍色图| 亚洲成av人片| 国产在线一区观看| 在线日韩av片| 日韩精品一区二区在线| 国产精品三级av| 亚洲成人一区在线| 国产夫妻精品视频| 欧美视频在线一区二区三区 | 日韩女优av电影| 欧美国产丝袜视频| 亚洲福利电影网| 福利一区二区在线| 欧美日韩1区2区| 国产日韩欧美一区二区三区乱码| 一区二区三区不卡视频| 国产成人免费av在线| 欧美精品丝袜中出| 亚洲免费观看高清完整| 激情综合网最新| 欧美亚洲图片小说| 中文字幕乱码日本亚洲一区二区| 日韩精品成人一区二区在线| 99久久精品国产一区二区三区| 日韩欧美亚洲另类制服综合在线 | 亚洲永久免费视频| 丁香婷婷综合色啪| 日韩精品专区在线| 一区二区三区精品在线| 国产一区二区中文字幕| 99在线热播精品免费| 日韩色视频在线观看| 国产精品久久久久国产精品日日| 亚州成人在线电影| 成人黄色一级视频| 日韩一区二区三区在线视频| 国产精品乱码人人做人人爱| 日韩成人一级大片| 国产精品影视在线| 久久天天做天天爱综合色| 亚洲精品视频一区二区| 极品销魂美女一区二区三区| 日本久久电影网| 国产午夜三级一区二区三| 麻豆精品新av中文字幕| 色视频欧美一区二区三区| 91麻豆精品国产91久久久资源速度 | 精品少妇一区二区| 亚洲精品写真福利| 99久久精品国产一区二区三区| 欧美不卡激情三级在线观看| 亚洲国产日韩一区二区| 成人免费电影视频| 久久综合九色综合97婷婷女人| 久久国产精品色| 欧美丝袜第三区| 亚洲精品一二三四区| 成人app网站| 久久欧美中文字幕| 男人操女人的视频在线观看欧美| 91官网在线免费观看| 亚洲欧美在线观看| 成人av在线影院| 国产日韩欧美高清在线| 激情偷乱视频一区二区三区| 在线播放/欧美激情| 国产欧美日韩一区二区三区在线观看| 成人激情免费电影网址| 久久久久国色av免费看影院| 美腿丝袜亚洲色图| 91精品国产免费久久综合| 亚洲高清一区二区三区| 91色在线porny| 亚洲区小说区图片区qvod| 成人av在线观| 国产精品福利一区二区| av电影在线观看不卡| 国产精品美女久久久久久2018| 国产成人精品三级| 国产日韩欧美高清在线| 成人精品免费看| 亚洲欧洲日产国码二区| 波多野洁衣一区| 亚洲一级不卡视频| 欧美日韩成人一区| 日韩成人精品在线| 精品国产一区二区三区不卡| 亚洲在线中文字幕| 日韩精品一区二区三区swag| 捆绑紧缚一区二区三区视频 | 欧美本精品男人aⅴ天堂| 国内精品伊人久久久久av影院| 精品成人免费观看| 国产福利一区在线| 中文成人综合网| 97国产一区二区| 亚洲一区二区三区四区不卡| 91精品国产麻豆国产自产在线| 韩日欧美一区二区三区| 欧美韩国日本综合| 91小视频免费看| 麻豆中文一区二区| 国产婷婷色一区二区三区在线| www.亚洲免费av| 一区二区三区四区国产精品| 日韩一级免费观看| 成人免费视频播放| 亚洲一区日韩精品中文字幕| 91精品国产入口| 久久电影网电视剧免费观看| 亚洲欧美精品午睡沙发| 欧美高清激情brazzers| 国内精品在线播放| 亚洲欧美国产77777| 精品国产一区a| 99re这里只有精品视频首页| 五月综合激情网| 久久精品欧美一区二区三区麻豆| 91久久国产综合久久| 精品综合免费视频观看| 中文字幕一区三区| 欧美一二三在线|