# DNN 和切片的带宽控制功能 ## 需求分析: 依据《面向垂直行业的边缘N4解耦UPF测试规范v2.0.docx》中测试案例11.13.1和11.13.2的要求,当 UE 访问 DNN(或当 UE 使用目标切片发起请求), UPF 能支持对不同 DNN (或不同切片里)的业务通信进行带宽控制、流量统计的功能。 ## vpp 满足度测试: 1. 准备环境: ![topology0](../../../_static/DNN_band_control_topology.png) 启动 VPP 并配置接口 ip : ```bash set int ip address GigabitEthernet0/4/0 10.0.1.166/24 set int state GigabitEthernet0/4/0 up set int ip address GigabitEthernet0/5/0 10.0.2.40/24 set int state GigabitEthernet0/5/0 up ``` 配置 linux 1 和 linux 2 两台机器的路由表: ```bash # linux 1 route add -net 10.1.3.0/24 gw 10.1.1.1 # linux 2 route add -net 10.1.1.0/24 gw 10.1.3.1 ``` 测试 linux 1 到 linux 2 之间链路是否可以正常通信: ![image-test_ping](../../../_static/DNN_band_control_test_ping.png) 2. 测试 1. 使用 scp 命令从 linux 1 上传文件到 linux 2 ,测试带宽控制是否生效: ![image-test1_topology](../../../_static/DNN_band_control_test1_topology.png) 在 linux 1 上测试 scp 命令未限速前的速度: ![image-test1_scp1](../../../_static/DNN_band_control_test1_scp1.png) 配置 VPP 接口带宽限速: ```bash # 1 配置限速规则 policer configure policer name policy1 cir 800 cb 9000 rate kbps round closest type 1r2c conform-action transmit exceed-action drop # 2 配置分类表 classify table classify table mask l3 ip4 src/24 # table index: 0 # 3 配置分类表中的命中规则 classify session ,该规则关联限速规则 policy1 classify session policer-hit-next policy1 exceed-color table-index 0 match l3 ip4 src 10.0.1.0 # 4 关联接口和分类表(1->2方向的包,节点流转是 G4 -> input -> output -> G5 , Qos 配置节点在 input 之后,所以必须关联 G4 接口才能生效。) set policer classify interface GigabitEthernet0/4/0 ip4-table 0 # 第 2 和 3 步也可换成如下两个配置: classify table mask l3 ip4 dst/24 classify session policer-hit-next policy1 exceed-color table-index 0 match l3 ip4 dst 10.0.2.0 ``` 在 linux 1 上测试 scp 命令,查看带宽控制是否生效: 上传文件,带宽明显受限下降: ![image-test1_scp2](../../../_static/DNN_band_control_test1_scp2.png) trace 查看节点流转,数据包在分类表有命中配置的规则: ```bash trace add dpdk-input 10 sh trace ``` ![image-test1_trace](../../../_static/DNN_band_control_test1_trace.png) 也可通过分类表查看包命中个数: ```bash sh classify tables verbose ``` ![image-test1_hit](../../../_static/DNN_band_control_test1_hit.png) 2. 使用 scp 命令下载 linux 2 的文件到 linux 1 中,测试带宽控制是否生效: ![image-test2_topology](../../../_static/DNN_band_control_test2_topology.png) 在 linux 1 上测试 scp 命令未限速前的速度: ![image-test2_scp1](../../../_static/DNN_band_control_test2_scp1.png) 配置 VPP 接口带宽限速: ```bash # 1 配置限速规则 policer configure policer name policy1 cir 800 cb 9000 rate kbps round closest type 1r2c conform-action transmit exceed-action drop # 2 配置分类表 classify table classify table mask l3 ip4 src/24 # table index: 0 # 3 配置分类表中的命中规则 classify session ,该规则关联限速规则 policy1 classify session policer-hit-next policy1 exceed-color table-index 0 match l3 ip4 src 10.0.2.0 # 4 关联接口和分类表(2->1方向的包,节点流转是 G5 -> input -> output -> G4 , Qos 配置节点在 input 之后,所以必须关联 G5 接口才能生效。) set policer classify interface GigabitEthernet0/5/0 ip4-table 0 # 第 2 和 3 步也可换成如下两个配置: classify table mask l3 ip4 dst/24 classify session policer-hit-next policy1 exceed-color table-index 0 match l3 ip4 dst 10.0.1.0 ``` 在 linux 1 上测试 scp 命令,查看带宽控制是否生效: 下载文件,带宽明显受限下降: ![image-test2_scp2](../../../_static/DNN_band_control_test2_scp2.png) trace 查看节点流转,数据包在分类表有命中配置的规则: ```bash trace add dpdk-input 10 sh trace ``` ![image-test2_trace](../../../_static/DNN_band_control_test2_trace.png) 也可通过分类表查看包命中个数: ```bash sh classify tables verbose 3 ``` ![image-test2_hit](../../../_static/DNN_band_control_test2_hit.png) 3. 总结: 目前 vpp 支持基于接口的带宽控制功能,由于原生节点 classify 在 ip-input 节点之后,所以关联网卡时必须关联在数据包入口才能生效;该功能支持网段配置,可以模拟 DNN 和切片的场景。