J-Sim v1.2.1-p7 API

drcl.net.traffic
Class TrafficShaper

java.lang.Object
  extended bydrcl.DrclObj
      extended bydrcl.net.traffic.TrafficShaper
All Implemented Interfaces:
java.lang.Cloneable, ObjectDuplicable, java.io.Serializable
Direct Known Subclasses:
tsCDSmooth, tsPeriodic, tsRTSmooth, tsTokenBucket

public abstract class TrafficShaper
extends DrclObj

Defines the base class for regulating incoming packets and outputing the packets according to the associated traffic model.

A TrafficShaper holds a buffer that accommodates the difference of the traffic patterns between the incoming traffic and the traffic model instance that is associated with this component.

To embed this class in a component (e.g., TrafficShaperComponent), call adjust(drcl.net.Packet, double) for each packet to be regulated. The method returns the amount of time that must be delayed for outputting the packet in order to conform to the associated traffic model. If the time is greater than zero, then the packet is held in the buffer until dequeue() is called to release the packet. One can use nextOutputTime() to get the absolute time when the next packet in the buffer can be released.

Subclasses must override adjust(double, int). Subclasses do not need to be concerned about the buffer as it is taken care of in adjust(drcl.net.Packet, double). The current time passed to this method is maintained relatively to the time when this shaper instance starts. A subclass also needs to override duplicate(Object), info(String) and reset().

See Also:
TrafficModel, Serialized Form

Constructor Summary
TrafficShaper()
           
 
Method Summary
protected abstract  double adjust(double now_, int size_)
          Returns the time adjustment (relative to the current time now_) for outputing the packet.
 double adjust(Packet p_, double now_)
          Returns the time adjustment (relative to the current time now_) for outputing the packet.
 Packet dequeue()
          Releases and returns the first packet being held in the buffer.
 void duplicate(java.lang.Object source_)
          opies the content of the source_ object to this object.
 int getAvailableBufferSize()
          Returns the available buffer size of this traffic shaper (byte).
 int getBufferLength()
          Returns the current buffer length of this traffic shaper (# of packets).
 int getBufferSize()
          Returns the (maximum) buffer size of this traffic shaper (byte).
abstract  TrafficModel getTrafficModel()
          Returns the associated traffic model.
 java.lang.String info(java.lang.String prefix_)
          Prints out the content of this traffic shaper instance.
 double nextOutputTime()
          Returns the output time of next packet.
 void reset()
           
 void setBufferSize(int size_)
          Sets the (maximum) buffer size of this traffic shaper (byte).
abstract  void setTrafficModel(TrafficModel traffic_)
          Sets the associated traffic model.
 
Methods inherited from class drcl.DrclObj
clone, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TrafficShaper

public TrafficShaper()
Method Detail

adjust

protected abstract double adjust(double now_,
                                 int size_)
Returns the time adjustment (relative to the current time now_) for outputing the packet. This is the main method a subclass must override to regulate the incoming packets. The current time passed to this method is maintained relatively to the time when this component starts.

Parameters:
now_ - current time, relative to the start time of the shaper.
size_ - the packet size.

reset

public void reset()

duplicate

public void duplicate(java.lang.Object source_)
Description copied from class: DrclObj
opies the content of the source_ object to this object. he subclass must implement this method to realize DrclObj.clone().

Specified by:
duplicate in interface ObjectDuplicable
Overrides:
duplicate in class DrclObj

info

public java.lang.String info(java.lang.String prefix_)
Prints out the content of this traffic shaper instance. This class prints out the associated traffic model and the buffer. A subclass only needs to call super.info(prefix_) and then supply the content of the parameters defined in the subclass.

Parameters:
prefix_ - prefix_ that should be prepended at each line.

adjust

public final double adjust(Packet p_,
                           double now_)
Returns the time adjustment (relative to the current time now_) for outputing the packet.

Returns:
a negative value if the caller should drop the packet.

dequeue

public Packet dequeue()
Releases and returns the first packet being held in the buffer.


getTrafficModel

public abstract TrafficModel getTrafficModel()
Returns the associated traffic model.


setTrafficModel

public abstract void setTrafficModel(TrafficModel traffic_)
Sets the associated traffic model.


setBufferSize

public void setBufferSize(int size_)
Sets the (maximum) buffer size of this traffic shaper (byte).


getBufferSize

public int getBufferSize()
Returns the (maximum) buffer size of this traffic shaper (byte).


getBufferLength

public int getBufferLength()
Returns the current buffer length of this traffic shaper (# of packets).


nextOutputTime

public double nextOutputTime()
Returns the output time of next packet.


getAvailableBufferSize

public int getAvailableBufferSize()
Returns the available buffer size of this traffic shaper (byte).


J-Sim v1.2.1-p7 API

Copyright © 1998-2003 Distributed Real-time Computing Lab (DRCL). All Rights Reserved.     ~ To J-Sim Home ~