OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
MessageObserver.h
Go to the documentation of this file.
1
//
2
// This program is free software; you can redistribute it and/or
3
// modify it under the terms of the GNU General Public License
4
// as published by the Free Software Foundation; either version 2
5
// of the License, or (at your option) any later version.
6
//
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License for more details.
11
//
12
// You should have received a copy of the GNU General Public License
13
// along with this program; if not, write to the Free Software
14
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
//
16
22
#ifndef __MESSAGEOBSERVER_H__
23
#define __MESSAGEOBSERVER_H__
24
25
#include <stdint.h>
26
#include "
OverlayKey.h
"
27
28
class
ALMTestTracedMessage
;
29
30
class
MessageObserver
:
public
cSimpleModule {
31
public
:
32
MessageObserver
();
33
~MessageObserver
();
34
35
void
initialize
();
36
37
void
finish
();
38
39
void
handleMessage
(cMessage* msg);
40
44
void
joinedGroup
(
int
moduleId,
OverlayKey
groupId);
45
49
void
leftGroup
(
int
moduleId,
OverlayKey
groupId);
50
55
void
sentMessage
(
ALMTestTracedMessage
* msg);
56
60
void
receivedMessage
(
ALMTestTracedMessage
* msg);
61
65
void
nodeDead
(
int
moduleId);
66
67
private
:
68
/*
69
* Tracks data related to a single group
70
*/
71
struct
MulticastGroup
{
72
MulticastGroup
() :
size
(0),
sent
(0),
received
(0) {}
73
74
// Number of nodes in the group
75
uint32_t
size
;
76
77
// Number of messages that should have been received
78
uint64_t
sent
;
79
80
// Number of messages recieved total by all nodes
81
uint64_t
received
;
82
83
};
84
85
simtime_t
creationTime
;
86
87
typedef
std::pair<int, OverlayKey>
NodeGroupPair
;
88
89
typedef
std::pair<int, long>
NodeMessagePair
;
90
91
// Info about a specific group
92
std::map<OverlayKey, MulticastGroup>
groups
;
93
94
// When a node joined a given group
95
std::map<NodeGroupPair, simtime_t>
joinedAt
;
96
97
// When a node received a given message
98
std::map<NodeMessagePair, simtime_t>
receivedAt
;
99
100
// Periodically clean up the above map. Set to 0 to disable.
101
cMessage*
gcTimer
;
102
103
// How often to clean up
104
double
gcInterval
;
105
106
// How long data will be kept in the received cache
107
double
cacheMaxAge
;
108
109
// How many messages have been received by their sender (have looped)
110
int
numLooped
;
111
112
GlobalStatistics
*
globalStatistics
;
113
114
friend
std::ostream&
operator<<
(std::ostream& os,
MessageObserver::MulticastGroup
const
& mg);
115
friend
std::ostream&
operator<<
(std::ostream& os,
MessageObserver::NodeGroupPair
const
& ngp);
116
};
117
118
std::ostream&
operator<<
(std::ostream& os,
MessageObserver::MulticastGroup
const
& mg);
119
std::ostream&
operator<<
(std::ostream& os,
MessageObserver::NodeGroupPair
const
& ngp);
120
121
#endif
src
applications
almtest
MessageObserver.h
Generated on Fri Dec 7 2012 13:37:52 for OverSim by
1.8.1.2