OverSim
LoginCache.cc
Go to the documentation of this file.
1 #include "LoginCache.h"
2 #include "Quon_m.h"
3 #include <limits>
4 
6 
8 {
10 
11  movementSpeed = par("movementSpeed");
12  bytesrecv = 0;
13  bytessend = 0;
14 }
15 
17 {
18  nodelist[node] = lcEntry(pos, simTime() );
19 
22  );
23 }
24 
26 {
27  double bestDist = std::numeric_limits<double>::infinity();
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  }
38  bytessend += (NODEHANDLE_L)/8;
39  );
40  return bestNode;
41 }
42 
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 }