[LARTC] Unable to shape with mldonkey

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying (without many success) to optimize my DSL connection. My
principal interest is allowing me to connect from an external machine
with ssh and vnc thru ssh. I also want to allow 3 internal computers to
connect from 192.168.0.2-4 and browse the web, etc.

However, once mldonkey is started all the connections seem to go to a
crawl. This is my preliminary script, modified from wondershaper and
some mldonkey-specific script:



 IPTCMD="iptables -A WSHAPER -t mangle -p"

      tc disc del dev $DEV root 2> /dev/null > /dev/null
      tc disc del dev $DEV ingress 2> /dev/null > /dev/null
      iptables -t mangle -D POSTROUTING -o $DEV -j WSHAPER 2> /dev/null
\
         > /dev/null

      ip link set dev $DEV qlen $QLEN
      tc qdisc add dev $DEV root handle 1: htb r2q $RQ default 13

      tc class add dev $DEV parent 1: classid 1:1 htb rate
$[$UPLINK-2]kbit \
            ceil $[$UPLINK-2]kbit burst ${BURST}k
      tc class add dev $DEV parent 1:1 classid 1:10 htb rate \
            $[(($UPLINK-2)* 5)/100]kbit ceil $[$UPLINK-2]kbit prio 0
      tc class add dev $DEV parent 1:1 classid 1:11 htb rate \
            $[(($UPLINK-2)*40)/100]kbit ceil $[$UPLINK-2]kbit prio 1
      tc class add dev $DEV parent 1:1 classid 1:12 htb rate \
            $[(($UPLINK-2)*50)/100]kbit ceil $[$UPLINK-2]kbit prio 2
      tc class add dev $DEV parent 1:1 classid 1:13 htb rate \
            $[(($UPLINK-2)* 5)/100]kbit ceil $[$UPLINK-2]kbit prio 3

      tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
      tc qdisc add dev $DEV parent 1:11 handle 11: sfq perturb 10
      tc qdisc add dev $DEV parent 1:12 handle 12: sfq perturb 10
      tc qdisc add dev $DEV parent 1:13 handle 13: sfq perturb 10

      tc filter add dev $DEV parent 1:0 prio 0 protocol ip handle 10 \
         fw flowid 1:10
      tc filter add dev $DEV parent 1:0 prio 1 protocol ip handle 11 \
         fw flowid 1:11
      tc filter add dev $DEV parent 1:0 prio 2 protocol ip handle 12 \
         fw flowid 1:12
      tc filter add dev $DEV parent 1:0 prio 3 protocol ip handle 13 \
         fw flowid 1:13

     iptables -t mangle -N WSHAPER
     iptables -t mangle -I POSTROUTING -o $DEV -j WSHAPER

     # Class 10
     $IPTCMD tcp -m length --length :64 -j MARK --set-mark 10   ## ACKs
     # Class 11
     $IPTCMD tcp --dport ssh -j MARK --set-mark 11              ## SSH
     $IPTCMD tcp --sport ssh -j MARK --set-mark 11
     $IPTCMD icmp -j MARK --set-mark 11                         ## ICMP
     $IPTCMD udp --dport domain -j MARK --set-mark 11           ## DNS
     $IPTCMD all --source 192.168.0.2 -j MARK --set-mark 11     ##
linuxclient
     $IPTCMD all --destination 192.168.0.2 -j MARK --set-mark 11
     $IPTCMD all --source 192.168.0.3 -j MARK --set-mark 11     ##
linuxlaptop
     $IPTCMD all --destination 192.168.0.3 -j MARK --set-mark 11
     $IPTCMD all --source 192.168.0.4 -j MARK --set-mark 11     ##
compaqlaptop
     $IPTCMD all --destination 192.168.0.4 -j MARK --set-mark 11

     # Class 12
     for PORTPROTODEST in $CLASS12 ; do
        PORT=`echo $PORTPROTODEST | awk -F/ '{print $1}'`
        PROTO=`echo $PORTPROTODEST | awk -F/ '{print $2}'`
        DEST=`echo $PORTPROTODEST | awk -F/ '{print $3}'`

       if [ "$PROTO" = "both" ]; then
           if [ "$DEST" = "both" ]; then
              $IPTCMD tcp --dport $PORT -j MARK --set-mark 12
              $IPTCMD udp --sport $PORT -j MARK --set-mark 12
              $IPTCMD tcp --sport $PORT -j MARK --set-mark 12
              $IPTCMD udp --dport $PORT -j MARK --set-mark 12
           else
              $IPTCMD tcp --$DEST $PORT -j MARK --set-mark 12
              $IPTCMD udp --$DEST $PORT -j MARK --set-mark 12
           fi
        else
           if [ "$DEST" = "both" ]; then
              $IPTCMD $PROTO --dport $PORT -j MARK --set-mark 12
              $IPTCMD $PROTO --sport $PORT -j MARK --set-mark 12
           else
              $IPTCMD $PROTO --$DEST $PORT -j MARK --set-mark 12
           fi
        fi
      done

      # Class 13 default
      $IPTCMD udp --sport 4660:4670 -j MARK --set-mark 13
      $IPTCMD udp --dport 4660:4670 -j MARK --set-mark 13
      $IPTCMD udp --dport 4242 -j MARK --set-mark 13
      
      tc qdisc add dev $DEV handle ffff: ingress

      tc filter add dev $DEV parent ffff: protocol ip prio 4 u32 match
ip src \
         0.0.0.0/0 police rate $[${DOWNLINK}-2]kbit burst 10k drop
flowid :1

What do you think? :-(. TIA.




[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux