gov.nist.antd.optical
Class BasicQueue

java.lang.Object
  |
  +--gov.nist.antd.optical.BasicQueue
All Implemented Interfaces:
packetQueue

public class BasicQueue
extends java.lang.Object
implements packetQueue

This class allows the transmission of messages along different lambdas at the same time. A queue is managed for each lambda.

 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:
borchert
, rouil

Nested Class Summary
private  class BasicQueue.Info
          internal class to store information about the queue of a specific lambda.
 
Field Summary
private  ONIC forNIC
          The ONIC that uses this queue
private  Host localHost
          The host where this queue is running
private  long maxQueueingDelay
          The maximum delay for transmission
private  PacketQueueMonitor myMonitor
          The packet queue monitor
private  boolean pktDropped
          Indicates if the packet has been dropped
(package private)  java.util.Hashtable table
          Map a lambda to the delay information.
 
Constructor Summary
BasicQueue()
          Default constructor
BasicQueue(ONIC onic)
          Called by NIC if DML attribute interface.queue is omitted; then BasicQueue is the default packetQueue installed.
 
Method Summary
private  long calibrate(BasicQueue.Info info)
          If we have moved forward in time, recalibrate the accumulated delay so that it remains relative to "now".
 void config(NIC nic, com.renesys.raceway.DML.Configuration cfg)
          Does not accept any user-defined Configuration.
 void configure(OpticalLink link)
          Configure the hashtable that map a lambda to the sending information
 boolean enqueue(ProtocolMessage msg)
          Put the given message in the queue.
 long getNumberOfBitsInQueue(Lambda lambda)
          Returns queue size in bits at the moment of calling.
 int getPktCount(Lambda lambda)
          Return the total number of packets used for this lambda
 int getPktDropCount(Lambda lambda)
          Return the total number of packets dropped for this lambda
 void init()
          Required by interface packetQueue.
 boolean isPktDropped()
          Indicates if the last packet has been dropped
 void setMonitor(PacketQueueMonitor mon)
          Set reference to a correctly configured class implementing the Java interface PacketQueueMonitor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxQueueingDelay

private long maxQueueingDelay
The maximum delay for transmission


forNIC

private ONIC forNIC
The ONIC that uses this queue


localHost

private Host localHost
The host where this queue is running


pktDropped

private boolean pktDropped
Indicates if the packet has been dropped


myMonitor

private PacketQueueMonitor myMonitor
The packet queue monitor


table

java.util.Hashtable table
Map a lambda to the delay information.

Constructor Detail

BasicQueue

public BasicQueue()
Default constructor


BasicQueue

public BasicQueue(ONIC onic)
Called by NIC if DML attribute interface.queue is omitted; then BasicQueue is the default packetQueue installed.

Parameters:
onic - The ONIC that uses this queue.
Method Detail

config

public void config(NIC nic,
                   com.renesys.raceway.DML.Configuration cfg)
Does not accept any user-defined Configuration. Obtains values of attributes buffer and bitrate from the instance of ONIC that constructs this BasicQueue.

Specified by:
config in interface packetQueue
Parameters:
nic - the ONIC that use this queue.
cfg - The DML configuration

init

public void init()
Required by interface packetQueue. Called by NIC.init().

Specified by:
init in interface packetQueue

setMonitor

public void setMonitor(PacketQueueMonitor mon)
Set reference to a correctly configured class implementing the Java interface PacketQueueMonitor.

Parameters:
mon - The PacketQueueMonitor

enqueue

public boolean enqueue(ProtocolMessage msg)
Put the given message in the queue. Return true if a packet is successfully enqueued, or false if the queue rejects the packet.

Specified by:
enqueue in interface packetQueue
Parameters:
msg - The message to send.
Returns:
true if the packet is enqueued.

calibrate

private long calibrate(BasicQueue.Info info)
If we have moved forward in time, recalibrate the accumulated delay so that it remains relative to "now". Re-calibrate before every transmission. Returns the recalibrated accumulated queueing delay.

Parameters:
info - The information for the transmission.
Returns:
The queueing delay.

getNumberOfBitsInQueue

public long getNumberOfBitsInQueue(Lambda lambda)
Returns queue size in bits at the moment of calling. Queue size is calculated as queueing delay (long, in tick units) times interface bitrate (double, in bits/tick) therefore it is rounded down to nearest long integer value.

Parameters:
lambda - The lambda used for the transmission
Returns:
The queue size in bits.

configure

public void configure(OpticalLink link)
Configure the hashtable that map a lambda to the sending information

Parameters:
link - The optical link that contains all the lambdas.

isPktDropped

public boolean isPktDropped()
Indicates if the last packet has been dropped

Returns:
true if the packet is dropped

getPktCount

public int getPktCount(Lambda lambda)
Return the total number of packets used for this lambda

Parameters:
lambda - The lambda we want the information from
Returns:
The total number of packets used for this lambda

getPktDropCount

public int getPktDropCount(Lambda lambda)
Return the total number of packets dropped for this lambda

Parameters:
lambda - The lambda we want the information from
Returns:
The total number of packets dropped for this lambda