GridSim
v3.3

gridsim.net
Class FIFOScheduler

Object
  extended bygridsim.net.PacketScheduler
      extended bygridsim.net.FIFOScheduler

public class FIFOScheduler
extends 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 (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.
 boolean isEmpty()
          Determines whether the scheduler is currently keeping any packets in its queue(s).
 int size()
          Determines the number of packets that are currently enqueued in this scheduler.
 
Methods inherited from class gridsim.net.PacketScheduler
getBaudRate, getName, setBaudRate
 
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 (bits/s). The name is set to a generic "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 being the simulation is started.

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 being the simulation is started.

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 class 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 class 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 class 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 class PacketScheduler
Returns:
the number of packets enqueud by this scheduler.
Pre Condition:
$none
Post Condition:
$none

GridSim
v3.3

The University of Melbourne, Australia, 2005