logging-data-struct.h
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:4k
源码类别:

通讯编程

开发平台:

Visual C++

  1. /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
  2. /*
  3.  * Copyright (c) 2000  International Computer Science Institute
  4.  * All rights reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted provided that the following conditions
  8.  * are met:
  9.  * 1. Redistributions of source code must retain the above copyright
  10.  *    notice, this list of conditions and the following disclaimer.
  11.  * 2. Redistributions in binary form must reproduce the above copyright
  12.  *    notice, this list of conditions and the following disclaimer in the
  13.  *    documentation and/or other materials provided with the distribution.
  14.  * 3. All advertising materials mentioning features or use of this software
  15.  *    must display the following acknowledgement:
  16.  * This product includes software developed by ACIRI, the AT&T 
  17.  *      Center for Internet Research at ICSI (the International Computer
  18.  *      Science Institute).
  19.  * 4. Neither the name of ACIRI nor of ICSI may be used
  20.  *    to endorse or promote products derived from this software without
  21.  *    specific prior written permission.
  22.  *
  23.  * THIS SOFTWARE IS PROVIDED BY ICSI AND CONTRIBUTORS ``AS IS'' AND
  24.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26.  * ARE DISCLAIMED.  IN NO EVENT SHALL ICSI OR CONTRIBUTORS BE LIABLE
  27.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33.  * SUCH DAMAGE.
  34.  *
  35.  */
  36. #ifndef ns_logging_data_struct_h
  37. #define ns_logging_data_struct_h
  38. #include "node.h"
  39. #include "packet.h"
  40. #include "route.h"
  41. #include "rate-estimator.h"
  42. #include "pushback-constants.h"
  43. class LoggingDataStructNode {
  44.  public:
  45.   int nid_;      //the neighbors id.
  46.   RateEstimator * rateEstimator_;
  47.   int pushbackSent_;  //whether pushback message was sent to this neighbor
  48.   double limit_;      //limit specified in the pushback message sent to it.
  49.   
  50.   //status details of this neighbor.
  51.   int gotStatus_;   
  52.   double statusArrivalRate_;
  53.   int countLessReportedRate_;   //variable used to protect low senders
  54.     
  55.   int sentRefresh_; //whether we have sent a refresh to this neighbor yet.
  56.   LoggingDataStructNode * next_;
  57.   
  58.   LoggingDataStructNode(int id, LoggingDataStructNode * next); 
  59.   ~LoggingDataStructNode();
  60.   
  61.   void sentRefresh(double limit);
  62.   void pushbackSent(double limit, double expectedStatusRate);
  63.   void registerStatus(double arrRate);
  64.   void log(Packet *pkt);
  65. };
  66. class LoggingDataStruct {
  67.  public:
  68.   LoggingDataStructNode * first_;
  69.   int count_;       //number of members in this struct
  70.   int myID_;        // id of the my node, needed to figure out who sent the pkt.
  71.   RateEstimator * rateEstimator_;   // rate estimator for all bytes coming in for this RLS.
  72.   double reset_time_;  //time when logging was last reset.
  73.   //consolidated status details.
  74.   int gotStatusAll_;
  75.   double statusArrivalRateAll_;
  76.   RouteLogic * rtLogic_;
  77.   
  78.   LoggingDataStruct(Node *, RouteLogic *, int sampleAddress, double estimate);
  79.   ~LoggingDataStruct();
  80.   void log(Packet * pkt);
  81.   int consolidateStatus();
  82.   void registerStatus(int sender, double arrRate);
  83.   LoggingDataStructNode * getNodeByID(int id);
  84.   void resetStatus();
  85. };
  86. #endif