#==================================================================
# Queueing algorithms -- Shamelessly stolen from Stephen Mller
#--------------------

# RED: Random Early Drop
#
#      Short description:
#      ------------------
#
#        When a new packet arrives we calculate the average queue length:
#
#        avg = (1-W)*avg + W*current_queue_len,
#
#        W is the filter time constant (choosen as 2^(-Wlog)), it controls
#        the inertia of the algorithm. To allow larger bursts, W should be
#        decreased.
#
#        if (avg > th_max) -> packet marked (dropped).
#        if (avg < th_min) -> packet passes.
#        if (th_min < avg < th_max) we calculate probability:
#
#        Pb = max_P * (avg - th_min)/(th_max-th_min)
#
#        and mark (drop) packet with this probability.
#        Pb changes from 0 (at avg==th_min) to max_P (avg==th_max).
#        max_P should be small (not 1), usually 0.01..0.02 is good value.
#
#        max_P is chosen as a number, so that max_P/(th_max-th_min)
#        is a negative power of two in order arithmetics to contain
#        only shifts
#
#      In order to use RED, you must decide on three parameters: Min, Max, and burst.
#      Min sets the minimum queue size in bytes before dropping will begin,
#      Max is a soft maximum that the algorithm will attempt to stay under,
#      and burst sets the maximum number of packets that can 'burst through'.
#      RED_min: Link multiplied with max. acceptabe throughput (queue length in bytes)
#      RED_max: twice min, on slow links up to four times min (queue length in bytes)
#      RED_burst: (2*min+max)/(3*avpkt) should be efficient
#      RED_limit: queue size where RED becomes tail-drop, eight times max
#      RED_avpkt: average packet size

RED_min=2500
RED_max=7500
RED_burst=4
RED_limit=60000
RED_avpkt=1000


# SFQ: Stocastic Fair Queueing
#
#      ADVANTAGE:
#        - It is very cheap. Both CPU and memory requirements are minimal.
#
#      DRAWBACKS:
#        - "Stochastic" -> It is not 100% fair.
#        When hash collisions occur, several flows are considered as one.
#
#        - "Round-robin" -> It introduces larger delays than virtual clock
#        based schemes, and should not be used for isolating interactive
#        traffic from non-interactive. It means, that this scheduler
#        should be used as leaf of CBQ or P3, which put interactive traffic
#        to higher priority band.
#
#      We still need true WFQ for top level CSZ, but using WFQ
#      for the best effort traffic is absolutely pointless:
#      SFQ is superior for this purpose.
#
#      IMPLEMENTATION:
#        This implementation limits maximal queue length to 128;
#        maximal mtu to 2^15-1; number of hash buckets to 1024.
#        The only goal of this restrictions was that all data
#        fit into one 4K page :-). Struct sfq_sched_data is
#        organized in anti-cache manner: all the data for a bucket
#        are scattered over different locations. This is not good,
#        but it allowed me to put it into 4K.
#
#      quantum: bytes
#      perturb: seconds

SFQ_quantum="1514b"
SFQ_perturb="15"


# TBF: Simple Token Bucket Filter
#
#      Description.
#        The TBF implementation consists of a buffer (bucket),
#        constatly filled by some virtual pieces of information
#        called tokens, at specific rate (token rate). The most
#        important parameter of the bucket is its size, that is
#        number of tokens it can store.
#
#        Each arriving token lets one incoming data packet of
#        out the queue and is then deleted from the bucket.
#        Associating this algorithm with the two flows --
#        token and data, gives us three possible scenarios:
#
#        -The data arrives into TBF at rate equal the rate of
#         incoming tokens. In this case each incoming packet
#         has its matching token and passes the queue without delay.
#        -The data arrives into TBF at rate smaller than the token
#         rate. Only some tokens are deleted at output of each
#         data packet sent out the queue, so the tokens accumulate,
#         up to the bucket size. The saved tokens can be then used
#         to send data over the token rate, if short data burst occurs.
#        -The data arrives into TBF at rate bigger than the token
#         rate. In this case filter overrun occurs -- incoming data
#         can be only sent out without loss until all accumulated
#         tokens are used. After that, overlimit packets are dropped.
#
#        A data flow obeys TBF with rate R and depth B, if for any
#        time interval t_i...t_f the number of transmitted bits
#        does not exceed B + R*(t_f-t_i).
#
#        Packetized version of this definition:
#        The sequence of packets of sizes s_i served at moments t_i
#        obeys TBF, if for any i<=k:
#
#        s_i+....+s_k <= B + R*(t_k - t_i)
#
#      Algorithm.
#        Let N(t_i) be B/R initially and N(t) grow continuously with time as:
#
#        N(t+delta) = min{B/R, N(t) + delta}
#
#        If the first packet in queue has length S, it may be
#        transmited only at the time t_* when S/R <= N(t_*),
#        and in this case N(t) jumps:
#
#        N(t_* + 0) = N(t_* - 0) - S/R.
#
#
#        Actually, QoS requires two TBF to be applied to a data stream.
#        One of them controls steady state burst size, another
#        one with rate P (peak rate) and depth M (equal to link MTU)
#        limits bursts at a smaller time scale.
#
#        It is easy to see that P>R, and B>M. If P is infinity, this double
#        TBF is equivalent to a single one.
#
#        When TBF works in reshaping mode, latency is estimated as:
#
#        lat = max ((L-B)/R, (L-M)/P)
#
#      NOTES.
#        If TBF throttles, it starts a watchdog timer, which will wake it up
#        when it is ready to transmit.
#        Note that the minimal timer resolution is 1/HZ.
#        If no new packets arrive during this period,
#        or if the device is not awaken by EOI for some previous packet,
#        TBF can stop its activity for 1/HZ.
#
#
#        This means, that with depth B, the maximal rate is
#
#        R_crit = B*HZ
#
#        F.e. for 10Mbit ethernet and HZ=100 the minimal allowed B is ~10Kbytes.
#
#        Note that the peak rate TBF is much more tough: with MTU 1500
#        P_crit = 150Kbytes/sec. So, if you need greater peak
#        rates, use alpha with HZ=1000 :-)

TBF_limit=""		# in Bytes
TBF_burst=""		# in Bytes
TBF_rate=""		# in KBPS
TBF_mtu="1500"		# in Bytes
TBF_peakrate=""		# in KBPS
TBF_latency=""		# Time
