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 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

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     onlyCommonAPIMessages = false;
00064 
00065     srMsgBook = new SearchMsgBookkeeping();
00066 
00067     // statistics
00068     stat_keyListMessagesSent = 0;
00069     stat_keyListBytesSent = 0;
00070     stat_searchMessagesSent = 0;
00071     stat_searchBytesSent = 0;
00072     stat_searchResponseMessages = 0;
00073     stat_searchResponseBytes = 0;
00074 
00075     // initiate test message emision
00076     search_timer = new cMessage("search_timer");
00077     scheduleAt(simulation.simTime() + truncnormal(mean, deviation),
00078                search_timer);
00079 
00080     keyList_timer = new cMessage("keyList_timer");
00081     scheduleAt(simulation.simTime() + uniform(0.0, 10.0), keyList_timer);
00082 }

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

method to handle non-commonAPI messages from the overlay

Parameters:
msg message to handle

Reimplemented from BaseApp.

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

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.

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

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

collects statistical data

Reimplemented from BaseApp.

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


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 Wed Sep 26 12:13:01 2007 for ITM OverSim by  doxygen 1.5.1