基于UDP传输协议的实现分析之流量和拥塞控制
UDP的概念
UDP 是User Datagram Protocol的简称, 中文名是用户数据报协议,是OSI(Open System Interconnection,开放式系统互联) 参考模型中一种无连接的传输层协议,提供面向事务的简单不可靠信息传送服务,IETF RFC 768是UDP的正式规范。UDP在IP报文的协议号是17。
流量控制
对于一个带宽1Gbps, RTT为100ms的网络来说
BDP=1,000,000,000*0.1/8=12,500,000字节=12207K=12M
传统TCP接收窗口大小=65535byte=64K, 显然满足不了
udt使用包大小1500byte, 默认接口窗口大小为8192, 因此
接收窗口的大小为=1500*8192=12,288,000字节=12000K=11.7M
因此, 可以看到udt的默认设置已经足够.
Congestion Control(拥塞控制)
1. 两个重要的参数:
congestion window size and the inter-packet sending interval
2. 主要的接口
1) init: when the UDT socket is connected.
2) close: when the UDT socket is closed.
3) onACK: when ACK is received.
4) onLOSS: when NACK is received.
5) onTimeout: when timeout occurs.
6) onPktSent: when a data packet is sent.
7) onPktRecv: when a data packet is received.
3. udt的拥塞算法:
On ACK packet received:
1) If the current status is in the slow start phase, set the
congestion window size to the product of packet arrival rate and
(RTT + SYN). Slow Start ends. Stop.
2) Set the congestion window size (CWND) to: CWND = A * (RTT + SYN) +16.
3) The number of sent packets to be increased in the next SYN period
(inc) is calculated as:
if (B <= C)
inc = 1/PS;
else
inc = max(10^(ceil(log10((B-C)*PS*8))) * Beta/PS, 1/PS);
where B is the estimated link capacity and C is the current
sending speed. All are counted as packets per second. PS is the
fixed size of UDT packet counted in bytes. Beta is a constant
value of 0.0000015.
4) The SND period is updated as:
SND = (SND * SYN) / (SND * inc + SYN).
Java代码
复制代码代码如下:strong /strong1.Java代码
2./
3.publicvoidonACK(longackSeqno){
4.//increasewindowduringslowstart
5.if(slowStartPhase){
6.congestionwindowsize+=ackSeqno-lastAckSeqNumber;
7.lastAckSeqNumber=ackSeqno;
8.//butnotbeyondamaximumsize
9.if(congestionwindowsizesession.getFlowWindowSize()){
10.slowStartPhase=false;
11.if(packetArrivalRate0){
12.packetSendingPeriod=1000000.0/packetArrivalRate;
13.}
14.else{
15.packetSendingPeriod=(double)congestionWindowSize/(roundTripTime+Util.getSYNTimeD());
16.}
17.}
18.
19.}else{
20.//1.ifitisnotinslowstartphase,setthecongestionwindowsize
21.//totheproductofpacketarrivalrateand(rtt+SYN)
22.doubleA=packetArrivalRate/1000000.0(roundTripTime+Util.getSYNTimeD());
23.congestionWindowSize=(long)A+16;
24.if(logger.isLoggable(Level.FINER)){
25.logger.finer("receiverate"+packetArrivalRate+"rtt"+roundTripTime+"settowindowsize:"+(A+16));
26.}
27.}
28.
29.//norateincreaseduringslowstart
30.if(slowStartPhase)return;
31.
32.//norateincrease"immediately"afteraNAK
33.if(loss){
34.loss=false;
35.return;
36.}
37.
38.//4.computetheincreaseinsentpacketsforthenextSYNperiod
39.doublenumOfIncreasingPacket=computeNumOfIncreasingPacket();
40.
41.//5.updatethesendperiod
42.doublefactor=Util.getSYNTimeD()/(packetSendingPeriodnumOfIncreasingPacket+Util.getSYNTimeD());
43.packetSendingPeriod=factorpacketSendingPeriod;
44.//packetSendingPeriod=0.995*packetSendingPeriod;
45.
46.statistics.setSendPeriod(packetSendingPeriod);
47.}
<><>>>
On NAK packet received:
1) If it is in slow start phase, set inter-packet interval to
1/recvrate. Slow start ends. Stop.
2) If this NAK starts a new congestion period, increase inter-packet
interval (snd) to snd = snd * 1.125; Update AvgNAKNum, reset
NAKCount to 1, and compute DecRandom to a random (average
distribution) number between 1 and AvgNAKNum. Update LastDecSeq.
Stop.
3) If DecCount <= 5, and NAKCount == DecCount * DecRandom:
a. Update SND period: SND = SND * 1.125;
b. Increase DecCount by 1;
c. Record the current largest sent sequence number (LastDecSeq).
Java代码
复制代码代码如下: 1./(non-Javadoc)
2.@seeudt.CongestionControl#onNAK(java.util.List)
3./
4.publicvoidonLoss(ListIntegerlossInfo){
5.loss=true;
6.longfirstBiggestlossSeqNo=lossInfo.get(0);
7.nACKCount++;
8./1)Ifitisinslowstartphase,setinter-packetintervalto
9.1/recvrate.Slowstartends.Stop./
10.if(slowStartPhase){
11.if(packetArrivalRate0){
12.packetSendingPeriod=100000.0/packetArrivalRate;
13.}
14.else{
15.packetSendingPeriod=congestionWindowSize/(roundTripTime+Util.getSYNTime());
16.}
17.slowStartPhase=false;
18.return;
19.}
20.
21.longcurrentMaxSequenceNumber=session.getSocket().getSender().getCurrentSequenceNumber();
22.//2)IfthisNAKstartsanewcongestionepoch
23.if(firstBiggestlossSeqNolastDecreaseSeqNo){
24.//-increaseinter-packetinterval
25.packetSendingPeriod=Math.ceil(packetSendingPeriod1.125);
26.//-UpdateAvgNAKNum(theaveragenumberofNAKspercongestion)
27.averageNACKNum=(int)Math.ceil(averageNACKNum0.875+nACKCount0.125);
28.//-resetNAKCountandDecCountto1,
29.nACKCount=1;
30.decCount=1;
31./-computeDecRandomtoarandom(averagedistribution)numberbetween1andAvgNAKNum/
32.decreaseRandom=(int)Math.ceil((averageNACKNum-1)Math.random()+1);
33.//-UpdateLastDecSeq
34.lastDecreaseSeqNo=currentMaxSequenceNumber;
35.//-Stop.
36.}
37.//3)IfDecCount=5,andNAKCount==DecCountDecRandom:
38.elseif(decCount=5nACKCount==decCountdecreaseRandom){
39.//a.UpdateSNDperiod:SNDSND=SND1.125;
40.packetSendingPeriod=Math.ceil(packetSendingPeriod1.125);
41.//b.IncreaseDecCountby1;
42.decCount++;
43.//c.Recordthecurrentlargestsentsequencenumber(LastDecSeq).
44.lastDecreaseSeqNo=currentMaxSequenceNumber;
45.}
46.
47.statistics.setSendPeriod(packetSendingPeriod);
48.return;
49.}
<>>><<&&
以上就是基于UDP传输协议的流量和拥塞控制的代码,希望能帮到大家,谢谢阅读。
推荐系统
windows11中文版镜像 微软win11正式版简体中文GHOST ISO镜像64位系统下载
语言:中文版系统大小:5.31GB系统类型:Win11windows11中文版镜像 微软win11正式版简体中文GHOST ISO镜像64位系统下载,微软win11发布快大半年了,其中做了很多次补丁和修复一些BUG,比之前的版本有一些功能上的调整,目前已经升级到最新版本的镜像系统,并且优化了自动激活,永久使用。windows11中文版镜像国内镜像下载地址微软windows11正式版镜像 介绍:1、对函数算法进行了一定程度的简化和优化
微软windows11正式版GHOST ISO镜像 win11下载 国内最新版渠道下载
语言:中文版系统大小:5.31GB系统类型:Win11微软windows11正式版GHOST ISO镜像 win11下载 国内最新版渠道下载,微软2022年正式推出了win11系统,很多人迫不及待的要体验,本站提供了最新版的微软Windows11正式版系统下载,微软windows11正式版镜像 是一款功能超级强大的装机系统,是微软方面全新推出的装机系统,这款系统可以通过pe直接的完成安装,对此系统感兴趣,想要使用的用户们就快来下载
微软windows11系统下载 微软原版 Ghost win11 X64 正式版ISO镜像文件
语言:中文版系统大小:0MB系统类型:Win11微软Ghost win11 正式版镜像文件是一款由微软方面推出的优秀全新装机系统,这款系统的新功能非常多,用户们能够在这里体验到最富有人性化的设计等,且全新的柔软界面,看起来非常的舒服~微软Ghost win11 正式版镜像文件介绍:1、与各种硬件设备兼容。 更好地完成用户安装并有效地使用。2、稳定使用蓝屏,系统不再兼容,更能享受无缝的系统服务。3、为
雨林木风Windows11专业版 Ghost Win11官方正式版 (22H2) 系统下载
语言:中文版系统大小:4.75GB系统类型:雨林木风Windows11专业版 Ghost Win11官方正式版 (22H2) 系统下载在系统方面技术积累雄厚深耕多年,打造了国内重装系统行业的雨林木风品牌,其系统口碑得到许多人认可,积累了广大的用户群体,雨林木风是一款稳定流畅的系统,一直以来都以用户为中心,是由雨林木风团队推出的Windows11国内镜像版,基于国内用户的习惯,做了系统性能的优化,采用了新的系统
雨林木风win7旗舰版系统下载 win7 32位旗舰版 GHOST 免激活镜像ISO
语言:中文版系统大小:5.91GB系统类型:Win7雨林木风win7旗舰版系统下载 win7 32位旗舰版 GHOST 免激活镜像ISO在系统方面技术积累雄厚深耕多年,加固了系统安全策略,雨林木风win7旗舰版系统在家用办公上跑分表现都是非常优秀,完美的兼容各种硬件和软件,运行环境安全可靠稳定。win7 32位旗舰装机版 v2019 05能够帮助用户们进行系统的一键安装、快速装机等,系统中的内容全面,能够为广大用户
番茄花园Ghost Win7 x64 SP1稳定装机版2022年7月(64位) 高速下载
语言:中文版系统大小:3.91GB系统类型:Win7欢迎使用 番茄花园 Ghost Win7 x64 SP1 2022.07 极速装机版 专业装机版具有更安全、更稳定、更人性化等特点。集成最常用的装机软件,集成最全面的硬件驱动,精心挑选的系统维护工具,加上独有人性化的设计。是电脑城、个人、公司快速装机之首选!拥有此系统
番茄花园 Windows 10 极速企业版 版本1903 2022年7月(32位) ISO镜像快速下载
语言:中文版系统大小:3.98GB系统类型:Win10番茄花园 Windows 10 32位极速企业版 v2022年7月 一、系统主要特点: 使用微软Win10正式发布的企业TLSB版制作; 安装过程全自动无人值守,无需输入序列号,全自动设置; 安装完成后使用Administrator账户直接登录系统,无需手动设置账号。 安装过程中自动激活
新萝卜家园电脑城专用系统 Windows10 x86 企业版 版本1507 2022年7月(32位) ISO镜像高速下载
语言:中文版系统大小:3.98GB系统类型:Win10新萝卜家园电脑城专用系统 Windows10 x86企业版 2022年7月 一、系统主要特点: 使用微软Win10正式发布的企业TLSB版制作; 安装过程全自动无人值守,无需输入序列号,全自动设置; 安装完成后使用Administrator账户直接登录系统,无需手动设置账号。 安装过程
热门系统
- 1华硕笔记本&台式机专用系统 GhostWin7 32位正式旗舰版2018年8月(32位)ISO镜像下载
- 2深度技术 Windows 10 x86 企业版 电脑城装机版2018年10月(32位) ISO镜像免费下载
- 3电脑公司 装机专用系统Windows10 x86喜迎国庆 企业版2020年10月(32位) ISO镜像快速下载
- 4雨林木风 Ghost Win7 SP1 装机版 2020年4月(32位) 提供下载
- 5深度技术 Windows 10 x86 企业版 六一节 电脑城装机版 版本1903 2022年6月(32位) ISO镜像免费下载
- 6深度技术 Windows 10 x64 企业版 电脑城装机版2021年1月(64位) 高速下载
- 7新萝卜家园电脑城专用系统 Windows10 x64 企业版2019年10月(64位) ISO镜像免费下载
- 8新萝卜家园 GhostWin7 SP1 最新电脑城极速装机版2018年8月(32位)ISO镜像下载
- 9电脑公司Ghost Win8.1 x32 精选纯净版2022年5月(免激活) ISO镜像高速下载
- 10新萝卜家园Ghost Win8.1 X32 最新纯净版2018年05(自动激活) ISO镜像免费下载
热门文章
- 1迅雷云播“手机看片神器”使用教程(随时随地秒速离线云播放)
- 2微信公众号怎么年审? 微信公众号年审流程及所需材料介绍
- 3Win10怎么设置网络按流量计费 Win10网络设置流量收费教程
- 4i7 6700主频是多少 i7-6700参数详解
- 5Steam提示“需要在线进行更新,请确认您的网络连接正常”怎么办?
- 6win7蓝屏代码7f指什 怎么解决 很严重
- 7安卓手机安装运行win7系统教程 安卓手机装win7系统教程
- 8aoc一体机电脑win10改win7系统及bios设置
- 9华硕b460主板装win7系统及bios设置教程 10代CPU安装Win7教程 BIOS设置 U盘启动 完美支持USB驱动
- 10高通骁龙8cx怎么样 高通骁龙8cx处理器详细介绍
常用系统
- 1深度技术 Windows 10 x64 企业版 电脑城装机版2020年5月(64位) 高速下载
- 2深度技术Ghost Win8.1 x32位 特别纯净版2022年6月(免激活) ISO镜像高速下载
- 3华硕笔记本&台式机专用系统 GhostWin7 64位旗舰版2018年5月(64位) 好用下载
- 4电脑公司Ghost Win8.1 x32 精选纯净版2018年4月(免激活) ISO镜像快速下载
- 5电脑公司 GhostXpSp3 电脑城装机版 2020年12月 ISO镜像高速下载
- 6雨林木风Ghost Win8.1 (X32) 喜迎国庆 快速纯净版2020年10月(免激活) ISO镜像快速下载
- 7新萝卜家园电脑城专用系统 Windows10 x86 企业版 版本1507 2021年4月(32位) ISO镜像高速下载
- 8番茄花园 Windows 10 极速企业版 2019年11月(32位) ISO镜像快速下载
- 9电脑公司 装机专用系统Windows10 x64 企业装机版 版本1507 2021年9月(64位) ISO镜像高速下载
- 10雨林木风Ghost Win8.1 (X32) 中秋特别 快速纯净版2021年9月(免激活) ISO镜像快速下载