GridSim 5.0 beta

gridsim.net.fnb
Class FnbRIPRouter

Object
  extended by Thread
      extended by Sim_entity
          extended by Router
              extended by FnbRIPRouter
All Implemented Interfaces:
Cloneable, Runnable

public class FnbRIPRouter
extends Router

This class implements a Router using a form of RIP for routing. The routing protocol used here is similar to Routing Information Protocol (RIP) . The routing protocol is run before Gridlets etc. can be submitted. Note that this class is based on RIPRouter class.

In case there are more than two routes to a destination, the route with the lower hopcount is used. Since in this simulation routers relay perfect information and links do not break down, RIP should be a reliable protocol to use.

Since:
GridSim Toolkit 4.2
Author:
Agustin Caminero, University of Castilla La Mancha, Spain.
Invariant:
$none

Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class Router
DELAY, MAX_HOP_COUNT, reportWriter_
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FnbRIPRouter(String name, boolean trace, int my_id)
          Creates a new FnbRIPRouter object with logging facility if it is turned on.
FnbRIPRouter(String name, boolean trace, int my_id, boolean stats)
          Creates a new FnbRIPRouter object with logging facility if it is turned on.
FnbRIPRouter(String name, int my_id)
          Creates a new RIPRouter object.
FnbRIPRouter(String name, int my_id, boolean stats)
          Creates a new RIPRouter object.
 
Method Summary
protected  void advertiseHosts()
          All hosts connected to this router are advertised to adjacent routers
 void attachHost(GridSimCore entity, PacketScheduler sched)
          Attaches an entity to this router.
 void attachRouter(Router router, Link link, PacketScheduler sched)
          Joins two routers together.
 void attachRouter(Router router, Link link, PacketScheduler thisSched, PacketScheduler otherSched)
          Joins two routers with a Link.
 int getMyID()
          Returns the user specified ID of this router
 PacketScheduler getScheduler(int dest)
          Returns the Scheduler that the router would use to reach a particular destination.
 PacketScheduler getScheduler(Packet np)
          Returns the Scheduler associated with a packet.
 PacketScheduler getScheduler(String dest)
          Returns the Scheduler that the router would use to reach a particular destination.
 void printRoutingTable()
          Prints this router's routing table in a nice-formatted layout
protected  void processEndSimulation()
          At the end of simulations, write the counters into files.
protected  void processEvent(Sim_event ev)
          Processes incoming events
protected  void sendInitialEvent()
          Sends an initial event to itself regarding to the ARED parameters.
 
Methods inherited from class Router
body, registerOtherEntity, write
 
Methods inherited from class Sim_entity
add_generator, add_param, add_port, clone, get_id, get_name, get_port, get_port, get_stat, run, send_on, set_invisible, set_stat, sim_cancel, sim_completed, sim_current, sim_get_next, sim_get_next, sim_hold_for, sim_hold, sim_pause_for, sim_pause_for, sim_pause_until, sim_pause_until, sim_pause, sim_process_for, sim_process_for, sim_process_until, sim_process_until, sim_process, sim_putback, sim_schedule, sim_schedule, sim_schedule, sim_schedule, sim_schedule, sim_schedule, sim_select, sim_trace, sim_wait_for, sim_wait_for, sim_wait_for, sim_wait, sim_waiting, sim_waiting
 
Methods inherited from class Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FnbRIPRouter

public FnbRIPRouter(String name,
                    int my_id)
             throws NullPointerException
Creates a new RIPRouter object. By default, no recording or logging is done for packets' activities. If you want to log operations of this entity, please use FnbRIPRouter(String, boolean, int).

Parameters:
name - Name of this router
my_id - the user specified router ID. For a router named "router0", my_id will be 0.
Throws:
NullPointerException - This happens when name is empty or null
See Also:
FnbRIPRouter(String, boolean, int)
Pre Condition:
name != null
Post Condition:
$none

FnbRIPRouter

public FnbRIPRouter(String name,
                    boolean trace,
                    int my_id)
             throws NullPointerException
Creates a new FnbRIPRouter object with logging facility if it is turned on.
NOTE: If logging facility is turned on, there are some overheads in terms of performance and memory consumption.

Parameters:
name - Name of this router
trace - true if you want to record this router's activity, false otherwise
my_id - the user specified router ID. For a router named "router0", my_id will be 0.
Throws:
NullPointerException - This happens when name is empty or null
Pre Condition:
name != null
Post Condition:
$none

FnbRIPRouter

public FnbRIPRouter(String name,
                    int my_id,
                    boolean stats)
             throws NullPointerException
Creates a new RIPRouter object. By default, no recording or logging is done for packets' activities. If you want to log operations of this entity, please use FnbRIPRouter(String, boolean, int).

Parameters:
name - Name of this router
my_id - the user specified router ID. For a router named "router0", my_id will be 0.
stats - true if we want to record statistics
Throws:
NullPointerException - This happens when name is empty or null
See Also:
FnbRIPRouter(String, boolean, int)
Pre Condition:
name != null
Post Condition:
$none

FnbRIPRouter

public FnbRIPRouter(String name,
                    boolean trace,
                    int my_id,
                    boolean stats)
             throws NullPointerException
Creates a new FnbRIPRouter object with logging facility if it is turned on.
NOTE: If logging facility is turned on, there are some overheads in terms of performance and memory consumption.

Parameters:
name - Name of this router
trace - true if you want to record this router's activity, false otherwise
my_id - the user specified router ID. For a router named "router0", my_id will be 0.
stats - true if we want to recor statistics
Throws:
NullPointerException - This happens when name is empty or null
Pre Condition:
name != null
Post Condition:
$none
Method Detail

attachRouter

public void attachRouter(Router router,
                         Link link,
                         PacketScheduler thisSched,
                         PacketScheduler otherSched)
Joins two routers with a Link.

Specified by:
attachRouter in class Router
Parameters:
router - The router on the other side to which this one will be attached.
link - This is the link that will be used to connect the two routers.
thisSched - The scheduling policy used on this routers egress port when sending data through it.
otherSched - The scheduling policy that will be used on the egress port of the router being connected to when sending data to this router.
Pre Condition:
router != null, link != null, thisSched != null, otherSched != null
Post Condition:
$none

attachRouter

public void attachRouter(Router router,
                         Link link,
                         PacketScheduler sched)
Joins two routers together. This is called by the routers themselves and should not be called by other entities.

Specified by:
attachRouter in class Router
Parameters:
router - The Router to which this router will be connected.
link - The Link that will be used to join these routers.
sched - The scheduling policy used on the egress port of the router when sending data through this route.
Pre Condition:
router != null, link != null, sched != null
Post Condition:
$none

attachHost

public void attachHost(GridSimCore entity,
                       PacketScheduler sched)
Attaches an entity to this router. The link between the router and the entity being attached is taken from GridSimCore.getLink().

Specified by:
attachHost in class Router
Parameters:
entity - The entity to be attached.
sched - The scheduling policy that will be used on the egress port when the router sends data to the entity being joined.
See Also:
GridSimCore.getLink()
Pre Condition:
entity != null, sched != null
Post Condition:
$none

processEvent

protected void processEvent(Sim_event ev)
Processes incoming events

Specified by:
processEvent in class Router
Parameters:
ev - a Sim_event object
Pre Condition:
ev != null
Post Condition:
$none

processEndSimulation

protected void processEndSimulation()
At the end of simulations, write the counters into files.

Specified by:
processEndSimulation in class Router

sendInitialEvent

protected void sendInitialEvent()
Sends an initial event to itself regarding to the ARED parameters.

Overrides:
sendInitialEvent in class Router

getScheduler

public PacketScheduler getScheduler(Packet np)
Returns the Scheduler associated with a packet.

Specified by:
getScheduler in class Router
Parameters:
np - FnbNetPacket for which the associated scheduler is to be returned
Returns:
the packet's scheduler or null if the packet is empty
Pre Condition:
np != null
Post Condition:
$none

getScheduler

public PacketScheduler getScheduler(int dest)
Returns the Scheduler that the router would use to reach a particular destination. This can be used to set weigths, priorities etc. as the case may be on the Scheduler

Specified by:
getScheduler in class Router
Parameters:
dest - id of the destination for which the Scheduler is required.
Returns:
the destination's packet scheduler
Pre Condition:
dest > 0
Post Condition:
$none

getScheduler

public PacketScheduler getScheduler(String dest)
Returns the Scheduler that the router would use to reach a particular destination. This can be used to set weigths, priorities etc. as the case may be on the Scheduler

Specified by:
getScheduler in class Router
Parameters:
dest - Name of the destination for which the Scheduler is required.
Returns:
destination's packet scheduler or null if destination name is invalid.
Pre Condition:
dest != null
Post Condition:
$none

printRoutingTable

public void printRoutingTable()
Prints this router's routing table in a nice-formatted layout

Specified by:
printRoutingTable in class Router
Pre Condition:
$none
Post Condition:
$none

getMyID

public int getMyID()
Returns the user specified ID of this router

Returns:
the user specified ID of this router
Pre Condition:
$none
Post Condition:
$none

advertiseHosts

protected void advertiseHosts()
All hosts connected to this router are advertised to adjacent routers

Specified by:
advertiseHosts in class Router
Pre Condition:
$none
Post Condition:
$none

GridSim 5.0 beta

The University of Melbourne, Australia, 2009