simnet
Class ShortestPath

java.lang.Object
  extended bysimnet.RoutingTable
      extended bysimnet.ShortestPath
All Implemented Interfaces:
Pluggable, PlugoutListener
Direct Known Subclasses:
AggregateShortestPath

public class ShortestPath
extends RoutingTable
implements Pluggable

A routing table that uses global knowledge to route packets on the shortest path. If changes are made to the topology, the update shortest path (usp) command must be run.


Field Summary
private  java.util.Hashtable idx2ip
          For conversion between indicies and ip's.
private  java.util.Hashtable ip2idx
          For conversion between ip's and indicies.
private  int[][] link
          Link weight table
private  int[] path
          Shortest path table
private  int[] table
          Distances to destinations
 
Fields inherited from class simnet.RoutingTable
node, NODE_ID
 
Constructor Summary
ShortestPath()
           
 
Method Summary
private  boolean allSeen(boolean[] seen)
          Determines whether all Nodes have been seen.
 boolean applicableLink(Link l)
           
 void build()
          Generates a static and centralized routing table using Dijkstra' s shortest path algorithm.
private  int getClosest(int[] table, boolean[] seen)
          Determines the ID of the Node closest to the current Node that hasn' t been seen yet.
 int getDist(int to)
          This is a dirty hack needed for Speed Test (to test how well bandwidth and latency are modeled)
private  int idx(int ip)
          convert a node ip into an index
 void initialize(Node parent_node)
          Initializes a new ShortestPath routing table by initializing its num_nodes and links fields as well as its link and path arrays.
private  int ip(int idx)
          convert a node index into an ip
private  boolean isApplicableFromNATRouter(NATRouter nr, Link l)
           
private  boolean isApplicableRecursive(Link l)
           
 int lookup(int to)
          Determines the ID of the next hop in the path to the specified node.
 boolean prePlugout(java.lang.Object replacement)
          Don't need to do anything special to get removed or replaced.
private  void printTable(int[] table)
          Prints out an array (poorly named function).
 
Methods inherited from class simnet.RoutingTable
finalize, plugoutNotification
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ip2idx

private java.util.Hashtable ip2idx
For conversion between ip's and indicies.


idx2ip

private java.util.Hashtable idx2ip
For conversion between indicies and ip's.


link

private int[][] link
Link weight table


path

private int[] path
Shortest path table


table

private int[] table
Distances to destinations

Constructor Detail

ShortestPath

public ShortestPath()
Method Detail

initialize

public void initialize(Node parent_node)
Initializes a new ShortestPath routing table by initializing its num_nodes and links fields as well as its link and path arrays.

Overrides:
initialize in class RoutingTable
Parameters:
parent_node - The Node this routing algorithm is running on

ip

private int ip(int idx)
convert a node index into an ip


idx

private int idx(int ip)
convert a node ip into an index


build

public void build()
Generates a static and centralized routing table using Dijkstra' s shortest path algorithm.


allSeen

private boolean allSeen(boolean[] seen)
Determines whether all Nodes have been seen.

Parameters:
seen - a boolean array used to keep track of which nodes have been seen
Returns:
TRUE if all nodes have been seen; FALSE otherwise

getClosest

private int getClosest(int[] table,
                       boolean[] seen)
Determines the ID of the Node closest to the current Node that hasn' t been seen yet.

Parameters:
table - the path table
seen - an array that keeps track of seen Nodes

lookup

public int lookup(int to)
Determines the ID of the next hop in the path to the specified node.

Specified by:
lookup in class RoutingTable
Parameters:
to - the end of the path
Returns:
the node ID of the next hop

getDist

public int getDist(int to)
This is a dirty hack needed for Speed Test (to test how well bandwidth and latency are modeled)


printTable

private void printTable(int[] table)
Prints out an array (poorly named function).

Parameters:
table - the table to print

applicableLink

public boolean applicableLink(Link l)

isApplicableRecursive

private boolean isApplicableRecursive(Link l)

isApplicableFromNATRouter

private boolean isApplicableFromNATRouter(NATRouter nr,
                                          Link l)

prePlugout

public boolean prePlugout(java.lang.Object replacement)
Don't need to do anything special to get removed or replaced.

Specified by:
prePlugout in interface Pluggable
Returns:
if this object can now be removed (was the operation sucessful)