simnet
Class AggregateRouter

java.lang.Object
  extended byjava.lang.Thread
      extended bysimnet.Node
          extended bysimnet.Router
              extended bysimnet.AggregateRouter
All Implemented Interfaces:
Pluggable, java.lang.Runnable, SimnetWindowListener

public class AggregateRouter
extends Router

A router that simulates a having a subnet attached to it.


Nested Class Summary
private  class AggregateRouter.Subnet
           
 
Field Summary
protected  AggregateRouter.Subnet[] subnets
          Array of our subnets.
protected  int total_hosts
          Total hosts in all subnets
 
Fields inherited from class simnet.Router
fixed_bits
 
Fields inherited from class simnet.Node
applications, default_plugins_loaded, frame, frozen, id, in_filters, in_links, ipid, isNatted, keep_going, name, natGW, ns, out_filters, out_links, pause, proc, random, resolver, routing_table, running, sim, sleeping, transports, ui, win
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AggregateRouter()
           
 
Method Summary
protected  void forward(IP_Packet ip_packet)
          Forward a packet as normal, unless it is in our subnet and not for us - in that case, silently drop the packet.
 int getHopCount(int ip)
          Returns the number of hops to an IP if it exists within our subnet, or -1 if that IP does not exist.
 int getSubnet(int ip)
          Returns the subnet number the IP address is in, or -1 if that subnet doesn't exist or is outside the router's subnet.
 int getSubnetCount()
          Return the number of /24 subnets based on our fixed_bits.
 void initialize(int router_id, java.lang.String name)
          Initializes a new Router by setting its ID, name, node class (Router) and a pointer to the Simulator.
 boolean isSubnetPresent(int num)
          Does the specfied subnet number (NOT IP) exist?
 
Methods inherited from class simnet.Router
getFixedBits, getNodeClass, setFixedBits
 
Methods inherited from class simnet.Node
addBPF, addLink, addRule, clear, closeWindow, command, command, deleteRule, empty, finalize, getApplication, getHostByName, getLink, getPluginCount, getTitleString, getTransport, getTransport, integrate, isolate, kill, lookup, lookup, out, prePlugout, printout, printout, processWindowCommand, removeBPF, removeLink, run, setupNAT, start, stateful_kill, stateful_start, toString, toString, window
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

subnets

protected AggregateRouter.Subnet[] subnets
Array of our subnets.


total_hosts

protected int total_hosts
Total hosts in all subnets

Constructor Detail

AggregateRouter

public AggregateRouter()
Method Detail

initialize

public void initialize(int router_id,
                       java.lang.String name)
Initializes a new Router by setting its ID, name, node class (Router) and a pointer to the Simulator.

Overrides:
initialize in class Router
Parameters:
router_id - ID of new node
name - name of new node

getSubnetCount

public int getSubnetCount()
Return the number of /24 subnets based on our fixed_bits.


forward

protected void forward(IP_Packet ip_packet)
Forward a packet as normal, unless it is in our subnet and not for us - in that case, silently drop the packet. Not checking if the TTL is OK, or the IP actually exists...

Overrides:
forward in class Router
Parameters:
ip_packet - incoming IP packet to be forwarded

getSubnet

public int getSubnet(int ip)
Returns the subnet number the IP address is in, or -1 if that subnet doesn't exist or is outside the router's subnet.


isSubnetPresent

public boolean isSubnetPresent(int num)
Does the specfied subnet number (NOT IP) exist?


getHopCount

public int getHopCount(int ip)
Returns the number of hops to an IP if it exists within our subnet, or -1 if that IP does not exist.