一、Output Drop 原因
Output Drop/discards 通常是由多对一或大带宽打小带宽导致接口超负载。
接口缓冲区 interface buffer 是一种有限的资源,可一定程度缓解突发丢包,但是不能保证 0 丢弃。
二、Buffer Allocation 缓冲区分配
传统情况下,缓冲区是为每个队列静态分配的,随着队列数量的增加,预留的缓冲区数量会减少。因此效率低下,且可能耗尽处理所有队列的帧所需的缓冲区数量。
1. Hard Buffers vs Soft Buffers
Catalyst 3650/3850 平台使用硬缓冲区和软缓冲区解决该问题:
-
Hard Buffers: 特定队列预留的最小缓冲区,这些缓冲区对其他队列不可用。
-
Soft Buffers: 分配给队列的缓冲区,但如果该队列不使用,其中 400 可以由其他队列和接口共享(任何队列配置的默认最大阈值)。
2. 默认缓冲区分配(未应用服务策略)
接口默认缓冲数量:
- 1GB 端口 -> 300 个缓冲区(1 个缓冲区 = 256 字节)
- 10GB 端口 -> 1800 个缓冲区
接口最大缓冲区
端口最多可以使用从具有默认设置的公共池分配的默认值的 400%。默认可从公共池借用的缓冲区数量为 400。
- 1GB 接口 -> 1200 个缓冲区
- 10GB 接口 -> 7200 个缓冲区
三、Queue Structure 队列结构
未应用服务策略时,有 2 个默认队列。队列 0 用于控制流量(DSCP 32、48 或 56),队列 1 用于数据流量。
1. Queue 0
默认情况下,可以为队列 0 提供接口 40% 的缓冲区作为其硬缓冲区。
1G 接口 -> 硬 - 120,软 - 480
10G 接口 -> 硬 - 720,软 - 2880
2. Queue 1
队列 1 没有硬缓冲区,队列 1 的软缓冲区值为分配给队列 0 后剩余的接口缓冲区的 400%。
1G 接口 -> 180 * 400%
10G 接口 -> 1080 * 400% (1800-720)
3. 接口输出
1. 1 G
3850#show platform qos queue config gigabitEthernet 1/0/1
DATA Port:20 GPN:66 AFD:Disabled QoSMap:0 HW Queues: 160 - 167
DrainFast:Disabled PortSoftStart:1 - 1080
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 5 120 6 480 6 320 0 0 3 1440
1 1 4 0 7 720 3 480 2 180 3 1440
2 1 4 0 5 0 5 0 0 0 3 1440
3 1 4 0 5 0 5 0 0 0 3 1440
4 1 4 0 5 0 5 0 0 0 3 1440
5 1 4 0 5 0 5 0 0 0 3 1440
6 1 4 0 5 0 5 0 0 0 3 1440
7 1 4 0 5 0 5 0 0 0 3 1440
2. 10G
3850#show platform qos queue config tenGigabitEthernet 1/0/37
DATA Port:1 GPN:37 AFD:Disabled QoSMap:0 HW Queues: 8 - 15
DrainFast:Disabled PortSoftStart:2 - 6480
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 6 720 8 2880 7 1280 0 0 4 8640
1 1 4 0 9 4320 8 1920 3 1080 4 8640
2 1 4 0 5 0 5 0 0 0 4 8640
3 1 4 0 5 0 5 0 0 0 4 8640
4 1 4 0 5 0 5 0 0 0 4 8640
Hardmax 或 Hard Buffers 是始终保留并可用于此队列的 Buffer 量。
Softmax 或 Soft Buffers 是可以从其他队列或全局池借用的缓冲区量。
四、调整缓冲区数量
要调整 3650/3850 的缓冲区,需要在相应接口下附加服务策略 Service policy。可通过 service-policy 调整 Hardmax 和 Softmax 缓冲区分配。
1. Hard Buffers + Soft Buffers 计算
总端口缓冲区 = 300 (1G)/800 (10G)
如果总共有 5 个队列(class),则默认情况下每个队列获得 20% 的缓冲区。
Priority Queue 优先队列
1G
HardMax = Oper_Buff = 20% of 300 = 60.
HardMax = Oper_Buff = 300 的 20% = 60。
qSoftMax = (Oper_Buff * Max_Threshold)/100=60*400/100=240
qSoftMax = (Oper_Buff * Max_Threshold)/100=60*400/100=240
10G
HardMax = Oper_Buff = 20% of 1800 = 360
HardMax = Oper_Buff = 1800 的 20% = 360
qsoftMax = (Oper_Buff * Max_Threshold)/100 = 360*400/100= 1440
qsoftMax = (Oper_Buff * Max_Threshold)/100 = 360*400/100= 1440
Non-Priority Queue 非优先队列
1G
HardMax = 0
qSoftMax = (Oper_Buffer*Max_Threshold)/100 = 300*20/100= 60. 400% of 60 = 240
qSoftMax = (Oper_Buffer*Max_Threshold)/100 = 300*20/100= 60。60 的 400% = 240
10G
HardMax = 0
qSoftMax = (Oper_Buffer*Max_Threshold)/100 = 1800*20/100= 360. 400% of 360 = 1440
qSoftMax = (Oper_Buffer*Max_Threshold)/100 = 1800*20/100= 360。360 的 400% = 1440
2. 应用服务策略
如果应用了服务策略,只有“级别为 1/2 的优先级队列”才会获得 Hardmax。创建的队列越多,每个队列在 Hardmax 和 Softmax 方面的缓冲区就越少(因为 Hardmax 也取决于 Softmax 值)。
从 3.6.3 或 3.7.2 开始,可以使用 命令 qos queue-softmax-multiplier 1200
修改 Softmax 的最大值,并将 100 作为默认值。如果配置为 1200,则非优先级队列和非主优先级队列 (!=level 1) 的 Softmax 将从其默认值乘以 12。此命令仅在附加了策略映射的端口上生效。它也不适用于优先级队列级别 。
未应用任何服务策略
如果链路是 1G 链路,则 queue-0 将获得默认 Hardmax 120,如果链路是 10G 链路,则为 720 缓冲区。
3850#show platform qos queue config gigabitEthernet 1/0/1
DATA Port:0 GPN:119 AFD:Disabled QoSMap:0 HW Queues: 0 - 7
DrainFast:Disabled PortSoftStart:1 - 1080
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 5 120 6 480 6 320 0 0 3 1440
1 1 4 0 7 720 3 480 2 180 3 1440
2 1 4 0 5 0 5 0 0 0 3 1440
3850#show platform qos queue config tenGigabitEthernet 1/0/37
DATA Port:1 GPN:37 AFD:Disabled QoSMap:0 HW Queues: 8 - 15
DrainFast:Disabled PortSoftStart:2 - 6480
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 6 720 8 2880 7 1280 0 0 4 8640
1 1 4 0 9 4320 8 1920 3 1080 4 8640
2 1 4 0 5 0 5 0 0 0 4 8640
例1.
应用服务策略时,如果未配置优先级队列或未设置优先级队列级别,则不能为该队列分配 Hardmax。
1. 1G 接口
policy-map MYPOL
class ONE
priority percent 20
class TWO
bandwidth percent 40
class THREE
bandwidth percent 10
class FOUR
bandwidth percent 5
3850#show run interface gig1/0/1
Current configuration : 67 bytes
!
interface GigabitEthernet1/0/1
service-policy output MYPOL
end
3800#show platform qos queue config gigabitEthernet 1/0/1
DATA Port:21 GPN:65 AFD:Disabled QoSMap:1 HW Queues: 168 - 175
DrainFast:Disabled PortSoftStart:2 - 360
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 4 0 8 240 7 160 3 60 4 480
1 1 4 0 8 240 7 160 3 60 4 480
2 1 4 0 8 240 7 160 3 60 4 480
3 1 4 0 8 240 7 160 3 60 4 480
4 1 4 0 8 240 7 160 3 60 4 480
一共 5 个 class 代表创建了 4 个,第 5 个是 default class
每个 class 代表一个队列,顺序与 policy-map MYPOL 中对应
2. 10 G 接口
policy-map MYPOL
class ONE
priority percent 20
class TWO
bandwidth percent 40
class THREE
bandwidth percent 10
class FOUR
bandwidth percent 5
3850#show run interface TenGigabitEthernet1/0/37
Current configuration : 67 bytes
!
interface TenGigabitEthernet1/0/37
service-policy output MYPOL
end
3850#show platform qos queue config tenGigabitEthernet 1/0/40
DATA Port:2 GPN:40 AFD:Disabled QoSMap:1 HW Queues: 16 - 23
DrainFast:Disabled PortSoftStart:4 - 2160
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 4 0 10 1440 9 640 4 360 5 2880
1 1 4 0 10 1440 9 640 4 360 5 2880
2 1 4 0 10 1440 9 640 4 360 5 2880
3 1 4 0 10 1440 9 640 4 360 5 2880
4 1 4 0 10 1440 9 640 4 360 5 2880
5 1 4 0 5 0 5 0 0 0 5 2880
例2.
应用优先级级别 1 时,queue-0 将获得 60 个缓冲区作为 Hardmax。
1Gig 接口
policy-map MYPOL
class ONE
priority level 1 percent 20
class TWO
bandwidth percent 40
class THREE
bandwidth percent 10
class FOUR
bandwidth percent 5
3850#show run interface gig1/0/1
Current configuration : 67 bytes
!
interface GigabitEthernet1/0/1
service-policy output MYPOL
end
BGL.L.13-3800-1#show platform qos queue config gigabitEthernet 1/0/1
DATA Port:21 GPN:65 AFD:Disabled QoSMap:1 HW Queues: 168 - 175
DrainFast:Disabled PortSoftStart:2 - 360
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 6 60 8 240 7 160 0 0 4 480
1 1 4 0 8 240 7 160 3 60 4 480
2 1 4 0 8 240 7 160 3 60 4 480
3 1 4 0 8 240 7 160 3 60 4 480
4 1 4 0 8 240 7 160 3 60 4 480
10G 接口
policy-map MYPOL
class ONE
priority level 1 percent 20
class TWO
bandwidth percent 40
class THREE
bandwidth percent 10
class FOUR
bandwidth percent 5
3850#show run interface Te1/0/37
Current configuration : 67 bytes
!
interface TenGigabitEthernet1/0/37
service-policy output MYPOL
end
3850_1#show platform qos queue config tenGigabitEthernet 1/0/37
DATA Port:2 GPN:40 AFD:Disabled QoSMap:1 HW Queues: 16 - 23
DrainFast:Disabled PortSoftStart:3 - 2160
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 7 360 10 1440 9 640 0 0 5 2880
1 1 4 0 10 1440 9 640 4 360 5 2880
2 1 4 0 10 1440 9 640 4 360 5 2880
3 1 4 0 10 1440 9 640 4 360 5 2880
4 1 4 0 10 1440 9 640 4 360 5 2880
5 1 4 0 5 0 5 0 0 0 5 2880
例3.
队列总数变为 6。配置了 2 个优先级后,每个队列将获得 51 个缓冲区作为 Hardmax。
1Gig 接口
policy-map MYPOL
class ONE
priority level 1 percent 20
class TWO
priority level 2 percent 10
class THREE
bandwidth percent 10
class FOUR
bandwidth percent 5
class FIVE
bandwidth percent 10
3850#show run interface gigabitEthernet1/0/1
Current configuration : 67 bytes
!
interface GigabitEthernet1/0/1
service-policy output MYPOL
end
3850#show platform qos queue config gigabitEthernet 1/0/1
DATA Port:16 GPN:10 AFD:Disabled QoSMap:1 HW Queues: 128 - 135
DrainFast:Disabled PortSoftStart:3 - 306
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 7 51 10 204 9 136 0 0 5 408
1 1 7 51 10 204 9 136 0 0 5 408
2 1 4 0 10 204 9 136 4 51 5 408
3 1 4 0 10 204 9 136 4 51 5 408
4 1 4 0 11 192 10 128 5 48 5 408
5 1 4 0 11 192 10 128 5 48 5 408
6 1 4 0 5 0 5 0 0 0 5 408
10G 接口
policy-map MYPOL
class ONE
priority level 1 percent 20
class TWO
priority level 2 percent 10
class THREE
bandwidth percent 10
class FOUR
bandwidth percent 5
class FIVE
bandwidth percent 10
3850#show run interface Te1/0/37
Current configuration : 67 bytes
!
interface TenGigabitEthernet1/0/37
service-policy output MYPOL
end
3850_2#show platform qos queue config tenGigabitEthernet 1/0/37
DATA Port:2 GPN:40 AFD:Disabled QoSMap:1 HW Queues: 16 - 23
DrainFast:Disabled PortSoftStart:4 - 1836
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 8 306 12 1224 11 544 0 0 6 2448
1 1 8 306 12 1224 11 544 0 0 6 2448
2 1 4 0 12 1224 11 544 6 306 6 2448
3 1 4 0 12 1224 11 544 6 306 6 2448
4 1 4 0 13 1152 12 512 7 288 6 2448
5 1 4 0 13 1152 12 512 7 288 6 2448
6 1 4 0 5 0 5 0 0 0 6 2448
3. 使用服务策略手动更改 softmax 缓冲区值
Troubleshoot Catalyst 3850 Output Drops - Cisco
五、Output Drop 排查
1. 丢包日志
3850#show interfaces gig1/0/1 | in output drop
Input queue: 0/2000/0/0 (size/max/drops/flushes); Total output drops: 497000 <<<
3800#show platform qos queue stats gigabitEthernet 1/0/1
<snip>
DATA Port:21 Drop Counters
-------------------------------
Queue Drop-TH0 Drop-TH1 Drop-TH2 SBufDrop QebDrop
----- ----------- ----------- ----------- ----------- -----------
0 0 0 497000 0 0 <<<
1 0 0 0 0 0
系统可以使用最大阈值作为丢弃阈值,即 Drop-Th2
2. 调整 service-policy
policy-map TEST_POLICY
class class-default
bandwidth percent 100
queue-buffers ratio 100
3850#show run interface gigabitEthernet1/0/1
Current configuration : 67 bytes
!
interface GigabitEthernet1/0/1
service-policy output TEST_POLICY
end
3850#show platform qos queue config gigabitEthernet 2/0/1
DATA Port:21 GPN:65 AFD:Disabled QoSMap:1 HW Queues: 168 - 175
DrainFast:Disabled PortSoftStart:0 - 900
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 4 0 8 1200 7 800 3 300 2 2400 <-- queue 0 gets all the buffer.
丢包减少 - 对于相同的流量突增,丢弃数从 497000 减少到 385064。然而,仍然有下降。之后,
3850#show interfaces gigabitEthernet1/0/1 | include output drop
Input queue: 0/2000/0/0 (size/max/drops/flushes); Total output drops: 385064
3. 丢弃数为零
配置 qos queue-softmax-multiplier 1200 global config 命令。
3850#show platform qos queue config gigabitEthernet 1/0/1
DATA Port:21 GPN:65 AFD:Disabled QoSMap:1 HW Queues: 168 - 175
DrainFast:Disabled PortSoftStart:0 - 900
----------------------------------------------------------
DTS Hardmax Softmax PortSMin GlblSMin PortStEnd
--- -------- -------- -------- --------- ---------
0 1 4 0 8 10000 7 800 3 300 2 10000
3850#show interfaces gigabitEthernet1/0/1 | in output drop
Input queue: 0/2000/0/0 (size/max/drops/flushes); Total output drops: 0
六、结论
每个平台都有自己的使用极限和适用场景,没事儿别瞎用、瞎调。