Class RoutingTable

java.lang.Object
  extended by RoutingTable

public class RoutingTable
extends java.lang.Object

For simplicity, there is only one routing table class. It keeps next-hop information, which they all do. It also keeps distance to the destination, which not all need or do.

These routing tables can create a vector of changes made to them. This is useful in sending 'diffs' around in update packets.


Nested Class Summary
 class RoutingTable.Entry
          A class encapsulated the notion of a routing table entry.
 
Field Summary
protected  boolean doLog
          Controls whether or not logging is performed.
protected  java.util.Vector<RoutingTable.LogEntry> log
          The 'diff' log used to record changes to the table.
protected  RoutingTable.Entry[] table
          The actual routing table.
 
Constructor Summary
RoutingTable()
          Routing tables are always the size of the number of nodes in the sole Network object that exists.
 
Method Summary
 void addLogEntry(Node dest)
          Adds an entry to the log.
 void cleanTable()
          Clears out the table -- throws away all next hop information and and log info that might exist, and turns off logging.
 void clearTableOf(Node badNode)
          Eliminates all entries that have the given node as their next hop, and makes distance to the destination infinite.
 int getDistTo(Node dest)
           
 Node getHopTo(Node dest)
           
 java.util.Vector<RoutingTable.LogEntry> getLog()
          Accessor for log.
 boolean isLogging()
          Returns true if table is currently logging changes, false otherwise.
 void setEntry(Node dest, Node next, int d)
          Sets an entry -- both next hop and distance.
 int size()
          Returns the number of entries in the routing table.
 void startLog()
          Indicate that want to keep log of changes starting now.
 void stopLog()
          Turn off logging.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

table

protected RoutingTable.Entry[] table
The actual routing table.


log

protected java.util.Vector<RoutingTable.LogEntry> log
The 'diff' log used to record changes to the table.


doLog

protected boolean doLog
Controls whether or not logging is performed.

Constructor Detail

RoutingTable

public RoutingTable()
Routing tables are always the size of the number of nodes in the sole Network object that exists.

Method Detail

size

public int size()
Returns the number of entries in the routing table.


startLog

public void startLog()
Indicate that want to keep log of changes starting now.


stopLog

public void stopLog()
Turn off logging.


isLogging

public boolean isLogging()
Returns true if table is currently logging changes, false otherwise.


getLog

public java.util.Vector<RoutingTable.LogEntry> getLog()
Accessor for log.


getHopTo

public Node getHopTo(Node dest)

getDistTo

public int getDistTo(Node dest)

setEntry

public void setEntry(Node dest,
                     Node next,
                     int d)
Sets an entry -- both next hop and distance.


addLogEntry

public void addLogEntry(Node dest)
Adds an entry to the log.


clearTableOf

public void clearTableOf(Node badNode)
Eliminates all entries that have the given node as their next hop, and makes distance to the destination infinite.


cleanTable

public void cleanTable()
Clears out the table -- throws away all next hop information and and log info that might exist, and turns off logging.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object