Sim.Routing.GPSR
Class Algorithm

java.lang.Object
  extended by Sim.Routing.AbstractRoutingAlgorithm
      extended by Sim.Routing.GPSR.Algorithm
All Implemented Interfaces:
RoutingAlgorithm

public class Algorithm
extends AbstractRoutingAlgorithm

Greedy Perimeter Stateless Routing (GPSR) Algorithm, based on nodes know their own locations. Uses a broadcast technique to keep 1 hop nodes up to date with locations of neighbors. Packet sending is done based on greedy, or perimeter routing. Greedy uses the node nearest to the destination location to route the packet. Because there isn't always a node closer than the originator, perimeter routing attempts to push the packet around voids in a right hand rule method.


Field Summary
 
Fields inherited from class Sim.Routing.AbstractRoutingAlgorithm
myNode
 
Constructor Summary
Algorithm()
           
 
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 newPacket(Node dest, Packet packet)
          Event when a Node wants to send a new Packet.
 void overheard(HardwareFrame in)
          Action when a packet is overheard.
 void setSimulation(Simulation sim)
          Configures initial events to start when the simulation starts.
 void terminated(HardwareFrame in)
          Action when a packet has finished it's journey.
 
Methods inherited from class Sim.Routing.AbstractRoutingAlgorithm
attached, getTime, loopback, scheduleEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Algorithm

public Algorithm()
Method Detail

setSimulation

public void setSimulation(Simulation sim)
Configures initial events to start when the simulation starts.

Specified by:
setSimulation in interface RoutingAlgorithm
Overrides:
setSimulation in class AbstractRoutingAlgorithm
Parameters:
sim - the simulation to run with this algorithm

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
Overrides:
newPacket in class AbstractRoutingAlgorithm
Parameters:
src - non-null Node originating the Packet (packet.getSource() == src.getAddress())
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.

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
Overrides:
arrived in class AbstractRoutingAlgorithm
Parameters:
us - non-null Node receiving the HardwareFrame
in - non-null HardwareFrame received

overheard

public void overheard(HardwareFrame in)
Action when a packet is overheard. Only thing we need to do is update our neighbor table, these are packets not destined for us.

Specified by:
overheard in interface RoutingAlgorithm
Overrides:
overheard in class AbstractRoutingAlgorithm
Parameters:
in - the hardwareframe that is overheard

terminated

public void terminated(HardwareFrame in)
Action when a packet has finished it's journey.

Specified by:
terminated in interface RoutingAlgorithm
Overrides:
terminated in class AbstractRoutingAlgorithm
Parameters:
in - hardwareframe that is at it's destination.