Re: [LARTC] Tcng and wondershaper

Linux Advanced Routing and Traffic Control

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

 



> Wouter,
> 
>  : Has anybody converted the wondershaper to tcng? I'm very interessed in
>  : it and would like to see how it's done.
> 
> I would love to do this--I simply haven't made the time to do so yet.  I
> would imagine somebody will beat me to it, but if not, I'll have my
> variant available at some point in the future, and I'll remember to post a
> note here to let people know it's available.
> 

Here is a first  untested draft of wshaper_tcng.htb:
- Jacob

#!/bin/bash
# Wonder Shaper
# please read the README before filling out these values
#
# Set the following values to somewhat less than your actual download
# and uplink speed. 


#Set the device that is to be shaped.

DEV=ppp0

# Set  uplink, downlink and worse fate claasifier. Search for downlink, uplink and  worse_fate.

#Now remove the following two lines :-)
echo Please read the documentation in 'README' first
exit

if [ "$1" = "status" ]
then
        tc -s qdisc ls dev $DEV
        tc -s class ls dev $DEV
        exit
fi

# clean existing down- and uplink qdiscs, hide errors
tc qdisc del dev $DEV root    2> /dev/null > /dev/null
tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null

if [ "$1" = "stop" ]
then
        exit
fi

tcc -Xp,-DDEVICE=$DEV <<EOF | /bin/bash -v

// Set the following values to somewhat less than your actual download  and uplink speed. 

\$downlink = 800 kbps;
\$uplink   = 220 kbps;

// some traffic however suffers a worse fate
\$worse_fate = 1;
/*
  \$worse_fate =
  (ip_src != 1.1.1.1 && ip_src:24 == 1.1.1.0 && ip_dst:24 == 2.2.2.0 &&
  tcp_sport == PORT_SSH) ||
  ip_tos != 0x10 || tcp_dport >= 2000;

!!!!!!!  Do NOT use ip_src == 1.1.1.0/24 or ip_src:24 == 1.1.1.1   !!!!!!!

*/

#define xstr(s) str(s)
#define str(s) #s
dev xstr(DEVICE) {
     ingress {
	\$all_pol = SLB(cir \$downlink, cbs 10 kB);
	class (<>)  if SLB_ok(\$all_pol);
        drop if 1;
     }
     egress {
          class (<\$interactive>) if 

// ICMP (ip protocol 1) in the interactive  so we
// can do measurements & impress our friends:
	ip_proto == IPPROTO_ICMP || 
// TOS Minimum Delay (ssh, NOT scp) :
	ip_tos == 0x10 || 
// To speed up downloads while an upload is going on, put ACK packets in
//  the interactive class:
			(tcp_ACK && ip_len < 64);
// some traffic however suffers a worse fate
          class (<\$worse_fate_class>) if \$worse_fate;

// bulk & default class
          class (<\$bulk>) if 1;

          htb () {
               class (rate \$uplink, burst 6kB) {
                    \$interactive = class (prio 1 ,rate \$uplink)   {sfq (perturb 10 sec);};
                    \$bulk  = class (prio 2, rate 0.9 *\$uplink) {sfq(perturb 10 sec);};
                    \$worse_fate_class  = class (prio 3, rate 0.8 *\$uplink) {sfq(perturb 10 sec);};
               }
          }
     }
}
EOF


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