通过Qos 策略来对P2P限速
 
       在定义突发速率时,需要考虑一些协议(如TCP)会针对丢包而采用流控制机制。例如,TCP将把每个要丢失的数据包的窗口缩小一半,相应地,当对某个速率进行策略时,有效的链路使用率就会低于配置的速率。您可以增加突发速率从而实现更高的利用率。对这些流量来说,比较简单易行的方式就是将突发速率的大小增加一倍(在我们的例子中可以从13 Kbits增加到26 Kbits),监控性能,然后根据需要进行调整。

mls qos
!--- 激活 QoS
mls qos flow-policing
class-map match-any bit
match protocol bittorrent !-匹配BT的协议
match protocol eDonkey !-匹配电骡的协议
match access-group edonkey
match … !-用户根据实际情况定义
policy-map p2p
class bit !-调用 先前定义的bit 类图
police flow 100000 2000 conform-action transmit exceed-action drop
!--- 定义微流管理器,限制每个p2p应用流为100 Kbps的微流量
police 20000000 13000 26000 conform-action transmit exceed-action drop
!--- 定义聚合管理器,以便限制所有p2p应用流为20Mbps聚合流量
三、在接口上应用策略(设备可能仅支持input方向)

interface gigabitEthernet0/2
service-policy input p2p
service-policy output p2p
如果实施基于VLAN的QoS配置,需要在二层接口配置mls qos vlan-based
四、验证策略实施情况
sh mls qos
sh mls qos ip gigabitEthernet 0/2
sh mls ip detail #进行微流策略统计
sh int g0/2 rate-limit
show policy-map interface g0/2
show ip nbar unclassified-port-stats
show ip nbar protocol stats byte-count
show ip nbar port-map | include custom
注:以上配置适用于cisco6509sup720平台,可用IOS版本12.1以上。