simnet
Class RIPRoutingTable

java.lang.Object
  extended bysimnet.RoutingTable
      extended bysimnet.RIPRoutingTable
All Implemented Interfaces:
Pluggable, PlugoutListener, java.lang.Runnable

public class RIPRoutingTable
extends RoutingTable
implements java.lang.Runnable, Pluggable

An implementation of the Routing Information Protocol (RIP). On routers, a RIP "daemon" will be run, but on hosts, all packets are forwarded to the host's gateway.


Nested Class Summary
(package private)  class RIPRoutingTable.RIPTimerTask
          Inner class used to periodically send RIP Advertisments.
 
Field Summary
static int INFINITY
           
(package private)  long last_start
           
(package private)  long last_update
           
(package private)  int msg_count
           
static int NORMAL_UPDATE_DELAY
          How often (in ms) to send out advertisments.
protected  java.util.LinkedList queue
           
static int REPORT_STABLE_DELAY
           
(package private)  Trie routeTrie
           
protected  boolean sending_update
           
(package private)  DatagramSocket sock
           
(package private)  java.util.Timer timer
           
(package private)  RIPRoutingTable.RIPTimerTask timertask
           
static int TRIGGERED_UPDATE_DELAY
          How long to wait (in ms) before sending out a triggered update.
 
Fields inherited from class simnet.RoutingTable
node, NODE_ID
 
Constructor Summary
RIPRoutingTable()
           
 
Method Summary
 int getDist(int to)
          This is a dirty hack needed for Speed Test (to test how well bandwidth and latency are modelled)
 void initialize(Node parent_node)
          If we are on a host, just keep a copy the node, if we are on a router, start open a socket and initalize the timer
 int lookup(int to)
          Determines the ID of the next hop in the path to the specified node.
 boolean prePlugout(java.lang.Object replacement)
          To clean up, stop the timer and close the socket; the routing table will get copied if appropriate.
 void PrintRoutingTable()
          Prints the routing table.
 void processMessage(java.lang.Object o)
          Receive a RIP advertisment message.
protected  void processMessageNow(java.lang.Object o)
          Process a RIP advertisment message right now.
 void prt()
          Prints the routing table.
(package private)  void reportTime()
          For debugging, print out how long it took for the routing table to converge.
 void run()
          Receives RIP advertisments.
(package private)  void updateTime()
          For debugging, keep track of convergence status.
 
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

routeTrie

Trie routeTrie

timer

java.util.Timer timer

timertask

RIPRoutingTable.RIPTimerTask timertask

sock

DatagramSocket sock

last_update

long last_update

last_start

long last_start

REPORT_STABLE_DELAY

public static final int REPORT_STABLE_DELAY
See Also:
Constant Field Values

sending_update

protected boolean sending_update

queue

protected java.util.LinkedList queue

INFINITY

public static final int INFINITY
See Also:
Constant Field Values

NORMAL_UPDATE_DELAY

public static final int NORMAL_UPDATE_DELAY
How often (in ms) to send out advertisments.

See Also:
Constant Field Values

TRIGGERED_UPDATE_DELAY

public static final int TRIGGERED_UPDATE_DELAY
How long to wait (in ms) before sending out a triggered update.

See Also:
Constant Field Values

msg_count

int msg_count
Constructor Detail

RIPRoutingTable

public RIPRoutingTable()
Method Detail

initialize

public void initialize(Node parent_node)
If we are on a host, just keep a copy the node, if we are on a router, start open a socket and initalize the timer

Overrides:
initialize in class RoutingTable
Parameters:
parent_node - the node this routing table will run on

run

public void run()
Receives RIP advertisments.

Specified by:
run in interface java.lang.Runnable

prt

public void prt()
Prints the routing table.


processMessage

public void processMessage(java.lang.Object o)
Receive a RIP advertisment message. If we are currently sending advertisments, queue it, otherwise, process the message now.


processMessageNow

protected void processMessageNow(java.lang.Object o)
Process a RIP advertisment message right now.


reportTime

void reportTime()
For debugging, print out how long it took for the routing table to converge.


updateTime

void updateTime()
For debugging, keep track of convergence status.


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 modelled)


prePlugout

public boolean prePlugout(java.lang.Object replacement)
To clean up, stop the timer and close the socket; the routing table will get copied if appropriate.

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

PrintRoutingTable

public void PrintRoutingTable()
Prints the routing table.