OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
LoginCache.cc
Go to the documentation of this file.
1
#include "
LoginCache.h
"
2
#include "
Quon_m.h
"
3
#include <limits>
4
5
Define_Module
(
LoginCache
);
6
7
void
LoginCache::initialize
()
8
{
9
globalStatistics
=
GlobalStatisticsAccess
().
get
();
10
11
movementSpeed
= par(
"movementSpeed"
);
12
bytesrecv
= 0;
13
bytessend
= 0;
14
}
15
16
void
LoginCache::registerPos
(
NodeHandle
node,
Vector2D
pos )
17
{
18
nodelist
[node] =
lcEntry
(pos, simTime() );
19
20
RECORD_STATS
(
21
bytesrecv
+= (
NODEHANDLE_L
+
QUONPOSITION_L
)/8;
22
);
23
}
24
25
NodeHandle
LoginCache::getLoginNode
(
Vector2D
pos )
26
{
27
double
bestDist = std::numeric_limits<double>::infinity();
28
NodeHandle
bestNode =
NodeHandle::UNSPECIFIED_NODE
;
29
for
( std::map<NodeHandle,lcEntry>::iterator it =
nodelist
.begin(); it !=
nodelist
.end(); ++it ){
30
double
age = SIMTIME_DBL(simTime() - it->second.time);
31
double
dist = pos.
distanceSqr
(it->second.pos) +
movementSpeed
*
movementSpeed
*age*age;
32
if
( dist < bestDist ) {
33
bestNode = it->first;
34
bestDist = dist;
35
}
36
}
37
RECORD_STATS
(
38
bytessend
+= (
NODEHANDLE_L
)/8;
39
);
40
return
bestNode;
41
}
42
43
void
LoginCache::finish
() {
44
45
simtime_t time =
globalStatistics
->
calcMeasuredLifetime
(0);
46
if
(time <
GlobalStatistics::MIN_MEASURED
)
return
;
47
48
globalStatistics
->
addStdDev
(
"LoginChache: Sent Bytes/s"
,
bytessend
/ time);
49
globalStatistics
->
addStdDev
(
"LoginChache: Received Bytes/s"
,
bytesrecv
/ time);
50
51
}
src
overlay
quon
LoginCache.cc
Generated on Fri Dec 7 2012 13:37:52 for OverSim by
1.8.1.2