Sim.Routing
Interface RoutingAlgorithm

All Known Implementing Classes:
AbstractRoutingAlgorithm, Algorithm, ChampAlgorithm, DSRRoutingAlgorithm, FloodingRoutingAlgorithm

public interface RoutingAlgorithm

RoutingAlgorithm specifies the interface for a routing algorithm for a Node. Frames and new Packets are passed from the Node to the RoutingAlgorithm, and the RoutingAlgorithm is responsible for queuing a HardwareFrame at the Node in order to forward the Packet towards its destination.

In order to facilitate easy dynamic loading, all implementations of RoutingAlgorithm must have a default constructor.


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.
 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 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.
 

Method Detail

setSimulation

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

Parameters:
sim - non-null Simulation

attached

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

Parameters:
us - non-null Node

arrived

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.

Parameters:
in - non-null HardwareFrame received

terminated

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.

Parameters:
in - non-null HardwareFrame received

overheard

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

Parameters:
in - non-null HardwareFrame received

loopback

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

Parameters:
in - non-null HardwareFrame received whose source equals the "us" address

newPacket

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.

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.