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.
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, cMessage *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 |
void I3Anycast::initializeApp | ( | int | stage | ) | [virtual] |
App initialization - should be overwritten by application.
I3 related commands should go in initializeI3.
stage | Initialization stage passed from initialize() |
Reimplemented from I3BaseApp.
void I3Anycast::initializeI3 | ( | ) | [virtual] |
Application I3 initialize - should be overwritten by application.
Reimplemented from I3BaseApp.
00053 { 00054 sendPacketTimer = new cMessage("packet timer"); 00055 scheduleAt(simulation.simTime() + 20, sendPacketTimer); 00056 00057 I3Identifier identifier("I3 Anycast test"); // create an identifier with the given string hash as prefix 00058 identifier.createRandomSuffix(); // set the suffix as random 00059 insertTrigger(identifier); // and insert a trigger with that id 00060 00061 }
void I3Anycast::deliver | ( | I3Trigger & | trigger, | |
I3IdentifierStack & | stack, | |||
cMessage * | msg | |||
) | [virtual] |
Delivers packets coming from I3 - should be overwritten by application.
trigger | Application trigger to which the packet was sent | |
stack | Identifier stack passed from I3 | |
msg | Arriving message |
Reimplemented from I3BaseApp.
00079 { 00080 // after arrival, repeat the same process 00081 I3Identifier id("I3 Anycast test"); // create an identifier with the previously used hash as prefix 00082 id.createRandomSuffix(); // and a random suffix 00083 00084 parentModule()->bubble("Got message - sending back!"); 00085 sendPacket(id, msg); // and send back to I3 00086 }
void I3Anycast::handleTimerEvent | ( | cMessage * | msg | ) | [virtual] |
Handles timers - should be overwritten by application.
msg | Timer to be handled |
Reimplemented from I3BaseApp.
00064 { 00065 if (myIndex == 0) { // only the first node 00066 cMessage *cmsg = new cMessage("woot"); 00067 00068 I3Identifier id("I3 Anycast test"); // create an identifier with the previously used hash as prefix 00069 id.createRandomSuffix(); // and a random suffix 00070 00071 //cout << "Send message!" << endl; 00072 parentModule()->bubble("Sending message!"); 00073 sendPacket(id, cmsg); // send the first message with that identifier 00074 } 00075 delete msg; 00076 }
int I3Anycast::index = 0 [static, private] |
cMessage* I3Anycast::sendPacketTimer |