中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 操作系统 > Linux > Linux综合
Shaping Script for VoIP Priority
作者:未知 时间:2005-09-13 22:22 出处:Blog.ChinaUnix.net 责编:chinaitpower
              摘要:Shaping Script for VoIP Priority
续。。。


#!/bin/sh
#
# Script by Ron Senykoff 2005
#####################################
############ VARIABLES ##############
#                                   #
e=eth0 # interface
nonVoipRate=150kbps # throttle for nonVoip - make sure to keep is slow enough
citrix=60kbps
video=110kbps
sametime=5kbps
bulk=10kbps

COLO1="x.x.x.x" # substitute IPs here
COLO2="x.x.x.x"
SAMETIME="x.x.x.x"
#                                   #
#####################################
#####################################

# Delete any old rules #
tc qdisc del root dev $e

#ifconfig $e txqueuelen 10
# root qdisc /  qdisc = queueing discipline #
tc qdisc add dev $e root handle 1: prio bands 2 priomap 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
# creates classes 1:1 and 1:2

# put a pfifo on so we can see it at the console
tc qdisc add dev $e parent 1:1 handle 11: pfifo

# on the second band of the prio we but an htb to keep
# the rest of the traffic from ever overrunning the link
# any traffic not caught by our filters goes to the bulk category
tc qdisc add dev $e parent 1:2 handle 10: htb default 40
tc class add dev $e parent 10: classid 10:1 htb rate $nonVoipRate

# define the inner classes of the htb - prioritized from 10 - 40
tc class add dev $e parent 10:1 classid 10:10 htb rate $citrix ceil $nonVoipRate quantum 1500
tc class add dev $e parent 10:1 classid 10:20 htb rate $video ceil $nonVoipRate
tc class add dev $e parent 10:1 classid 10:30 htb rate $sametime ceil $nonVoipRate quantum 1500
tc class add dev $e parent 10:1 classid 10:40 htb rate $bulk ceil $nonVoipRate quantum 1500

# add queues onto the htb classes
# default is pfifo - but this lets us see it with tc -s qdisc show dev eth0
tc qdisc add dev $e parent 10:10 handle 100: pfifo limit 50
tc qdisc add dev $e parent 10:20 handle 200: pfifo limit 10
tc qdisc add dev $e parent 10:30 handle 300: pfifo limit 10
# fair queuing on the bulk traffic
tc qdisc add dev $e parent 10:40 handle 400: sfq perturb 10

#####################################
############### VoIP ################
#                                   #

# IAX # this is the old format - IAX2 should be what's really seen going on
tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip sport 5036 0xffff flowid 1:1
tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip dport 5036 0xffff flowid 1:1

# IAX2 #
tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip sport 4569 0xffff flowid 1:1
tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip dport 4569 0xffff flowid 1:1

# match icmp echo request
#tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip icmp_type 0x08 0xff flowid 1:1

# match icmp echo reply
#tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip icmp_type 0x00 0xff flowid 1:1

######################################
# forward the rest to second priority#
tc filter add dev $e protocol ip parent 1: prio 2 u32 match ip src 0.0.0.0/0 flowid 1:2
tc filter add dev $e protocol ip parent 1: prio 2 u32 match ip dst 0.0.0.0/0 flowid 1:2


#####################################################
#### Classify band 2 of the priority queue ##########
#####################################################
##                                                 ##
##                                                 ##


#####################################
############### Citrix ##############
#                                   #

# SSH #
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 22 0xffff flowid 10:10
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 22 0xffff flowid 10:10

# CITRIX/ICA #
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 1494 0xffff flowid 10:10
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 1494 0xffff flowid 10:10

# CITRIX Metaframe #
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip src $CONNECTRIA1/32 flowid 10:10
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dst $CONNECTRIA1/32 flowid 10:10

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip src $CONNECTRIA2/32 flowid 10:10
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dst $CONNECTRIA2/32 flowid 10:10

#####################################
############### Video ###############
#                                   #

### Fixme - use better masks on the h323 ports to reduce the number of lines needed - should be faster

# H323 #
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 1720 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 1720 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 15328 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 15328 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 15329 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 15329 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 15330 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 15330 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 15331 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 15331 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 15332 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 15332 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3230 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3230 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3231 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3231 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3232 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3232 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3233 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3233 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3234 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3234 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3235 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3235 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3236 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3236 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3237 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3237 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3238 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3238 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3239 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3239 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3240 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3240 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3241 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3241 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3242 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3242 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3243 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3243 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3244 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3244 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3245 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3245 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3246 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3246 0xffff flowid 10:20

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 3247 0xffff flowid 10:20
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 3247 0xffff flowid 10:20

#####################################
############ Sametime ###############
#                                   #

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip src $SAMETIME/32 flowid 10:30
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dst $SAMETIME/32 flowid 10:30

#####################################
######### Bulk / Default ############
#                                   #

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip src 0.0.0.0/0 flowid 10:40
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dst 0.0.0.0/0 flowid 10:40

hidden fields
关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有