GridSim 5.0 beta

gridsim.net
Class RateControlledScheduler

Object
  extended by Thread
      extended by Sim_entity
          extended by RateControlledScheduler
All Implemented Interfaces:
PacketScheduler, Cloneable, Runnable

public class RateControlledScheduler
extends Sim_entity
implements PacketScheduler

RateControlledScheduler is an implementation of a rate-jitter controlling regulator. For more details refer to H. Zhang and D.Ferrari's INFOCOM '93 paper Rate-Controlled Static-Priority Queueing.

RateControlledScheduler can be used to control the bandwidth that is assigned to each class of user at a Router. This is a non-work conserving algorithm, which means that the router can remain idle even if there are packets in its queue.

At a RateControlledScheduler each class of users is assigned a certain percentage of bandwidth, and the scheduler makes sure that each class remains constrained within its bandwidth limits at all times.

Since:
GridSim Toolkit 4.0
Author:
Gokul Poduval & Chen-Khong Tham, National University of Singapore
Invariant:
$none

Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RateControlledScheduler(String name, double baudRate, int numClasses)
          Creates a new RateControlled packet scheduler with the specified name and baud rate (in bits/s).
RateControlledScheduler(String name, double baudRate, int routerID, int numClasses)
          Creates a new RateControlled packet scheduler with the specified name and baud rate (in bits/s).
RateControlledScheduler(String name, int numClasses)
          Creates a new RateControlled packet scheduler with the specified name.
 
Method Summary
 void body()
          Handles an incoming events coming from a specified Router
 Packet deque()
          The method deque() has to decide which queue is to be served next -- This method is not used
 boolean enque(Packet np)
          Puts a packet into the queue -- This method is not used
 double getBaudRate()
          Returns the baud rate of the egress port that is using this scheduler.
 int getNumClass()
          Gets the number of classes for prioritizing incoming packets
 double[] getRate()
          Gets the list of rates for each packet class
 int getRouterID()
          Gets the router ID that hosts this scheduler.
 int getSchedID()
          Gets the ID of this scheduler.
 String getSchedName()
          Gets the name of this scheduler.
 boolean isEmpty()
          Determines whether the scheduler is currently keeping any packets in its queue(s).
 boolean setBaudRate(double rate)
          Sets the baud rate that this scheduler will be sending packets at.
 boolean setRates(double[] rates)
          This method allows you to set different rates for different types of traffic.
 boolean setRouterID(int routerID)
          Sets the router ID that hosts this scheduler.
 int size()
          Determines the number of packets that are currently enqueued in this scheduler.
 
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

RateControlledScheduler

public RateControlledScheduler(String name,
                               double baudRate,
                               int numClasses)
                        throws ParameterException
Creates a new RateControlled packet scheduler with the specified name and baud rate (in bits/s). The name can be useful for debugging purposes, but serves no functional purposes. Don't forget to set the rate for each packet class by using the setRates(double[]) method.

Parameters:
name - Name of this scheduler
baudRate - baud rate in bits/s of the port that is using this scheduler.
numClasses - number of classes for prioritizing a packet
Throws:
ParameterException - This happens when the name is null or the baud rate <= 0 or num of classes <= 0
Pre Condition:
name != null, baudRate > 0, numClasses > 0
Post Condition:
$none

RateControlledScheduler

public RateControlledScheduler(String name,
                               int numClasses)
                        throws ParameterException
Creates a new RateControlled packet scheduler with the specified name. The baud rate is left at 0, and should be set with PacketScheduler.setBaudRate(double) before the simulation starts. The name can be useful for debugging purposes, but serves no functional purposes. Don't forget to set the rate for each packet class by using the setRates(double[]) method.

Parameters:
name - Name of this scheduler
numClasses - number of classes for prioritizing a packet
Throws:
ParameterException - This happens when the name is null or the baud rate <= 0 or num of classes <= 0
Pre Condition:
name != null, numClasses > 0
Post Condition:
$none

RateControlledScheduler

public RateControlledScheduler(String name,
                               double baudRate,
                               int routerID,
                               int numClasses)
                        throws ParameterException
Creates a new RateControlled packet scheduler with the specified name and baud rate (in bits/s). The name can be useful for debugging purposes, but serves no functional purposes. Don't forget to set the rate for each packet class by using the setRates(double[]) method.

Parameters:
name - Name of this scheduler
baudRate - baud rate in bits/s of the port that is using this scheduler.
routerID - the router ID that hosts this packet scheduler
numClasses - number of classes for prioritizing a packet
Throws:
ParameterException - This happens when the name is null or router ID <= 0 or the baud rate <= 0 or num of classes <= 0
Pre Condition:
name != null, baudRate > 0, routerID > 0, numClasses > 0
Post Condition:
$none
Method Detail

getNumClass

public int getNumClass()
Gets the number of classes for prioritizing incoming packets

Returns:
number of classes
Pre Condition:
$none
Post Condition:
$none

getRate

public double[] getRate()
Gets the list of rates for each packet class

Returns:
the list of rates or null if empty
Pre Condition:
$none
Post Condition:
$none

body

public void body()
Handles an incoming events coming from a specified Router

Overrides:
body in class Sim_entity
Pre Condition:
$none
Post Condition:
$none

setRates

public boolean setRates(double[] rates)
This method allows you to set different rates for different types of traffic. Traffic of class n are assigned a rate of rates[n]. The higher the rate of a class, the better the service it receives. NOTE: Each rate must be a positive number.

Parameters:
rates - a linear array of the rates to be assigned to different classes of traffic.
Pre Condition:
rates != null
Post Condition:
$none

isEmpty

public boolean isEmpty()
Determines whether the scheduler is currently keeping any packets in its queue(s).

Specified by:
isEmpty in interface PacketScheduler
Returns:
true if no packets are enqueued, false otherwise
Pre Condition:
$none
Post Condition:
$none

size

public int size()
Determines the number of packets that are currently enqueued in this scheduler.

Specified by:
size in interface PacketScheduler
Returns:
the number of packets enqueud by this scheduler.
Pre Condition:
$none
Post Condition:
$none

getBaudRate

public double getBaudRate()
Returns the baud rate of the egress port that is using this scheduler. If the baud rate is zero, it means you haven't set it up.

Specified by:
getBaudRate in interface PacketScheduler
Returns:
the baud rate in bits/s
See Also:
PacketScheduler.setBaudRate(double)
Pre Condition:
$none
Post Condition:
$result >= 0

setBaudRate

public boolean setBaudRate(double rate)
Sets the baud rate that this scheduler will be sending packets at.

Specified by:
setBaudRate in interface PacketScheduler
Parameters:
rate - the baud rate of this scheduler (in bits/s)
Pre Condition:
rate > 0
Post Condition:
$none

getSchedName

public String getSchedName()
Gets the name of this scheduler.

Specified by:
getSchedName in interface PacketScheduler
Returns:
the name of this scheduler
Pre Condition:
$none
Post Condition:
$none

getSchedID

public int getSchedID()
Gets the ID of this scheduler.

Specified by:
getSchedID in interface PacketScheduler
Returns:
the ID of this scheduler or -1 if no ID is found
Pre Condition:
$none
Post Condition:
$none

setRouterID

public boolean setRouterID(int routerID)
Sets the router ID that hosts this scheduler.

Specified by:
setRouterID in interface PacketScheduler
Parameters:
routerID - the router ID that hosts this scheduler
Returns:
true if successful or false otherwise
Pre Condition:
routerID > 0
Post Condition:
$none

getRouterID

public int getRouterID()
Gets the router ID that hosts this scheduler.

Specified by:
getRouterID in interface PacketScheduler
Returns:
the router ID or -1 if no ID is found
Pre Condition:
$none
Post Condition:
$none

enque

public boolean enque(Packet np)
Puts a packet into the queue -- This method is not used

Specified by:
enque in interface PacketScheduler
Parameters:
np - A Packet to be enqued by this scheduler.
Returns:
true if enqued, false otherwise
Pre Condition:
pnp != null
Post Condition:
$none

deque

public Packet deque()
The method deque() has to decide which queue is to be served next -- This method is not used

Specified by:
deque in interface PacketScheduler
Returns:
the packet to be sent out or null if empty
Pre Condition:
$none
Post Condition:
$none

GridSim 5.0 beta

The University of Melbourne, Australia, 2009