ISP QoS Lab
ISP QoS Lab
1-PQ
優先級隊列(PQ,Priority Queue)中,有高、中、普通、低優先級四個隊列。數據包
根據事先的定義放在不同的隊列中,路由器按照高、中、普通、低順序服務,只有高優先級
的隊列為空后才為中優先級的隊列服務,依次類推。這樣能保證高優先級數據包一定是優先
服務,然而如果高優先級隊列長期不空,則低優先級的隊列永遠不會被服務。我們可以為每
個隊列設置一個長度,隊列滿后,數據包將被丟棄
R1(config)#priority-list 1 protocol ip ? \\可以定義四個優先級
high
medium
normal
low
R1(config)#priority-list 1 protocol ip high tcp 23 \\我們把telenet流量放在最高優先級
R1(config)#priority-list 1 interface f0/0 medium \\把某個接口收到的流量放在中等優先級
R1(config)#priority-list 1 default low
R1(config)#int f1/0
R1(config-if)#pri
R1(config-if)#priority-group ?
<1-16> Priority group
R1(config-if)#priority-group 1
R1#sh int f1/0
FastEthernet1/0 is up, line protocol is up
Hardware is AmdFE, address is cc00.2618.0010 (bia cc00.2618.0010)
Internet address is 192.168.12.1/24
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full-duplex, 100Mb/s, 100BaseTX/FX
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:04, output 00:00:01, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: priority-list 1
Output queue (queue priority: size/max/drops):
high: 0/20/0, medium: 0/40/0, normal: 0/60/0, low: 0/80/0
R1#show queueing priority
Current DLCI priority queue configuration:
Current priority queue configuration:
List Queue Args
1 low default
1 high protocol ip tcp port telnet
1 medium interface FastEthernet0/0
2-CQ
自定義隊列(CQ,Custom Queue)和PQ 不一樣,在CQ 中有16 個隊列。數據包根據事
先的定義放在不同的隊列中,路由器將為第一個隊列服務一定包數量或者字節數的數據包
后,就轉為為第二個隊列服務。我們可以定義不同隊列中的深度,這樣可以保證某個隊列被
服務的數據包數量較多,但不至于使得某個隊列永遠不會被服務。CQ 中的隊列0 比較特殊,
只有隊列0 為空了,才能為其他隊列服務。
R1(config)#queue-list 1 protocol ip 1 tcp telnet \\把telenet流量放到隊列1中
R1(config)#queue-list 1 default 6 \\其他流量默認放在隊列6中
R1(config)#int f1/0
R1(config-if)#custom-queue-list 1
R1#sh int f1/0
FastEthernet1/0 is up, line protocol is up
Hardware is AmdFE, address is cc00.2618.0010 (bia cc00.2618.0010)
Internet address is 192.168.12.1/24
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full-duplex, 100Mb/s, 100BaseTX/FX
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:00, output 00:00:01, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: custom-list 1
Output queues: (queue #: size/max/drops)
0: 0/20/0 1: 0/20/0 2: 0/20/0 3: 0/20/0 4: 0/20/0
5: 0/20/0 6: 0/20/0 7: 0/20/0 8: 0/20/0 9: 0/20/0
10: 0/20/0 11: 0/20/0 12: 0/20/0 13: 0/20/0 14: 0/20/0
15: 0/20/0 16: 0/20/0
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
3-WFQ
加權公平隊列(WFQ,Weight Fair Queue)是低速鏈路(2.048M 以下)上的默認設置。
WFQ 將數據包區分為不同的流,例如在IP 中利用IP 地址和端口號可以區分不同的TCP 流或
者UDP 流。WFQ 為不同的流根據權重分配不同的帶寬,權因子是IP 數據包中的優先級字段。
例如有3 個流,兩個流的優先級為0,第三個為5,總權為(1+1+6)=8,則前兩個流每個
得到帶寬的1/8,第三個流得到6/8。
R1(config)#int f1/0
R1(config-if)#fair-queue 512 1024 10 \\以上是在接口上啟用WFQ,實際上在E1 速(2.048M)或者更低速率的鏈路上,WFQ 是默認啟用的。512 是丟棄值,當隊列達到512 數據包時,數據將被丟棄;1024 是最大的會話數;10 是RSVP 可預留隊列。
Show int f1/0
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: weighted fair
Output queue: 0/1000/512/0 (size/max total/threshold/drops)
Conversations 0/1/1024 (active/max active/max total)
Reserved Conversations 0/0 (allocated/max allocated)
Available Bandwidth 75000 kilobits/sec
4-CBWFQ
基于類的加權公平隊列(CBWFQ,Class Based Weight Fair Queue)允許用戶自定義類
別,并對這些類別的帶寬進行控制。這在實際中很有用,例如我們可以控制我們的網絡訪問
Internet 時的web 流量的帶寬。可以根據數據包的協議類型、ACL、IP 優先級或者輸入接口
等條件事先定義好流量的類型,為不同類別的流量配置最大帶寬、占用接口帶寬的百分比等。
CBWFQ 可以和NBAR、WRED 等一起使用。
Step1: 定義Class map
R1(config)#class-map match-any map1
R1(config-cmap)#match protocol http
R1(config-cmap)#match protocol ftp
R1(config-cmap)#exit
R1(config)#class-map match-all map2
R1(config-cmap)#match protocol telnet
Step2:定義Policy-Map
R1(config)#policy-map my-policy
R1(config-pmap)#class map1
R1(config-pmap-c)#bandwidth 60
R1(config-pmap-c)#class map2
R1(config-pmap-c)#bandwidth 10
R1(config-pmap-c)#exit
Step3:調用到接口
R1(config)#int f1/0
R1(config-if)#service-policy output my-polic
【技術要點】class-map 命令格式為:“class-map [ match-all | match-any ] name”:
match-all:指明下面的條件必須全部滿足,才可以執行,此為默認值;
match-any:表示匹配任何一個條件就可以執行。
在class-map 模式下,可以設置各種匹配條件,例如:
匹配一種協議類型:match protocol protocol-name 。協議類型包括EGP,ICMP,EIGRP,
DNS,HTTP,Telnet 等上百種具體協議。
匹配訪問列表:match access-group { number | name acl_name } 。可以匹配基
于號碼的list 和基于Name 的Access list。
匹配CoS (class of Servie):match cos cos-value 。匹配IP 包中的CoS 值。
匹配IP 優先級(IP Precedence):match ip precedence precedence-value 。匹配
IP 包中的IP 優先級值。
匹配DSCP 值(Differentiated Services Code Point): match ip dscp dscp_value 。
匹配IP 包中的DSCP 值。
匹配入接口:match input-interface type number。匹配IP 包的進入接口。
R1#show class-map
Class Map match-any class-default (id 0)
Match any
Class Map match-any map1 (id 1)
Match protocol http
Match protocol ftp
Class Map match-all map2 (id 2)
Match protocol telnet
R1#show policy-map
Policy Map my-policy
Class map1
Bandwidth 60 (kbps) Max Threshold 64 (packets)
Class map2
Bandwidth 10 (kbps) Max Threshold 64 (packets)
5-LLQ
低延遲隊列(LLQ,Low Latency Queue)的配置和CBWFQ 很類似。有的數據包,例如
VOIP 的數據包,對數據的延遲非常敏感。LLQ 允許用戶自定義數據類別,并優先讓這些類別
的數據傳輸,在這些數據沒有傳輸完之前不會傳輸其他類別的數據。
LLQ=CBWFQ + PQ
Default queue默認是WFQ
R1(config)#class-map match-any map3
R1(config-cmap)#match ip precedence critical
R1(config-cmap)#exit
R1(config)#policy
R1(config)#policy-map my-policy
R1(config-pmap)#class map3
R1(config-pmap-c)#priority ?
<8-2000000> Kilo Bits per second
percent % of total bandwidth
R1(config-pmap-c)#priority 15
\\LLQ 的配置和CQWFQ 配置很類似,不過使用了priority 命令,我們這里限制它的帶寬為
15k,超過這個帶寬的數據包將被丟棄。這樣CLASS-MAP3 的流量將優先被發送,然后才發送
CLASS-MAP1 和CLASS-MAP2 等流量。
R1#sh policy-map interface f1/0
FastEthernet1/0
Class-map: map3 (match-any)
0 packets, 0 bytes
5 minute offered rate 0 bps, drop rate 0 bps
Match: ip precedence 5
0 packets, 0 bytes
5 minute rate 0 bps
Queueing
Strict Priority
Output Queue: Conversation 264
Bandwidth 15 (kbps) Burst 375 (Bytes)
(pkts matched/bytes matched) 0/0
(total drops/bytes drops) 0/0
Class-map: class-default (match-any)
763 packets, 63162 bytes
5 minute offered rate 0 bps, drop rate 0 bps
Match: any
R1(config)#policy-map my-policy
R1(config-pmap)#class class-default
R1(config-pmap-c)#?
QoS policy-map class configuration commands:
bandwidth Bandwidth
compression Activate Compression
drop Drop all packets
exit Exit from QoS class action configuration mode
fair-queue Enable Flow-based Fair Queuing in this Class
netflow-sampler NetFlow action
no Negate or set default values of a command
police Police
priority Strict Scheduling Priority for this Class
queue-limit Queue Max Threshold for Tail Drop
random-detect Enable Random Early Detection as drop policy
service-policy Configure Flow Next
set Set QoS values
shape Traffic Shaping
R1(config-pmap-c)#no fair-queue \\更改default 隊列機制
6-WRED
加權隨機早期檢測(WRED,Weight Random Early Detect)是RED 的Cisco 實現。當
多個TCP 連接在傳輸數據時,全部連接都按照最大能力傳輸數據,很快造成隊列滿,隊列滿
后的全部數據被丟失;這時所有的發送者立即同時以最小能力傳輸數據,帶寬開始空閑。接
著全部發送者開始慢慢加大速度,于是又同時達到最大速率,又出現堵塞,如此反復。這樣
網絡時空時堵,帶寬的利用率不高。RED 則隨機地丟棄TCP 的數據包,保證鏈路的整體利用
率。WRED 是對RED 的改進,數據包根據IP 優先級分成不同隊列,每個隊列有最小閥值、最
大閥值,當平均長度小于最小閥值時,數據包不會被丟棄;隨著平均隊列的長度增加,丟棄
的概率也增加;當平均長度大于最大閥值時,數據包按照設定的比例丟棄數據包。
R1(config)#int f1/0
R1(config-if)#random-detect
//以上在接口上啟用WRED
R1(config-if)#random-detect precedence 0 18 42 12
//以上配置IP 優先級為0 的隊列,最低閥值為18,平均隊列長度小于18 時,數據包不會
被丟棄;當平均隊列長度大于18 時,開始丟棄數據包,平均隊列長度越大,丟棄的數據包
越多;最大閥值為42,平均隊列長度小于42 時,數據包按照1/12 的比例丟棄。
R1#show queueing random-detect
Current random-detect configuration:
FastEthernet1/0
Queueing strategy: random early detection (WRED)
Random-detect not active on the dialer
Exp-weight-constant: 9 (1/512)
Mean queue depth: 0
class Random drop Tail drop Minimum Maximum Mark
pkts/bytes pkts/bytes thresh thresh prob
0 0/0 0/0 18 42 1/12
1 0/0 0/0 22 40 1/10
2 0/0 0/0 24 40 1/10
3 0/0 0/0 26 40 1/10
4 0/0 0/0 28 40 1/10
5 0/0 0/0 31 40 1/10
6 0/0 0/0 33 40 1/10
7 0/0 0/0 35 40 1/10
rsvp 0/0 0/0 37 40 1/10
\\以上顯示WRED 的配置情況,默認時不同IP 優先級的隊列的最低有所不同,我們更改了
IP 優先級為0 的隊列。
7-CAR
承諾訪問速率(CAR,Commited Access Rate)是一種流量策略的分類和標記的方法,
它基于IP 優先級、DSCP 值、MAC 地址或者訪問控制列表來限制IP 流量的速率。標記則可以
改變IP 優先級或者DSCP。
CAR 使用令牌桶的機制,檢查令牌桶中是否有足夠的令牌。如果一個接口有可用的令牌,
令牌可以從令牌桶中挪走,數據包被轉發,當這個時間間隔過去后,令牌會重新添加到令牌
桶中。如果接口沒有可用的令牌,那么CAR 可以定義對數據包采取的行為。CAR 使用3 種速
率定義來定義流量的速率:
Normal rate(正常的速率):令牌被添加到令牌桶中的平均速率,就是數據包的平均
傳輸速率。
1- Normal burst(正常的突發):正常的突發時在時間間隔內允許正常流量速率的流量。
2-Excess burst(過量突發):超過正常突發的流量。當配置過量突發時,會借令牌并且
將它添加到令牌桶中來允許某種程度的流量突發。當被借的令牌已經使用后在這個接口
上收到的任何超出的流量會被扔掉。流量突發只會發生在短時間內,直到令牌桶中沒有
令牌存在才停止傳輸。
通常建議正常的流量速率配置為等于在一段時間內的平均流量速率。正常的突發速率應
當等于正常速率的1.5 倍。過量速率是正常突發速率的2 倍。
R1(config-if)#rate-limit output access-group 101 64000 12000 16000 conform-action
set-prec-transmit 3 exceed-action set-prec-transmit 0
//以上在接口上啟用CAR,對于符合ACL 101 的流量,平均速率為64000 位/秒,正常突發
量為12000 字節/秒,過量突發量為12000 字節/秒。
rate-limit { output | input } { CIR BC BE } conform-action { action } exceed-action
{ action }
CIR 單位是bit/s;而BC 和BE 的單位是byte/s。
conform-action 的條件是指當要發的數據小于正常突發(bc)的時候
exceed-action 是指要發的數據大于普通突發,小于最大突發(be)的時候。
action 的選項共有如下這些:
continue:繼續執行下一條CAR 語句
drop:丟棄數據包
tranmsit:轉發數據包
set-prec-continue { precedence }:設置IP 優先級并繼續執行下一條CAR 語句
set-prec-transmit { precedence }:設置IP 優先級并轉發數據包
set-dscp-continue { dscp }:設置dscp 值并繼續執行下一條CAR 語句
set-dscp-transmit { dscp }:設置dscp 值并轉發數據包
R1#show interfaces rate-limit
9-NBAR
基于網絡的應用識別(NBAR,Network Based Application Recognition)實際上一個
分類引擎,它查看數據包,對數據包包含的信息進行分析。NBAR 使得路由器不僅要做轉發
數據的工作,還要對數據包進行檢查,這樣會大大增加負載。NBAR 可以檢查應用層的內容,
例如可以檢查URL 是否有“.java”字樣。NBAR 可以和許多QOS 配合使用。
R1(config)#class-map exchange
R1(config-cmap)#match protocol exchange
R1(config-cmap)#exit
R1(config)#policy-map deny-exchange
R1(config-pmap)#class exchange
R1(config-pmap-c)#?
QoS policy-map class configuration commands:
bandwidth Bandwidth
compression Activate Compression
drop Drop all packets
exit Exit from QoS class action configuration mode
netflow-sampler NetFlow action
no Negate or set default values of a command
police Police
priority Strict Scheduling Priority for this Class
queue-limit Queue Max Threshold for Tail Drop
random-detect Enable Random Early Detection as drop policy
service-policy Configure Flow Next
set Set QoS values
shape Traffic Shaping
R1(config-pmap-c)#drop
R1(config)#int f1/0
R1(config-if)#service-policy output deny-exchange
NABR 的配置和CBWFQ 沒什么差別,因為NBAR 實際上只是一個分類技術。
在舊的IOS 中,class-map 模式下不能使用“match protocol bittorrent”等命令,要先從Cisco 網站下載bittorrent.pdlm 等文件,上傳到路由器上的FLASH 中,并使用命令“ip nbar pdlm flash: bittorrent.pdlm”后,才能在class-map 模式下,使用“matchprotocol bittorrent”命令。
【提示】NBAR 需要路由器啟用CEF,默認時CEF 是開啟的,如果沒有開啟,可以使用“ip cef”
命令。
10-命令總結
priority-list 1 protocol ip high tcp telnet創建優先級隊列,標號為1。把telnet 流量放在高優先級隊列中
priority-list 1 queue-limit 20 30 40 50 定義優先級隊列高、中、普通、低隊列中的長度
priority-group 1 把定義好的優先級隊列應用接口上
show queueing priority 查看優先級隊列情況
debug priority 調試優先級隊列
queue-list 1 protocol ip 1 tcp telnet 創建自定義隊列,標號為1。把telnet 流量放在隊列1 中
queue-list 1 queue 1 limit 40 定義隊列1 的深度為40,
custom-queue-list 1 把定義好的自定義隊列應用接口上
fair-queue 512 1024 10 在接口上啟用WFQ,512 是丟棄值,1024 是最大的會話數,10 是RSVP 可預留隊列
class-map match-any CLASS-MAP1 定義class-map,名為CLASS-MAP1
match protocol http 匹配http 協議
轉載于:https://blog.51cto.com/ericfu/1707327
總結
以上是生活随笔為你收集整理的ISP QoS Lab的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 西瓜仿站高手v1.08官方正式版
- 下一篇: 关于静态库、动态库的区别汇总