// $Id: RoutingTable.java,v 1.14 2007/11/08 07:14:17 zahorjan Exp $ import java.util.*; import org.jgrapht.graph.*; import org.jgrapht.traverse.*; /** * 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.
*/
public class RoutingTable {
/**
* A class encapsulated the notion of a routing table entry.
*/
public class Entry {
public Node nextHop;
public int dist;
public Entry() {
nextHop = null;
dist = ConstAlg.INFINITY;
}
/**
* Copy constructor.
*/
public Entry(Entry other) {
this.nextHop = other.nextHop;
this.dist = other.dist;
}
}
/**
* The actual routing table.
*/
protected Entry[] table;
/**
* A class representing a single log entry.
*/
class LogEntry {
public Node dest;
public int dist;
public LogEntry(Node d) {
dest = d;
dist = table[dest.getUID()].dist;
}
}
/**
* The 'diff' log used to record changes to the table.
*/
protected Vector