gov.nist.antd.diffserv
Class SimplePacketQueue

java.lang.Object
  |
  +--gov.nist.antd.diffserv.SimplePacketQueue
Direct Known Subclasses:
DiffServQueue, MPLSQueue

public class SimplePacketQueue
extends java.lang.Object

Simple packet queue provides the basic fifoQueue(LinkedList) to implement various packet queue (e.g. DropTail, RED, RIO).

 This class was developed at the National Institute of Standards and
 Technology by employees of the Federal Government in the course of
 their official duties. Pursuant to title 17 Section 105 of the United
 States Code this software is not subject to copyright protection and
 is in the public domain.
 NIST assumes no responsibility whatsoever for its use by other parties,
 and makes no guarantees, expressed or implied, about its quality,
 reliability, or any other characteristic.
 
We would appreciate acknowledgement if the software is used.
NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.

Author:
Young-Tak Kim
, Eun-Hyuk Lim , borchert

Field Summary
(package private)  java.util.LinkedList fifoQueue
          The queue itself.
private  int maxSize
          The maximumsize of the queue.
private  int qlength
          The length of the queue.
 
Constructor Summary
SimplePacketQueue()
          Constructs the simplequeue.
 
Method Summary
 MessageWrapper dequeue()
          Retunr the first element in the queue and delete it out of the queue.
 boolean enqueue(ProtocolMessage message, ProtocolSession fromSession)
          Add the given message to the queue.
 int getAvailableQLength()
          Returns the available length of the queue.
 MessageWrapper getFirstPacket()
          Returns the first wrapper packet in the queue.
 int getMaxSize()
          Returns the maximum size of the queue.
 int getQLength()
          Return the length of the queue.
 void init(int maxSize)
          Initializes the queue.
 boolean isEmpty()
          Returns if the queue is empty or not.
 boolean isFull(int size)
          Determines if the kapacity of the queue can take a package withthe given size.
 void reset()
          Method reset - not implemented yet.
 void setMaxSize(int newMaxSize)
          Set the maximum size of the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxSize

private int maxSize
The maximumsize of the queue.


qlength

private int qlength
The length of the queue.


fifoQueue

java.util.LinkedList fifoQueue
The queue itself. It contains objects of ProtocolMessageWrapper.

Constructor Detail

SimplePacketQueue

public SimplePacketQueue()
Constructs the simplequeue.

Method Detail

init

public void init(int maxSize)
Initializes the queue.

Parameters:
maxSize - The new maximum size of the queue.

reset

public void reset()
Method reset - not implemented yet.


isEmpty

public boolean isEmpty()
Returns if the queue is empty or not.

Returns:
true if the queue is empty; otherwise false.

isFull

public boolean isFull(int size)
Determines if the kapacity of the queue can take a package withthe given size.

Parameters:
size - The size of the next package
Returns:
true if the queue can not store the package with the given size.

getQLength

public int getQLength()
Return the length of the queue.

Returns:
The length of the queue.

getMaxSize

public int getMaxSize()
Returns the maximum size of the queue.

Returns:
The maximum size of the queue.

getAvailableQLength

public int getAvailableQLength()
Returns the available length of the queue.

Returns:
The available length of the queue.

setMaxSize

public void setMaxSize(int newMaxSize)
Set the maximum size of the queue.

Parameters:
newMaxSize - The maximum size of the queue.

enqueue

public boolean enqueue(ProtocolMessage message,
                       ProtocolSession fromSession)
Add the given message to the queue.

Parameters:
message - The message that has to be stored in the queue.
fromSession - The session the message comes from.
Returns:
boolean false if the queue is already full.

dequeue

public MessageWrapper dequeue()
Retunr the first element in the queue and delete it out of the queue.

Returns:
The first element in the queue.

getFirstPacket

public MessageWrapper getFirstPacket()
Returns the first wrapper packet in the queue.

Returns:
The first wrapper packet in the queue.