GridSim 5.0 beta

gridsim.net
Class SCFQScheduler

Object
  extended by SCFQScheduler
All Implemented Interfaces:
PacketScheduler

public class SCFQScheduler
extends Object
implements PacketScheduler

SCFQScheduler 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.

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 3.1
Author:
Gokul Poduval & Chen-Khong Tham, National University of Singapore
Invariant:
$none

Constructor Summary
SCFQScheduler()
          Creates a new packet scheduler with the name "SCFQScheduler".
SCFQScheduler(double baudRate)
          Creates a new SCFQ packet scheduler with the specified baud rate (bits/s).
SCFQScheduler(String name)
          Creates a new SCFQ packet scheduler with the specified name.
SCFQScheduler(String name, double baudRate)
          Creates a new SCFQ packet scheduler with the specified name and baud rate (in bits/s).
 
Method Summary
 Packet deque()
          The method deque() has to decide which queue is to be served next.
 boolean enque(Packet pnp)
          Puts a packet into the queue
 double getBaudRate()
          Returns the baud rate of the egress port that is using this scheduler.
 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 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.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SCFQScheduler

public SCFQScheduler(String name,
                     double baudRate)
              throws ParameterException
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.
Throws:
ParameterException - This happens when the name is null or the baud rate <= 0
Pre Condition:
name != null, baudRate > 0
Post Condition:
$none

SCFQScheduler

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

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

SCFQScheduler

public SCFQScheduler(String name)
              throws ParameterException
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
Throws:
ParameterException - This happens when the name is null
See Also:
PacketScheduler.setBaudRate(double)
Pre Condition:
name != null
Post Condition:
$none

SCFQScheduler

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

Throws:
ParameterException - This happens when the name is null
See Also:
PacketScheduler.setBaudRate(double)
Pre Condition:
$none
Post Condition:
$none
Method Detail

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 boolean enque(Packet pnp)
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

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

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

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

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

GridSim 5.0 beta

The University of Melbourne, Australia, 2009