类、策略的定义及应用
Switch(config)#mls qos
在交换机上启用QoS服务,如果不启用,以下配置将不起作用。
Switch(config)#class-map [match-any | match-all ] class-name
定义一个类图,名字为class-name。
注意:当match-any/match-all省略时,表示match-all,match-any表示匹配该类所定义语句中的任意一条,match-all表示匹配所有。
Switch(config)#policy-map policy-name
定义一个策略图(可以包含多个策略),名字为policy-name
Switch(config-if)#service-policy { input | output } policy-name
将策略应用到端口
Switch(config-if)#mls qos trust { cos | dscp | ip_precedence }
配置策略类的信任状态,cos表示信任数据包第二层帧头的优先级位;dscp表示信任IP数据包中的dscp的值;
例1:
access-list 100 permit ip any any
新建class
class-map match-all speedlimit
match access-group 100
新建policy
policy-map 10M
class speedlimit
police cir 10000000 bc 4000000 be 4000000 conform-action transmit exceed-action drop violate-action drop
应用到端口
service-policy input speedlimit
例2:
Switch(config)#policy-map po_bandwith
Switch(config-?)#class-map a1
Switch(config-?)#bandwith 3000 (k)
Switch(config-?)#class-map a2
Switch(config-?)#bandwith 2000
Switch(config)#interface fastethernet 0/1
Switch(config-if)#service-policy input po_bandwith
查看策略的应用
Switch#show class-map class-name
Switch#show policy-map int interface-spec
Switch#show policy-map interface interface-spec [input | output] class class-name
基于类的标记
标记就是把数据包中一些特殊的为做一些更改和设置。如:更改IP Precedence/DSCP(differentiated services code point),设置第二层帧的服务类别的值;把ATM信元修改该类的标记时,要在策略图的类别中修改(如下)
Switch(config)#policy-map policy-name
Switch(config-pmap)#class class-name
修改ip precedence等配置的值(如下)
Switch(config-pmap-c)#set ip precedence ip-prec-value
Switch(config-pmap-c)#set ipdscp ip-dscp-value
IP RTP Priority(实时传输协议)Commands
Switch(config-if)#ip rtp priority start-port port-range bw (起始端口号、端口范围、带宽)
Switch(config-if)#max-reserved-bandwidth percent (最大带宽所占总带宽的百分比)
Switch#show queue interface-type interface-number (查看端口配置)