Skip to content
Snippets Groups Projects

WIP: Broadcast messages in application layer

29 files
+ 453
207
Compare changes
  • Side-by-side
  • Inline

Files

@@ -11,6 +11,7 @@ import report.PingAppReporter;
import core.Application;
import core.DTNHost;
import core.Message;
import core.OneToOneMessage;
import core.Settings;
import core.SimClock;
import core.SimScenario;
@@ -123,10 +124,10 @@ public class PingApplication extends Application {
if (type==null) return msg; // Not a ping/pong message
// Respond with pong if we're the recipient
if (msg.getTo()==host && type.equalsIgnoreCase("ping")) {
if (msg.isFinalRecipient(host) && type.equalsIgnoreCase("ping")) {
String id = "pong" + SimClock.getIntTime() + "-" +
host.getAddress();
Message m = new Message(host, msg.getFrom(), id, getPongSize());
Message m = new OneToOneMessage(host, msg.getFrom(), id, getPongSize());
m.addProperty("type", "pong");
m.setAppID(APP_ID);
host.createNewMessage(m);
@@ -137,7 +138,7 @@ public class PingApplication extends Application {
}
// Received a pong reply
if (msg.getTo()==host && type.equalsIgnoreCase("pong")) {
if (msg.isFinalRecipient(host) && type.equalsIgnoreCase("pong")) {
// Send event to listeners
super.sendEventToListeners("GotPong", null, host);
}
@@ -176,7 +177,7 @@ public class PingApplication extends Application {
double curTime = SimClock.getTime();
if (curTime - this.lastPing >= this.interval) {
// Time to send a new ping
Message m = new Message(host, randomHost(), "ping" +
Message m = new OneToOneMessage(host, randomHost(), "ping" +
SimClock.getIntTime() + "-" + host.getAddress(),
getPingSize());
m.addProperty("type", "ping");
Loading