|
GridSim v3.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectThread
eduni.simjava.Sim_entity
gridsim.net.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.
Field Summary | |
protected SimReport |
reportWriter_
An attribute that logs incoming and outgoing packets into a file. |
Fields inherited from class eduni.simjava.Sim_entity |
|
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. |
protected 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 |
processEvent(Sim_event ev)
Overrides this method when creating a new type of router. |
protected void |
registerOtherEntity()
Overrides this method when making a type of router. |
protected void |
write(String str)
Writes a debug information to a file. |
Methods inherited from class eduni.simjava.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, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected SimReport reportWriter_
write(String)
to log or record the information.
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.protected 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()
to register other type to
GridInformationService
entity. In doing so, you
need to create a new child class extending from
GridInformationService
.
body()
method, if
you use this method.
GridInformationService
protected void write(String str)
str
- a string message
|
GridSim v3.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |