免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1544 | 回复: 0
打印 上一主题 下一主题

hash filter of tc [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-25 19:41 |只看该作者 |倒序浏览

tc filter add dev imq1 parent 1:0 prio 1 handle 10: protocol ip u32 divisor 256
tc filter add dev imq1 protocol ip parent 1:0 prio 1 u32 ht 800:: match ip src 192.168.1.0/24 hashkey mask 0x000000ff at 12 link 10:
tc filter add dev imq1 parent 1:0 protocol ip prio 2 u32 ht 10:2: match ip src 192.168.1.2/32 flowid 1:2
tc filter add dev imq1 parent 1:0 protocol ip prio 2 u32 ht 10:3: match ip src 192.168.1.3/32 flowid 1:3
tc filter add dev imq1 parent 1:0 protocol ip prio 2 u32 ht 10:4: match ip src 192.168.1.4/32 flowid 1:4
tc filter add dev imq0 parent 1:0 prio 1 handle 100: protocol ip u32 divisor 256
tc filter add dev imq0 protocol ip parent 1:0 prio 1 u32 ht 800:: match ip dst 192.168.1.0/24 hashkey mask 0x000000ff at 16 link 100:
tc filter add dev imq0 parent 1:0 protocol ip prio 2 u32 ht 100:2: match ip dst 192.168.1.2/32 flowid 1:2
tc filter add dev imq0 parent 1:0 protocol ip prio 2 u32 ht 100:3: match ip dst 192.168.1.3/32 flowid 1:3
tc filter add dev imq0 parent 1:0 protocol ip prio 2 u32 ht 100:4: match ip dst 192.168.1.4/32 flowid 1:4
tc class add dev imq1 parent 1:1 classid 1:2 htb rate 2kbps ceil 10kbps prio 2
tc class add dev imq1 parent 1:1 classid 1:3 htb rate 2kbps ceil 10kbps prio 2
tc class add dev imq1 parent 1:1 classid 1:4 htb rate 2kbps ceil 10kbps prio 2
tc class add dev imq0 parent 1:1 classid 1:2 htb rate 10kbps ceil 150kbps prio 2
tc class add dev imq0 parent 1:1 classid 1:3 htb rate 10kbps ceil 150kbps prio 2
tc class add dev imq0 parent 1:1 classid 1:4 htb rate 10kbps ceil 150kbps prio 2
tc filter add dev imq1 parent 1:0 prio 1 handle 10: protocol ip u32 divisor 64
tc filter add dev imq1 protocol ip parent 1:0 prio 1 u32 ht 800:: match ip src 192.168.1.0/26 hashkey mask 0x0000003f at 12 link 10:
tc filter add dev imq0 parent 1:0 prio 1 handle 20: protocol ip u32 divisor 64
tc filter add dev imq0 protocol ip parent 1:0 prio 1 u32 ht 800:: match ip dst 192.168.1.0/26 hashkey mask 0x0000003f at 16 link 20:
i=2
j=2
m=2
n=2
while [ $i -le 63 ]
do
tc filter add dev imq1 parent 1:0 protocol ip prio 2 u32 ht 10:${n}: match ip src 192.168.1.${i}/32 flowid 1:$j
tc filter add dev imq0 parent 1:0 protocol ip prio 2 u32 ht 20:${n}: match ip dst 192.168.1.${i}/32 flowid 1:$j
tc class add dev imq1 parent 1:1 classid 1:$j htb rate 2kbps ceil 8kbps prio 2
tc class add dev imq0 parent 1:1 classid 1:$j htb rate 8kbps ceil 120kbps prio 2
tc qdisc add dev imq1 parent 1:$j handle $j: sfq perturb 12
tc qdisc add dev imq0 parent 1:$j handle $j: sfq perturb 12
i=`expr $i + 1`
m=`expr $m + 1`
j=$(echo $i|awk '{printf "%x\n",$0}')
n=$(echo $m|awk '{printf "%x\n",$0}')
done
tc filter add dev imq1 parent 1:0 prio 1 handle 11: protocol ip u32 divisor 64
tc filter add dev imq1 protocol ip parent 1:0 prio 1 u32 ht 800:: match ip src 192.168.1.64/26 hashkey mask 0x0000003f at 12 link 11:
tc filter add dev imq0 parent 1:0 prio 1 handle 21: protocol ip u32 divisor 64
tc filter add dev imq0 protocol ip parent 1:0 prio 1 u32 ht 800:: match ip dst 192.168.1.64/26 hashkey mask 0x0000003f at 16 link 21:
i=64
j=40
m=0
n=0
while [ $i -le 127 ]
do
tc filter add dev imq1 parent 1:0 protocol ip prio 2 u32 ht 11:${n}: match ip src 192.168.1.${i}/32 flowid 1:$j
tc filter add dev imq0 parent 1:0 protocol ip prio 2 u32 ht 21:${n}: match ip dst 192.168.1.${i}/32 flowid 1:$j
tc class add dev imq1 parent 1:1 classid 1:$j htb rate 2kbps ceil 8kbps prio 2
tc class add dev imq0 parent 1:1 classid 1:$j htb rate 8kbps ceil 120kbps prio 2
tc qdisc add dev imq1 parent 1:$j handle $j: sfq perturb 12
tc qdisc add dev imq0 parent 1:$j handle $j: sfq perturb 12
i=`expr $i + 1`
m=`expr $m + 1`
j=$(echo $i|awk '{printf "%x\n",$0}')
n=$(echo $m|awk '{printf "%x\n",$0}')
done
tc filter add dev imq1 parent 1:0 prio 1 handle 12: protocol ip u32 divisor 64
tc filter add dev imq1 protocol ip parent 1:0 prio 1 u32 ht 800:: match ip src 192.168.1.128/26 hashkey mask 0x0000003f at 12 link 12:
tc filter add dev imq0 parent 1:0 prio 1 handle 22: protocol ip u32 divisor 64
tc filter add dev imq0 protocol ip parent 1:0 prio 1 u32 ht 800:: match ip dst 192.168.1.128/26 hashkey mask 0x0000003f at 16 link 22:
i=128
j=80
m=0
n=0
while [ $i -le 191 ]
do
tc filter add dev imq1 parent 1:0 protocol ip prio 2 u32 ht 12:${n}: match ip src 192.168.1.${i}/32 flowid 1:$j
tc filter add dev imq0 parent 1:0 protocol ip prio 2 u32 ht 22:${n}: match ip dst 192.168.1.${i}/32 flowid 1:$j
tc class add dev imq1 parent 1:1 classid 1:$j htb rate 2kbps ceil 8kbps prio 2
tc class add dev imq0 parent 1:1 classid 1:$j htb rate 8kbps ceil 120kbps prio 2
tc qdisc add dev imq1 parent 1:$j handle $j: sfq perturb 12
tc qdisc add dev imq0 parent 1:$j handle $j: sfq perturb 12
i=`expr $i + 1`
m=`expr $m + 1`
j=$(echo $i|awk '{printf "%x\n",$0}')
n=$(echo $m|awk '{printf "%x\n",$0}')
done
tc filter add dev imq1 parent 1:0 prio 1 handle 13: protocol ip u32 divisor 64
tc filter add dev imq1 protocol ip parent 1:0 prio 1 u32 ht 800:: match ip src 192.168.1.192/26 hashkey mask 0x0000003f at 12 link 13:
tc filter add dev imq0 parent 1:0 prio 1 handle 23: protocol ip u32 divisor 64
tc filter add dev imq0 protocol ip parent 1:0 prio 1 u32 ht 800:: match ip dst 192.168.1.192/26 hashkey mask 0x0000003f at 16 link 23:
i=192
j=c0
m=0
n=0
while [ $i -le 254 ]
do
tc filter add dev imq1 parent 1:0 protocol ip prio 2 u32 ht 13:${n}: match ip src 192.168.1.${i}/32 flowid 1:$j
tc filter add dev imq0 parent 1:0 protocol ip prio 2 u32 ht 23:${n}: match ip dst 192.168.1.${i}/32 flowid 1:$j
tc class add dev imq1 parent 1:1 classid 1:$j htb rate 2kbps ceil 8kbps prio 2
tc class add dev imq0 parent 1:1 classid 1:$j htb rate 8kbps ceil 120kbps prio 2
tc qdisc add dev imq1 parent 1:$j handle $j: sfq perturb 12
tc qdisc add dev imq0 parent 1:$j handle $j: sfq perturb 12
i=`expr $i + 1`
m=`expr $m + 1`
j=$(echo $i|awk '{printf "%x\n",$0}')
n=$(echo $m|awk '{printf "%x\n",$0}')
done


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/110758/showart_2160292.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP