📄 stat.hpp
字号:
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Authors : Benjamin GAUTHIER - 24 Mar 2004 * Joseph BANINO * Olivier JACQUES * Richard GAYRAUD * From Hewlett Packard Company. * */#ifndef __STAT_H__#define __STAT_H__#define TIME_LENGTH 32#define DEFAULT_FILE_NAME (char*)"dumpFile"#define DEFAULT_EXTENSION (char*)".csv"#define MAX_REPARTITION_HEADER_LENGTH 1024#define MAX_REPARTITION_INFO_LENGTH 1024#define MAX_CHAR_BUFFER_SIZE 1024#define MAX_COUNTER 5#include <ctime> #include <sys/time.h> #include <time.h> #include <iostream>#include <fstream>#include <stdio.h>/* For MAX_RTD_INFO_LENGTH. */#include "scenario.hpp"using namespace std;/*__________________________________________________________________________ C S t a t C L A S S__________________________________________________________________________*/ /** * This class provides some means to compute and display statistics. * This is a singleton class. */class CStat {public: /* * This struct is used for repartition table * border max is the max value allow for this range * nbInThisBorder is the counter of value in this range */ typedef struct _T_dynamicalRepartition { unsigned int borderMax; unsigned long nbInThisBorder; } T_dynamicalRepartition; typedef struct _T_value_rtt { double date ; double rtt ; } T_value_rtt, *T_pValue_rtt ; /** * Actions on counters */ enum E_Action { E_CREATE_OUTGOING_CALL, E_CREATE_INCOMING_CALL, E_CALL_FAILED, E_CALL_SUCCESSFULLY_ENDED, E_RESET_PD_COUNTERS, E_RESET_PL_COUNTERS, E_ADD_CALL_DURATION, E_ADD_RESPONSE_TIME_DURATION, E_FAILED_CANNOT_SEND_MSG, E_FAILED_MAX_UDP_RETRANS, E_FAILED_UNEXPECTED_MSG, E_FAILED_CALL_REJECTED, E_FAILED_CMD_NOT_SENT, E_FAILED_REGEXP_DOESNT_MATCH, E_FAILED_REGEXP_HDR_NOT_FOUND, E_FAILED_OUTBOUND_CONGESTION, E_FAILED_TIMEOUT_ON_RECV, E_OUT_OF_CALL_MSGS, E_RETRANSMISSION, E_AUTO_ANSWERED, E_ADD_GENERIC_COUNTER, }; /** * Counters management */ enum E_CounterName { // Cumulative counters CPT_C_IncomingCallCreated, CPT_C_OutgoingCallCreated, CPT_C_SuccessfulCall, CPT_C_FailedCall, CPT_C_CurrentCall, CPT_C_NbOfCallUsedForAverageCallLength, CPT_C_AverageCallLength, CPT_C_AverageCallLength_Squares, CPT_C_NbOfCallUsedForAverageResponseTime, CPT_C_NbOfCallUsedForAverageResponseTime_2, CPT_C_NbOfCallUsedForAverageResponseTime_3, CPT_C_NbOfCallUsedForAverageResponseTime_4, CPT_C_NbOfCallUsedForAverageResponseTime_5, // This must match or exceed MAX_RTD_INFO CPT_C_AverageResponseTime, CPT_C_AverageResponseTime_2, CPT_C_AverageResponseTime_3, CPT_C_AverageResponseTime_4, CPT_C_AverageResponseTime_5, // This must match or exceed MAX_RTD_INFO CPT_C_AverageResponseTime_Squares, CPT_C_AverageResponseTime_Squares_2, CPT_C_AverageResponseTime_Squares_3, CPT_C_AverageResponseTime_Squares_4, CPT_C_AverageResponseTime_Squares_5, CPT_C_FailedCallCannotSendMessage, CPT_C_FailedCallMaxUdpRetrans, CPT_C_FailedCallUnexpectedMessage, CPT_C_FailedCallCallRejected, CPT_C_FailedCallCmdNotSent, CPT_C_FailedCallRegexpDoesntMatch, CPT_C_FailedCallRegexpHdrNotFound, CPT_C_FailedOutboundCongestion, CPT_C_FailedTimeoutOnRecv, CPT_C_OutOfCallMsgs, CPT_C_Retransmissions, CPT_C_Generic, CPT_C_Generic_2, CPT_C_Generic_3, CPT_C_Generic_4, CPT_C_Generic_5, // This must match or exceed MAX_COUNTER CPT_C_AutoAnswered, // Periodic Display counter CPT_PD_IncomingCallCreated, // must be first (RESET_PD_COUNTER macro) CPT_PD_OutgoingCallCreated, CPT_PD_SuccessfulCall, CPT_PD_FailedCall, CPT_PD_NbOfCallUsedForAverageCallLength, CPT_PD_AverageCallLength, CPT_PD_AverageCallLength_Squares, CPT_PD_NbOfCallUsedForAverageResponseTime, CPT_PD_NbOfCallUsedForAverageResponseTime_2, // This must match or exceed MAX_RTD_INFO CPT_PD_NbOfCallUsedForAverageResponseTime_3, // This must match or exceed MAX_RTD_INFO CPT_PD_NbOfCallUsedForAverageResponseTime_4, // This must match or exceed MAX_RTD_INFO CPT_PD_NbOfCallUsedForAverageResponseTime_5, // This must match or exceed MAX_RTD_INFO CPT_PD_AverageResponseTime, CPT_PD_AverageResponseTime_2, CPT_PD_AverageResponseTime_3, CPT_PD_AverageResponseTime_4, CPT_PD_AverageResponseTime_5, CPT_PD_AverageResponseTime_Squares, CPT_PD_AverageResponseTime_Squares_2, CPT_PD_AverageResponseTime_Squares_3, CPT_PD_AverageResponseTime_Squares_4, CPT_PD_AverageResponseTime_Squares_5, CPT_PD_FailedCallCannotSendMessage, CPT_PD_FailedCallMaxUdpRetrans, CPT_PD_FailedCallUnexpectedMessage, CPT_PD_FailedCallCallRejected, CPT_PD_FailedCallCmdNotSent, CPT_PD_FailedCallRegexpDoesntMatch, CPT_PD_FailedCallRegexpHdrNotFound, CPT_PD_FailedOutboundCongestion, CPT_PD_FailedTimeoutOnRecv, CPT_PD_OutOfCallMsgs, CPT_PD_Retransmissions, CPT_PD_Generic, CPT_PD_Generic_2, CPT_PD_Generic_3, CPT_PD_Generic_4, CPT_PD_Generic_5, // This must match or exceed MAX_COUNTER CPT_PD_AutoAnswered, // must be last (RESET_PD_COUNTER) // Periodic logging counter CPT_PL_IncomingCallCreated, // must be first (RESET_PL_COUNTER macro) CPT_PL_OutgoingCallCreated, CPT_PL_SuccessfulCall, CPT_PL_FailedCall, CPT_PL_NbOfCallUsedForAverageCallLength, CPT_PL_AverageCallLength, /* The squares let us compute the standard deviation. */ CPT_PL_AverageCallLength_Squares, CPT_PL_NbOfCallUsedForAverageResponseTime, CPT_PL_NbOfCallUsedForAverageResponseTime_2, CPT_PL_NbOfCallUsedForAverageResponseTime_3, CPT_PL_NbOfCallUsedForAverageResponseTime_4, CPT_PL_NbOfCallUsedForAverageResponseTime_5, CPT_PL_AverageResponseTime, CPT_PL_AverageResponseTime_2, CPT_PL_AverageResponseTime_3, CPT_PL_AverageResponseTime_4, CPT_PL_AverageResponseTime_5, CPT_PL_AverageResponseTime_Squares, CPT_PL_AverageResponseTime_Squares_2, CPT_PL_AverageResponseTime_Squares_3, CPT_PL_AverageResponseTime_Squares_4, CPT_PL_AverageResponseTime_Squares_5, CPT_PL_FailedCallCannotSendMessage, CPT_PL_FailedCallMaxUdpRetrans, CPT_PL_FailedCallUnexpectedMessage, CPT_PL_FailedCallCallRejected, CPT_PL_FailedCallCmdNotSent, CPT_PL_FailedCallRegexpDoesntMatch, CPT_PL_FailedCallRegexpHdrNotFound, CPT_PL_FailedOutboundCongestion, CPT_PL_FailedTimeoutOnRecv, CPT_PL_OutOfCallMsgs, CPT_PL_Retransmissions, CPT_PL_Generic, CPT_PL_Generic_2, CPT_PL_Generic_3, CPT_PL_Generic_4, CPT_PL_Generic_5, CPT_PL_AutoAnswered, // must be last (RESET_PL_COUNTER) E_NB_COUNTER }; /* ** exported methods */ /** * Get the single instance of the class. * * Only one instance of CStat exists in the component. This * instance is automatically created the first time the instance() * method is called. * * @return the single instance of the CStat class. */ static CStat* instance (); /** * Delete the single instance of the class. * * Only one instance of CStat exists in the component. This * instance is deleted when the close method is called. */ void close (); /** * ComputeStat Methods are used to modify counter value * It's the main interface to update counter * * @return 0 if the action is known * -1 else */ int computeStat (E_Action P_action); int computeStat (E_Action P_action, unsigned long P_value); int computeStat (E_Action P_action, unsigned long P_value, int which); /** * ComputeRtt Methods are used to calculate the response time
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -