2 # Sets HTB/Netem parameters for the server interfaces. netroot script
3 # must be run before this.
9 if [ ! $SWFTPORT ]; then
10 echo No swift port defined!
14 if [ ! $EMLOSS ]; then
18 if [ ! $EMDELAY ]; then
26 if [ ! $EMJTTR ]; then
31 if [ ! $EMLOSS_IN ]; then
35 if [ ! $EMDELAY_IN ]; then
39 # zero delay in lo may affect htb performance accuracy (?)
40 if [ $EMDELAY_IN == 0ms ]; then
43 EMDELAY_LO_IN=$EMDELAY_IN
46 if [ ! $EMBW_IN ]; then
50 if [ ! $EMJTTR_IN ]; then
55 if [ ! $EMLOSS_OUT ]; then
59 if [ ! $EMDELAY_OUT ]; then
63 if [ ! $EMBW_OUT ]; then
67 if [ ! $EMJTTR_OUT ]; then
73 CLASSID=$(($SWFTPORT - 9900))
77 echo adding htb class 1:$CLASSID with rate $EMBW_IN to ifb0
78 $TC class add dev ifb0 parent 1: classid 1:$CLASSID htb rate $EMBW_IN || exit 2
79 echo adding filter for destination port $SWFTPORT for to ifb0
80 $TC filter add dev ifb0 protocol ip prio 1 handle ::$CLASSID u32 \
81 match ip dport $SWFTPORT 0xffff flowid 1:$CLASSID || exit 3
82 echo adding downlink netem handle $HANDLEID for $EMDELAY_IN, $EMLOSS_IN to ifb0
83 $TC qdisc add dev ifb0 parent 1:$CLASSID handle $HANDLEID \
84 netem delay $EMDELAY_IN $EMJTTR_IN 25% loss $EMLOSS_IN || exit 4
86 echo adding htb class 1:$CLASSID with rate $EMBW_IN to lo
87 $TC class add dev lo parent 1: classid 1:$CLASSID htb rate $EMBW_IN || exit 5
88 echo adding filter for destination port $SWFTPORT for to lo
89 $TC filter add dev lo protocol ip prio 1 handle ::$CLASSID u32 \
90 match ip dport $SWFTPORT 0xffff flowid 1:$CLASSID || exit 6
91 echo adding downlink netem handle $HANDLEID for $EMDELAY_LO_IN, $EMLOSS_IN to lo
92 $TC qdisc add dev lo parent 1:$CLASSID handle $HANDLEID \
93 netem delay $EMDELAY_LO_IN $EMJTTR_IN 25% loss $EMLOSS_IN || exit 7
96 echo adding htb class 1:$CLASSID with rate $EMBW_OUT to $EMIF
97 $TC class add dev $EMIF parent 1: classid 1:$CLASSID htb rate $EMBW_OUT || exit 8
98 echo adding filter for source port $SWFTPORT for to $EMIF
99 $TC filter add dev $EMIF protocol ip prio 1 handle ::$CLASSID u32 \
100 match ip sport $SWFTPORT 0xffff flowid 1:$CLASSID || exit 9
101 echo adding uplink netem handle $HANDLEID for $EMDELAY_OUT, $EMLOSS_OUT to $EMIF
102 $TC qdisc add dev $EMIF parent 1:$CLASSID handle $HANDLEID \
103 netem delay $EMDELAY_OUT $EMJTTR_OUT 25% loss $EMLOSS_OUT || exit 10