GIASearchApp Class Reference

Gia search test application. More...

#include <GIASearchApp.h>

Inheritance diagram for GIASearchApp:
BaseApp BaseRpc RpcListener

List of all members.

Public Member Functions

 GIASearchApp ()
virtual ~GIASearchApp ()

Protected Member Functions

virtual void initializeApp (int stage)
 initializes base class-attributes
void handleLowerMessage (cMessage *msg)
 processes self-messages
virtual void handleTimerEvent (cMessage *msg)
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 GlobalNodeList?
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 uint32_t ID_L = 16
static const uint32_t SEQNUM_L = 16

Private Attributes

std::vector< OverlayKey > * keyList
 list of all maintained key of this application

Detailed Description

Gia search test application.

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

See also:
BaseApp

Definition at line 45 of file GIASearchApp.h.


Constructor & Destructor Documentation

GIASearchApp::GIASearchApp (  ) 

Definition at line 37 of file GIASearchApp.cc.

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

GIASearchApp::~GIASearchApp (  )  [virtual]

Definition at line 43 of file GIASearchApp.cc.

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


Member Function Documentation

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

collects statistical data

Reimplemented from BaseApp.

Definition at line 178 of file GIASearchApp.cc.

00179 {
00180     // record scalar data
00181     GiaSearchStats stats = srMsgBook->getStatisticalData();
00182 
00183     if (stats.minDelay == 0 &&
00184         stats.maxDelay == 0 &&
00185         stats.minHopCount == 0 &&
00186         stats.maxHopCount == 0 &&
00187         stats.responseCount == 0) return;
00188 
00189         globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. min delay",
00190                                     stats.minDelay);
00191     globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. max delay",
00192                                 stats.maxDelay);
00193     globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. min hops",
00194                                 stats.minHopCount);
00195     globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. max hops",
00196                                 stats.maxHopCount);
00197     globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. response count",
00198                                 stats.responseCount);
00199 }

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

processes self-messages

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

Parameters:
msg self-message method to handle non-commonAPI messages from the overlay
msg message to handle

Reimplemented from BaseApp.

Definition at line 154 of file GIASearchApp.cc.

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

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

Reimplemented from BaseRpc.

Definition at line 83 of file GIASearchApp.cc.

00084 {
00085     if(msg == keyList_timer) {
00086         keyList = globalNodeList->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->setBitLength(GIAPUT_L(putMsg));
00101 
00102         sendMessageToLowerTier(putMsg);
00103 
00104         if (debugOutput)
00105            EV << "[GIASearchApp::handleTimerEvent() @ " << overlay->getThisNode().getAddress()<< "]\n"
00106               << "    Node sent keylist to overlay."
00107               << endl;
00108 
00109         stat_keyListMessagesSent++;
00110         stat_keyListBytesSent += putMsg->getByteLength();
00111     }
00112     else if(msg == search_timer) {
00113         // schedule next search-message
00114         scheduleAt(simTime() + truncnormal(mean, deviation), msg);
00115 
00116         // do nothing, if the network is still in the initiaization phase
00117         if((!par("activeNetwInitPhase")) && (underlayConfigurator->isInInitPhase()))
00118             return;
00119 
00120         OverlayKey keyListItem;
00121         uint32_t maximumTries = 20;
00122         // pic a search key we are not already searching
00123         do {
00124             if (maximumTries-- == 0)
00125                 break;
00126             keyListItem = globalNodeList->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->setBitLength(GIAGET_L(getMsg));
00137 
00138             sendMessageToLowerTier(getMsg);
00139 
00140             // add search key to our bookkeeping list
00141             srMsgBook->addMessage(keyListItem);
00142 
00143             if (debugOutput)
00144                 EV << "[GIASearchApp::handleTimerEvent() @ " << overlay->getThisNode().getAddress()<< "]\n"
00145                    << "    Node sent get-message to overlay."
00146                    << endl;
00147 
00148             stat_searchMessagesSent++;
00149             stat_searchBytesSent += getMsg->getByteLength();
00150         }
00151     }
00152 }

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

initializes base class-attributes

Parameters:
stage the init stage

Reimplemented from BaseApp.

Definition at line 53 of file GIASearchApp.cc.

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(simTime() + truncnormal(mean, deviation),
00077                search_timer);
00078 
00079     keyList_timer = new cMessage("keyList_timer");
00080     scheduleAt(simTime() + uniform(0.0, 10.0), keyList_timer);
00081 }


Member Data Documentation

double GIASearchApp::deviation [protected]

deviation of mean interval

Definition at line 77 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

const uint32_t GIASearchApp::ID_L = 16 [static, protected]

Definition at line 82 of file GIASearchApp.h.

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

list of all maintained key of this application

Definition at line 53 of file GIASearchApp.h.

Referenced by handleTimerEvent().

cMessage* GIASearchApp::keyList_timer [protected]

timer for initial key list packet to overlay

Definition at line 95 of file GIASearchApp.h.

Referenced by GIASearchApp(), handleTimerEvent(), initializeApp(), and ~GIASearchApp().

int GIASearchApp::maxResponses [protected]

maximum number of responses per search message

Definition at line 79 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

double GIASearchApp::mean [protected]

mean interval for next message

Definition at line 76 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

int GIASearchApp::msgByteLength [protected]

Definition at line 84 of file GIASearchApp.h.

bool GIASearchApp::randomNodes [protected]

use random destination nodes or only nodes from GlobalNodeList?

Definition at line 78 of file GIASearchApp.h.

Referenced by initializeApp().

cMessage* GIASearchApp::search_timer [protected]

timer for search messages

Definition at line 94 of file GIASearchApp.h.

Referenced by GIASearchApp(), handleTimerEvent(), initializeApp(), and ~GIASearchApp().

const uint32_t GIASearchApp::SEQNUM_L = 16 [static, protected]

Definition at line 83 of file GIASearchApp.h.

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

Definition at line 73 of file GIASearchApp.h.

Referenced by finishApp(), GIASearchApp(), handleLowerMessage(), handleTimerEvent(), initializeApp(), and ~GIASearchApp().

number of keyList-Bytes sent

Definition at line 88 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

number of keyList-Messages sent

Definition at line 87 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

number of search-Messages-Bytes sent

Definition at line 90 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

number of search-Messages sent

Definition at line 89 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

number of received search-Response-Messages-Bytes

Definition at line 92 of file GIASearchApp.h.

Referenced by handleLowerMessage(), and initializeApp().

number of received search-Response-Messages

Definition at line 91 of file GIASearchApp.h.

Referenced by handleLowerMessage(), and initializeApp().


The documentation for this class was generated from the following files:
Generated on Wed May 26 16:21:17 2010 for OverSim by  doxygen 1.6.3