-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStatisticsManager.hpp
More file actions
executable file
·268 lines (224 loc) · 8.07 KB
/
StatisticsManager.hpp
File metadata and controls
executable file
·268 lines (224 loc) · 8.07 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
//
// StatisticsManager.hpp
// AggregationNS3
//
// Created by Alper Sinan Akyurek on 8/12/16.
// Copyright © 2016 Alper Sinan Akyurek. All rights reserved.
//
#ifndef StatisticsManager_hpp
#define StatisticsManager_hpp
#include <map>
#include "Measurement.hpp"
#include "MeasurementQueue.hpp"
#include "TransmissionManager.hpp"
/**
This class defines the main statistical manager regarding the whole simulation.
*/
class StatisticsManager
{
private:
/** A map type from measurement IDs to related queues **/
typedef std::map< Measurement::TId, MeasurementQueue > TMeasurementMap;
/** A packet counter type **/
typedef unsigned int TPacketCount;
/** Smart pointer to a node **/
typedef TransmissionManager::TNodePtr TNodePtr;
/** A map from nodes to the number of packets **/
typedef std::map< TransmissionManager::TNodePtr, TPacketCount > TPacketCountMap;
public:
/** Defines a Delay type **/
typedef ns3::Time TDelay;
/** Expiration Rate type **/
typedef double TExpirationRate;
/** Information Freshness type **/
typedef ns3::Time TInformationFreshness;
private:
/** Collects the generated measurements by each application ID **/
TMeasurementMap m_generatedMeasurements;
/** Collects the received measurements by each application ID **/
TMeasurementMap m_receivedMeasurements;
/** Counts the number of transmitted packets **/
TPacketCountMap m_txPacketCounts;
/** Counts the number of received packets **/
TPacketCount m_rxPacketCount;
/** Name of the Log File **/
std::string m_logFileName = "results.txt";
/** Indicates whether to write the timeseries file. **/
bool m_writeTimeseries = false;
private:
/** Private constructor for Singleton construction **/
StatisticsManager( void ){}
/**
Calculates the average delay of a queue.
\param queue The queue to be processed.
\return Average delay of the queue.
**/
TDelay
GetAverageDelay( const MeasurementQueue & queue ) const;
/**
Calculates the maximum delay of a queue.
\param queue The queue to be processed.
\return Maximum delay of the queue.
**/
TDelay
GetMaximumDelay( const MeasurementQueue & queue ) const;
/**
Calculates the total delay of a queue.
\param queue The queue to be processed.
\return Total delay of the queue.
**/
TDelay
GetTotalDelay( const MeasurementQueue & queue ) const;
/**
Calculates the expiration rate of a measurement queue.
\param queue The queue to be processed.
\return Expiration rate.
**/
TExpirationRate
GetExpirationRate( const MeasurementQueue & queue ) const;
/**
Calculates the number of expired measurements.
\param queue The queue to be processed.
\return Number of expired measurements.
**/
MeasurementQueue::TQueueSize
GetNumberOfExpired( const MeasurementQueue & queue ) const;
/**
Calculates the total Information Freshness.
\param queue The queue to be processed.
\return Total Information Freshness.
**/
TInformationFreshness
GetTotalInformationFreshness( const MeasurementQueue & queue ) const;
/**
Calculates the average Information Freshness.
\param queue The queue to be processed.
\return Average Information Freshness.
**/
TInformationFreshness
GetAverageInformationFreshness( const MeasurementQueue & queue ) const;
/**
Calculates the total number of lost measurements.
\return Total number of lost measurements.
**/
MeasurementQueue::TQueueSize
GetTotalNumberOfLost( void ) const;
/**
Calculates the total number of expired measurements.
\return Total number of expired measurements.
**/
MeasurementQueue::TQueueSize
GetTotalNumberOfExpired( void ) const;
/**
Calculates the total number of sent measurements.
\return Total number of sent measurements.
**/
MeasurementQueue::TQueueSize
GetTotalNumberOfSent( void ) const;
/**
Calculates the total number of transmitted packets.
\return Total number of transmitted packets.
**/
MeasurementQueue::TQueueSize
GetTotalNumberOfTransmitted( void ) const;
/**
Calculates the total number of received packets.
\return Total number of received packets.
**/
MeasurementQueue::TQueueSize
GetTotalNumberOfReceived( void ) const;
/**
Calculates the average delay.
\return Average delay.
**/
TDelay
GetAverageDelay( void ) const;
/**
Calculates the maximum delay.
\return Maximum delay.
**/
TDelay
GetMaximumDelay( void ) const;
/**
Calculates the Total Information Freshness over all packets.
\return Total Information Freshness.
**/
TInformationFreshness
GetTotalInformationFreshness( void ) const;
/**
Calculates the Average Information Freshness over all packets.
\return Average Information Freshness.
**/
TInformationFreshness
GetAverageInformationFreshness( void ) const;
/**
Calculates the total Information Freshness per Packet.
\return Information Freshness per packet.
**/
TInformationFreshness
GetInformationFreshnessPerPacket( void ) const;
/**
Calculates the Expiration Rate of all packets.
\return Expiration Rate
**/
TExpirationRate
GetExpirationRate( void ) const;
public:
/**
Static method to obtain the singleton.
\return Single instance of the StatisticsManager class.
**/
static StatisticsManager &
GetStatisticsManager( void );
/**
This function is called to notify a measurement is generated. The
measurement is stored for statistical purposes in ID based maps.
\param measurement Generated measurement.
**/
void
MeasurementGenerated( const TMeasurementPtr & measurement );
/**
This function is called to notify a measurement is received. The
measurement is stored for statistical purposes in ID based maps.
\param measurement Received measurement.
**/
void
MeasurementReceived( const TMeasurementPtr & measurement );
/**
This function is called when a packet is transmitted. The internal
counters are increased for statistical purposes.
\param transmittingNode Pointer to the transmitting node.
**/
void
PacketTransmitted( TNodePtr & transmittingNode );
/**
This function is called when a packet is received. Since the receiver
can only be sink, no input is required.
**/
void
PacketReceived( void );
/**
Prints statistics to the console and to a file.
**/
void
PrintStatistics( void );
/**
Sets the name of the log file.
\param logFileName Name of the log file.
**/
void
SetLogFileName( const std::string & logFileName )
{
this->m_logFileName = logFileName;
}
/**
Configures the timeseries writing preference.
\param timeSeries Whether to write to the timeseries file.
**/
void
SetTimeseriesPreference( const bool timeSeries )
{
this->m_writeTimeseries = timeSeries;
}
};
#endif /* StatisticsManager_hpp */