Home | History | Annotate | Download | only in examples
      1 #! /bin/sh
      2 
      3 TC=/home/root/tc
      4 IP=/home/root/ip
      5 DEVICE=eth1
      6 BANDWIDTH="bandwidth 10Mbit"
      7 
      8 # Attach CBQ on $DEVICE. It will have handle 1:.
      9 #   $BANDWIDTH is real $DEVICE bandwidth (10Mbit).
     10 #   avpkt is average packet size.
     11 #   mpu is minimal packet size.
     12 
     13 $TC qdisc add dev $DEVICE  root  handle 1:  cbq \
     14 $BANDWIDTH avpkt 1000 mpu 64
     15 
     16 # Create root class with classid 1:1. This step is not necessary.
     17 #   bandwidth is the same as on CBQ itself.
     18 #   rate == all the bandwidth
     19 #   allot is MTU + MAC header
     20 #   maxburst measure allowed class burstiness (please,read S.Floyd and VJ papers)
     21 #   est 1sec 8sec means, that kernel will evaluate average rate
     22 #                 on this class with period 1sec and time constant 8sec.
     23 #                 This rate is viewed with "tc -s class ls dev $DEVICE"
     24 
     25 $TC class add dev $DEVICE parent 1:0 classid :1 est 1sec 8sec cbq \
     26 $BANDWIDTH rate 10Mbit allot 1514 maxburst 50 avpkt 1000
     27 
     28 # Bulk.
     29 #    New parameters are: 
     30 #    weight, which is set to be proportional to
     31 #            "rate". It is not necessary, weight=1 will work as well.
     32 #    defmap and split say that best effort ttraffic, not classfied
     33 #            by another means will fall to this class.
     34 
     35 $TC class add dev $DEVICE parent 1:1 classid :2 est 1sec 8sec cbq \
     36 $BANDWIDTH rate 4Mbit allot 1514 weight 500Kbit \
     37 prio 6 maxburst 50 avpkt 1000 split 1:0 defmap ff3d
     38 
     39 # OPTIONAL.
     40 # Attach "sfq" qdisc to this class, quantum is MTU, perturb
     41 # gives period of hash function perturbation in seconds.
     42 #
     43 $TC qdisc add dev $DEVICE parent 1:2 sfq quantum 1514b perturb 15
     44 
     45 # Interactive-burst class
     46 
     47 $TC class add dev $DEVICE parent 1:1 classid :3 est 2sec 16sec cbq \
     48 $BANDWIDTH rate 1Mbit allot 1514 weight 100Kbit \
     49 prio 2 maxburst 100 avpkt 1000 split 1:0 defmap c0
     50 
     51 $TC qdisc add dev $DEVICE parent 1:3 sfq quantum 1514b perturb 15
     52 
     53 # Background.
     54 
     55 $TC class add dev $DEVICE parent 1:1 classid :4 est 1sec 8sec cbq \
     56   $BANDWIDTH rate 100Kbit allot 1514 weight 10Mbit \
     57   prio 7 maxburst 10 avpkt 1000 split 1:0 defmap 2
     58 
     59 $TC qdisc add dev $DEVICE parent 1:4 sfq quantum 1514b perturb 15
     60 
     61 # Realtime class for RSVP
     62 
     63 $TC class add dev $DEVICE parent 1:1 classid 1:7FFE cbq \
     64 rate 5Mbit $BANDWIDTH allot 1514b avpkt 1000 \
     65 maxburst 20
     66 
     67 # Reclassified realtime traffic
     68 #
     69 # New element: split is not 1:0, but 1:7FFE. It means,
     70 #     that only real-time packets, which violated policing filters
     71 #     or exceeded reshaping buffers will fall to it.
     72 
     73 $TC class add dev $DEVICE parent 1:7FFE classid 1:7FFF  est 4sec 32sec cbq \
     74 rate 1Mbit $BANDWIDTH allot 1514b avpkt 1000 weight 10Kbit \
     75 prio 6 maxburst 10 split 1:7FFE defmap ffff
     76 
     77