ISP QoS Lab
ISP QoS Lab
1-PQ
優(yōu)先級(jí)隊(duì)列(PQ,Priority Queue)中,有高、中、普通、低優(yōu)先級(jí)四個(gè)隊(duì)列。數(shù)據(jù)包
根據(jù)事先的定義放在不同的隊(duì)列中,路由器按照高、中、普通、低順序服務(wù),只有高優(yōu)先級(jí)
的隊(duì)列為空后才為中優(yōu)先級(jí)的隊(duì)列服務(wù),依次類推。這樣能保證高優(yōu)先級(jí)數(shù)據(jù)包一定是優(yōu)先
服務(wù),然而如果高優(yōu)先級(jí)隊(duì)列長(zhǎng)期不空,則低優(yōu)先級(jí)的隊(duì)列永遠(yuǎn)不會(huì)被服務(wù)。我們可以為每
個(gè)隊(duì)列設(shè)置一個(gè)長(zhǎng)度,隊(duì)列滿后,數(shù)據(jù)包將被丟棄
R1(config)#priority-list 1 protocol ip ? \\可以定義四個(gè)優(yōu)先級(jí)
high
medium
normal
low
R1(config)#priority-list 1 protocol ip high tcp 23 \\我們把telenet流量放在最高優(yōu)先級(jí)
R1(config)#priority-list 1 interface f0/0 medium \\把某個(gè)接口收到的流量放在中等優(yōu)先級(jí)
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
自定義隊(duì)列(CQ,Custom Queue)和PQ 不一樣,在CQ 中有16 個(gè)隊(duì)列。數(shù)據(jù)包根據(jù)事
先的定義放在不同的隊(duì)列中,路由器將為第一個(gè)隊(duì)列服務(wù)一定包數(shù)量或者字節(jié)數(shù)的數(shù)據(jù)包
后,就轉(zhuǎn)為為第二個(gè)隊(duì)列服務(wù)。我們可以定義不同隊(duì)列中的深度,這樣可以保證某個(gè)隊(duì)列被
服務(wù)的數(shù)據(jù)包數(shù)量較多,但不至于使得某個(gè)隊(duì)列永遠(yuǎn)不會(huì)被服務(wù)。CQ 中的隊(duì)列0 比較特殊,
只有隊(duì)列0 為空了,才能為其他隊(duì)列服務(wù)。
R1(config)#queue-list 1 protocol ip 1 tcp telnet \\把telenet流量放到隊(duì)列1中
R1(config)#queue-list 1 default 6 \\其他流量默認(rèn)放在隊(duì)列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
加權(quán)公平隊(duì)列(WFQ,Weight Fair Queue)是低速鏈路(2.048M 以下)上的默認(rèn)設(shè)置。
WFQ 將數(shù)據(jù)包區(qū)分為不同的流,例如在IP 中利用IP 地址和端口號(hào)可以區(qū)分不同的TCP 流或
者UDP 流。WFQ 為不同的流根據(jù)權(quán)重分配不同的帶寬,權(quán)因子是IP 數(shù)據(jù)包中的優(yōu)先級(jí)字段。
例如有3 個(gè)流,兩個(gè)流的優(yōu)先級(jí)為0,第三個(gè)為5,總權(quán)為(1+1+6)=8,則前兩個(gè)流每個(gè)
得到帶寬的1/8,第三個(gè)流得到6/8。
R1(config)#int f1/0
R1(config-if)#fair-queue 512 1024 10 \\以上是在接口上啟用WFQ,實(shí)際上在E1 速(2.048M)或者更低速率的鏈路上,WFQ 是默認(rèn)啟用的。512 是丟棄值,當(dāng)隊(duì)列達(dá)到512 數(shù)據(jù)包時(shí),數(shù)據(jù)將被丟棄;1024 是最大的會(huì)話數(shù);10 是RSVP 可預(yù)留隊(duì)列。
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
基于類的加權(quán)公平隊(duì)列(CBWFQ,Class Based Weight Fair Queue)允許用戶自定義類
別,并對(duì)這些類別的帶寬進(jìn)行控制。這在實(shí)際中很有用,例如我們可以控制我們的網(wǎng)絡(luò)訪問(wèn)
Internet 時(shí)的web 流量的帶寬。可以根據(jù)數(shù)據(jù)包的協(xié)議類型、ACL、IP 優(yōu)先級(jí)或者輸入接口
等條件事先定義好流量的類型,為不同類別的流量配置最大帶寬、占用接口帶寬的百分比等。
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:調(diào)用到接口
R1(config)#int f1/0
R1(config-if)#service-policy output my-polic
【技術(shù)要點(diǎn)】class-map 命令格式為:“class-map [ match-all | match-any ] name”:
match-all:指明下面的條件必須全部滿足,才可以執(zhí)行,此為默認(rèn)值;
match-any:表示匹配任何一個(gè)條件就可以執(zhí)行。
在class-map 模式下,可以設(shè)置各種匹配條件,例如:
匹配一種協(xié)議類型:match protocol protocol-name 。協(xié)議類型包括EGP,ICMP,EIGRP,
DNS,HTTP,Telnet 等上百種具體協(xié)議。
匹配訪問(wèn)列表:match access-group { number | name acl_name } 。可以匹配基
于號(hào)碼的list 和基于Name 的Access list。
匹配CoS (class of Servie):match cos cos-value 。匹配IP 包中的CoS 值。
匹配IP 優(yōu)先級(jí)(IP Precedence):match ip precedence precedence-value 。匹配
IP 包中的IP 優(yōu)先級(jí)值。
匹配DSCP 值(Differentiated Services Code Point): match ip dscp dscp_value 。
匹配IP 包中的DSCP 值。
匹配入接口:match input-interface type number。匹配IP 包的進(jìn)入接口。
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
低延遲隊(duì)列(LLQ,Low Latency Queue)的配置和CBWFQ 很類似。有的數(shù)據(jù)包,例如
VOIP 的數(shù)據(jù)包,對(duì)數(shù)據(jù)的延遲非常敏感。LLQ 允許用戶自定義數(shù)據(jù)類別,并優(yōu)先讓這些類別
的數(shù)據(jù)傳輸,在這些數(shù)據(jù)沒(méi)有傳輸完之前不會(huì)傳輸其他類別的數(shù)據(jù)。
LLQ=CBWFQ + PQ
Default queue默認(rèn)是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 配置很類似,不過(guò)使用了priority 命令,我們這里限制它的帶寬為
15k,超過(guò)這個(gè)帶寬的數(shù)據(jù)包將被丟棄。這樣CLASS-MAP3 的流量將優(yōu)先被發(fā)送,然后才發(fā)送
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 隊(duì)列機(jī)制
6-WRED
加權(quán)隨機(jī)早期檢測(cè)(WRED,Weight Random Early Detect)是RED 的Cisco 實(shí)現(xiàn)。當(dāng)
多個(gè)TCP 連接在傳輸數(shù)據(jù)時(shí),全部連接都按照最大能力傳輸數(shù)據(jù),很快造成隊(duì)列滿,隊(duì)列滿
后的全部數(shù)據(jù)被丟失;這時(shí)所有的發(fā)送者立即同時(shí)以最小能力傳輸數(shù)據(jù),帶寬開(kāi)始空閑。接
著全部發(fā)送者開(kāi)始慢慢加大速度,于是又同時(shí)達(dá)到最大速率,又出現(xiàn)堵塞,如此反復(fù)。這樣
網(wǎng)絡(luò)時(shí)空時(shí)堵,帶寬的利用率不高。RED 則隨機(jī)地丟棄TCP 的數(shù)據(jù)包,保證鏈路的整體利用
率。WRED 是對(duì)RED 的改進(jìn),數(shù)據(jù)包根據(jù)IP 優(yōu)先級(jí)分成不同隊(duì)列,每個(gè)隊(duì)列有最小閥值、最
大閥值,當(dāng)平均長(zhǎng)度小于最小閥值時(shí),數(shù)據(jù)包不會(huì)被丟棄;隨著平均隊(duì)列的長(zhǎng)度增加,丟棄
的概率也增加;當(dāng)平均長(zhǎng)度大于最大閥值時(shí),數(shù)據(jù)包按照設(shè)定的比例丟棄數(shù)據(jù)包。
R1(config)#int f1/0
R1(config-if)#random-detect
//以上在接口上啟用WRED
R1(config-if)#random-detect precedence 0 18 42 12
//以上配置IP 優(yōu)先級(jí)為0 的隊(duì)列,最低閥值為18,平均隊(duì)列長(zhǎng)度小于18 時(shí),數(shù)據(jù)包不會(huì)
被丟棄;當(dāng)平均隊(duì)列長(zhǎng)度大于18 時(shí),開(kāi)始丟棄數(shù)據(jù)包,平均隊(duì)列長(zhǎng)度越大,丟棄的數(shù)據(jù)包
越多;最大閥值為42,平均隊(duì)列長(zhǎng)度小于42 時(shí),數(shù)據(jù)包按照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
\\以上顯示W(wǎng)RED 的配置情況,默認(rèn)時(shí)不同IP 優(yōu)先級(jí)的隊(duì)列的最低有所不同,我們更改了
IP 優(yōu)先級(jí)為0 的隊(duì)列。
7-CAR
承諾訪問(wèn)速率(CAR,Commited Access Rate)是一種流量策略的分類和標(biāo)記的方法,
它基于IP 優(yōu)先級(jí)、DSCP 值、MAC 地址或者訪問(wèn)控制列表來(lái)限制IP 流量的速率。標(biāo)記則可以
改變IP 優(yōu)先級(jí)或者DSCP。
CAR 使用令牌桶的機(jī)制,檢查令牌桶中是否有足夠的令牌。如果一個(gè)接口有可用的令牌,
令牌可以從令牌桶中挪走,數(shù)據(jù)包被轉(zhuǎn)發(fā),當(dāng)這個(gè)時(shí)間間隔過(guò)去后,令牌會(huì)重新添加到令牌
桶中。如果接口沒(méi)有可用的令牌,那么CAR 可以定義對(duì)數(shù)據(jù)包采取的行為。CAR 使用3 種速
率定義來(lái)定義流量的速率:
Normal rate(正常的速率):令牌被添加到令牌桶中的平均速率,就是數(shù)據(jù)包的平均
傳輸速率。
1- Normal burst(正常的突發(fā)):正常的突發(fā)時(shí)在時(shí)間間隔內(nèi)允許正常流量速率的流量。
2-Excess burst(過(guò)量突發(fā)):超過(guò)正常突發(fā)的流量。當(dāng)配置過(guò)量突發(fā)時(shí),會(huì)借令牌并且
將它添加到令牌桶中來(lái)允許某種程度的流量突發(fā)。當(dāng)被借的令牌已經(jīng)使用后在這個(gè)接口
上收到的任何超出的流量會(huì)被扔掉。流量突發(fā)只會(huì)發(fā)生在短時(shí)間內(nèi),直到令牌桶中沒(méi)有
令牌存在才停止傳輸。
通常建議正常的流量速率配置為等于在一段時(shí)間內(nèi)的平均流量速率。正常的突發(fā)速率應(yīng)
當(dāng)?shù)扔谡K俾实?.5 倍。過(guò)量速率是正常突發(fā)速率的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,對(duì)于符合ACL 101 的流量,平均速率為64000 位/秒,正常突發(fā)
量為12000 字節(jié)/秒,過(guò)量突發(fā)量為12000 字節(jié)/秒。
rate-limit { output | input } { CIR BC BE } conform-action { action } exceed-action
{ action }
CIR 單位是bit/s;而B(niǎo)C 和BE 的單位是byte/s。
conform-action 的條件是指當(dāng)要發(fā)的數(shù)據(jù)小于正常突發(fā)(bc)的時(shí)候
exceed-action 是指要發(fā)的數(shù)據(jù)大于普通突發(fā),小于最大突發(fā)(be)的時(shí)候。
action 的選項(xiàng)共有如下這些:
continue:繼續(xù)執(zhí)行下一條CAR 語(yǔ)句
drop:丟棄數(shù)據(jù)包
tranmsit:轉(zhuǎn)發(fā)數(shù)據(jù)包
set-prec-continue { precedence }:設(shè)置IP 優(yōu)先級(jí)并繼續(xù)執(zhí)行下一條CAR 語(yǔ)句
set-prec-transmit { precedence }:設(shè)置IP 優(yōu)先級(jí)并轉(zhuǎn)發(fā)數(shù)據(jù)包
set-dscp-continue { dscp }:設(shè)置dscp 值并繼續(xù)執(zhí)行下一條CAR 語(yǔ)句
set-dscp-transmit { dscp }:設(shè)置dscp 值并轉(zhuǎn)發(fā)數(shù)據(jù)包
R1#show interfaces rate-limit
9-NBAR
基于網(wǎng)絡(luò)的應(yīng)用識(shí)別(NBAR,Network Based Application Recognition)實(shí)際上一個(gè)
分類引擎,它查看數(shù)據(jù)包,對(duì)數(shù)據(jù)包包含的信息進(jìn)行分析。NBAR 使得路由器不僅要做轉(zhuǎn)發(fā)
數(shù)據(jù)的工作,還要對(duì)數(shù)據(jù)包進(jìn)行檢查,這樣會(huì)大大增加負(fù)載。NBAR 可以檢查應(yīng)用層的內(nèi)容,
例如可以檢查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 沒(méi)什么差別,因?yàn)镹BAR 實(shí)際上只是一個(gè)分類技術(shù)。
在舊的IOS 中,class-map 模式下不能使用“match protocol bittorrent”等命令,要先從Cisco 網(wǎng)站下載bittorrent.pdlm 等文件,上傳到路由器上的FLASH 中,并使用命令“ip nbar pdlm flash: bittorrent.pdlm”后,才能在class-map 模式下,使用“matchprotocol bittorrent”命令。
【提示】NBAR 需要路由器啟用CEF,默認(rèn)時(shí)CEF 是開(kāi)啟的,如果沒(méi)有開(kāi)啟,可以使用“ip cef”
命令。
10-命令總結(jié)
priority-list 1 protocol ip high tcp telnet創(chuàng)建優(yōu)先級(jí)隊(duì)列,標(biāo)號(hào)為1。把telnet 流量放在高優(yōu)先級(jí)隊(duì)列中
priority-list 1 queue-limit 20 30 40 50 定義優(yōu)先級(jí)隊(duì)列高、中、普通、低隊(duì)列中的長(zhǎng)度
priority-group 1 把定義好的優(yōu)先級(jí)隊(duì)列應(yīng)用接口上
show queueing priority 查看優(yōu)先級(jí)隊(duì)列情況
debug priority 調(diào)試優(yōu)先級(jí)隊(duì)列
queue-list 1 protocol ip 1 tcp telnet 創(chuàng)建自定義隊(duì)列,標(biāo)號(hào)為1。把telnet 流量放在隊(duì)列1 中
queue-list 1 queue 1 limit 40 定義隊(duì)列1 的深度為40,
custom-queue-list 1 把定義好的自定義隊(duì)列應(yīng)用接口上
fair-queue 512 1024 10 在接口上啟用WFQ,512 是丟棄值,1024 是最大的會(huì)話數(shù),10 是RSVP 可預(yù)留隊(duì)列
class-map match-any CLASS-MAP1 定義class-map,名為CLASS-MAP1
match protocol http 匹配http 協(xié)議
轉(zhuǎn)載于:https://blog.51cto.com/ericfu/1707327
總結(jié)
以上是生活随笔為你收集整理的ISP QoS Lab的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 西瓜仿站高手v1.08官方正式版
- 下一篇: 关于静态库、动态库的区别汇总