26 #define NUM_PARTNERS 5
54 void initializeApp(
int stage);
56 void handleTimerEvent(cMessage *msg);
57 void handleUDPMessage(cMessage* msg);
60 void discoverPartners();
74 recordScalar(
"Number of sent packets", numSentPackets);
75 recordScalar(
"Number of lost packets", packets.size());
79 checkedPartners =
false;
81 poolId.createFromHash(
"HostMobility");
82 poolId.setName(
"HostMobility");
83 poolId.createRandomSuffix();
84 insertTrigger(poolId);
86 closestId = retrieveClosestIdentifier();
87 insertTrigger(closestId);
89 cMessage *msg =
new cMessage();
91 scheduleAt(simTime() + 5, msg);
93 cMessage *nmsg =
new cMessage();
95 scheduleAt(simTime() + 60, nmsg);
105 switch (msg->getKind()) {
111 sendPacket(otherId, msg);
115 partners.push_back(mc->
source);
121 sendPacket(mc->
source, msg);
124 packets.erase(mc->
id);
134 switch (msg->getKind()) {
136 if (checkedPartners) {
142 for (
unsigned int i = 0; i < partners.size(); i++) {
143 cPacket *cmsg =
new cPacket();
146 packets.insert(numSentPackets);
147 mc->
id = numSentPackets++;
149 cmsg->setContextPointer(mc);
151 cmsg->setBitLength((32 + intrand(512)) * 8);
153 sendPacket(partners[i], cmsg,
true);
155 scheduleAt(simTime() + truncnormal(0.5, 0.1), msg);
158 scheduleAt(simTime() + 10, msg);
162 closestId = retrieveClosestIdentifier();
163 insertTrigger(closestId);
167 checkedPartners =
false;
168 scheduleAt(simTime() + 60, msg);
179 cPacket *cmsg =
new cPacket();
185 cmsg->setContextPointer(mc);
190 sendPacket(partner, cmsg);
192 checkedPartners =
true;
196 if (stage == I3_MOBILITY_UPDATED) {
197 cMessage *msg =
new cMessage();
199 scheduleAt(simTime() + 10, msg);