Sim.Routing
Class AbstractRoutingAlgorithm

java.lang.Object
  extended by Sim.Routing.AbstractRoutingAlgorithm
All Implemented Interfaces:
RoutingAlgorithm
Direct Known Subclasses:
Algorithm, ChampAlgorithm, DSRRoutingAlgorithm, FloodingRoutingAlgorithm

public class AbstractRoutingAlgorithm
extends java.lang.Object
implements RoutingAlgorithm

AbstractRoutingAlgorithm is a RoutingAlgorithm implementation whose methods take no action, so that only the methods of interest can be overridden.


Field Summary
protected  Node myNode
           
 
Constructor Summary
AbstractRoutingAlgorithm()
           
 
Method Summary
 void arrived(HardwareFrame in)
          Event when a HardwareFrame arrives destined for this Node that does not have a user Packet, or has a Packet not for this Node.
 void attached(Node us)
          Event called when a Node is given a RemoteAlgorithm to route packets for it.
protected  double getTime()
          Returns the current time of the Simulation.
 void loopback(HardwareFrame in)
          Event when a Node hears its own HardwareFrame (which is guaranteed to happen after a send completes).
 void newPacket(Node dest, Packet packet)
          Event when a Node wants to send a new Packet.
 void overheard(HardwareFrame in)
          Event when a HardwareFrame is overheard by a Node (the HardwareFrame's destination is not the Node).
 void scheduleEvent(double t, SimulationEvent event)
          Schedules a new event to take place in the future.
 void setSimulation(Simulation sim)
          Sets the simulation for this RoutingAlgorithm.
 void terminated(HardwareFrame in)
          Event when a HardwareFrame arrives destined for this Node that has a user Packet that is destined for this Node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myNode

protected Node myNode
Constructor Detail

AbstractRoutingAlgorithm

public AbstractRoutingAlgorithm()
Method Detail

setSimulation

public void setSimulation(Simulation sim)
Sets the simulation for this RoutingAlgorithm. This method must be called immediately after construction and before any other methods.

Specified by:
setSimulation in interface RoutingAlgorithm
Parameters:
sim - non-null Simulation

attached

public void attached(Node us)
Event called when a Node is given a RemoteAlgorithm to route packets for it.

Specified by:
attached in interface RoutingAlgorithm
Parameters:
us - non-null Node

arrived

public void arrived(HardwareFrame in)
Event when a HardwareFrame arrives destined for this Node that does not have a user Packet, or has a Packet not for this Node. The data in the frame may need to be routed.

Specified by:
arrived in interface RoutingAlgorithm
Parameters:
in - non-null HardwareFrame received

terminated

public void terminated(HardwareFrame in)
Event when a HardwareFrame arrives destined for this Node that has a user Packet that is destined for this Node. The data has arrived at its final destination, so it does not need to be routed.

Specified by:
terminated in interface RoutingAlgorithm
Parameters:
in - non-null HardwareFrame received

overheard

public void overheard(HardwareFrame in)
Event when a HardwareFrame is overheard by a Node (the HardwareFrame's destination is not the Node).

Specified by:
overheard in interface RoutingAlgorithm
Parameters:
in - non-null HardwareFrame received

loopback

public void loopback(HardwareFrame in)
Event when a Node hears its own HardwareFrame (which is guaranteed to happen after a send completes).

Specified by:
loopback in interface RoutingAlgorithm
Parameters:
in - non-null HardwareFrame received whose source equals the "us" address

newPacket

public void newPacket(Node dest,
                      Packet packet)
Event when a Node wants to send a new Packet. The RoutingAlgorithm should bundle the Packet in a HardwareFrame and send it through the Node.

Specified by:
newPacket in interface RoutingAlgorithm
Parameters:
dest - non-null Node as the destination (packet.getDest() == dest.getAddress())
packet - user packet data to send, with a destination address not equal to the address for the sending Node.

getTime

protected double getTime()
Returns the current time of the Simulation.

Returns:
non-null Simulation's time

scheduleEvent

public void scheduleEvent(double t,
                          SimulationEvent event)
Schedules a new event to take place in the future. Once an event has been scheduled, it cannot be cancelled or rescheduled.

Parameters:
t - event time greater than or equal to the current simulation time
event - non-null SimulationEvent