#include <ALMTest.h>
Public Member Functions | |
ALMTest () | |
~ALMTest () | |
void | initializeApp (int stage) |
initializes derived class-attributes | |
void | finishApp () |
collects statistical data of derived app | |
Protected Member Functions | |
void | handleLowerMessage (cMessage *msg) |
processes self-messages | |
void | handleReadyMessage (CompReadyMessage *msg) |
method to handle ready messages from the overlay | |
void | handleTransportAddressChangedNotification () |
This method gets call if the node has a new TransportAddress (IP address) because he changed his access network. | |
void | handleUDPMessage (cMessage *msg) |
method to handle messages that come directly from the UDP gate | |
void | handleUpperMessage (cMessage *msg) |
handleUpperMessage gets called of handleMessage(cMessage* msg) if msg arrivedOn from_upperTier (currently msg gets deleted in this function) | |
void | handleTimerEvent (cMessage *msg) |
void | joinGroup (int i) |
void | leaveGroup (int i) |
void | sendDataToGroup (int i) |
void | handleMCast (ALMMulticastMessage *mcast) |
Protected Attributes | |
cMessage * | timer |
int | groupNum |
Private Attributes | |
bool | joinGroups |
bool | sendMessages |
MessageObserver * | observer |
int | msglen |
Definition at line 34 of file ALMTest.h.
ALMTest::ALMTest | ( | ) |
Definition at line 31 of file ALMTest.cc.
{ timer = new cMessage( "app_timer"); joinGroups = true; sendMessages = true; observer = NULL; }
ALMTest::~ALMTest | ( | ) |
Definition at line 39 of file ALMTest.cc.
{ cancelAndDelete( timer ); }
void ALMTest::finishApp | ( | ) | [virtual] |
void ALMTest::handleLowerMessage | ( | cMessage * | msg | ) | [protected, virtual] |
processes self-messages
method to handle self-messages should be overwritten in derived application if needed
msg | self-message method to handle non-commonAPI messages from the overlay | |
msg | message to handle |
Reimplemented from BaseApp.
Definition at line 78 of file ALMTest.cc.
{ ALMMulticastMessage* mcast = dynamic_cast<ALMMulticastMessage*>(msg); if ( mcast != 0 ) { handleMCast(mcast); } }
void ALMTest::handleMCast | ( | ALMMulticastMessage * | mcast | ) | [protected] |
Definition at line 151 of file ALMTest.cc.
Referenced by handleLowerMessage().
{ getParentModule()->getParentModule()->bubble("Received message!"); EV << "[ALMTest::handleMCast()]\n" << " App received data message for group: " << mcast->getGroupId() << endl; ALMTestTracedMessage* traced = check_and_cast<ALMTestTracedMessage*>(mcast->decapsulate()); traced->setReceiverId(getId()); observer->receivedMessage(traced); delete traced; delete mcast; }
void ALMTest::handleReadyMessage | ( | CompReadyMessage * | msg | ) | [protected, virtual] |
method to handle ready messages from the overlay
msg | message to handle |
Reimplemented from BaseApp.
Definition at line 86 of file ALMTest.cc.
void ALMTest::handleTimerEvent | ( | cMessage * | msg | ) | [protected] |
Definition at line 63 of file ALMTest.cc.
{ if( msg == timer ) { double random = uniform( 0, 1 ); if( (random < 0.1 && joinGroups) || groupNum < 1 ) { joinGroup( ++groupNum ); } else if( random < 0.2 && joinGroups ) { leaveGroup( groupNum-- ); } else if ( sendMessages ) { sendDataToGroup( intuniform( 1, groupNum )); } scheduleAt( simTime() + 10, timer ); } }
void ALMTest::handleTransportAddressChangedNotification | ( | ) | [protected, virtual] |
This method gets call if the node has a new TransportAddress (IP address) because he changed his access network.
Reimplemented from BaseApp.
Definition at line 96 of file ALMTest.cc.
{ //TODO: Implement assert(false); }
void ALMTest::handleUDPMessage | ( | cMessage * | msg | ) | [protected, virtual] |
method to handle messages that come directly from the UDP gate
msg | message to handle |
Reimplemented from BaseApp.
Definition at line 102 of file ALMTest.cc.
{ //TODO: Implement assert(false); }
void ALMTest::handleUpperMessage | ( | cMessage * | msg | ) | [protected, virtual] |
handleUpperMessage gets called of handleMessage(cMessage* msg) if msg arrivedOn from_upperTier (currently msg gets deleted in this function)
msg | the message to handle |
Reimplemented from BaseApp.
Definition at line 108 of file ALMTest.cc.
{ //TODO: Implement assert(false); }
void ALMTest::initializeApp | ( | int | stage | ) | [virtual] |
initializes derived class-attributes
stage | the init stage |
Reimplemented from BaseApp.
Definition at line 44 of file ALMTest.cc.
{ if( stage != (numInitStages()-1)) { return; } observer = check_and_cast<MessageObserver*>( simulation.getModuleByPath("globalObserver.globalFunctions[0].function.observer")); joinGroups = par("joinGroups"); msglen = par("messageLength"); sendMessages = par("sendMessages"); }
void ALMTest::joinGroup | ( | int | i | ) | [protected] |
Definition at line 114 of file ALMTest.cc.
Referenced by handleTimerEvent().
{ ALMSubscribeMessage* msg = new ALMSubscribeMessage; msg->setGroupId(OverlayKey(i)); send(msg, "to_lowerTier"); observer->joinedGroup(getId(), OverlayKey(i)); }
void ALMTest::leaveGroup | ( | int | i | ) | [protected] |
Definition at line 123 of file ALMTest.cc.
Referenced by handleTimerEvent().
{ ALMLeaveMessage* msg = new ALMLeaveMessage; msg->setGroupId(OverlayKey(i)); send(msg, "to_lowerTier"); observer->leftGroup(getId(), OverlayKey(i)); }
void ALMTest::sendDataToGroup | ( | int | i | ) | [protected] |
Definition at line 132 of file ALMTest.cc.
Referenced by handleTimerEvent().
{ ALMMulticastMessage* msg = new ALMMulticastMessage("Multicast message"); msg->setGroupId(OverlayKey(i)); ALMTestTracedMessage* traced = new ALMTestTracedMessage("Traced message"); traced->setTimestamp(); traced->setGroupId(OverlayKey(i)); traced->setMcastId(traced->getId()); traced->setSenderId(getId()); traced->setByteLength(msglen); msg->encapsulate(traced); send(msg, "to_lowerTier"); observer->sentMessage(traced); }
int ALMTest::groupNum [protected] |
Definition at line 58 of file ALMTest.h.
Referenced by handleReadyMessage(), and handleTimerEvent().
bool ALMTest::joinGroups [private] |
Definition at line 65 of file ALMTest.h.
Referenced by ALMTest(), handleTimerEvent(), and initializeApp().
int ALMTest::msglen [private] |
Definition at line 70 of file ALMTest.h.
Referenced by initializeApp(), and sendDataToGroup().
MessageObserver* ALMTest::observer [private] |
Definition at line 69 of file ALMTest.h.
Referenced by ALMTest(), finishApp(), handleMCast(), initializeApp(), joinGroup(), leaveGroup(), and sendDataToGroup().
bool ALMTest::sendMessages [private] |
Definition at line 67 of file ALMTest.h.
Referenced by ALMTest(), handleTimerEvent(), and initializeApp().
cMessage* ALMTest::timer [protected] |
Definition at line 57 of file ALMTest.h.
Referenced by ALMTest(), finishApp(), handleReadyMessage(), handleTimerEvent(), and ~ALMTest().