GridSim
v3.1

gridsim.net
Class PacketScheduler

Object
  extended bygridsim.net.PacketScheduler
Direct Known Subclasses:
FIFOScheduler, SCFQScheduler

public abstract class PacketScheduler
extends Object

This class provides a template for schedulers that will be used at routers. Every egress port of a router needs to instantiate a PacketScheduler object which it uses to determine the order in which packets should be sent out.

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

Constructor Summary
PacketScheduler()
          Creates a new packet scheduler with the name "PacketScheduler".
PacketScheduler(double baudRate)
          Creates a new packet scheduler with the specified baud rate (bits/s).
PacketScheduler(String name)
          Creates a new packet scheduler with the specified name.
PacketScheduler(String name, double baudRate)
          Creates a new packet scheduler with the specified name and baud rate (in bits/s).
 
Method Summary
abstract  Packet deque()
          Removes a single packet and returns it.
abstract  boolean enque(Packet np)
          This method enques a packet in this scheduler.
 double getBaudRate()
          Returns the baud rate of the egress port that is using this scheduler.
 String getName()
          Returns the name of this scheduler, if one was specified during setup.
abstract  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.
abstract  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

PacketScheduler

public PacketScheduler(String name,
                       double baudRate)
                throws ParameterException
Creates a new packet scheduler with the specified name and baud rate (in bits/s). The name can be useful for debugging purposes, but server no functional purpose.

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

PacketScheduler

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

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

PacketScheduler

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

Parameters:
name - Name of this scheduler
Throws:
ParameterException - This happens when the name is null
Pre Condition:
name != null
Post Condition:
$none

PacketScheduler

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

Pre Condition:
$none
Post Condition:
$none
Method Detail

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.

Returns:
the baud rate in bits/s
See Also:
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.

Parameters:
rate - the baud rate of this scheduler (in bits/s)
Returns:
true if it is successful, false otherwise
Pre Condition:
rate > 0
Post Condition:
$none

enque

public abstract boolean enque(Packet np)
This method enques a packet in this scheduler. If the implementing class has buffer management policies too, then it should return true if the packet was successfully enqued. If the packet was dropped, or could not be accomodated due to any other reason, it should return false.

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

deque

public abstract Packet deque()
Removes a single packet and returns it. This packet should be sent out by the router from the port using this scheduler.

Returns:
the packet to be sent out
Pre Condition:
$none
Post Condition:
$none

isEmpty

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

Returns:
true if no packets are enqueued, false otherwise
Pre Condition:
$none
Post Condition:
$none

size

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

Returns:
the number of packets enqueud by this scheduler.
Pre Condition:
$none
Post Condition:
$none

getName

public String getName()
Returns the name of this scheduler, if one was specified during setup. Otherwise "PacketScheduler" is returned. This could be used for debugging purposes.

Returns:
the name of this scheduler
Pre Condition:
$none
Post Condition:
$none

GridSim
v3.1

The University of Melbourne, Australia, 2004