-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstats.cc
163 lines (138 loc) · 3.83 KB
/
stats.cc
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include "client.hpp"
#include "stats.hpp"
#include "utils_netgen.hpp"
#include <iostream>
using namespace std;
// The singleton of the class. The compiler initializes it to null.
stats *stats::singleton;
stats::stats(const cli_args &args, const traffic &tra):
args(args), tra(tra)
{
assert(!singleton);
singleton = this;
schedule(0);
// The user part of the wall clock time.
cout << "usertime" << " ";
// The time elapsed in the simulation.
cout << "simtime" << " ";
// The seed of the simulation.
cout << "seed" << " ";
// The hash of the simulation.
cout << "hash" << " ";
// The mean connection arrival time.
cout << "mcat" << " ";
// The offered load.
cout << "oload" << " ";
// The network utilization.
cout << "utilization" << " ";
// The probability of establishing a connection.
cout << "pec" << " ";
// The mean length of an established connection.
cout << "lenec" << " ";
// The mean number of links of an established connection.
cout << "nolec" << " ";
// The mean number of slices of an established connection.
cout << "nscec" << " ";
// The number of currently active connections.
cout << "conns" << " ";
// The capacity served.
cout << "capser" << " ";
// The mean number of fragments on links.
cout << "frags" << " ";
// The average time a shortest path search (successful or not) takes.
cout << "spsat";
// That's it. Thank you.
cout << endl;
}
stats &
stats::get()
{
return *singleton;
}
void
stats::operator()(double st)
{
cpu_times ttime = ttimer.elapsed();
cpu_times dtime = dtimer.elapsed();
// Total user time.
double tut = ttime.user / 1e+9;
// Delta of the user time.
double dut = dtime.user / 1e+9;
// The user part of the wall clock time.
cout << tut << " ";
// The time elapsed in the simulation.
cout << st << " ";
// The seed of the simulation.
cout << args.seed << " ";
// The hash of the simulation.
cout << args.hash << " ";
// The mean connection arrival time.
cout << args.mcat << " ";
// The offered load.
cout << args.ol << " ";
// The network utilization.
cout << calculate_utilization(m_mdl) << " ";
// The probability of establishing a connection.
cout << ba::mean(m_pec) << " ";
// The mean length of an established connection.
cout << ba::mean(m_lenec) << " ";
// The mean number of links of an established connection.
cout << ba::mean(m_nolec) << " ";
// The mean number of slices of an established connection.
cout << ba::mean(m_nscec) << " ";
// The number of currently active connections.
cout << tra.nr_clients() << " ";
// The capacity served.
cout << tra.capacity_served() << " ";
// The mean number of fragments of links.
cout << calculate_frags() << " ";
// The average time a shortest path search (successful or not) takes.
cout << dut / ba::count(m_pec) << " ";
// That's it. Thanks!
cout << endl;
// We reset the accumulators to get new means in the next interval.
m_pec = dbl_acc();
m_lenec = dbl_acc();
m_nolec = dbl_acc();
m_nscec = dbl_acc();
// Start again to get next delta time.
dtimer.start();
schedule(st);
}
// Schedule the next event based on the current time 0.
void
stats::schedule(double t)
{
// We call the stats every second.
module::schedule(t + 1);
}
void
stats::established(bool status)
{
m_pec(status);
}
void
stats::established_conn(const connection &conn)
{
int len = conn.get_len();
int nol = conn.get_nol();
int nsc = conn.get_nsc();
m_lenec(len);
m_nolec(nol);
m_nscec(nsc);
}
double
stats::calculate_frags()
{
dbl_acc frags;
// Iterate over all edges.
graph::edge_iterator ei, ee;
for (tie(ei, ee) = boost::edges(m_mdl); ei != ee; ++ei)
{
const edge e = *ei;
const SSC &ssc = boost::get(boost::edge_ssc, m_mdl, e);
int f = calculate_fragments(ssc);
frags(f);
}
return ba::mean(frags);
}