GridSim 5.0 beta

gridsim.net
Class FIFOScheduler

Object
  extended by FIFOScheduler
All Implemented Interfaces:
PacketScheduler

public class FIFOScheduler
extends Object
implements PacketScheduler

FIFOScheduler implements a First in First Out Scheduler. This means that all the packets are enqued at the tail of a queue, and packets depart from the head of the queue. Packets are not reordered, and no differentiated service will be provided.

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

Constructor Summary
FIFOScheduler()
          Creates a new packet scheduler with the name "FIFOScheduler".
FIFOScheduler(double baudRate)
          Creates a new FIFO packet scheduler with the specified baud rate (in bits/s).
FIFOScheduler(String name)
          Creates a new FIFO packet scheduler with the specified name.
FIFOScheduler(String name, double baudRate)
          Creates a new FIFO packet scheduler with the specified name and baud rate (in bits/s).
 
Method Summary
 Packet deque()
          In this scheduler, the packet returned is always from the head of the queue.
 boolean enque(Packet np)
          In this scheduler, the packet is put into the tail of 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.
 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

FIFOScheduler

public FIFOScheduler(String name,
                     double baudRate)
              throws ParameterException
Creates a new FIFO packet scheduler with the specified name and baud rate (in bits/s). The name can be useful for debugging purposes, but serves 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

FIFOScheduler

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

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

FIFOScheduler

public FIFOScheduler(String name)
              throws ParameterException
Creates a new FIFO 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

FIFOScheduler

public FIFOScheduler()
              throws ParameterException
Creates a new packet scheduler with the name "FIFOScheduler". 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

enque

public boolean enque(Packet np)
In this scheduler, the packet is put into the tail of the queue. There is no buffer management, so packets are never dropped, and the queue can grow as long as system memory is available.

Specified by:
enque in interface PacketScheduler
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 Packet deque()
In this scheduler, the packet returned is always from the head of the queue.

Specified by:
deque in interface PacketScheduler
Returns:
the packet to be sent out, or null if a list is empty
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