jist.swans.app
Class AppHeartbeat

java.lang.Object
  extended by jist.swans.app.AppHeartbeat
All Implemented Interfaces:
JistAPI.Proxiable, JistAPI.Timeless, AppInterface, NetInterface.NetHandler

public class AppHeartbeat
extends java.lang.Object
implements AppInterface, NetInterface.NetHandler

Heartbeat application.

Since:
SWANS1.0
Version:
$Id: AppHeartbeat.java,v 1.13 2004/04/06 16:07:46 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu&rt;

Nested Class Summary
private static class AppHeartbeat.MessageHeartbeat
          Heartbeat packet.
private static class AppHeartbeat.NeighbourEntry
          Neighbour entry information.
 
Nested classes/interfaces inherited from interface jist.swans.app.AppInterface
AppInterface.TcpApp, AppInterface.ThreadedApp, AppInterface.UdpApp
 
Field Summary
private  boolean display
          whether to display application output.
static short FRESHNESS
          throw out information older than FRESHNESS beats.
static long HEARTBEAT_MAX
          maximum heartbeat period.
static long HEARTBEAT_MIN
          minimum heartbeat period.
private  java.util.HashMap neighbours
          list of neighbours.
private  NetInterface netEntity
          network entity.
private  int nodenum
          node identifier.
private  java.lang.Object self
          self-referencing proxy entity.
 
Constructor Summary
AppHeartbeat(int nodenum, boolean display)
          Create new heartbeat application instance.
 
Method Summary
private  long calcDelay()
          Compute random heartbeat delay.
 AppInterface getAppProxy()
          Return self-referencing APPLICATION proxy entity.
 NetInterface.NetHandler getNetProxy()
          Return self-referencing NETWORK proxy entity.
private  void neighbourDiscovered(MacAddress mac)
          Neighbour discovered.
private  void neighbourLost(MacAddress mac)
          Neighbour lost.
 void receive(Message msg, NetAddress src, MacAddress lastHop, byte macId, NetAddress dst, byte priority, byte ttl)
          Receive a message from network layer.
 void run()
          Run application.
 void run(java.lang.String[] args)
          Run application.
 void setNetEntity(NetInterface netEntity)
          Set network entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEARTBEAT_MIN

public static final long HEARTBEAT_MIN
minimum heartbeat period.

See Also:
Constant Field Values

HEARTBEAT_MAX

public static final long HEARTBEAT_MAX
maximum heartbeat period.

See Also:
Constant Field Values

FRESHNESS

public static final short FRESHNESS
throw out information older than FRESHNESS beats.

See Also:
Constant Field Values

netEntity

private NetInterface netEntity
network entity.


self

private java.lang.Object self
self-referencing proxy entity.


neighbours

private java.util.HashMap neighbours
list of neighbours.


nodenum

private int nodenum
node identifier.


display

private boolean display
whether to display application output.

Constructor Detail

AppHeartbeat

public AppHeartbeat(int nodenum,
                    boolean display)
Create new heartbeat application instance.

Parameters:
nodenum - node identifier
display - whether to display application output
Method Detail

setNetEntity

public void setNetEntity(NetInterface netEntity)
Set network entity.

Parameters:
netEntity - network entity

getNetProxy

public NetInterface.NetHandler getNetProxy()
Return self-referencing NETWORK proxy entity.

Returns:
self-referencing NETWORK proxy entity

getAppProxy

public AppInterface getAppProxy()
Return self-referencing APPLICATION proxy entity.

Returns:
self-referencing APPLICATION proxy entity

neighbourLost

private void neighbourLost(MacAddress mac)
Neighbour lost.

Parameters:
mac - mac adddress of neighbour lost

neighbourDiscovered

private void neighbourDiscovered(MacAddress mac)
Neighbour discovered.

Parameters:
mac - mac address of neighbour discovered

receive

public void receive(Message msg,
                    NetAddress src,
                    MacAddress lastHop,
                    byte macId,
                    NetAddress dst,
                    byte priority,
                    byte ttl)
Receive a message from network layer.

Specified by:
receive in interface NetInterface.NetHandler
Parameters:
msg - message received
src - source network address
lastHop - source link address
macId - incoming interface
dst - destination network address
priority - packet priority
ttl - packet time-to-live

calcDelay

private long calcDelay()
Compute random heartbeat delay.

Returns:
delay to next heartbeat

run

public void run(java.lang.String[] args)
Run application.

Specified by:
run in interface AppInterface
Parameters:
args - command-line parameters

run

public void run()
Run application.

Specified by:
run in interface AppInterface