diff options
Diffstat (limited to 'lib/Vyatta/Qos/Util.pm')
-rw-r--r-- | lib/Vyatta/Qos/Util.pm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Vyatta/Qos/Util.pm b/lib/Vyatta/Qos/Util.pm index 3aefbd8..72b4963 100644 --- a/lib/Vyatta/Qos/Util.pm +++ b/lib/Vyatta/Qos/Util.pm @@ -319,4 +319,23 @@ sub ethtoolRate { return $rate; } +# Compute parameters for RED algorithim based on bandwidth and latency +# +# 0.01 * Bandwidth Share * Desired Latency * Network Bandwidth +# Maximum Threshold = ------------------------------------------------------------------- +# 8 bits/byte* 1000 ms/sec +# +# Minimum Threshold = 1/2 * Maximum Threshold +# Avpkt = Average Packet Length +# Burst = ( 2 * MinThreshold + MaxThreshold) / ( 3 * Avpkt ) +# Limit = 4 * MaxThreshold +sub RedParam { + my ($bandwidth, $latency, $avgpkt) = @_; + my $qmax = ($bandwidth * $latency) / 8000; + my $qmin = $qmax / 2; + my $burst = ( 2 * $qmin + $qmax ) / ( 3 * $avgpkt ); + + return ($qmin, $qmax, $burst); +} + 1; |