merge qos-scripts changes from kamikaze in whiterussian
authorFelix Fietkau <nbd@openwrt.org>
Sat, 30 Jun 2007 02:37:45 +0000 (02:37 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 30 Jun 2007 02:37:45 +0000 (02:37 +0000)
SVN-Revision: 7783

openwrt/package/qos-scripts/Makefile
openwrt/package/qos-scripts/files/etc/config/qos
openwrt/package/qos-scripts/files/usr/lib/qos/generate.sh
openwrt/package/qos-scripts/files/usr/lib/qos/tcrules.awk

index ec5a052c5ed52fa41e640b22b5cc24e2f18e2512..625fb14634de80ff69e02254e2dc76554ffc8e84 100644 (file)
@@ -3,8 +3,8 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME := qos-scripts
-PKG_VERSION := 1.1.0
-PKG_RELEASE := 1
+PKG_VERSION := 1.2.0
+PKG_RELEASE := 0
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
index 7d3501cc6edc208dc8b166aefc6b887e85b826fe..51959b5304d7573b4aa286794d36940376bf44ea 100644 (file)
@@ -4,6 +4,7 @@
 config interface wan
        option classgroup  "Default"
        option enabled      1
+       option overhead     1
        option upload       128
        option download     1024
 
index 0e750bbe747415f2a9951093e7ea6e4523c93eff..fe59d436321f3a8cd41282beb39fde2c92e325e7 100755 (executable)
@@ -95,6 +95,14 @@ parse_matching_rule() {
                                esac
                                ports=1
                        ;;
+                       *:direction)
+                               value="$(echo "$value" | sed -e 's,-,:,g')"
+                               if [ "$value" = "out" ]; then
+                                       append "$var" "-o $device"
+                               elif [ "$value" = "in" ]; then
+                                       append "$var" "-i $device"
+                               fi
+                       ;;
                        1:pktsize)
                                value="$(echo "$value" | sed -e 's,-,:,g')"
                                add_insmod ipt_length
@@ -147,15 +155,13 @@ config_cb() {
        config_get TYPE "$CONFIG_SECTION" TYPE
        case "$TYPE" in
                interface)
-                       config_get enabled "$CONFIG_SECTION" enabled
-                       config_get download "$CONFIG_SECTION" download
+                       config_get_bool enabled "$CONFIG_SECTION" enabled 1
+                       [ 1 -eq "$enabled" ] || return 0
                        config_get classgroup "$CONFIG_SECTION" classgroup
                        config_set "$CONFIG_SECTION" imqdev "$C"
-                       [ -z "$enabled" -o "$(($enabled))" -eq 0 ] || {
-                               C=$(($C+1))
-                               INTERFACES="$INTERFACES $CONFIG_SECTION"
-                               config_set "$classgroup" enabled 1
-                       }
+                       C=$(($C+1))
+                       append INTERFACES "$CONFIG_SECTION"
+                       config_set "$classgroup" enabled 1
                        config_get device "$CONFIG_SECTION" device
                        [ -z "$device" ] && device="$(nvram get ${CONFIG_SECTION}_ifname)"
                        config_set "$CONFIG_SECTION" device "${device:-eth0}"
@@ -216,19 +222,23 @@ start_interface() {
        local iface="$1"
        local num_imq="$2"
        config_get device "$iface" device
-       config_get enabled "$iface" enabled
-       [ -z "$device" -o -z "$enabled" ] && exit
+       config_get_bool enabled "$iface" enabled 1
+       [ -z "$device" -o 1 -ne "$enabled" ] && {
+               echo "Interface '$iface' not found or disabled." >&2
+               return 1 
+       }
        config_get upload "$iface" upload
        config_get halfduplex "$iface" halfduplex
        config_get download "$iface" download
        config_get classgroup "$iface" classgroup
+       config_get_bool overhead "$iface" overhead 0
        
        download="${download:-${halfduplex:+$upload}}"
        enum_classes "$classgroup"
        for dir in up${halfduplex} ${download:+down}; do
                case "$dir" in
                        up)
-                               upload=$(($upload * 98 / 100 - (32 * 128 / $upload)))
+                               [ "$overhead" = 1 ] && upload=$(($upload * 98 / 100 - (15 * 128 / $upload)))
                                dev="$device"
                                rate="$upload"
                                dl_mode=""
@@ -237,7 +247,7 @@ start_interface() {
                        down)
                                add_insmod imq numdevs="$num_imq"
                                config_get imqdev "$iface" imqdev
-                               download=$(($download * 98 / 100 - (100 * 1024 / $download)))
+                               [ "$overhead" = 1 ] && download=$(($download * 98 / 100 - (80 * 1024 / $download)))
                                dev="imq$imqdev"
                                rate="$download"
                                dl_mode=1
@@ -332,6 +342,7 @@ start_cg() {
                                append down "iptables -t mangle -A POSTROUTING -o $device -j IMQ --todev $imqdev" "$N"
                        }
                        append down "iptables -t mangle -A PREROUTING -i $device -j ${cg}" "$N"
+                       append down "iptables -t mangle -A POSTROUTING -o $device -j ${cg}" "$N"
                        append down "iptables -t mangle -A PREROUTING -i $device -j IMQ --todev $imqdev" "$N"
                }
        done
index d236b2df93e1528e0f44f409dcf1ae083d6b49e9..7bef85b0d01d42e3bcf6279e4eb1ef2280dd82f0 100644 (file)
@@ -77,20 +77,41 @@ END {
        # leaf qdisc
        avpkt = 1200
        for (i = 1; i <= n; i++) {
-               ql = int((avgrate[i] + linespeed) * 1024 / (8 * pktsize[i]))
                printf "tc qdisc add dev "device" parent 1:"class[i]"0 handle "class[i]"00: "
+
+               # RED parameters - also used to determine the queue length for sfq
+               # calculate min value. for links <= 256 kbit, we use 1500 bytes
+               # use 50 ms queue length as min threshold for faster links
+               # max threshold is fixed to 3*min
+               base_pkt=3000
+               base_rate=256
+               min_lat=50
+               if (maxrate[i] <= base_rate) min = base_pkt
+               else min = int(maxrate[i] * 1024 / 8 * 0.05)
+               max = 3 * min
+               limit = (min + max) * 3
+
                if (rtm1[i] > 0) {
                        # rt class - use sfq
-                       print "sfq perturb 2 limit " ql
+                       print "sfq perturb 2 limit "  limit
                } else {
-                       # non-rt class - use red
-                       min = int(maxrate[i] * 1024 / 8 * 0.05)
-                       if (min < avpkt) min = avpkt
-                       dqb = 8 * min;
-                       max = int(2.1*min)
-                       rburst = int((2*min + max) / (3 * avpkt))
+                       # non-rt class - use RED
+
+                       avpkt = pktsize[i]
+                       # don't use avpkt values less than 500 bytes
+                       if (avpkt < 500) avpkt = 500
+                       # if avpkt is too close to min, scale down avpkt to allow proper bursting
+                       if (avpkt > min * 0.70) avpkt *= 0.70
+
+
+                       # according to http://www.cs.unc.edu/~jeffay/papers/IEEE-ToN-01.pdf a drop
+                       # probability somewhere between 0.1 and 0.2 should be a good tradeoff
+                       # between link utilization and response time (0.1: response; 0.2: utilization)
+                       prob="0.12"
+               
+                       rburst=int((2*min + max) / (3 * avpkt))
                        if (rburst < 2) rburst = 2
-                       print "red min " min " max " max " burst " rburst " avpkt " avpkt " limit " dqb " probability 0.04 ecn"
+                       print "red min " min " max " max " burst " rburst " avpkt " avpkt " limit " limit " probability " prob " ecn"
                }
        }