applications
Class PingApplication

java.lang.Object
  extended by core.Application
      extended by applications.PingApplication

public class PingApplication
extends Application

Simple ping application to demonstrate the application support. The application can be configured to send pings with a fixed interval or to only answer to pings it receives. When the application receives a ping it sends a pong message in response. The corresponding PingAppReporter class can be used to record information about the application behavior.

See Also:
PingAppReporter

Field Summary
static java.lang.String APP_ID
          Application ID
static java.lang.String PING_DEST_RANGE
          Destination address range - inclusive lower, exclusive upper
static java.lang.String PING_INTERVAL
          Ping generation interval
static java.lang.String PING_OFFSET
          Ping interval offset - avoids synchronization of ping sending
static java.lang.String PING_PASSIVE
          Run in passive mode - don't generate pings but respond
static java.lang.String PING_PING_SIZE
          Size of the ping message
static java.lang.String PING_PONG_SIZE
          Size of the pong message
static java.lang.String PING_SEED
          Seed for the app's random number generator
 
Fields inherited from class core.Application
appID
 
Constructor Summary
PingApplication(PingApplication a)
          Copy-constructor
PingApplication(Settings s)
          Creates a new ping application with the given settings.
 
Method Summary
 int getDestMax()
           
 int getDestMin()
           
 double getInterval()
           
 double getLastPing()
           
 int getPingSize()
           
 int getPongSize()
           
 int getSeed()
           
 Message handle(Message msg, DTNHost host)
          Handles an incoming message.
 boolean isPassive()
           
 Application replicate()
           
 void setDestMax(int destMax)
           
 void setDestMin(int destMin)
           
 void setInterval(double interval)
           
 void setLastPing(double lastPing)
           
 void setPassive(boolean passive)
           
 void setPingSize(int pingSize)
           
 void setPongSize(int pongSize)
           
 void setSeed(int seed)
           
 void update(DTNHost host)
          Sends a ping packet if this is an active application instance.
 
Methods inherited from class core.Application
getAppID, getAppListeners, sendEventToListeners, setAppID, setAppListeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PING_PASSIVE

public static final java.lang.String PING_PASSIVE
Run in passive mode - don't generate pings but respond

See Also:
Constant Field Values

PING_INTERVAL

public static final java.lang.String PING_INTERVAL
Ping generation interval

See Also:
Constant Field Values

PING_OFFSET

public static final java.lang.String PING_OFFSET
Ping interval offset - avoids synchronization of ping sending

See Also:
Constant Field Values

PING_DEST_RANGE

public static final java.lang.String PING_DEST_RANGE
Destination address range - inclusive lower, exclusive upper

See Also:
Constant Field Values

PING_SEED

public static final java.lang.String PING_SEED
Seed for the app's random number generator

See Also:
Constant Field Values

PING_PING_SIZE

public static final java.lang.String PING_PING_SIZE
Size of the ping message

See Also:
Constant Field Values

PING_PONG_SIZE

public static final java.lang.String PING_PONG_SIZE
Size of the pong message

See Also:
Constant Field Values

APP_ID

public static final java.lang.String APP_ID
Application ID

See Also:
Constant Field Values
Constructor Detail

PingApplication

public PingApplication(Settings s)
Creates a new ping application with the given settings.

Parameters:
s - Settings to use for initializing the application.

PingApplication

public PingApplication(PingApplication a)
Copy-constructor

Parameters:
a -
Method Detail

handle

public Message handle(Message msg,
                      DTNHost host)
Handles an incoming message. If the message is a ping message replies with a pong message. Generates events for ping and pong messages.

Specified by:
handle in class Application
Parameters:
msg - message received by the router
host - host to which the application instance is attached
Returns:
the (possibly modified) message to forward or null if the application wants the router to stop forwarding the message.

replicate

public Application replicate()
Specified by:
replicate in class Application

update

public void update(DTNHost host)
Sends a ping packet if this is an active application instance.

Specified by:
update in class Application
Parameters:
host - to which the application instance is attached

getLastPing

public double getLastPing()
Returns:
the lastPing

setLastPing

public void setLastPing(double lastPing)
Parameters:
lastPing - the lastPing to set

getInterval

public double getInterval()
Returns:
the interval

setInterval

public void setInterval(double interval)
Parameters:
interval - the interval to set

isPassive

public boolean isPassive()
Returns:
the passive

setPassive

public void setPassive(boolean passive)
Parameters:
passive - the passive to set

getDestMin

public int getDestMin()
Returns:
the destMin

setDestMin

public void setDestMin(int destMin)
Parameters:
destMin - the destMin to set

getDestMax

public int getDestMax()
Returns:
the destMax

setDestMax

public void setDestMax(int destMax)
Parameters:
destMax - the destMax to set

getSeed

public int getSeed()
Returns:
the seed

setSeed

public void setSeed(int seed)
Parameters:
seed - the seed to set

getPongSize

public int getPongSize()
Returns:
the pongSize

setPongSize

public void setPongSize(int pongSize)
Parameters:
pongSize - the pongSize to set

getPingSize

public int getPingSize()
Returns:
the pingSize

setPingSize

public void setPingSize(int pingSize)
Parameters:
pingSize - the pingSize to set