32 gcTimer =
new cMessage(
"garbage_collection");
60 uint64_t totalSent = 0;
61 uint64_t totalReceived = 0;
62 for (std::map<OverlayKey, MulticastGroup>::iterator i =
groups.begin(); i !=
groups.end(); ++i) {
63 std::stringstream message;
64 message <<
"MessageObserver: Group " << i->first;
67 name = message.str() +
" Sent Messages";
68 recordScalar(name.c_str(), (double)i->second.sent);
70 name = message.str() +
" Received Messages";
71 recordScalar(name.c_str(), (double)i->second.received);
73 name = message.str() +
" Delivered Percentage";
74 recordScalar(name.c_str(), ((double)i->second.received * 100.0) / (double)i->second.sent);
76 totalSent += i->second.sent;
77 totalReceived += i->second.received;
80 recordScalar(
"MessageObserver: Total Sent Messages", (
double)totalSent);
81 recordScalar(
"MessageObserver: Total Received Messages", (
double)totalReceived);
82 recordScalar(
"MessageObserver: Total Delivered Percentage", ((
double)totalReceived * 100.0) / (
double)totalSent);
92 simtime_t now = OPP::simTime();
93 std::map<NodeMessagePair, simtime_t>::iterator i, iPrev;
113 groups[groupId].size += 1;
121 std::map<OverlayKey, MulticastGroup>::iterator iter =
groups.find(groupId);
122 if (iter ==
groups.end()) {
123 EV <<
"Warning: MessageObserver asked to remove node from nonexistent group " << groupId.
toString();
125 else if (iter->second.size == 0) {
126 EV <<
"Warning: MessageObserver asked to remove node from empty group " << groupId.
toString();
129 iter->second.size -= 1;
140 error(
"%s called with null message.", __PRETTY_FUNCTION__);
143 std::map<OverlayKey, MulticastGroup>::iterator iter;
145 if (iter ==
groups.end()) {
146 EV <<
"Warning: MessageObserver notified of sent message for nonexistent group " << msg->
getGroupId().
toString();
148 else if (iter->second.size == 0) {
149 EV <<
"Warning: MessageObserver notified of sent message for empty group " << msg->
getGroupId().
toString();
152 iter->second.sent += iter->second.size - 1;
161 error(
"%s called with null message.", __PRETTY_FUNCTION__);
164 std::map<OverlayKey, MulticastGroup>::iterator iGroup;
166 if (iGroup ==
groups.end()) {
167 EV <<
"Warning: MessageObserver notified of received message for nonexistent group " << msg->
getGroupId().
toString();
169 else if (iGroup->second.size == 0) {
170 EV <<
"Warning: MessageObserver notified of received message for empty group " << msg->
getGroupId().
toString();
175 std::map<NodeGroupPair, simtime_t>::iterator iJoinInfo;
178 if (iJoinInfo !=
joinedAt.end() && iJoinInfo->second < msg->getTimestamp()) {
183 iGroup->second.received += 1;
199 for (std::map<OverlayKey, MulticastGroup>::iterator ig =
groups.begin(); ig !=
groups.end(); ++ig) {
209 return os <<
"Nodes: " << mg.
size <<
"; Messages Sent: " << mg.
sent
214 cModule* module = OPP::cSimulation::getActiveSimulation()->getModule(ngp.first);
215 return os <<
"(" << (module != NULL ? module->getFullPath() :
"Deleted node")
216 <<
", " << ngp.second <<
")";