40 minAOI = (double)par(
"minAOIWidth") + (double)par(
"AOIBuffer");
41 maxAOI = (double)par(
"AOIWidth") + (double)par(
"AOIBuffer");
58 loginCache =
dynamic_cast<LoginCache*
>(simulation.getModuleByPath(
"globalObserver.globalFunctions[0].function.loginCache"));
142 SIMTIME_DBL(simTime()) - SIMTIME_DBL(
joinTime) + par(
"addJoinDelay").doubleValue()
178 EV <<
"UNINITIALIZED";
187 EV <<
" state." << endl;
193 if(msg->isName(
"join_timer")) {
202 else if(msg->isName(
"sec_timer")) {
205 scheduleAt(simTime() + 1, msg);
209 else if(msg->isName(
"delete_timer")) {
213 else if(msg->isName(
"alive_timer")) {
220 else if(msg->isName(
"backup_timer")) {
232 if(gameAPIMsg != NULL) {
237 <<
" Node " <<
thisSite->
address.
getIp() <<
" received " << gameAPIMsg->getName() <<
" from application."
267 if(quonMsg != NULL) {
318 QuonSiteMap::iterator itSites =
Sites.find(node.
getKey());
325 if(itSites ==
Sites.end()) {
329 <<
" Site " << node.
getIp() <<
" at " << p <<
" has been added to the list."
345 else if(update ==
QDIRECT || !itSites->second->alive) {
349 <<
" Site " << node.
getIp() <<
" at " << p <<
" has been updated in the list."
352 itSites->second->position = p;
353 itSites->second->dirty =
true;
354 itSites->second->alive =
true;
355 itSites->second->softNeighbor = isSoft;
357 itSites->second->AOIwidth = AOI;
369 <<
" This Site position has been updated to " << p <<
"."
377 if(
Sites.size() > 0) {
381 for(
int ii = 0; ii < 4; ++ii ){
382 bindingCandidates[i][ii] = 0;
385 double (*bindingDistance)[4] =
new double[
numBackups+1][4];
387 for(
int ii = 0; ii < 4; ++ii ){
388 bindingDistance[i][ii] = std::numeric_limits<double>::infinity();
392 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
397 itSites->second->dirty =
true;
400 else if(itSites->second->type !=
QUNDEFINED) {
402 itSites->second->dirty =
true;
413 if( dist < bindingDistance[
numBackups][quad] ){
418 while( backupPos >= 0 && dist < bindingDistance[backupPos][quad] ){
421 bindingCandidates[backupPos+1][quad] = bindingCandidates[backupPos][quad];
422 bindingDistance[backupPos+1][quad] = bindingDistance[backupPos][quad];
426 bindingCandidates[backupPos+1][quad] = itSites->second;
427 bindingDistance[backupPos+1][quad] = dist;
431 for(
int i = 0; i < 4; ++i ){
432 if( bindingCandidates[0][i] ){
434 bindingCandidates[0][i]->
dirty =
true;
436 if( bindingCandidates[ii][i] ){
443 delete[] bindingCandidates;
444 delete[] bindingDistance;
458 QuonSiteMap::iterator itSites =
Sites.find(node.
getKey());
459 if(itSites !=
Sites.end()) {
463 <<
" Site " << node.
getIp() <<
" at " << itSites->second->position <<
" has been removed from the list."
466 delete itSites->second;
467 Sites.erase(itSites);
476 QuonSiteMap::iterator itSites =
Sites.begin();
477 while(itSites !=
Sites.end()) {
479 if(itSites->second->type ==
QUNDEFINED && ( purgeSoftSites ==
QPURGESOFT || !itSites->second->softNeighbor) ) {
483 <<
" Site " << itSites->second->address.getIp() <<
" at " << itSites->second->position <<
" has been removed from the list.\n"
484 <<
" Status: " << ((itSites->second->type ==
QUNDEFINED) ?
"QUNDEFINED" :
"QSOFT")
487 delete itSites->second;
488 Sites.erase(itSites++);
504 }
else if(
Sites.size() > 0 ){
508 double avgNeighborAOI = 0;
509 for( QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites ){
510 avgNeighborAOI += itSites->second->AOIwidth;
512 avgNeighborAOI /=
Sites.size();
538 if(
Sites.size() > 0) {
549 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
554 quonListMsg->setBitLength(
QUONLIST_L(quonListMsg));
556 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
558 sendMessage(quonCopyMsg, itSites->second->address);
581 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
582 switch(itSites->second->type) {
590 if( itSites->second->softNeighbor ){
617 cancelAndDelete(quonMsg);
622 bool rebuild =
false;
623 QuonSiteMap::iterator itSites =
Sites.begin();
624 while(itSites !=
Sites.end()) {
625 if(itSites->second->alive) {
626 itSites->second->alive =
false;
661 for(
unsigned int i=0; i<4; i++) {
693 quonMsg->setBitLength(
QUON_L(quonMsg));
714 quonMoveMsg->setBitLength(
QUONMOVE_L(quonMoveMsg));
720 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
721 if(itSites->second->type ==
QBINDING || itSites->second->softNeighbor ) {
736 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
738 if(itSites->second->type ==
QBINDING || itSites->second->softNeighbor ) {
740 if(itSites->second->type ==
QBINDING) {
753 delete quonMoveBindingMsg;
766 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
769 quonMsg->encapsulate((cPacket*)msg->
dup());
782 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
783 if(itSites->second->position.distanceSqr(joinPosition) < min_dist) {
785 forwardSite = itSites->second;
790 if(min_dist == 0.0) {
803 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
811 quonListMsg->setBitLength(
QUONLIST_L(quonListMsg));
834 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
841 if(itSites->second->type ==
QBINDING) {
844 quonMoveMsg->setBitLength(
QUONMOVE_L(quonMoveMsg));
845 sendMessage(quonMoveMsg, itSites->second->address);
855 SIMTIME_DBL(simTime()) - SIMTIME_DBL(quonMoveMsg->getCreationTime())
870 if(itSites !=
Sites.end() && itSites->second->AOIwidth < quonMoveMsg->
getAOIsize()) {
871 oldAOI.resize(itSites->second->AOIwidth);
901 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
902 if(quonMoveMsg->
getSender() != itSites->second->address &&
903 !oldAOI.collide(itSites->second->position) &&
904 newAOI.collide(itSites->second->position)) {
914 quonListMsg->setBitLength(
QUONLIST_L(quonListMsg));
974 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
975 if(itSites->second->type ==
QBINDING) {
983 quonLeaveMsg->setBitLength(
QUONLIST_L(quonLeaveMsg));
998 int remSize, addSize;
999 remSize = addSize = 0;
1000 for(QuonSiteMap::iterator itSites =
Sites.begin(); itSites !=
Sites.end(); ++itSites) {
1001 if(itSites->second->type ==
QUNDEFINED && (purgeSoftSites ==
QPURGESOFT || !itSites->second->softNeighbor) && itSites->second->dirty) {
1005 else if(itSites->second->dirty) {
1008 itSites->second->dirty =
false;
1013 if(remSize > 0 || addSize > 0) {
1041 <<
" Node " <<
thisSite->
address.
getIp() <<
" sending " << msg->getName() <<
" to application."
1044 send(msg,
"appOut");
1088 getParentModule()->getParentModule()->getDisplayString().setTagArg(
"i2", 1,
"red");
1089 getDisplayString().setTagArg(
"i", 1,
"red");
1092 getParentModule()->getParentModule()->getDisplayString().setTagArg(
"i2", 1,
"yellow");
1093 getDisplayString().setTagArg(
"i", 1,
"yellow");
1096 getParentModule()->getParentModule()->getDisplayString().setTagArg(
"i2", 1,
"green");
1097 getDisplayString().setTagArg(
"i", 1,
"green");
1110 if(overallBytesSend != 0.0) {
1137 Enter_Method_Silent();
1143 Enter_Method_Silent();
1144 return AOIWidth - (double)par(
"AOIBuffer");
1149 Enter_Method_Silent();
1155 Enter_Method_Silent();
1161 Enter_Method_Silent();
1167 Enter_Method_Silent();
1181 QuonSiteMap::iterator itSites =
Sites.begin();
1182 while(itSites !=
Sites.end()) {
1183 delete itSites->second;