#!/bin/sh

tc qdisc del dev vlan0891 root

tc qdisc add dev vlan0891 root handle 11:0 hfsc default 8192

tc class add dev vlan0891 parent 11:0 classid 11:1 hfsc ls m2 2560kbps ul m2 2560kbps

tc class add dev vlan0891 parent 11:1 classid 11:3 hfsc ls m2 2560kbps ul m2 2560kbps 

tc class add dev vlan0891 parent 11:1 classid 11:8192 hfsc ls m2 1kbit ul m2 1kbit

tc qdisc add dev vlan0891 parent 11:8192 sfq quantum 1500 perturb 120
tc qdisc add dev vlan0891 parent 11:3 sfq quantum 1500 perturb 120
#####################################################################################################



tc filter add dev vlan0891 parent 11:0 prio 1 protocol ip u32
tc filter add dev vlan0891 parent 11:0 prio 1 handle 1: protocol ip u32 divisor 256

tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.48.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.49.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.50.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.51.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.52.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.53.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.54.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.55.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.56.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.57.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.58.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.59.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.60.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.61.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.62.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.63.0/24 hashkey mask 0x000000ff at 12 link 1:
tc filter add dev vlan0891 protocol ip parent 11:0 prio 2 u32 ht 800:: match ip src xxx.xxx.64.0/24 hashkey mask 0x000000ff at 12 link 1:


i=48;
flow_id=4;

while [ $i -le 64 ]; do
	j=0;
	while [ $j -le 255 ]; do
		hex=`echo "obase=16; $j" |bc`;
		tc filter add dev vlan0891 protocol ip parent 11:0 prio 4 u32 ht 1:$hex: match ip src xxx.xxx.$i.$j flowid 11:$flow_id
		tc class add dev vlan0891 parent 11:3 classid 11:$flow_id hfsc rt m2 1kbit ls d 5ms m2 2kbit ul m2 256kbit 
		tc qdisc add dev vlan0891 parent 11:$flow_id esfq quantum 1500 perturb 60 hash dst limit 16

		j=$((j+1));
		flow_id=$((flow_id+1));
	done

	i=$((i+1));
done

