@Override public Message handle(Message msg,DTNHost host){
  String type=(String)msg.getProperty("type");
  if (type == null)   return msg;
  if (msg.getTo() == host && type.equalsIgnoreCase("ping")) {
    String id="pong" + SimClock.getIntTime() + "-"+ host.getAddress();
    Message m=new Message(host,msg.getFrom(),id,getPongSize());
    m.addProperty("type","pong");
    m.setAppID(APP_ID);
    host.createNewMessage(m);
    super.sendEventToListeners("GotPing",null,host);
    super.sendEventToListeners("SentPong",null,host);
  }
  if (msg.getTo() == host && type.equalsIgnoreCase("pong")) {
    super.sendEventToListeners("GotPong",null,host);
  }
  return msg;
}

@ Override public Message handle ( Message msg , DTNHost host ) { String type = ( String ) msg . getProperty ( "type" ) ; if ( type == null ) return msg ; if ( msg . getTo ( ) == host && type . equalsIgnoreCase ( "ping" ) ) { String id = "pong" + SimClock . getIntTime ( ) + "-" + host . getAddress ( ) ; Message m = new Message ( host , msg . getFrom ( ) , id , getPongSize ( ) ) ; m . addProperty ( "type" , "pong" ) ; m . setAppID ( APP_ID ) ; host . createNewMessage ( m ) ; super . sendEventToListeners ( "GotPing" , null , host ) ; super . sendEventToListeners ( "SentPong" , null , host ) ; } if ( msg . getTo ( ) == host && type . equalsIgnoreCase ( "pong" ) ) { super . sendEventToListeners ( "GotPong" , null , host ) ; } return msg ; }
handles an incoming message . if the message is a ping message replies with a pong message . generates events for ping and pong messages .
