Class SyntheticREDQueue

java.lang.Object
net.i2p.router.transport.SyntheticREDQueue
All Implemented Interfaces:
BandwidthEstimator

class SyntheticREDQueue extends Object implements BandwidthEstimator
A "synthetic" queue in that it doesn't actually queue anything. Actual queueing is assumed to be "dowstream" of this. Maintains an average estimated "queue size" assuming a constant output rate declared in the constructor. The queue size is measured in bytes. With offer(), will return true for "accepted" or false for "dropped", based on the RED algorithm which uses the current average queue size and the offered data size to calculate a drop probability. Bandwidth is not directly used in the RED algorithm, except to synthetically calculate an average queue size assuming the queue is being drained precisely at that rate, byte-by-byte (not per-packet). addSample() unconditionally accepts the packet. Also maintains a Westwood+ bandwidth estimator. The bandwidth and queue size estimates are only updated if the packet is "accepted". The average queue size is calculated in the same manner as the bandwidth, with an update every WESTWOOD_RTT_MIN ms. Both estimators use a first stage anti-aliasing low pass filter based on RTT, and the time-varying Westwood filter based on inter-arrival time. Ref: Random Early Detection Gateways for Congestion Avoidance Sally Floyd and Van Jacobson Ref: TCP Westwood: End-to-End Congestion Control for Wired/Wireless Networks Casetti et al (Westwood) Ref: End-to-End Bandwidth Estimation for Congestion Control in Packet Networks Grieco and Mascolo (Westwood+) Adapted from: Linux kernel tcp_westwood.c (GPLv2)
Since:
0.9.50 adapted from streaming
  • Constructor Details

    • SyntheticREDQueue

      SyntheticREDQueue(I2PAppContext ctx, int bwBps)
      Default thresholds. Min: 100 ms of traffic; max: 500 ms.
      Parameters:
      bwBps - the output rate of the queue in Bps
    • SyntheticREDQueue

      SyntheticREDQueue(I2PAppContext ctx, int bwBps, int minThB, int maxThB)
      Specified queue size thresholds. offer() drops a 1024 byte packet at 2% probability just lower than maxThKB, and at 100% probability higher than maxThKB.
      Parameters:
      bwBps - the output rate of the queue in Bps
      minThB - the minimum queue size to start dropping in Bytes
      maxThB - the queue size to drop everything in Bytes
  • Method Details

    • getMaxBandwidth

      public int getMaxBandwidth()
      Nominal bandwidth limit in bytes per second, as passed to the constructor.
    • addSample

      public void addSample(int size)
      Unconditional, never drop. The queue size and bandwidth estimates will be updated.
      Specified by:
      addSample in interface BandwidthEstimator
      Parameters:
      size - how many bytes or packets were acked with this ack
    • offer

      public boolean offer(int size, float factor)
      Should we drop this packet? If accepted, the queue size and bandwidth estimates will be updated.
      Parameters:
      size - how many bytes to be offered
      factor - how to adjust the size for the drop probability calculation, or 1.0 for standard probability. 0 to prevent dropping. Does not affect bandwidth calculations.
      Returns:
      true for accepted, false for drop
    • getBandwidthEstimate

      public float getBandwidthEstimate()
      Specified by:
      getBandwidthEstimate in interface BandwidthEstimator
      Returns:
      the current bandwidth estimate in bytes/ms.
    • getQueueSizeEstimate

      public float getQueueSizeEstimate()
      Returns:
      the current queue size estimate in bytes.
    • toString

      public String toString()
      Overrides:
      toString in class Object