Public Member Functions | Public Attributes | Static Private Attributes

I3Anycast Class Reference

Random ping test application for I3. More...

Inheritance diagram for I3Anycast:
I3BaseApp

List of all members.

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.

Public Attributes

int myIndex
cMessage * sendPacketTimer

Static Private Attributes

static int index = 0

Detailed Description

Random ping test application for I3.

First, all nodes insert a trigger in which the identifier has a constant prefix but a random postfix. Then the first node sends a message with an identifier that has the previous prefix, but a different random suffix. That makes that, when the packet is matched within I3 and sent to the closest match, it will land each time on a random node. The fact that it retains the same prefix guarantees that a match will always exist and the packet won't be dropped. After arrival in each node, the process is repeated.

Definition at line 34 of file I3Anycast.cc.


Member Function Documentation

void I3Anycast::deliver ( I3Trigger trigger,
I3IdentifierStack stack,
cPacket *  msg 
) [virtual]

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

Parameters:
trigger Application trigger to which the packet was sent
stack Identifier stack passed from I3
msg Arriving message

Reimplemented from I3BaseApp.

Definition at line 81 of file I3Anycast.cc.

{
    // after arrival, repeat the same process
    I3Identifier id("I3 Anycast test"); // create an identifier with the previously used hash as prefix
    id.createRandomSuffix(); // and a random suffix

    getParentModule()->bubble("Got message - sending back!");
    sendPacket(id, msg); // and send back to I3
}

void I3Anycast::handleTimerEvent ( cMessage *  msg  )  [virtual]

Handles timers - should be overwritten by application.

Parameters:
msg Timer to be handled

Reimplemented from I3BaseApp.

Definition at line 66 of file I3Anycast.cc.

{
    if (myIndex == 0) { // only the first node
        cPacket *cmsg = new cPacket("woot");

        I3Identifier id("I3 Anycast test"); // create an identifier with the previously used hash as prefix
        id.createRandomSuffix(); // and a random suffix

        //cout << "Send message!" << endl;
        getParentModule()->bubble("Sending message!");
        sendPacket(id, cmsg); // send the first message with that identifier
    }
    delete msg;
}

void I3Anycast::initializeApp ( int  stage  )  [virtual]

App initialization - should be overwritten by application.

I3 related commands should go in initializeI3.

Parameters:
stage Initialization stage passed from initialize()

Reimplemented from I3BaseApp.

Definition at line 50 of file I3Anycast.cc.

                                       {
    myIndex = index++;
}

void I3Anycast::initializeI3 (  )  [virtual]

Application I3 initialize - should be overwritten by application.

Reimplemented from I3BaseApp.

Definition at line 55 of file I3Anycast.cc.

{
    sendPacketTimer = new cMessage("packet timer");
    scheduleAt(simTime() + 20, sendPacketTimer);

    I3Identifier identifier("I3 Anycast test"); // create an identifier with the given string hash as prefix
    identifier.createRandomSuffix(); // set the suffix as random
    insertTrigger(identifier); // and insert a trigger with that id

}


Member Data Documentation

int I3Anycast::index = 0 [static, private]

Definition at line 37 of file I3Anycast.cc.

Referenced by initializeApp().

Definition at line 39 of file I3Anycast.cc.

Referenced by handleTimerEvent(), and initializeApp().

Definition at line 40 of file I3Anycast.cc.

Referenced by initializeI3().


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