/
stats.hpp
78 lines (60 loc) · 1.68 KB
/
stats.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef STATS_HPP
#define STATS_HPP
#include "event.hpp"
#include "connection.hpp"
#include "graph.hpp"
#include "module.hpp"
#include "cli_args.hpp"
#include "sim.hpp"
#include "traffic.hpp"
#include <vector>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics.hpp>
#include <boost/timer/timer.hpp>
namespace ba = boost::accumulators;
using boost::timer::cpu_timer;
using boost::timer::cpu_times;
class client;
class stats: public module<sim>
{
// The singleton of the class.
static stats *singleton;
// The traffic of the run.
const traffic &tra;
// The accumulator type with double values.
typedef ba::accumulator_set<double, ba::features<ba::tag::count,
ba::tag::mean>> dbl_acc;
// The probability of establishing a connection.
dbl_acc m_pec;
// The length of the established connection.
dbl_acc m_lenec;
// The number of links of the established connection.
dbl_acc m_nolec;
// The number of slices of the established connection.
dbl_acc m_nscec;
// The arguments of the run.
cli_args args;
// The total timer, i.e., keeps track from the beginning of the run.
cpu_timer ttimer;
// The delta timer, i.e., keeps track from the last report time.
cpu_timer dtimer;
public:
stats(const cli_args &, const traffic &);
static stats &
get();
void
schedule(double t);
void
operator()(double t);
// Report the establishment status.
void
established(bool status);
// Report the established connection.
void
established_conn(const connection &conn);
private:
// Calculate the average number of fragments on a link.
double
calculate_frags();
};
#endif