GridSim 5.0 beta

gridsim.net.fnb
Class FnbSCFQScheduler

Object
  extended by Thread
      extended by Sim_entity
          extended by FnbSCFQScheduler
All Implemented Interfaces:
PacketScheduler, Cloneable, Runnable
Direct Known Subclasses:
FIFO, RED

public abstract class FnbSCFQScheduler
extends Sim_entity
implements PacketScheduler

FnbSCFQScheduler implements a Self Clocked Fair Queueing Scheduler. A SCFQ is a variation of Weighted Fair Queueing (WFQ), which is easier to implement than WFQ because it does not need to compute round numbers at every iteration. For more details refer to S. R. Golestani's INFOCOM '94 paper A self-clocked fair queueing scheme for broadband applications. Note that this class is based on SCFQScheduler class.

A SCFQ scheduler can provide differentiated service to traffic by changing the weights associated with a certain class of traffic. The higher the weight of a class of traffic, the better treatment it receives. In this class, you can set the weights by calling setWeights() with a linear array of weights. Traffic that is class 0 (default), are assigned the first element of the array as its weight.

For example:
String userName = { "User_0", "User_1", User_2" }; // list of user names
int[] trafficClass = { 0, 1, 2 }; // a list of class for each user
int[] weights = { 1, 2, 3 }; // a list of weights for each class

From the above example, User_0 has a traffic class of 0 (low priority), whereas User_2 has a traffic class of 2 (high priority) judging from their respective weights.

Since:
GridSim Toolkit 4.2
Author:
Agustin Caminero, Universidad de Castilla-La Mancha (UCLM) (Spain)
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
FnbSCFQScheduler(boolean stats)
          Creates a new packet scheduler with the name "FnbSCFQScheduler".
FnbSCFQScheduler(double baudRate, int max_buf_size)
          Creates a new SCFQ packet scheduler with the specified baud rate (bits/s).
FnbSCFQScheduler(double baudRate, int max_buf_size, boolean stats)
          Creates a new SCFQ packet scheduler with the specified baud rate (bits/s).
FnbSCFQScheduler(String name, double baudRate, int max_buf_size, boolean stats)
          Creates a new SCFQ packet scheduler with the specified name and baud rate (in bits/s).
FnbSCFQScheduler(String name, int max_buf_size)
          Creates a new SCFQ packet scheduler with the specified name.
FnbSCFQScheduler(String name, int max_buf_size, boolean stats)
          Creates a new SCFQ packet scheduler with the specified name.
 
Method Summary
 void body()
          A method that gets one process event at one time until the end of a simulation, then delivers an event to the entity (its parent)
protected  boolean checkDroppedGlList(int gl, int user)
          Checks if there is an existing gridletID_userID in the droppedGl_user array.
 Packet deque()
          The method deque() has to decide which queue is to be served next.
abstract  boolean enque(Packet pnp)
          Checks queue size and puts a packet into the queue
abstract  double getAvg()
          Returns the avg buffer size
 double getBaudRate()
          Returns the baud rate of the egress port that is using this scheduler.
protected  double getCounterDroppedPkts()
          Returns the DROPPED_PKTS_COUNTER
protected  double getMaxBufferSize()
          This function returns maximum buffer size, up to this moment along the experiment.
protected  double getMaxBufferSizeInPkts()
          This function returns the max buffer size in pkts.
 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.
protected  void increaseDroppedPktCounter()
          Increases the counter for the dropped packets by 1
protected abstract  void initialize()
          This function initializes the parameters of the buffers policies (RED, ARED)
protected  void insertGlID_userID(FnbDroppedPacketInfo info)
          Adds the packet info to the dropped list
protected  boolean insertPacketIntoQueue(Packet pnp)
          Puts a packet into the queue
 boolean isEmpty()
          Determines whether the scheduler is currently keeping any packets in its queue(s).
protected  boolean makeRoomForPacket()
          This function tries to drop a data packet out of a full queue, so that a control packet can be stored in that queue.
protected  double pktListSize()
          Returns the size of the packet list.
protected  void resetCounterDroppedPkts()
          Resets the DROPPED_PKTS_COUNTER
 boolean setBaudRateSCFQ(double rate)
          Sets the baud rate that this scheduler will be sending packets at.
protected  void setMaxBufferSize(int maxSize)
          This function sets the maximum buffer size
 boolean setRouterID(int routerID)
          Sets the router ID that hosts this scheduler.
 boolean setWeights(double[] weights)
          This method allows you to set different weights for different types of traffic.
 int size()
          Determines the number of packets that are currently enqueued in this scheduler.
abstract  void updateStats()
          Update the statistics of this scheduler to a file.
 
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
 
Methods inherited from interface PacketScheduler
setBaudRate
 

Constructor Detail

FnbSCFQScheduler

public FnbSCFQScheduler(String name,
                        double baudRate,
                        int max_buf_size,
                        boolean stats)
                 throws Exception
Creates a new SCFQ 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.

Parameters:
name - Name of this scheduler
baudRate - baud rate in bits/s of the port that is using this scheduler.
max_buf_size - maximum buffer size for routers
stats - whether we want to store stats or not
Throws:
Exception - This happens when the name is null or the baud rate <= 0
Pre Condition:
name != null, baudRate > 0
Post Condition:
$none

FnbSCFQScheduler

public FnbSCFQScheduler(double baudRate,
                        int max_buf_size,
                        boolean stats)
                 throws Exception
Creates a new SCFQ packet scheduler with the specified baud rate (bits/s). The name is set to a generic name: "FnbSCFQScheduler".

Parameters:
baudRate - baud rate in bits/s of the port that is using this scheduler.
max_buf_size - maximum buffer size for routers
stats - whether we want to store stats or not
Throws:
Exception - This happens when the baud rate <= 0
Pre Condition:
baudRate > 0
Post Condition:
$none

FnbSCFQScheduler

public FnbSCFQScheduler(String name,
                        int max_buf_size,
                        boolean stats)
                 throws Exception
Creates a new SCFQ 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.

Parameters:
name - Name of this scheduler
max_buf_size - maximum buffer size for routers
stats - whether we want to store stats or not
Throws:
Exception - This happens when the name is null
See Also:
PacketScheduler.setBaudRate(double)
Pre Condition:
name != null
Post Condition:
$none

FnbSCFQScheduler

public FnbSCFQScheduler(boolean stats)
                 throws Exception
Creates a new packet scheduler with the name "FnbSCFQScheduler". The baud rate is left at 0, and should be set with PacketScheduler.setBaudRate(double) before the simulation starts.

Parameters:
stats - whether we want to store stats or not
Throws:
Exception - This happens when the name is null
See Also:
PacketScheduler.setBaudRate(double)
Pre Condition:
$none
Post Condition:
$none

FnbSCFQScheduler

public FnbSCFQScheduler(double baudRate,
                        int max_buf_size)
                 throws Exception
Creates a new SCFQ packet scheduler with the specified baud rate (bits/s). The name is set to a generic name: "FnbSCFQScheduler".

Parameters:
baudRate - baud rate in bits/s of the port that is using this scheduler.
max_buf_size - maximum buffer size for routers
Throws:
Exception - This happens when the baud rate <= 0
Pre Condition:
baudRate > 0
Post Condition:
$none

FnbSCFQScheduler

public FnbSCFQScheduler(String name,
                        int max_buf_size)
                 throws Exception
Creates a new SCFQ 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.

Parameters:
name - Name of this scheduler
max_buf_size - maximum buffer size for routers
Throws:
Exception - This happens when the name is null
See Also:
PacketScheduler.setBaudRate(double)
Pre Condition:
name != null
Post Condition:
$none
Method Detail

initialize

protected abstract void initialize()
This function initializes the parameters of the buffers policies (RED, ARED)


setWeights

public boolean setWeights(double[] weights)
This method allows you to set different weights for different types of traffic. Traffic of class n are assigned a weight of weights[n]. The higher the weight of a class, the better the service it receives.
NOTE: Do not set a weight to be 0 or a negative number.

Parameters:
weights - a linear array of the weights to be assigned to different classes of traffic.
Returns:
true if it is successful, falseotherwise
Pre Condition:
weights != null
Post Condition:
$none

enque

public abstract boolean enque(Packet pnp)
Checks queue size and puts a packet into the queue

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

insertPacketIntoQueue

protected boolean insertPacketIntoQueue(Packet pnp)
Puts a packet into the queue

Parameters:
pnp - 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. In the original WFQ algorithm, this is always the packet with lowest finish time. We also need to update the CF (current finish no.) to that of the packet being served.

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

pktListSize

protected double pktListSize()
Returns the size of the packet list.

Returns:
size of the list of packets

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

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

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

setBaudRateSCFQ

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

Parameters:
rate - the baud rate of this scheduler (in bits/s)
Returns:
true if the baud rate has been set properly, false otherwise
Pre Condition:
rate > 0
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

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:
$none
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

makeRoomForPacket

protected boolean makeRoomForPacket()
This function tries to drop a data packet out of a full queue, so that a control packet can be stored in that queue.

Returns:
true if we have been able to find a data packet to be dropped, false otherwise.

getCounterDroppedPkts

protected double getCounterDroppedPkts()
Returns the DROPPED_PKTS_COUNTER

Returns:
the counter of dropped packets

resetCounterDroppedPkts

protected void resetCounterDroppedPkts()
Resets the DROPPED_PKTS_COUNTER


getMaxBufferSize

protected double getMaxBufferSize()
This function returns maximum buffer size, up to this moment along the experiment. Note that this is not the max allowed buffer size in pkts.

Returns:
the maximum buffer size, up this moment

getMaxBufferSizeInPkts

protected double getMaxBufferSizeInPkts()
This function returns the max buffer size in pkts.

Returns:
the maximum number of packets that fit into this buffer

setMaxBufferSize

protected void setMaxBufferSize(int maxSize)
This function sets the maximum buffer size

Parameters:
maxSize - the new maximum buffer size

body

public void body()
A method that gets one process event at one time until the end of a simulation, then delivers an event to the entity (its parent)

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

getAvg

public abstract double getAvg()
Returns the avg buffer size

Returns:
the avg buffer size

increaseDroppedPktCounter

protected void increaseDroppedPktCounter()
Increases the counter for the dropped packets by 1


insertGlID_userID

protected void insertGlID_userID(FnbDroppedPacketInfo info)
Adds the packet info to the dropped list

Parameters:
info - a dropped packet info

checkDroppedGlList

protected boolean checkDroppedGlList(int gl,
                                     int user)
Checks if there is an existing gridletID_userID in the droppedGl_user array. We consider gridlets, datagridlets and files

Parameters:
gl - the gridlet
user - user to which the gridlet belongs
Returns:
true, if there is a gridletID_userID object, false otherwise

updateStats

public abstract void updateStats()
Update the statistics of this scheduler to a file.


GridSim 5.0 beta

The University of Melbourne, Australia, 2009