#include <GIASearchApp.h>
Inheritance diagram for GIASearchApp:
Gia search test application, sends periodically SEARCH-Messages and collects statistical data.
Protected Member Functions | |
virtual void | initializeApp (int stage) |
initializes base class-attributes | |
void | handleAppMessage (cMessage *msg) |
method to handle non-commonAPI messages from the overlay | |
virtual void | handleTimerEvent (cMessage *msg) |
processes self-messages | |
virtual void | finishApp () |
collects statistical data | |
Protected Attributes | |
SearchMsgBookkeeping * | srMsgBook |
pointer to Search-Message-Bookkeeping-List in this node | |
double | mean |
mean interval for next message | |
double | deviation |
deviation of mean interval | |
bool | randomNodes |
use random destination nodes or only nodes from BootstrapOracle? | |
int | maxResponses |
maximum number of responses per search message | |
int | msgByteLength |
int | stat_keyListMessagesSent |
number of keyList-Messages sent | |
int | stat_keyListBytesSent |
number of keyList-Bytes sent | |
int | stat_searchMessagesSent |
number of search-Messages sent | |
int | stat_searchBytesSent |
number of search-Messages-Bytes sent | |
int | stat_searchResponseMessages |
number of received search-Response-Messages | |
int | stat_searchResponseBytes |
number of received search-Response-Messages-Bytes | |
cMessage * | search_timer |
timer for search messages | |
cMessage * | keyList_timer |
timer for initial key list packet to overlay | |
Static Protected Attributes | |
static const uint | ID_L = 16 |
static const uint | SEQNUM_L = 16 |
Private Attributes | |
std::vector< OverlayKey > * | keyList |
list of all maintained key of this application |
void GIASearchApp::finishApp | ( | ) | [protected, virtual] |
collects statistical data
Reimplemented from BaseApp.
00162 { 00163 // record scalar data 00164 GiaSearchStats stats = srMsgBook->getStatisticalData(); 00165 00166 recordScalar("GIASearchApp: SearchMsg avg. min delay", stats.minDelay); 00167 recordScalar("GIASearchApp: SearchMsg avg. max delay", stats.maxDelay); 00168 recordScalar("GIASearchApp: SearchMsg avg. min hops", stats.minHopCount); 00169 recordScalar("GIASearchApp: SearchMsg avg. max hops", stats.maxHopCount); 00170 recordScalar("GIASearchApp: SearchMsg avg. response count", 00171 stats.responseCount); 00172 00173 delete srMsgBook; 00174 00175 cancelAndDelete(search_timer); 00176 cancelAndDelete(keyList_timer); 00177 }
void GIASearchApp::handleAppMessage | ( | cMessage * | msg | ) | [protected, virtual] |
method to handle non-commonAPI messages from the overlay
msg | message to handle |
Reimplemented from BaseApp.
00138 { 00139 GIAanswer* answer = check_and_cast<GIAanswer*>(msg); 00140 OverlayCtrlInfo* overlayCtrlInfo = 00141 check_and_cast<OverlayCtrlInfo*>(answer->removeControlInfo()); 00142 00143 OverlayKey searchKey = answer->getSearchKey(); 00144 00145 if (debugOutput) 00146 EV << "(GIASearchApp) Node " << thisNode.ip 00147 << " received answer-message from overlay:" 00148 << " (key: " << searchKey 00149 << " at node " << answer->getNode() 00150 << ")" << endl; 00151 00152 stat_searchResponseMessages++; 00153 stat_searchResponseBytes += answer->byteLength(); 00154 00155 if (srMsgBook->contains(searchKey)) 00156 srMsgBook->updateItem(searchKey, overlayCtrlInfo->getHopCount()); 00157 00158 delete answer; 00159 }
void GIASearchApp::handleTimerEvent | ( | cMessage * | msg | ) | [protected, virtual] |
processes self-messages
method to handle self-messages should be overwritten in derived application if needed
msg | self-message |
Reimplemented from BaseApp.
00069 { 00070 if(msg == keyList_timer) { 00071 keyList = bootstrapOracle->getKeyList(par("maximumKeys")); 00072 WATCH_VECTOR(*keyList); 00073 00074 // create message 00075 GIAput* putMsg = new GIAput("GIA-Keylist"); 00076 putMsg->setCommand(GIA_PUT); 00077 00078 putMsg->setKeysArraySize(keyList->size()); 00079 00080 std::vector<OverlayKey>::iterator it; 00081 int k; 00082 for(it = keyList->begin(), k = 0; it != keyList->end(); it++, k++) 00083 putMsg->setKeys(k, *it); 00084 00085 putMsg->setLength(GIAPUT_L(putMsg)); 00086 00087 sendMessageToOverlay(putMsg); 00088 00089 if (debugOutput) 00090 EV << "(GIASearchApp) Node " << thisNode.ip 00091 << " sent keylist to overlay." << endl; 00092 00093 stat_keyListMessagesSent++; 00094 stat_keyListBytesSent += putMsg->byteLength(); 00095 } 00096 else if(msg == search_timer) { 00097 // schedule next search-message 00098 scheduleAt(simulation.simTime() + truncnormal(mean, deviation), msg); 00099 00100 // do nothing, if the network is still in the initiaization phase 00101 if((!par("activeNetwInitPhase")) && (underlayConfigurator->isInit())) 00102 return; 00103 00104 OverlayKey keyListItem; 00105 uint maximumTries = 20; 00106 // pic a search key we are not already searching 00107 do { 00108 if (maximumTries-- == 0) 00109 break; 00110 keyListItem = bootstrapOracle->getRandomKeyListItem(); 00111 } while ((keyListItem.isUnspecified()) 00112 && ((srMsgBook->contains(keyListItem)))); 00113 00114 if (!keyListItem.isUnspecified()) { 00115 // create message 00116 GIAsearch* getMsg = new GIAsearch("GIA-Search"); 00117 getMsg->setCommand(GIA_SEARCH); 00118 getMsg->setSearchKey(keyListItem); 00119 getMsg->setMaxResponses(maxResponses); 00120 getMsg->setLength(GIAGET_L(getMsg)); 00121 00122 sendMessageToOverlay(getMsg); 00123 00124 // add search key to our bookkeeping list 00125 srMsgBook->addMessage(keyListItem); 00126 00127 if (debugOutput) 00128 EV << "(GIASearchApp) Node " << thisNode.ip 00129 << " sent get-message to overlay" << endl; 00130 00131 stat_searchMessagesSent++; 00132 stat_searchBytesSent += getMsg->byteLength(); 00133 } 00134 } 00135 }
void GIASearchApp::initializeApp | ( | int | stage | ) | [protected, virtual] |
initializes base class-attributes
stage | the init stage |
Reimplemented from BaseApp.
00037 { 00038 if (stage != MIN_STAGE_APP) 00039 return; 00040 00041 // fetch parameters 00042 mean = par("messageDelay"); 00043 deviation = mean / 3; 00044 randomNodes = par("randomNodes"); 00045 maxResponses = par("maxResponses"); 00046 00047 onlyCommonAPIMessages = false; 00048 00049 srMsgBook = new SearchMsgBookkeeping(); 00050 00051 // statistics 00052 stat_keyListMessagesSent = 0; 00053 stat_keyListBytesSent = 0; 00054 stat_searchMessagesSent = 0; 00055 stat_searchBytesSent = 0; 00056 stat_searchResponseMessages = 0; 00057 stat_searchResponseBytes = 0; 00058 00059 // initiate test message emision 00060 search_timer = new cMessage("search_timer"); 00061 scheduleAt(simulation.simTime() + truncnormal(mean, deviation), 00062 search_timer); 00063 00064 keyList_timer = new cMessage("keyList_timer"); 00065 scheduleAt(simulation.simTime() + uniform(0.0, 10.0), keyList_timer); 00066 }
double GIASearchApp::deviation [protected] |
deviation of mean interval
const uint GIASearchApp::ID_L = 16 [static, protected] |
std::vector<OverlayKey>* GIASearchApp::keyList [private] |
list of all maintained key of this application
cMessage* GIASearchApp::keyList_timer [protected] |
timer for initial key list packet to overlay
int GIASearchApp::maxResponses [protected] |
maximum number of responses per search message
double GIASearchApp::mean [protected] |
mean interval for next message
int GIASearchApp::msgByteLength [protected] |
bool GIASearchApp::randomNodes [protected] |
use random destination nodes or only nodes from BootstrapOracle?
cMessage* GIASearchApp::search_timer [protected] |
timer for search messages
const uint GIASearchApp::SEQNUM_L = 16 [static, protected] |
SearchMsgBookkeeping* GIASearchApp::srMsgBook [protected] |
pointer to Search-Message-Bookkeeping-List in this node
int GIASearchApp::stat_keyListBytesSent [protected] |
number of keyList-Bytes sent
int GIASearchApp::stat_keyListMessagesSent [protected] |
number of keyList-Messages sent
int GIASearchApp::stat_searchBytesSent [protected] |
number of search-Messages-Bytes sent
int GIASearchApp::stat_searchMessagesSent [protected] |
number of search-Messages sent
int GIASearchApp::stat_searchResponseBytes [protected] |
number of received search-Response-Messages-Bytes
int GIASearchApp::stat_searchResponseMessages [protected] |
number of received search-Response-Messages