OverSim
I3Composite Class Reference

Composite test application for I3. More...

Inheritance diagram for I3Composite:
I3BaseApp

Public Member Functions

void initializeApp (int stage)
 App initialization - should be overwritten by application.
void initializeI3 ()
 Application I3 initialize - should be overwritten by application.
void deliver (I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg)
 Delivers packets coming from I3 - should be overwritten by application.
void handleTimerEvent (cMessage *msg)
 Handles timers - should be overwritten by application.
void createMessage ()
- Public Member Functions inherited from I3BaseApp
 I3BaseApp ()
 Constructor.
 ~I3BaseApp ()
 Destructor.

Public Attributes

int myIndex
cMessage * sendPacketTimer

Static Private Attributes

static int index = 0

Additional Inherited Members

- Protected Types inherited from I3BaseApp
enum  I3MobilityStage { I3_MOBILITY_BEFORE_UPDATE, I3_MOBILITY_UPDATED }
- Protected Member Functions inherited from I3BaseApp
int numInitStages () const
 Returns number of init stages required.
void initialize (int stage)
 Basic initialization.
void bootstrapI3 ()
 Internal I3 bootstrap - connects to I3, inserts sampling triggers and initializes timers.
virtual void handleUDPMessage (cMessage *msg)
 Handles messages incoming from UDP gate.
void handleMessage (cMessage *msg)
 Handles incoming messages.
void sendToI3 (I3Message *msg)
 Sends a message to I3.
void sendThroughUDP (cMessage *msg, const I3IPAddress &ip)
 Sends a message through UDP.
void refreshTriggers ()
 Refreshes (reinserts) stored triggers.
void refreshSamples ()
 Refreshes sampling triggers and selects fastest server as gateway.
I3Identifier retrieveClosestIdentifier ()
void sendPacket (const I3Identifier &id, cPacket *msg, bool useHint=false)
 Routes a packet through I3, passing an identifier stack composed of a single identifier.
void sendPacket (const I3IdentifierStack &stack, cPacket *msg, bool useHint=false)
 Routes a packet through I3.
void insertTrigger (const I3Identifier &identifier, bool store=true)
 Inserts a trigger into I3, composed by the given identifier and an identifier stack containing only this node's IP address.
void insertTrigger (const I3Identifier &identifier, const I3IdentifierStack &stack, bool store=true)
 Inserts a trigger into I3 with the given identifier and identifier stack.
void insertTrigger (const I3Trigger &t, bool store=true)
 Inserts the given trigger into I3.
void removeTrigger (const I3Identifier &identifier)
 Removes all triggers from the list of inserted triggers whose identifiers equal the one given.
void removeTrigger (const I3Trigger &trigger)
 Removes a trigger from I3.
std::set< I3Trigger > & getInsertedTriggers ()
 Returns the list of inserted triggers.
void receiveChangeNotification (int category, const cPolymorphic *details)
virtual void doMobilityEvent (I3MobilityStage stage)
- Protected Attributes inherited from I3BaseApp
int numSent
 Number of sent messages.
int sentBytes
int numReceived
 Number of received messages.
int receivedBytes
int numIsolations
 Number of times this node has been isolated - i.e.
IPvXAddress nodeIPAddress
 Cached IP address of this node.
std::set< I3TriggerinsertedTriggers
 Stored I3 triggers sent from this node, to be refreshed automatically.
std::map< I3Identifier,
I3CachedServer
samplingCache
std::map< I3Identifier,
I3CachedServer
identifierCache
I3CachedServer gateway
cMessage * refreshTriggersTimer
int refreshTriggersTime
cMessage * refreshSamplesTimer
int refreshSamplesTime
cMessage * initializeTimer
cMessage * bootstrapTimer

Detailed Description

Composite test application for I3.

This tests the ability of I3 to realize service composition in which the receving node decides the routing of a packet. First, all nodes insert their own trigger. Then, node 0 creates an packet containing an empty sentence (""), and sends it to I3 with an identifier stack containing the triggers of service nodes 1, 2, 3, 4 and then node 0. I3 then routes the packet to each of those triggers in that order. Each service node adds some words to the sentence ands sends it back to I3 with the same identifier stack it received. When it returns to node 0 it displays the sentence it received and starts again.

Definition at line 43 of file I3Composite.cc.

Member Function Documentation

void I3Composite::createMessage ( )

Definition at line 80 of file I3Composite.cc.

{
cmsg->sentence = "";
I3Identifier id0("Composite 0"),
id1("Composite 1"),
id2("Composite 2"),
id3("Composite 3"),
id4("Composite 4");
stack.push(id0);
stack.push(id4);
stack.push(id3);
stack.push(id2);
stack.push(id1);
sendPacket(stack, cmsg);
}
void I3Composite::deliver ( I3Trigger trigger,
I3IdentifierStack stack,
cPacket *  msg 
)
virtual

Delivers packets coming from I3 - should be overwritten by application.

Parameters
triggerApplication trigger to which the packet was sent
stackIdentifier stack passed from I3
msgArriving message

Reimplemented from I3BaseApp.

Definition at line 110 of file I3Composite.cc.

{
I3CompositeMessage *cmsg = check_and_cast<I3CompositeMessage*>(msg);
switch (myIndex) {
case 0:
{
string final = "Final sentence: " + cmsg->sentence;
getParentModule()->bubble(final.c_str());
delete msg;
return;
}
case 1:
getParentModule()->bubble("Adding 'He pounds'");
cmsg->sentence += "He pounds ";
break;
case 2:
getParentModule()->bubble("Adding 'his fists'");
cmsg->sentence += "his fists ";
break;
case 3:
getParentModule()->bubble("Adding 'against'");
cmsg->sentence += "against ";
break;
case 4:
getParentModule()->bubble("Adding 'the posts'");
cmsg->sentence += "the posts ";
break;
default:
delete msg;
return;
}
sendPacket(stack, cmsg);
}
void I3Composite::handleTimerEvent ( cMessage *  msg)
virtual

Handles timers - should be overwritten by application.

Parameters
msgTimer to be handled

Reimplemented from I3BaseApp.

Definition at line 101 of file I3Composite.cc.

{
if (myIndex == 0) { // only the first node
getParentModule()->bubble("Starting chain!");
}
delete msg;
}
void I3Composite::initializeApp ( int  stage)
virtual

App initialization - should be overwritten by application.

I3 related commands should go in initializeI3.

Parameters
stageInitialization stage passed from initialize()

Reimplemented from I3BaseApp.

Definition at line 60 of file I3Composite.cc.

{
}
void I3Composite::initializeI3 ( )
virtual

Application I3 initialize - should be overwritten by application.

Reimplemented from I3BaseApp.

Definition at line 66 of file I3Composite.cc.

{
if (myIndex == 0) {
sendPacketTimer = new cMessage("packet timer");
scheduleAt(simTime() + 50, sendPacketTimer);
}
ostringstream os;
os << "Composite " << myIndex;
I3Identifier identifier(os.str());
insertTrigger(identifier);
}

Member Data Documentation

int I3Composite::index = 0
staticprivate

Definition at line 46 of file I3Composite.cc.

int I3Composite::myIndex

Definition at line 48 of file I3Composite.cc.

cMessage* I3Composite::sendPacketTimer

Definition at line 49 of file I3Composite.cc.


The documentation for this class was generated from the following file: