OverSim
GIASearchApp Class Reference

Gia search test application. More...

#include <GIASearchApp.h>

Inheritance diagram for GIASearchApp:
BaseApp BaseRpc BaseTcpSupport RpcListener

Public Member Functions

 GIASearchApp ()
virtual ~GIASearchApp ()
- Public Member Functions inherited from BaseApp
 BaseApp ()
virtual ~BaseApp ()
 virtual destructor
- Public Member Functions inherited from BaseRpc
 BaseRpc ()
const NodeHandlegetThisNode ()
 Returns the NodeHandle of this node.
simtime_t getUdpTimeout ()
- Public Member Functions inherited from RpcListener
virtual ~RpcListener ()
 destructor
- Public Member Functions inherited from BaseTcpSupport
virtual void socketDataArrived (int connId, void *yourPtr, cPacket *msg, bool urgent)
virtual void socketEstablished (int connId, void *yourPtr)
virtual void socketPeerClosed (int connId, void *yourPtr)
virtual void socketFailure (int connId, void *yourPtr, int code)
virtual void socketStatusArrived (int connId, void *yourPtr, TCPStatusInfo *status)

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 Member Functions inherited from BaseApp
int numInitStages () const
 method to set InitStage
void initialize (int stage)
 initializes base class-attributes
void handleMessage (cMessage *msg)
 checks for message type and calls corresponding method
virtual void receiveChangeNotification (int category, const cPolymorphic *details)
 callback-method for events at the NotificationBoard
virtual void handleTransportAddressChangedNotification ()
 This method gets call if the node has a new TransportAddress (IP address) because he changed his access network.
virtual void handleNodeLeaveNotification ()
 This method gets call **.gracefulLeaveDelay seconds before it is killed.
virtual void handleNodeGracefulLeaveNotification ()
 This method gets call **.gracefulLeaveDelay seconds before it is killed if this node is among the gracefulLeaveProbability nodes.
void finish ()
 collects statistical data
void callRoute (const OverlayKey &key, cPacket *msg, const TransportAddress &hint=TransportAddress::UNSPECIFIED_NODE, RoutingType routingType=DEFAULT_ROUTING)
 Common API function: calls route-method in overlay.
void callRoute (const OverlayKey &key, cPacket *msg, const std::vector< TransportAddress > &sourceRoute, RoutingType routingType=DEFAULT_ROUTING)
virtual void deliver (OverlayKey &key, cMessage *msg)
 Common API function: handles delivered messages from overlay.
virtual void forward (OverlayKey *key, cPacket **msg, NodeHandle *nextHopNode)
 Common API function: handles messages from overlay to be forwarded.
virtual void update (const NodeHandle &node, bool joined)
 Common API function: informs application about neighbors and own nodeID.
NodeVectorcallLocalLookup (const OverlayKey &key, int num, bool safe)
 Common API function: produces a list of nodes that can be used as next hops towards key.
NodeVectorcallNeighborSet (int num)
 Common API function: produces a list of neighbor nodes.
bool isSiblingFor (const NodeHandle &node, const OverlayKey &key, int numSiblings, bool *err)
 Query if a node is among the siblings for a given key.
virtual void handleUpperMessage (cMessage *msg)
 handleUpperMessage gets called of handleMessage(cMessage* msg) if msg arrivedOn from_upperTier (currently msg gets deleted in this function)
virtual void handleUDPMessage (cMessage *msg)
 method to handle messages that come directly from the UDP gate
virtual void handleReadyMessage (CompReadyMessage *msg)
 method to handle ready messages from the overlay
virtual void bindToPort (int port)
 Tells UDP we want to get all packets arriving on the given port.
virtual void sendMessageToUDP (const TransportAddress &destAddr, cPacket *msg, simtime_t delay=SIMTIME_ZERO)
 Sends a packet over UDP.
virtual void handleTraceMessage (cMessage *msg)
 handleTraceMessage gets called of handleMessage(cMessage* msg) if a message arrives at trace_in.
void sendMessageToLowerTier (cPacket *msg)
 sends non-commonAPI message to the lower tier
bool internalHandleRpcCall (BaseCallMessage *msg)
 Handles internal rpc requests.
void internalHandleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 Handles rpc responses internal in base classes

void internalSendRouteRpc (BaseRpcMessage *message, const OverlayKey &destKey, const std::vector< TransportAddress > &sourceRoute, RoutingType routingType)
virtual CompType getThisCompType ()
 Return the component type of this module.
void sendReadyMessage (bool ready=true, const OverlayKey &nodeId=OverlayKey::UNSPECIFIED_KEY)
- Protected Member Functions inherited from BaseRpc
virtual void internalHandleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey)
 Handles rpc timeouts internal in base classes

void initRpcs ()
 Initializes Remote-Procedure state.
void finishRpcs ()
 Deinitializes Remote-Procedure state.
virtual void internalHandleRpcMessage (BaseRpcMessage *msg)
 Handles incoming rpc messages and delegates them to the corresponding listeners or handlers.
uint32_t sendRouteRpcCall (CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseCallMessage *msg, cPolymorphic *context=NULL, RoutingType routingType=DEFAULT_ROUTING, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL)
 Routes a Remote-Procedure-Call message to an OverlayKey.
uint32_t sendRouteRpcCall (CompType destComp, const OverlayKey &destKey, BaseCallMessage *msg, cPolymorphic *context=NULL, RoutingType routingType=DEFAULT_ROUTING, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL)
 Routes a Remote-Procedure-Call message to an OverlayKey.
uint32_t sendRouteRpcCall (CompType destComp, const TransportAddress &dest, BaseCallMessage *msg, cPolymorphic *context=NULL, RoutingType routingType=DEFAULT_ROUTING, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL)
 Sends a Remote-Procedure-Call message using the overlay's UDP port
This replaces ROUTE_DIRECT calls!
uint32_t sendUdpRpcCall (const TransportAddress &dest, BaseCallMessage *msg, cPolymorphic *context=NULL, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL)
 Sends a Remote-Procedure-Call message to the underlay

uint32_t sendInternalRpcCall (CompType destComp, BaseCallMessage *msg, cPolymorphic *context=NULL, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL)
 Sends an internal Remote-Procedure-Call between two tiers

void cancelRpcMessage (uint32_t nonce)
 Cancels a Remote-Procedure-Call.
void cancelAllRpcs ()
 Cancels all RPCs.
void sendRpcResponse (TransportType transportType, CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseCallMessage *call, BaseResponseMessage *response)
 Send Remote-Procedure response message and deletes call message.
void sendRpcResponse (BaseCallMessage *call, BaseResponseMessage *response)
 Send Remote-Procedure response message to UDP and deletes call message.
int pingNode (const TransportAddress &dest, simtime_t timeout=-1, int retries=0, cPolymorphic *context=NULL, const char *caption="PING", RpcListener *rpcListener=NULL, int rpcId=-1, TransportType transportType=INVALID_TRANSPORT)
 ping a node by its TransportAddress
virtual bool handleRpcCall (BaseCallMessage *msg)
 Processes Remote-Procedure-Call invocation messages.
virtual void pingResponse (PingResponse *pingResponse, cPolymorphic *context, int rpcId, simtime_t rtt)
virtual void pingTimeout (PingCall *pingCall, const TransportAddress &dest, cPolymorphic *context, int rpcId)
bool internalHandleMessage (cMessage *msg)
- Protected Member Functions inherited from RpcListener
virtual void handleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 This method is called if an RPC response has been received.
virtual void handleRpcResponse (BaseResponseMessage *msg, const RpcState &rpcState, simtime_t rtt)
 This method is called if an RPC response has been received.
virtual void handleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey)
 This method is called if an RPC timeout has been reached.
virtual void handleRpcTimeout (const RpcState &rpcState)
 This method is called if an RPC timeout has been reached.
- Protected Member Functions inherited from BaseTcpSupport
void handleTCPMessage (cMessage *msg)
 Member function to handle incoming TCP messages.
void bindAndListenTcp (int port)
 Member function to bind service to the specified port and listen afterwards.
bool isAlreadyConnected (TransportAddress address)
 Member function to check if the service is already connected.
void establishTcpConnection (TransportAddress address)
 Member function to establish a connection to the specified node.
void sendTcpData (cPacket *msg, TransportAddress address)
 Member function to send TCP data to the specified node.
virtual void handleConnectionEvent (EvCode code, TransportAddress address)
 Member function to handle passive connection events.
virtual void handleDataReceived (TransportAddress address, cPacket *msg, bool urgent)
 Member function to handle incoming data.
virtual void handleIncomingConnection (TransportAddress address)
 Member function to handle newly opened connections.
void closeTcpConnection (TransportAddress address)
 Member function to close an established connection.
void setTcpOut (cGate *gate)
 Member function to set local gate towards the TCP module during init phase.
cGate * getTcpOut ()
 Member function to get local gate towards the TCP module.

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
- Protected Attributes inherited from BaseApp
UnderlayConfiguratorunderlayConfigurator
 pointer to UnderlayConfigurator in this node
GlobalNodeListglobalNodeList
 pointer to GlobalNodeList in this node
GlobalStatisticsglobalStatistics
 pointer to GlobalStatistics module in this node
NotificationBoard * notificationBoard
 pointer to NotificationBoard in this node
bool debugOutput
 debug output yes/no?
int numOverlaySent
 number of sent packets to overlay
int bytesOverlaySent
 number of sent bytes to overlay
int numOverlayReceived
 number of received packets from overlay
int bytesOverlayReceived
 number of received bytes from overlay
int numUdpSent
 number of sent packets to UDP
int bytesUdpSent
 number of sent bytes to UDP
int numUdpReceived
 number of received packets from UDP
int bytesUdpReceived
 number of received bytes from UDP
simtime_t creationTime
 simTime when the App has been created
- Protected Attributes inherited from BaseRpc
NodeHandle thisNode
 NodeHandle to this node.
BaseOverlayoverlay
bool debugOutput
 debug output ?
GlobalStatisticsglobalStatistics
 pointer to GlobalStatistics module in this node
CompType thisCompType
NeighborCacheneighborCache
 pointer to the neighbor cache
CryptoModulecryptoModule
 pointer to CryptoModule
int numPingSent
int bytesPingSent
int numPingResponseSent
int bytesPingResponseSent

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

Additional Inherited Members

- Public Types inherited from BaseTcpSupport
enum  EvCode {
  NO_EST_CONNECTION, PEER_CLOSED, PEER_TIMEDOUT, PEER_REFUSED,
  CONNECTION_RESET, CONNECTION_SUCC_ClOSED
}

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.

{
srMsgBook = NULL;
}
GIASearchApp::~GIASearchApp ( )
virtual

Definition at line 43 of file GIASearchApp.cc.

{
cancelAndDelete(search_timer);
cancelAndDelete(keyList_timer);
if (srMsgBook != NULL) {
delete srMsgBook;
srMsgBook = NULL;
}
}

Member Function Documentation

void GIASearchApp::finishApp ( )
protectedvirtual

collects statistical data

Reimplemented from BaseApp.

Definition at line 178 of file GIASearchApp.cc.

{
// record scalar data
if (stats.minDelay == 0 &&
stats.maxDelay == 0 &&
stats.minHopCount == 0 &&
stats.maxHopCount == 0 &&
stats.responseCount == 0) return;
globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. min delay",
stats.minDelay);
globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. max delay",
stats.maxDelay);
globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. min hops",
stats.minHopCount);
globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. max hops",
stats.maxHopCount);
globalStatistics->addStdDev("GIASearchApp: SearchMsg avg. response count",
stats.responseCount);
}
void GIASearchApp::handleLowerMessage ( cMessage *  msg)
protectedvirtual

processes self-messages

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

Parameters
msgself-message method to handle non-commonAPI messages from the overlay
msgmessage to handle

Reimplemented from BaseApp.

Definition at line 154 of file GIASearchApp.cc.

{
GIAanswer* answer = check_and_cast<GIAanswer*>(msg);
OverlayCtrlInfo* overlayCtrlInfo =
check_and_cast<OverlayCtrlInfo*>(answer->removeControlInfo());
OverlayKey searchKey = answer->getSearchKey();
EV << "[GIASearchApp::handleLowerMessage() @ " << overlay->getThisNode().getIp()<< "]\n"
<< " Node received answer-message from overlay:"
<< " (key: " << searchKey
<< " at node " << answer->getNode() << ")"
<< endl;
stat_searchResponseBytes += answer->getByteLength();
if (srMsgBook->contains(searchKey))
srMsgBook->updateItem(searchKey, overlayCtrlInfo->getHopCount());
delete answer;
}
void GIASearchApp::handleTimerEvent ( cMessage *  msg)
protectedvirtual

Reimplemented from BaseRpc.

Definition at line 83 of file GIASearchApp.cc.

{
if(msg == keyList_timer) {
keyList = globalNodeList->getKeyList(par("maximumKeys"));
WATCH_VECTOR(*keyList);
// create message
GIAput* putMsg = new GIAput("GIA-Keylist");
putMsg->setCommand(GIA_PUT);
putMsg->setKeysArraySize(keyList->size());
std::vector<OverlayKey>::iterator it;
int k;
for(it = keyList->begin(), k = 0; it != keyList->end(); it++, k++)
putMsg->setKeys(k, *it);
putMsg->setBitLength(GIAPUT_L(putMsg));
EV << "[GIASearchApp::handleTimerEvent() @ " << overlay->getThisNode().getIp()<< "]\n"
<< " Node sent keylist to overlay."
<< endl;
stat_keyListBytesSent += putMsg->getByteLength();
}
else if(msg == search_timer) {
// schedule next search-message
scheduleAt(simTime() + truncnormal(mean, deviation), msg);
// do nothing, if the network is still in the initiaization phase
if((!par("activeNetwInitPhase")) && (underlayConfigurator->isInInitPhase()))
return;
OverlayKey keyListItem;
uint32_t maximumTries = 20;
// pic a search key we are not already searching
do {
if (maximumTries-- == 0)
break;
} while ((keyListItem.isUnspecified())
&& ((srMsgBook->contains(keyListItem))));
if (!keyListItem.isUnspecified()) {
// create message
GIAsearch* getMsg = new GIAsearch("GIA-Search");
getMsg->setSearchKey(keyListItem);
getMsg->setBitLength(GIAGET_L(getMsg));
// add search key to our bookkeeping list
srMsgBook->addMessage(keyListItem);
EV << "[GIASearchApp::handleTimerEvent() @ " << overlay->getThisNode().getIp()<< "]\n"
<< " Node sent get-message to overlay."
<< endl;
stat_searchBytesSent += getMsg->getByteLength();
}
}
}
void GIASearchApp::initializeApp ( int  stage)
protectedvirtual

initializes base class-attributes

Parameters
stagethe init stage

Reimplemented from BaseApp.

Definition at line 53 of file GIASearchApp.cc.

{
if (stage != MIN_STAGE_APP)
return;
// fetch parameters
mean = par("messageDelay");
deviation = mean / 3;
randomNodes = par("randomNodes");
maxResponses = par("maxResponses");
// statistics
// initiate test message emision
search_timer = new cMessage("search_timer");
scheduleAt(simTime() + truncnormal(mean, deviation),
keyList_timer = new cMessage("keyList_timer");
scheduleAt(simTime() + uniform(0.0, 10.0), keyList_timer);
}

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
staticprotected

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
staticprotected

Definition at line 83 of file GIASearchApp.h.

SearchMsgBookkeeping* GIASearchApp::srMsgBook
protected

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().

int GIASearchApp::stat_keyListBytesSent
protected

number of keyList-Bytes sent

Definition at line 88 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

int GIASearchApp::stat_keyListMessagesSent
protected

number of keyList-Messages sent

Definition at line 87 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

int GIASearchApp::stat_searchBytesSent
protected

number of search-Messages-Bytes sent

Definition at line 90 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

int GIASearchApp::stat_searchMessagesSent
protected

number of search-Messages sent

Definition at line 89 of file GIASearchApp.h.

Referenced by handleTimerEvent(), and initializeApp().

int GIASearchApp::stat_searchResponseBytes
protected

number of received search-Response-Messages-Bytes

Definition at line 92 of file GIASearchApp.h.

Referenced by handleLowerMessage(), and initializeApp().

int GIASearchApp::stat_searchResponseMessages
protected

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: