~ubuntu-branches/ubuntu/utopic/sip-tester/utopic

« back to all changes in this revision

Viewing changes to stat.hpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell, Paul Belanger, Mark Purcell
  • Date: 2011-11-03 21:56:17 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20111103215617-nnxicj1oto9e8ix5
Tags: 1:3.2-1
[ Paul Belanger ]
* New Upstream Release (Closes: #623915).
* Switch to dpkg-source 3.0 (quilt) format
* Building with PCAP play.
* Switch back to Debhelper.
* debian/patches/spelling-error-in-binary: Fix lintian warning

[ Mark Purcell ]
* Drop pabs from Uploaders: at his request
* fix debhelper-overrides-need-versioned-build-depends
* fix description-synopsis-starts-with-article

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#define DEFAULT_FILE_NAME (char*)"dumpFile"
30
30
#define DEFAULT_EXTENSION (char*)".csv"
31
31
 
32
 
#define MAX_REPARTITION_HEADER_LENGTH 1024
33
 
#define MAX_REPARTITION_INFO_LENGTH   1024
34
32
#define MAX_CHAR_BUFFER_SIZE          1024
35
 
#define MAX_COUNTER                   5
36
33
 
37
34
#include <ctime> 
38
35
#include <sys/time.h> 
41
38
#include <fstream>
42
39
#include <stdio.h>
43
40
 
44
 
#ifdef HAVE_GSL
45
41
#include <gsl/gsl_rng.h>
46
42
#include <gsl/gsl_randist.h>
47
43
#include <gsl/gsl_cdf.h>
48
 
#endif
49
44
 
50
 
/* MAX_RTD_INFO_LENGTH defines the number of RTD begin and end points a single
51
 
 * call can have.  If you need more than five, you can increase this number,
52
 
 * but you also need to insert entries into the E_CounterName enum in stat.hpp.
53
 
 */
54
 
#define MAX_RTD_INFO_LENGTH 5
 
45
#include "variables.hpp"
55
46
 
56
47
using namespace std;
57
48
 
98
89
    E_CREATE_INCOMING_CALL,
99
90
    E_CALL_FAILED, 
100
91
    E_CALL_SUCCESSFULLY_ENDED,
 
92
    E_RESET_C_COUNTERS,
101
93
    E_RESET_PD_COUNTERS,
102
94
    E_RESET_PL_COUNTERS,
103
95
    E_ADD_CALL_DURATION,
110
102
    E_FAILED_CALL_REJECTED,
111
103
    E_FAILED_CMD_NOT_SENT,
112
104
    E_FAILED_REGEXP_DOESNT_MATCH,
 
105
    E_FAILED_REGEXP_SHOULDNT_MATCH,
113
106
    E_FAILED_REGEXP_HDR_NOT_FOUND,
114
107
    E_FAILED_OUTBOUND_CONGESTION,
115
108
    E_FAILED_TIMEOUT_ON_RECV,
116
109
    E_FAILED_TIMEOUT_ON_SEND,
117
110
    E_OUT_OF_CALL_MSGS,
 
111
    E_WATCHDOG_MAJOR,
 
112
    E_WATCHDOG_MINOR,
118
113
    E_DEAD_CALL_MSGS,
 
114
    E_FATAL_ERRORS,
 
115
    E_WARNING,
119
116
    E_RETRANSMISSION,
120
117
    E_AUTO_ANSWERED,
121
118
    E_ADD_GENERIC_COUNTER
137
134
  CPT_C_NbOfCallUsedForAverageCallLength,
138
135
  CPT_C_AverageCallLength_Sum,
139
136
  CPT_C_AverageCallLength_Squares,
140
 
  CPT_C_NbOfCallUsedForAverageResponseTime,
141
 
  CPT_C_NbOfCallUsedForAverageResponseTime_2,
142
 
  CPT_C_NbOfCallUsedForAverageResponseTime_3,
143
 
  CPT_C_NbOfCallUsedForAverageResponseTime_4,
144
 
  CPT_C_NbOfCallUsedForAverageResponseTime_5, // This must match or exceed MAX_RTD_INFO
145
 
  CPT_C_AverageResponseTime_Sum,
146
 
  CPT_C_AverageResponseTime_Sum_2,
147
 
  CPT_C_AverageResponseTime_Sum_3,
148
 
  CPT_C_AverageResponseTime_Sum_4,
149
 
  CPT_C_AverageResponseTime_Sum_5, // This must match or exceed MAX_RTD_INFO
150
 
  CPT_C_AverageResponseTime_Squares,
151
 
  CPT_C_AverageResponseTime_Squares_2,
152
 
  CPT_C_AverageResponseTime_Squares_3,
153
 
  CPT_C_AverageResponseTime_Squares_4,
154
 
  CPT_C_AverageResponseTime_Squares_5,
155
137
  CPT_C_FailedCallCannotSendMessage,
156
138
  CPT_C_FailedCallMaxUdpRetrans,
157
139
  CPT_C_FailedCallTcpConnect,
160
142
  CPT_C_FailedCallCallRejected,
161
143
  CPT_C_FailedCallCmdNotSent,
162
144
  CPT_C_FailedCallRegexpDoesntMatch,
 
145
  CPT_C_FailedCallRegexpShouldntMatch,
163
146
  CPT_C_FailedCallRegexpHdrNotFound,
164
147
  CPT_C_FailedOutboundCongestion,
165
148
  CPT_C_FailedTimeoutOnRecv,
166
149
  CPT_C_FailedTimeoutOnSend,
167
 
  CPT_C_Generic,
168
 
  CPT_C_Generic_2,
169
 
  CPT_C_Generic_3,
170
 
  CPT_C_Generic_4,
171
 
  CPT_C_Generic_5, // This must match or exceed MAX_COUNTER
172
150
  CPT_C_Retransmissions,
173
151
 
174
152
  // Periodic Display counter
204
182
  CPT_PD_FailedCallCallRejected,
205
183
  CPT_PD_FailedCallCmdNotSent,
206
184
  CPT_PD_FailedCallRegexpDoesntMatch,
 
185
  CPT_PD_FailedCallRegexpShouldntMatch,
207
186
  CPT_PD_FailedCallRegexpHdrNotFound,
208
187
  CPT_PD_FailedOutboundCongestion,
209
188
  CPT_PD_FailedTimeoutOnRecv,
210
189
  CPT_PD_FailedTimeoutOnSend,
211
 
  CPT_PD_Generic,
212
 
  CPT_PD_Generic_2,
213
 
  CPT_PD_Generic_3,
214
 
  CPT_PD_Generic_4,
215
 
  CPT_PD_Generic_5, // This must match or exceed MAX_COUNTER
216
190
  CPT_PD_Retransmissions,
217
191
 
218
192
  // Periodic logging counter
249
223
  CPT_PL_FailedCallCallRejected,
250
224
  CPT_PL_FailedCallCmdNotSent,
251
225
  CPT_PL_FailedCallRegexpDoesntMatch,
 
226
  CPT_PL_FailedCallRegexpShouldntMatch,
252
227
  CPT_PL_FailedCallRegexpHdrNotFound,
253
228
  CPT_PL_FailedOutboundCongestion,
254
229
  CPT_PL_FailedTimeoutOnRecv,
255
230
  CPT_PL_FailedTimeoutOnSend,
256
 
  CPT_PL_Generic,
257
 
  CPT_PL_Generic_2,
258
 
  CPT_PL_Generic_3,
259
 
  CPT_PL_Generic_4,
260
 
  CPT_PL_Generic_5,
261
231
  CPT_PL_Retransmissions,
262
232
 
263
233
  E_NB_COUNTER,
266
236
  // Cumulative counters
267
237
  CPT_G_C_OutOfCallMsgs,
268
238
  CPT_G_C_DeadCallMsgs,
 
239
  CPT_G_C_FatalErrors,
 
240
  CPT_G_C_Warnings,
 
241
  CPT_G_C_WatchdogMajor,
 
242
  CPT_G_C_WatchdogMinor,
269
243
  CPT_G_C_AutoAnswered,
270
244
  // Periodic Display counter
271
245
  CPT_G_PD_OutOfCallMsgs,
272
246
  CPT_G_PD_DeadCallMsgs,
 
247
  CPT_G_PD_FatalErrors,
 
248
  CPT_G_PD_Warnings,
 
249
  CPT_G_PD_WatchdogMajor,
 
250
  CPT_G_PD_WatchdogMinor,
273
251
  CPT_G_PD_AutoAnswered, // must be last (RESET_PD_COUNTER)
274
252
 
275
253
  // Periodic logging counter
276
254
  CPT_G_PL_OutOfCallMsgs,
277
255
  CPT_G_PL_DeadCallMsgs,
 
256
  CPT_G_PL_FatalErrors,
 
257
  CPT_G_PL_Warnings,
 
258
  CPT_G_PL_WatchdogMajor,
 
259
  CPT_G_PL_WatchdogMinor,
278
260
  CPT_G_PL_AutoAnswered, // must be last (RESET_PL_COUNTER)
279
261
 
280
262
  E_NB_G_COUNTER,
377
359
  void displayData (FILE *f);
378
360
  void displayStat(FILE *f);
379
361
  void displayRepartition(FILE *f);
380
 
  void displaySecondaryRepartition (FILE *f, int which);
381
 
 
 
362
  void displayRtdRepartition (FILE *f, int which);
382
363
 
383
364
  /**
384
365
   * Dump data periodically in the file M_FileName
428
409
   */
429
410
  static char* msToHHMMSSmmm (unsigned long P_ms);
430
411
 
 
412
  /* Get a counter ID by name. */
 
413
  int findCounter(const char *counter, bool alloc);
 
414
  int findRtd(const char *name, bool start);
 
415
  void validateRtds();
 
416
  int nRtds();
431
417
 
432
418
private:
433
419
  unsigned long long       M_counters[E_NB_COUNTER];
434
420
  static unsigned long long M_G_counters[E_NB_G_COUNTER - E_NB_COUNTER];
435
421
 
436
 
  T_dynamicalRepartition*  M_ResponseTimeRepartition[MAX_RTD_INFO_LENGTH];
 
422
#define GENERIC_C 0
 
423
#define GENERIC_PD 1
 
424
#define GENERIC_PL 2
 
425
#define GENERIC_TYPES 3
 
426
  unsigned long long       *M_genericCounters;
 
427
 
 
428
  str_int_map              M_genericMap;
 
429
  int_str_map              M_revGenericMap;
 
430
  int_str_map              M_genericDisplay;
 
431
 
 
432
  str_int_map              rtd_started;
 
433
  str_int_map              rtd_stopped;
 
434
 
 
435
#define RTD_COUNT 0
 
436
#define RTD_SUM 1
 
437
#define RTD_SUMSQ 2
 
438
#define RTD_TYPES 3
 
439
  unsigned long long       *M_rtdInfo;
 
440
  str_int_map              M_rtdMap;
 
441
  int_str_map              M_revRtdMap;
 
442
 
 
443
  T_dynamicalRepartition** M_ResponseTimeRepartition;
437
444
  T_dynamicalRepartition*  M_CallLengthRepartition;
438
445
  int                      M_SizeOfResponseTimeRepartition;
439
446
  int                      M_SizeOfCallLengthRepartition;
553
560
   */
554
561
  double computeMean(E_CounterName P_SumCounter,
555
562
                             E_CounterName P_NbOfCallUsed);
 
563
 
 
564
  double computeRtdMean(int which, int type);
 
565
  double computeRtdStdev(int which, int type);
 
566
 
556
567
  /**
557
568
   * Effective C++
558
569
   *
577
588
        virtual int textDescr(char *s, int len) = 0;
578
589
        virtual int timeDescr(char *s, int len) = 0;
579
590
        virtual double cdfInv(double percentile) = 0;
 
591
        virtual ~CSample();
580
592
private:
581
593
};
582
594
 
615
627
        double min, max;
616
628
};
617
629
 
618
 
#ifdef HAVE_GSL
619
630
/* Normal distribution. */
620
631
class CNormal : public CSample {
621
632
public:
717
728
        double p, n;
718
729
        gsl_rng *rng;
719
730
};
720
 
#endif
721
731
 
722
732
#endif // __STAT_H__