⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stats.h

📁 一个linux下的各种组播路由算法编程
💻 H
字号:
/*****************************************************************************
***                      Author: Hussein F. Salama                         ***
***                       Date: September 9, 1994                          ***
***                            File: stats.h                               ***
***          A library of C++ classes used to collect statistics from the  ***
***          discrete event simulator                                      *** 
*****************************************************************************/

#ifndef STATS_H
#define STATS_H

#include "node2.h"

#define dummy 2

class NodeStats {

   private: 
      Node *c; //current node
      Node *s; //source node of the packet
      int  addr; //addres of the packet
      int numB; //the number of batches in simulation
      unsigned long pReceived; //packets received
      unsigned long pLost; //packets lost
      unsigned long pMissed; //packets that missed the deadline
      double minD; //minimum end-to-end delay encountered
      double maxD; //maximum end-to-end delay encountered
      double aveD; //average end-to-end delay encountered
      double prevD;//last cell's end-to-end delays
      double confD;//the confidence interval of the average delay
      double aveL; //average packet loss rate
      double confL;// the confidence interval of the packet loss rate
      double jit;  //maximum time between two consecutive packets

      unsigned long prevSeqN; //The sequence number of the last packet received 
      double   *totalD; //used for calculating the average
      unsigned long *batchP; //packets per batch
      unsigned long *batchPL; //packets lost per batch
      NodeStats *n; //We will have a linked list of Stats
      
   public:
      NodeStats(Node *current, Node *source, int address, const int batches);
      NodeStats() { 
                    c = NULL; s = NULL; addr = 0; numB = dummy; 
                    totalD = new double[dummy];
                    batchP = new unsigned long[dummy];
      };
      ~NodeStats() { delete [] totalD; delete [] batchP; delete batchPL; };
      Node *current() { return(c); };
      void current(Node *cc) { c = cc; };
      Node *source() { return(s); };
      void source(Node *ss) { s = ss; };
      int  address() { return(addr); };
      void address(int a) { addr = a; };
      unsigned long packetsReceived() { return(pReceived); };
      void packetsReceived(unsigned long p) { pReceived = p; };
      unsigned long packetsLost() { return(pLost); };
      void packetsLost(unsigned long p) { pLost = p; };
      void addPacketsReceived(unsigned long i) { pReceived += i; };
      void addPacketsLost(unsigned long i) { pLost += i; };
      unsigned long packetsMissed() { return(pMissed); };
      void packetsMissed(unsigned long p) { pMissed = p; };
      void addPacketsMissed(unsigned long i) { pMissed += i; };
      double minDelay() { return(minD); };
      void minDelay(double d) { minD = d; };
      double maxDelay() { return(maxD); };
      void maxDelay(double d) { maxD = d; };
      double aveDelay() { return(aveD); };
      void aveDelay(double d) { aveD = d; };
      double aveLoss() { return(aveL); };
      void aveLoss( double l) { aveL = l; };
      double prevDelay() { return(prevD); };
      void prevDelay(double d) { prevD = d; };
      double jitter() { return(jit); };
      void jitter(double j) { jit = j; };
      double confDelay() { return(confD); };
      double confLoss() { return(confL); };
      unsigned long prevSeqNum() { return(prevSeqN); };
      void prevSeqNum(unsigned long n) { prevSeqN = n; };
      void addTotalDelay(int batch, double t) { (*(totalD + batch)) += t; };
      double totalDelay(int batch) { return(*(totalD + batch)); };
      void totalDelay(int batch, double t) { (*(totalD + batch)) = t; };
      void addBatchPacketsReceived(int batch, int i) { *(batchP + batch) += i; };
      void addBatchPacketsLost(int batch, int i) { *(batchPL + batch) += i; };
      unsigned long batchPackets(int batch) { return(*(batchP + batch)); };
      NodeStats *next() { return(n); };
      void next(NodeStats *nn) { n =nn; };
      double meanAndConf(int numBatches);

}; //NodeStats


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -