在运营商与数据中心网络中,我们经常需要对服务器实施精细化限速。传统的接口限速或基于单 IP 的静态策略在面对复杂多出口业务时往往力不从心——例如,你希望“仅对去往中国电信(CT)、中国联通(CNC)、亚太国际或北美方向的流量分别执行不同速率上限”,靠传统接口限速或海量 IP ACL 几乎无法运维。要优雅解决这一需求,我们需要将前几篇介绍的 BGP Community 控制面标签进一步延伸至转发平面,也就是今天的主角:Cisco QPPB 与 Juniper SCU/DCU。
本文将结合多区域实测拓扑,完整演示如何在 Cisco IOS-XE(QPPB) 与 Juniper Junos(SCU/DCU) 双平台上实现基于 BGP Community 的双向精确限速与 iperf3 实测验证。
什么是 QPPB 与 SCU/DCU?为什么不用 ACL?
常规 QoS 策略无法直接读取 BGP 的 AS_PATH 或 Community 属性。如果退而求其次用 ACL 穷举某家运营商或某个大洲的所有公网 IP 段,不仅维护成本极高,几十万条前缀对应的 ACL 还会瞬间耗尽路由器宝贵的 TCAM 硬件表项。
QPPB(QoS Policy Propagation Through the Border Gateway Protocol) 正是为了解决这一痛点而生的机制:路由器在控制面通过 community-list、as-path 或 prefix-list 匹配 BGP 路由,借助 table-map 将分类标记(如 qos-group 或 ip precedence)直接写入 FIB 转发表项;数据面转发数据包时,只需直接读取入站/出站查找命中的 FIB QoS 标记即可执行限速或队列调度,无需任何庞大 ACL。
在 Cisco 平台该机制称为 QPPB,而在 Juniper Junos 平台对应的是 SCU / DCU(Source Class Usage / Destination Class Usage)——两者核心思想完全一致,均是通过路由策略把 BGP 属性映射到转发表分类标签。
多区域实验拓扑与分方向限速 SLA 设计
本实验在 AS-LITTLEWOLF(AS 65000) 中同时部署了 Juniper 接入/骨干(Juniper-Access / Juniper-Backbone)与 Cisco IOS-XE 接入/骨干(Cisco-Access / Cisco-Backbone),分别对接四个模拟区域方向,拓扑架构如下:
AS 65000 针对不同目的/源方向的双向限速 SLA 目标如下:
- CNC 方向(经由 CT 绕转,携带
9929:0与65001:1):双向限速 5 Mbps - CT 方向(Direct XC 直连,携带
65001:1):双向限速 10 Mbps - Asia – Intl 方向(携带
65001:2):双向限速 50 Mbps - NA – Intl 方向(携带
65001:3):双向限速 200 Mbps
工作原理解析:QPPB 与 SCU/DCU 控制面到数据面映射
相比于传统 QoS 的“ACL 匹配 → Class-map → Policy-map → 接口调用”四步模型,基于 BGP 的限速架构额外增加了控制面到 FIB 的标记传播环节:
- Cisco QPPB 六步链路:定义
ip community-list→route-map设置ip qos-group→ BGP 进程挂载table-map写入 CEF/FIB → 接口配置bgp-policy destination/source ip-qos-map激活查询 →class-map匹配qos-group→ 出向接口挂载service-policy output执行 Shaping。 - Juniper SCU/DCU 四步链路:定义
community→policy-statement赋予destination-class与source-class→routing-options forwarding-table export写入 PFE 转发表 → 防火墙过滤规则(firewall family inet filter)按类匹配并调用policer,挂载至forwarding-options output(或接口出方向)。
实战一:在 Cisco IOS-XE 上配置双向 BGP QPPB 限速
首先定义匹配上游区域社区的 ip community-list(本实验中上游路由发来时已携带如下标准 Community,相关上游打标配置已省略):
- 从 CT 收到的路由:
65001:1 - 从 Asia 收到的路由:
65001:2 - 从 NA 收到的路由:
65001:3 - 通过 CT 收到的 CNC 路由:
9929:0(注意由于同时携带65001:1,route-map qppb中必须把cnc排在ct之前!)
1. 定义 Community-List 与有序 Route-Map
ip community-list standard na permit 65001:3 ip community-list standard asia permit 65001:2 ip community-list standard ct permit 65001:1 ip community-list standard cnc permit 9929:0 // 预先定义 community list (路由内的 community 为上游发过来已携带的值) route-map qppb permit 100 ordering-seq 100 match community na set ip qos-group 1 ! route-map qppb permit 110 ordering-seq 110 match community asia set ip qos-group 2 ! route-map qppb permit 115 ordering-seq 115 match community cnc set ip qos-group 4 ! route-map qppb permit 120 ordering-seq 120 match community ct set ip qos-group 3 ! route-map qppb permit 9999 ordering-seq 9999 ! named-ordering-route-map enable
2. 在 BGP 进程挂载 Table-Map 压入 QoS-Group
router bgp 65000 table-map qppb // 调用写好的 route-map,对感兴趣的路由压入 QoS Group,做好标记
3. 配置 Class-Map 与 Policy-Map(MQC Traffic Shaping)
class-map match-all na match qos-group 1 // 匹配预定义好的组( BGP 中的 Table-map 规则里面定义好的组) class-map match-all ct match qos-group 3 class-map match-all asia match qos-group 2 class-map match-all cnc match qos-group 4 ! policy-map traffic-shaping class na shape average 200000000 // 调用 class-map,对指定方向进行限速 class asia shape average 50000000 class ct shape average 10000000 class cnc shape average 5000000
4. 在上行与下行接口激活双向 QPPB(Destination + Source)
由于 shape average 属于出向队列整形(与入向 Policer CIR 不同),必须挂载在流量离开路由器的出接口上;同时必须在流量进入路由器的接口上开启 bgp-policy destination/source ip-qos-map 触发 FIB 查找。如果仅限制服务器出网(Upload)流量,只需在下游入接口开启 destination 匹配,在上游出接口挂载整形策略:
interface GigabitEthernet2 (Upstream) ip address 100.64.0.5 255.255.255.254 (...protocol config ignored) service-policy output traffic-shaping // 在这个接口上调用 shaping policy,实现限速功能 interface GigabitEthernet3 (Downstream) ip address 172.0.2.1 255.255.255.0 (...protocol config ignored) bgp-policy destination ip-qos-map // 为 BGP QPPB 激活接口功能,激活 Upstream 的 shaping policy // 激活的是基于目的地址的匹配,匹配流量去往的目的地。如果是 Policy CIR 则是在该接口 inbound 方向调用 Policy-map
若要同时限制服务器入网(Download)流量,只需对称补充上游入接口的 source 匹配与下游出接口的整形策略(最终实现双向同时限速):
interface GigabitEthernet2 (Upstream) ip address 100.64.0.5 255.255.255.254 (...protocol config ignored) bgp-policy source ip-qos-map // 为 BGP QPPB 激活接口功能,激活 Downstream 的 shaping policy // 激活的是基于源地址的匹配,匹配流量的来源。如果是 Policy CIR 则是在该接口 inbound 方向调用 Policy-map interface GigabitEthernet3 (Downstream) ip address 172.0.2.1 255.255.255.0 (...protocol config ignored) service-policy output traffic-shaping // 在这个接口上调用 shaping policy,实现限速功能
5. Cisco IOS-XE 平台 iperf3 双向实测验证
从 Cisco-Access 下挂的 Server-Silver-A(172.0.2.2) 分别向 CT(100.64.1.2)、CNC(100.64.2.2)、Asia(100.64.3.2)与 NA(100.64.4.2)执行双向 iperf3 测速:
root@localhost:~# iperf3 -c 100.64.1.2 -p 443 -t 5 // 去往 CT 的流量 Connecting to host 100.64.1.2, port 443 [ 5] local 172.0.2.2 port 15888 connected to 100.64.1.2 port 443 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 1.26 MBytes 10.5 Mbits/sec 42 33.9 KBytes [ 5] 1.00-2.00 sec 1.13 MBytes 9.49 Mbits/sec 0 28.3 KBytes [ 5] 2.00-3.00 sec 1.13 MBytes 9.46 Mbits/sec 0 25.5 KBytes [ 5] 3.00-4.00 sec 1.13 MBytes 9.46 Mbits/sec 0 28.3 KBytes [ 5] 4.00-5.00 sec 1.13 MBytes 9.50 Mbits/sec 0 28.3 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.00 sec 5.78 MBytes 9.69 Mbits/sec 42 sender [ 5] 0.00-5.06 sec 5.73 MBytes 9.51 Mbits/sec receiver iperf Done. root@localhost:~# iperf3 -c 100.64.1.2 -p 443 -t 5 -R // 来自于 CT 的流量 Connecting to host 100.64.1.2, port 443 Reverse mode, remote host 100.64.1.2 is sending [ 5] local 172.0.2.2 port 15892 connected to 100.64.1.2 port 443 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 1.24 MBytes 10.4 Mbits/sec [ 5] 1.00-2.00 sec 1.14 MBytes 9.57 Mbits/sec [ 5] 2.00-3.00 sec 1.14 MBytes 9.57 Mbits/sec [ 5] 3.00-4.00 sec 1.14 MBytes 9.57 Mbits/sec [ 5] 4.00-5.00 sec 1.14 MBytes 9.56 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.04 sec 5.86 MBytes 9.76 Mbits/sec 443 sender [ 5] 0.00-5.00 sec 5.80 MBytes 9.74 Mbits/sec receiver
root@localhost:~# iperf3 -c 100.64.2.2 -p 443 -t 5 // 去往 CNC 的流量 Connecting to host 100.64.2.2, port 443 [ 5] local 172.0.2.2 port 22762 connected to 100.64.2.2 port 443 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 739 KBytes 6.05 Mbits/sec 26 67.9 KBytes [ 5] 1.00-2.00 sec 498 KBytes 4.08 Mbits/sec 0 22.6 KBytes [ 5] 2.00-3.00 sec 581 KBytes 4.76 Mbits/sec 0 22.6 KBytes [ 5] 3.00-4.00 sec 602 KBytes 4.94 Mbits/sec 0 28.3 KBytes [ 5] 4.00-5.00 sec 580 KBytes 4.75 Mbits/sec 0 22.6 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.00 sec 2.93 MBytes 4.92 Mbits/sec 26 sender [ 5] 0.00-5.08 sec 2.88 MBytes 4.76 Mbits/sec receiver iperf Done. root@localhost:~# iperf3 -c 100.64.2.2 -p 443 -t 5 -R // 来自于 CNC 的流量 Connecting to host 100.64.2.2, port 443 Reverse mode, remote host 100.64.2.2 is sending [ 5] local 172.0.2.2 port 22766 connected to 100.64.2.2 port 443 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 636 KBytes 5.21 Mbits/sec [ 5] 1.00-2.00 sec 584 KBytes 4.78 Mbits/sec [ 5] 2.00-3.00 sec 584 KBytes 4.79 Mbits/sec [ 5] 3.00-4.00 sec 584 KBytes 4.78 Mbits/sec [ 5] 4.00-5.00 sec 583 KBytes 4.77 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.04 sec 2.95 MBytes 4.92 Mbits/sec 0 sender [ 5] 0.00-5.00 sec 2.90 MBytes 4.87 Mbits/sec receiver
root@localhost:~# iperf3 -c 100.64.3.2 -p 443 -t 5 // 去往 Asia 的流量 Connecting to host 100.64.3.2, port 443 [ 5] local 172.0.2.2 port 46002 connected to 100.64.3.2 port 443 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 6.06 MBytes 50.8 Mbits/sec 2212 110 KBytes [ 5] 1.00-2.00 sec 5.65 MBytes 47.4 Mbits/sec 0 73.5 KBytes [ 5] 2.00-3.00 sec 5.64 MBytes 47.3 Mbits/sec 0 70.7 KBytes [ 5] 3.00-4.00 sec 5.66 MBytes 47.5 Mbits/sec 0 73.5 KBytes [ 5] 4.00-5.00 sec 5.67 MBytes 47.5 Mbits/sec 0 65.0 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.00 sec 28.7 MBytes 48.1 Mbits/sec 2212 sender [ 5] 0.00-5.07 sec 28.6 MBytes 47.4 Mbits/sec receiver iperf Done. root@localhost:~# iperf3 -c 100.64.3.2 -p 443 -t 5 -R // 来自于 Asia 的流量 Connecting to host 100.64.3.2, port 443 Reverse mode, remote host 100.64.3.2 is sending [ 5] local 172.0.2.2 port 46006 connected to 100.64.3.2 port 443 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 6.03 MBytes 50.6 Mbits/sec [ 5] 1.00-2.00 sec 5.70 MBytes 47.8 Mbits/sec [ 5] 2.00-3.00 sec 5.70 MBytes 47.8 Mbits/sec [ 5] 3.00-4.00 sec 5.70 MBytes 47.8 Mbits/sec [ 5] 4.00-5.00 sec 5.70 MBytes 47.8 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.04 sec 28.9 MBytes 48.1 Mbits/sec 835 sender [ 5] 0.00-5.00 sec 28.8 MBytes 48.4 Mbits/sec receiver
root@localhost:~# iperf3 -c 100.64.4.2 -p 443 -t 5 // 去往 NA 的流量 Connecting to host 100.64.4.2, port 443 [ 5] local 172.0.2.2 port 18818 connected to 100.64.4.2 port 443 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 24.3 MBytes 204 Mbits/sec 1233 407 KBytes [ 5] 1.00-2.00 sec 22.9 MBytes 192 Mbits/sec 71 450 KBytes [ 5] 2.00-3.00 sec 22.5 MBytes 189 Mbits/sec 192 229 KBytes [ 5] 3.00-4.00 sec 22.9 MBytes 192 Mbits/sec 0 283 KBytes [ 5] 4.00-5.00 sec 22.8 MBytes 191 Mbits/sec 0 272 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.00 sec 115 MBytes 193 Mbits/sec 1496 sender [ 5] 0.00-5.04 sec 115 MBytes 192 Mbits/sec receiver iperf Done. root@localhost:~# iperf3 -c 100.64.4.2 -p 443 -t 5 -R // 来自于 NA 的流量 Connecting to host 100.64.4.2, port 443 Reverse mode, remote host 100.64.4.2 is sending [ 5] local 172.0.2.2 port 18822 connected to 100.64.4.2 port 443 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 23.9 MBytes 201 Mbits/sec [ 5] 1.00-2.00 sec 22.8 MBytes 191 Mbits/sec [ 5] 2.00-3.00 sec 22.8 MBytes 191 Mbits/sec [ 5] 3.00-4.00 sec 22.8 MBytes 191 Mbits/sec [ 5] 4.00-5.00 sec 22.8 MBytes 191 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.04 sec 116 MBytes 193 Mbits/sec 19 sender [ 5] 0.00-5.00 sec 115 MBytes 193 Mbits/sec receiver
四组方向上下行速率(9.5–9.7M / 4.8–4.9M / 47.4–48.4M / 192–193M)全部贴合 SLA 整形阈值且几乎零重传。下面转向 Juniper 平台配置 SCU/DCU。
实战二:在 Juniper Junos 上通过 SCU/DCU 实现相同限速
相比于 Cisco IOS-XE,Juniper Junos 的调用层次更加直观:先通过转发表导出策略(forwarding-table export)将 Community 映射为 destination-class 与 source-class,再用无状态防火墙过滤器匹配并触发限速 Policer。
1. 定义 Community 并注入转发表(SCU/DCU)
root@access> show policy-options...
community import-cnc-via-ct members [ 65001:1 9929:0 ];
community import-from-asia members 65001:2;
community import-from-ct members 65001:1;
community import-from-na members 65001:3;
// 预先定义 community list ( 路由内的 community 为上游发过来已携带的值 )
root@access> show policy-options policy-statement export-dcu-scu | no-more
term cnc {
from community import-cnc-via-ct;
then {
destination-class cnc-dcu; // 将该路由定义 Destination Class,用于匹配去往该区域的流量
source-class cnc-scu; // 将该路由定义 Source Class,用于匹配来自于该区域的流量
next policy; // 匹配上后,跳到下一个 policy ( 该处省略,lab 中为负载均衡 policy )
}
}
term ct {
from community import-from-ct;
then {
destination-class ct-dcu;
source-class ct-scu;
next policy;
}
}
term asia {
from community import-from-asia;
then {
destination-class asia-dcu;
source-class asia-scu;
next policy;
}
}
term na {
from community import-from-na;
then {
destination-class na-dcu;
source-class na-scu;
next policy;
}
}
term last {
then next policy;
}
root@access> show configuration routing-options forwarding-table
export [ export-dcu-scu lb-export ];
// 对转发表应用规则,压入 Source Class + Destination Class,为之后限速做准备
2. 创建限速 Policer 与 Firewall Filter 调用
root@access> show firewall policer...
policer cnc-via-ct {
if-exceeding {
bandwidth-limit 5m;
burst-size-limit 1m;
}
then discard;
}
policer asia {
if-exceeding {
bandwidth-limit 50m;
burst-size-limit 1m;
}
then discard;
}
policer na {
if-exceeding {
bandwidth-limit 200m;
burst-size-limit 1m;
}
then discard;
}
policer ct {
if-exceeding {
bandwidth-limit 10m;
burst-size-limit 1m;
}
then discard;
}
接着编写防火墙规则按 destination-class(去往目标区域,限定源网段 172.0.0.0/24)与 source-class(来自源区域)分别调用对应 Policer,并应用到全局 forwarding-options 的出方向(或实机接口的 output 方向):
root@access> show firewall family inet filter scu-dcu-shaping | no-more
term dest:na {
from {
destination-class na-dcu; // 匹配去往 NA 的流量
source-address {
172.0.0.0/24;
}
}
then policer na; // 调用限速 Policer
}
term dest:asia {
from {
destination-class asia-dcu;
source-address {
172.0.0.0/24;
}
}
then policer asia;
}
term dest:ct {
from {
destination-class ct-dcu;
source-address {
172.0.0.0/24;
}
}
then policer ct;
}
term dest:cnc {
from {
destination-class cnc-dcu;
source-address {
172.0.0.0/24;
}
}
then policer cnc-via-ct;
}
term src:cnc {
from {
source-class cnc-scu; // 匹配来自于 CNC 的流量
}
then policer cnc-via-ct; // 调用 Policer
}
term src:ct {
from {
source-class ct-scu;
}
then policer ct;
}
term src:asia {
from {
source-class asia-scu;
}
then policer asia;
}
term src:na {
from {
source-class na-scu;
}
then policer na;
}
term last {
then accept;
}
root@access> show configuration forwarding-options
family inet {
filter {
output scu-dcu-shaping;
}
}
// 将该防火墙规则应用到全局的 forarding-option 上面。
// Juniper 也支持将策略应用于接口,但是 SCP/DCP 必须应用于 Output 方向,Input 方向会不起作用。
// Lab 模拟环境内应用于接口有 bug,所以这里决定应用于 forwarding-options,实机中两种方式均可以。
3. Juniper Junos 平台 iperf3 双向实测验证
从 Juniper-Access 下挂的 Server-Platinum-A(172.0.0.2) 执行相同的四组双向 iperf3 测速:
root@localhost:~# iperf3 -c 100.64.1.2 -p 443 -t 5 // 去往 CT 的流量 Connecting to host 100.64.1.2, port 443 [ 5] local 172.0.0.2 port 14538 connected to 100.64.1.2 port 443 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 1.79 MBytes 15.0 Mbits/sec 708 50.9 KBytes [ 5] 1.00-2.00 sec 1.22 MBytes 10.2 Mbits/sec 202 17.0 KBytes [ 5] 2.00-3.00 sec 1.19 MBytes 9.99 Mbits/sec 157 33.9 KBytes [ 5] 3.00-4.00 sec 1.16 MBytes 9.77 Mbits/sec 47 14.1 KBytes [ 5] 4.00-5.00 sec 1.12 MBytes 9.37 Mbits/sec 86 25.5 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.00 sec 6.48 MBytes 10.9 Mbits/sec 1200 sender [ 5] 0.00-5.04 sec 6.42 MBytes 10.7 Mbits/sec receiver iperf Done. root@localhost:~# iperf3 -c 100.64.1.2 -p 443 -t 5 -R // 来自于 CT 的流量 Connecting to host 100.64.1.2, port 443 Reverse mode, remote host 100.64.1.2 is sending [ 5] local 172.0.0.2 port 14542 connected to 100.64.1.2 port 443 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 1.73 MBytes 14.5 Mbits/sec [ 5] 1.00-2.00 sec 1.28 MBytes 10.7 Mbits/sec [ 5] 2.00-3.00 sec 1.15 MBytes 9.65 Mbits/sec [ 5] 3.00-4.00 sec 1.16 MBytes 9.73 Mbits/sec [ 5] 4.00-5.00 sec 1.13 MBytes 9.44 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.04 sec 6.53 MBytes 10.9 Mbits/sec 1148 sender [ 5] 0.00-5.00 sec 6.45 MBytes 10.8 Mbits/sec receiver
root@localhost:~# iperf3 -c 100.64.2.2 -p 443 -t 5 // 去往 CNC 的流量 Connecting to host 100.64.2.2, port 443 [ 5] local 172.0.0.2 port 18480 connected to 100.64.2.2 port 443 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 1.10 MBytes 9.23 Mbits/sec 510 11.3 KBytes [ 5] 1.00-2.00 sec 421 KBytes 3.45 Mbits/sec 250 56.6 KBytes [ 5] 2.00-3.00 sec 619 KBytes 5.07 Mbits/sec 47 22.6 KBytes [ 5] 3.00-4.00 sec 577 KBytes 4.73 Mbits/sec 46 22.6 KBytes [ 5] 4.00-5.00 sec 568 KBytes 4.66 Mbits/sec 69 25.5 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.00 sec 3.24 MBytes 5.43 Mbits/sec 922 sender [ 5] 0.00-5.05 sec 3.21 MBytes 5.33 Mbits/sec receiver iperf Done. root@localhost:~# iperf3 -c 100.64.2.2 -p 443 -t 5 -R // 来自于 CNC 的流量 Connecting to host 100.64.2.2, port 443 Reverse mode, remote host 100.64.2.2 is sending [ 5] local 172.0.0.2 port 18484 connected to 100.64.2.2 port 443 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 834 KBytes 6.83 Mbits/sec [ 5] 1.00-2.00 sec 699 KBytes 5.72 Mbits/sec [ 5] 2.00-3.00 sec 467 KBytes 3.82 Mbits/sec [ 5] 3.00-4.00 sec 718 KBytes 5.89 Mbits/sec [ 5] 4.00-5.00 sec 595 KBytes 4.88 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.04 sec 3.31 MBytes 5.52 Mbits/sec 966 sender [ 5] 0.00-5.00 sec 3.24 MBytes 5.43 Mbits/sec receiver
root@localhost:~# iperf3 -c 100.64.3.2 -p 443 -t 5 // 去往 Asia 的流量 Connecting to host 100.64.3.2, port 443 [ 5] local 172.0.0.2 port 58888 connected to 100.64.3.2 port 443 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 6.48 MBytes 54.3 Mbits/sec 1969 481 KBytes [ 5] 1.00-2.00 sec 5.55 MBytes 46.6 Mbits/sec 2273 997 KBytes [ 5] 2.00-3.00 sec 5.21 MBytes 43.7 Mbits/sec 2681 417 KBytes [ 5] 3.00-4.00 sec 4.80 MBytes 40.2 Mbits/sec 2244 625 KBytes [ 5] 4.00-5.00 sec 4.58 MBytes 38.4 Mbits/sec 1464 533 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.00 sec 26.6 MBytes 44.6 Mbits/sec 10631 sender [ 5] 0.00-5.04 sec 25.9 MBytes 43.1 Mbits/sec receiver iperf Done. root@localhost:~# iperf3 -c 100.64.3.2 -p 443 -t 5 -R // 来自于 Asia 的流量 Connecting to host 100.64.3.2, port 443 Reverse mode, remote host 100.64.3.2 is sending [ 5] local 172.0.0.2 port 58892 connected to 100.64.3.2 port 443 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 4.99 MBytes 41.8 Mbits/sec [ 5] 1.00-2.00 sec 5.78 MBytes 48.5 Mbits/sec [ 5] 2.00-3.00 sec 5.03 MBytes 42.2 Mbits/sec [ 5] 3.00-4.00 sec 5.33 MBytes 44.7 Mbits/sec [ 5] 4.00-5.00 sec 4.43 MBytes 37.2 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.04 sec 26.5 MBytes 44.2 Mbits/sec 10458 sender [ 5] 0.00-5.00 sec 25.6 MBytes 42.9 Mbits/sec receiver
root@localhost:~# iperf3 -c 100.64.4.2 -p 443 -t 5 -b 400M // 去往 NA 的流量 Connecting to host 100.64.4.2, port 443 [ 5] local 172.0.0.2 port 50024 connected to 100.64.4.2 port 443 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 19.8 MBytes 166 Mbits/sec 3853 452 KBytes [ 5] 1.00-2.00 sec 18.9 MBytes 159 Mbits/sec 3799 314 KBytes [ 5] 2.00-3.00 sec 22.9 MBytes 192 Mbits/sec 1522 123 KBytes [ 5] 3.00-4.00 sec 23.2 MBytes 194 Mbits/sec 1132 478 KBytes [ 5] 4.00-5.00 sec 23.3 MBytes 195 Mbits/sec 2893 574 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.00 sec 108 MBytes 181 Mbits/sec 13199 sender [ 5] 0.00-5.03 sec 107 MBytes 179 Mbits/sec receiver iperf Done. root@localhost:~# iperf3 -c 100.64.4.2 -p 443 -t 5 -b 400M -R // 来自于 NA 的流量 Connecting to host 100.64.4.2, port 443 Reverse mode, remote host 100.64.4.2 is sending [ 5] local 172.0.0.2 port 50028 connected to 100.64.4.2 port 443 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 11.1 MBytes 93.1 Mbits/sec [ 5] 1.00-2.00 sec 23.0 MBytes 193 Mbits/sec [ 5] 2.00-3.00 sec 23.0 MBytes 193 Mbits/sec [ 5] 3.00-4.00 sec 23.1 MBytes 194 Mbits/sec [ 5] 4.00-5.00 sec 23.2 MBytes 195 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-5.04 sec 104 MBytes 173 Mbits/sec 14906 sender [ 5] 0.00-5.00 sec 103 MBytes 174 Mbits/sec receiver
Policer CIR vs Traffic Shaping 实测差异与参考资料
两组平台实测均完美达成目标。值得注意的是,我们在 Juniper 实验中直接使用了 policer(CIR 硬限速丢包)而非 class-of-service Traffic Shaping(队列缓存整形),当 TCP 流试图突破阈值时超额报文会被直接丢弃,因此 iperf3 统计到的 Retr 重传数明显多于 Cisco 的 shape average。实际生产环境中可根据业务对时延与丢包的敏感度灵活选用。
这个看起来是针对一个用户或者一个端口的限速,不过我印象中记得运营商是针对per IP 进行的,这个也能实现吗?
一般会使用定制设备来实现,或者其他定制方案