|
GridSim 5.0 beta | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object Thread Sim_entity Router
public abstract class Router
This class implements a Router which forwards data from one entity to another.
This abstract class only contains abstract methods to connect other routers and hosts. In addition, common functionalities are available in this class for its children classes to use. However, this class does not provide methods on how to setup forwarding tables, so the design of that is left to the user if he/she wants to create a Router with some specific routing algorithm.
Few important notes to consider when extending from this class:
body()
method as
it contains code/functionality to register this entity to
GridInformationService
entity, and finalizing
logging information before exiting the simulation.
advertiseHosts()
method. It is
needed for advertising all hosts or
entities connected to this entity to adjacent routers.
registerOtherEntity()
method : for registering other
event type/tag to GridInformationService
.
This is optional.
processEvent(Sim_event)
method.
It is needed for processing incoming events.
SimReport
object is created in this class,
hence, you only need to use write(String)
method.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected static int |
DELAY
Denotes a time delay (in second) for sending events in the future. |
static int |
MAX_HOP_COUNT
An attribute that denotes the maximum number of hopcount used for advertising adjacent routers. |
protected SimReport |
reportWriter_
An attribute that logs incoming and outgoing packets into a file. |
Fields inherited from class Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
Router(String name)
Creates a new RIPRouter object. |
|
Router(String name,
boolean trace)
Creates a new Router object with logging facility if it is turned on. |
Method Summary | |
---|---|
protected abstract void |
advertiseHosts()
All hosts connected to this router are advertised to adjacent routers |
abstract void |
attachHost(GridSimCore entity,
PacketScheduler sched)
Attaches an entity to this router. |
abstract void |
attachRouter(Router router,
Link link,
PacketScheduler sched)
Joins two routers together. |
abstract void |
attachRouter(Router router,
Link link,
PacketScheduler thisSched,
PacketScheduler otherSched)
Joins two routers with a Link. |
void |
body()
Handles incoming requests. |
abstract PacketScheduler |
getScheduler(int dest)
Returns the Scheduler that the router would use to reach a particular destination. |
abstract PacketScheduler |
getScheduler(Packet np)
Returns the Scheduler associated with a packet. |
abstract PacketScheduler |
getScheduler(String dest)
Returns the Scheduler that the router would use to reach a particular destination. |
abstract void |
printRoutingTable()
This method prints out the forwarding table of the router in a human readable form. |
protected abstract void |
processEndSimulation()
Informs the registered entities regarding to the end of a simulation. |
protected abstract void |
processEvent(Sim_event ev)
Overrides this method when creating a new type of router. |
protected void |
registerOtherEntity()
Overrides this method when making a new type of router. |
protected void |
sendInitialEvent()
Overrides this method when sending initial event(s) to itself or others BEFORE receiving incoming events from other entities. |
protected void |
write(String str)
Writes a debug information to a file. |
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 |
Field Detail |
---|
public static int MAX_HOP_COUNT
protected SimReport reportWriter_
write(String)
to log or record the information.
protected static int DELAY
Constructor Detail |
---|
public Router(String name) throws NullPointerException
Router(String, boolean)
.
name
- Name of this router
NullPointerException
- This happens when name is empty or nullRouter(String, boolean)
public Router(String name, boolean trace) throws NullPointerException
name
- Name of this routertrace
- true if you want to record this router's
activity, false otherwise
NullPointerException
- This happens when name is empty or nullMethod Detail |
---|
public abstract void attachRouter(Router router, Link link, PacketScheduler thisSched, PacketScheduler otherSched)
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.public abstract void attachRouter(Router router, Link link, PacketScheduler sched)
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.public abstract void attachHost(GridSimCore entity, PacketScheduler sched)
GridSimCore.getLink()
.
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.GridSimCore.getLink()
public abstract PacketScheduler getScheduler(Packet np)
np
- NetPacket for which the associated scheduler is to be
returned. This can be used to set weigths, priorities, etc.
as the case may be on the Scheduler.
public abstract PacketScheduler getScheduler(int dest)
dest
- id of the destination for which the Scheduler is required.
public abstract PacketScheduler getScheduler(String dest)
dest
- Name of the destination for which the Scheduler is required.
public abstract void printRoutingTable()
public void body()
GridInformationService
entity, and finalizing
logging information before exiting the simulation.
This method also calls these methods in the following order:
advertiseHosts()
method. It is
needed for advertising all hosts or
entities connected to this entity to adjacent routers.
registerOtherEntity()
method : for registering other
event type/tag to GridInformationService
.
This is optional.
processEvent(Sim_event)
method.
It is needed for processing incoming events.
body
in class Sim_entity
protected abstract void advertiseHosts()
protected abstract void processEvent(Sim_event ev)
body()
for incoming unknown tags.
The services or tags available for this resource are:
ev
- a Sim_event objectprotected void registerOtherEntity()
body()
method
to register to other type of the
GridInformationService
entity. In doing so, you
need to create a new child class extending from the
GridInformationService
class.
body()
method, if
you use this method.
GridInformationService
protected void sendInitialEvent()
body()
method, if
you use this method.
protected void write(String str)
str
- a string messageprotected abstract void processEndSimulation()
|
GridSim 5.0 beta | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |