GIASearchApp Class Reference

#include <GIASearchApp.h>

Inheritance diagram for GIASearchApp:

BaseApp BaseRpc RpcListener

List of all members.


Detailed Description

Gia search test application.

Gia search test application, sends periodically SEARCH-Messages and collects statistical data.

See also:
BaseApp

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

SearchMsgBookkeepingsrMsgBook
 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

Constructor & Destructor Documentation

GIASearchApp::GIASearchApp (  ) 

00037 {
00038     search_timer = keyList_timer = NULL;
00039     srMsgBook = NULL;
00040 }

GIASearchApp::~GIASearchApp (  )  [virtual]

00043 {
00044     cancelAndDelete(search_timer);
00045     cancelAndDelete(keyList_timer);
00046     if (srMsgBook != NULL) {
00047         delete srMsgBook;
00048         srMsgBook = NULL;
00049     }
00050 }


Member Function Documentation

void GIASearchApp::initializeApp ( int  stage  )  [protected, virtual]

initializes base class-attributes

Parameters:
stage the init stage

Reimplemented from BaseApp.

00053 {
00054     if (stage != MIN_STAGE_APP)
00055         return;
00056 
00057     // fetch parameters
00058     mean = par("messageDelay");
00059     deviation = mean / 3;
00060     randomNodes = par("randomNodes");
00061     maxResponses = par("maxResponses");
00062 
00063     srMsgBook = new SearchMsgBookkeeping();
00064 
00065     // statistics
00066     stat_keyListMessagesSent = 0;
00067     stat_keyListBytesSent = 0;
00068     stat_searchMessagesSent = 0;
00069     stat_searchBytesSent = 0;
00070     stat_searchResponseMessages = 0;
00071     stat_searchResponseBytes = 0;
00072 
00073     // initiate test message emision
00074     search_timer = new cMessage("search_timer");
00075     scheduleAt(simulation.simTime() + truncnormal(mean, deviation),
00076                search_timer);
00077 
00078     keyList_timer = new cMessage("keyList_timer");
00079     scheduleAt(simulation.simTime() + uniform(0.0, 10.0), keyList_timer);
00080 }

void GIASearchApp::handleLowerMessage ( cMessage *  msg  )  [protected, virtual]

method to handle non-commonAPI messages from the overlay

Parameters:
msg message to handle

Reimplemented from BaseApp.

00152 {
00153     GIAanswer* answer = check_and_cast<GIAanswer*>(msg);
00154     OverlayCtrlInfo* overlayCtrlInfo =
00155         check_and_cast<OverlayCtrlInfo*>(answer->removeControlInfo());
00156 
00157     OverlayKey searchKey = answer->getSearchKey();
00158 
00159     if (debugOutput)
00160         EV << "(GIASearchApp) Node " << thisNode.ip
00161         << " received answer-message from overlay:"
00162         << " (key: " << searchKey
00163         << " at node " << answer->getNode()
00164         << ")" << endl;
00165 
00166     stat_searchResponseMessages++;
00167     stat_searchResponseBytes += answer->byteLength();
00168 
00169     if (srMsgBook->contains(searchKey))
00170         srMsgBook->updateItem(searchKey, overlayCtrlInfo->getHopCount());
00171 
00172     delete answer;
00173 }

void GIASearchApp::handleTimerEvent ( cMessage *  msg  )  [protected, virtual]

processes self-messages

method to handle self-messages should be overwritten in derived application if needed

Parameters:
msg self-message

Reimplemented from BaseApp.

00083 {
00084     if(msg == keyList_timer) {
00085         keyList = bootstrapOracle->getKeyList(par("maximumKeys"));
00086         WATCH_VECTOR(*keyList);
00087 
00088         // create message
00089         GIAput* putMsg = new GIAput("GIA-Keylist");
00090         putMsg->setCommand(GIA_PUT);
00091 
00092         putMsg->setKeysArraySize(keyList->size());
00093 
00094         std::vector<OverlayKey>::iterator it;
00095         int k;
00096         for(it = keyList->begin(), k = 0; it != keyList->end(); it++, k++)
00097             putMsg->setKeys(k, *it);
00098 
00099         putMsg->setLength(GIAPUT_L(putMsg));
00100 
00101         sendMessageToOverlay(putMsg);
00102 
00103         if (debugOutput)
00104             EV << "(GIASearchApp) Node " << thisNode.ip
00105             << " sent keylist to overlay." << endl;
00106 
00107         stat_keyListMessagesSent++;
00108         stat_keyListBytesSent += putMsg->byteLength();
00109     }
00110     else if(msg == search_timer) {
00111         // schedule next search-message
00112         scheduleAt(simulation.simTime() + truncnormal(mean, deviation), msg);
00113 
00114         // do nothing, if the network is still in the initiaization phase
00115         if((!par("activeNetwInitPhase")) && (underlayConfigurator->isInit()))
00116             return;
00117 
00118         OverlayKey keyListItem;
00119         uint maximumTries = 20;
00120         // pic a search key we are not already searching
00121         do {
00122             if (maximumTries-- == 0)
00123                 break;
00124             keyListItem = bootstrapOracle->getRandomKeyListItem();
00125         } while ((keyListItem.isUnspecified())
00126                  && ((srMsgBook->contains(keyListItem))));
00127 
00128         if (!keyListItem.isUnspecified()) {
00129             // create message
00130             GIAsearch* getMsg = new GIAsearch("GIA-Search");
00131             getMsg->setCommand(GIA_SEARCH);
00132             getMsg->setSearchKey(keyListItem);
00133             getMsg->setMaxResponses(maxResponses);
00134             getMsg->setLength(GIAGET_L(getMsg));
00135 
00136             sendMessageToOverlay(getMsg);
00137 
00138             // add search key to our bookkeeping list
00139             srMsgBook->addMessage(keyListItem);
00140 
00141             if (debugOutput)
00142                 EV << "(GIASearchApp) Node " << thisNode.ip
00143                 << " sent get-message to overlay" << endl;
00144 
00145             stat_searchMessagesSent++;
00146             stat_searchBytesSent += getMsg->byteLength();
00147         }
00148     }
00149 }

void GIASearchApp::finishApp (  )  [protected, virtual]

collects statistical data

Reimplemented from BaseApp.

00176 {
00177     // record scalar data
00178     GiaSearchStats stats = srMsgBook->getStatisticalData();
00179 
00180         globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. min delay", stats.minDelay);
00181     globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. max delay", stats.maxDelay);
00182     globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. min hops", stats.minHopCount);
00183     globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. max hops", stats.maxHopCount);
00184     globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. response count",
00185                  stats.responseCount);
00186 }


Member Data Documentation

std::vector<OverlayKey>* GIASearchApp::keyList [private]

list of all maintained key of this application

SearchMsgBookkeeping* GIASearchApp::srMsgBook [protected]

pointer to Search-Message-Bookkeeping-List in this node

double GIASearchApp::mean [protected]

mean interval for next message

double GIASearchApp::deviation [protected]

deviation of mean interval

bool GIASearchApp::randomNodes [protected]

use random destination nodes or only nodes from BootstrapOracle?

int GIASearchApp::maxResponses [protected]

maximum number of responses per search message

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]

number of keyList-Messages sent

int GIASearchApp::stat_keyListBytesSent [protected]

number of keyList-Bytes sent

int GIASearchApp::stat_searchMessagesSent [protected]

number of search-Messages sent

int GIASearchApp::stat_searchBytesSent [protected]

number of search-Messages-Bytes sent

int GIASearchApp::stat_searchResponseMessages [protected]

number of received search-Response-Messages

int GIASearchApp::stat_searchResponseBytes [protected]

number of received search-Response-Messages-Bytes

cMessage* GIASearchApp::search_timer [protected]

timer for search messages

cMessage* GIASearchApp::keyList_timer [protected]

timer for initial key list packet to overlay


The documentation for this class was generated from the following files:
Generated on Thu Apr 17 13:19:29 2008 for ITM OverSim by  doxygen 1.5.3