当前位置:网站首页>【网络通信 -- WebRTC】WebRTC 源码分析 -- PacingController 相关知识点补充
【网络通信 -- WebRTC】WebRTC 源码分析 -- PacingController 相关知识点补充
2022-06-23 16:17:00 【奋斗企鹅CopperSun】
【网络通信 -- WebRTC】WebRTC 源码分析 -- PacingController 相关知识点补充
【1】漏桶限流算法简介
漏桶算法 (Leaky Bucket) 是网络中流量整形 (Traffic Shaping) 或速率限制 (Rate Limiting) 时经常使用的一种算法,其主要目的是控制数据注入到网络的速率,平滑网络上的突发流量;
如图所示,把请求比作是水,水来了都先放进桶里,并以限定出水的速度,当水来得过猛而出水不够快时就会导致水直接溢出,即拒绝服务;
漏桶限流算法 -- 主要的属性字段
- 1. 处理请求的速率 (rate),该值代表多久处理一个请求
- 2. 桶的最大容量 (capacity),该值代表最多允许多少个请求排队
- 3. 桶中最后一个排队请求被处理的时间(last)
- 1) 当有新请求进来的时候,可以计算出新请求需要被处理的时间,last + rate
- 2) 根据 last、当前时间(t) 以及速率(rate) 计算当前还有多少个请求等待被处理,waitRequests = (last - t) / rate
漏桶限流算法 -- 请求实际的被处理的时间计算方法
- 1. 计算当前时间距离上次被处理时间的间隔
- 2. 与 rate 进行比较,计算与 rate 的差值,然后补全该差值
delta = 当前时间(t) - last
last = 当前时间(t) + (rate - delta)漏桶限流算法 -- "桶" 满的判断方法
- 根据当前时间(t),和桶中排队的最后一个请求被处理的时间(last)之间的差值,再除以速率(rate),计算出正在等待被处理的请求数量,然后和桶的最大容量(capacity)进行比较即可
参考与致谢
本博客为博主学习笔记,同时参考了网上众博主的博文以及相关专业书籍,在此表示感谢,本文若存在不足之处,请批评指正。
边栏推荐
- The official Chinese course of zero foundation introduction jetpack compose is coming
- Image saving: torchvision utils. save_ image(img, imgPath)
- Coatnet: marrying revolution and attention for all data sizes
- 如何选择示波器?这10点一定要考虑!
- How to select an oscilloscope? These 10 points must be considered!
- 移动云共筑信创云能力底座,助力中国信创产业发展
- Implementation of network data transmission by golang Gob
- ABP framework - data access infrastructure (Part 2)
- Mobile cloud jointly builds the capability base of information innovation cloud and helps the development of China's information innovation industry
- Golang对JSON文件的写操作
猜你喜欢

Another breakthrough! Alibaba cloud enters the Gartner cloud AI developer service Challenger quadrant

The company recruited a tester with five years' experience and saw the real test ceiling

Tensorrt Paser loading onnx inference use

How to make sales management more efficient?

ASEMI快恢复二极管RS1M、US1M和US1G能相互代换吗

亚朵更新招股书:继续推进纳斯达克上市,已提前“套现”2060万元
![Leetcode: interview question 08.13 Stacking bin [top-down DFS + memory or bottom-up sorting + DP]](/img/22/220e802da7543c2b14b7057e4458b7.png)
Leetcode: interview question 08.13 Stacking bin [top-down DFS + memory or bottom-up sorting + DP]

公司招了个五年经验的测试员,见识到了真正的测试天花板

2022九峰小学(光谷第二十一小学)生源摸底

The evolution of social structure and capital system brought about by the yuan universe
随机推荐
聚焦:ZK-SNARK 技术
Golang write file code example
手机开户股票开户需要多久?在线开户安全么?
Tupu software builds smart city with lightweight modeling
[untitled] Application of laser welding in medical treatment
ABP framework - data access infrastructure (Part 2)
元宇宙带来的社会结构和资本制度演变
你女朋友也能读懂的LAMP架构
2022 Jiufeng primary school (Optics Valley No. 21 primary school) student source survey
Intel arc A380 graphics card message summary: the entry-level price products of running point and bright driving need to be optimized
接口的所有权之争
Golang对JSON文件的写操作
Asemi ultrafast recovery diode es1j parameters, es1j package, es1j specification
Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 2)
Network remote access raspberry pie (VNC viewer)
Elk log collection system deployment
How can the points mall make profits
VGg download (.Net file and imagenet-vgg-verydeep-19)
Focus: zk-snark Technology
右腿驱动电路原理?心电采集必备,有仿真文件!