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