#!/bin/sh
RATE_TOT=139        # In KiloBytes/Sec
RATE1=75
RATE1=`expr $RATE_TOT \* $RATE1`
RATE1=`expr $RATE1 / 100`
RATE2=`expr $RATE_TOT - $RATE1`

RATE_TOT=$RATE_TOT`echo kbps`
RATE1=$RATE1`echo kbps`
RATE2=$RATE2`echo kbps`

echo rate_tot: $RATE_TOT
echo rate1: $RATE1
echo rate1: $RATE2

PRIO1="prio 3"
PRIO2="prio 3"
 
IP=kriek
DEV="dev eth0"
OPTION="allot 1514 maxburst 20 avpkt 1000"

tc qdisc del $DEV root
tc qdisc         add $DEV root handle 10: cbq bandwidth 10mbit avpkt 1000

  tc class       add $DEV parent 10:0  classid 10:2   cbq bandwidth 10mbit  rate 400Kbit $OPTION prio 3 bounded isolated
    tc class     add $DEV parent 10:2  classid 10:10  cbq bandwidth 400Kbit rate 200Kbit $OPTION $PRIO1 bounded
      tc qdisc   add $DEV parent 10:10 handle  20:    cbq bandwidth 200Kbit allot 1514 avpkt 1000
        tc class add $DEV parent 20:   classid 20:20  cbq bandwidth 200Kbit rate 100Kbit $OPTION $PRIO1
    tc class     add $DEV parent 10:2  classid 10:20  cbq bandwidth 400Kbit rate 200Kbit $OPTION $PRIO1
      tc class   add $DEV parent 10:20 classid 10:200 cbq bandwidth 200Kbit rate 100Kbit $OPTION $PRIO2
        tc qdisc add $DEV parent 10:200 sfq
  tc class       add $DEV parent 10:0  classid 10:4   cbq bandwidth 10mbit rate  600Kbit $OPTION prio 3 bounded
    tc qdisc     add $DEV parent 10:4  tbf rate 600Kbit buffer 20Kb/8 limit 15Kb 
 
tc filter add $DEV parent 10: protocol ip prio 3 handle 1 fw classid 10:2
tc filter add $DEV parent 10: protocol ip prio 3 handle 2 fw classid 10:10
tc filter add $DEV parent 10:2 protocol ip prio 3 handle 2 fw classid 10:20
tc filter add $DEV parent 20: protocol ip prio 3 handle 2 fw classid 20:20

