📄 congestionwindow.cs
字号:
namespace NCindy.Protocol.RUDP.Window.BIC
{
using NCindy.Protocol.RUDP;
using NCindy.Protocol.RUDP.Packet;
using NCindy.Protocol.RUDP.Window;
using System;
internal sealed class CongestionWindow : AbstractWindow
{
private double beta;
private double default_max_win;
private bool is_BITCP_ss;
private double low_window;
private double max_win;
private double min_win;
private double prev_max;
private double Smax;
private double Smin;
private double ss_cwnd;
private double ss_target;
private double target_win;
internal CongestionWindow(RUDPSocket rudp) : base(rudp)
{
base._rudp = rudp;
}
internal override void OnACK_UpdateWindow(RUDPOutgoingPacket packet)
{
if (base.CWND < this.low_window)
{
base.CWND += ((double) base._rudp.MTU) / base.CWND;
}
else if (!this.is_BITCP_ss)
{
if ((this.target_win - base.CWND) < this.Smax)
{
base.CWND += (this.target_win - base.CWND) / base.CWND;
}
else
{
base.CWND += this.Smax / base.CWND;
}
if (this.max_win > base.CWND)
{
this.min_win = base.CWND;
this.target_win = (this.max_win + this.min_win) / 2;
}
else
{
this.is_BITCP_ss = true;
this.ss_cwnd = 1;
this.ss_target = base.CWND + 1;
this.max_win = this.default_max_win;
}
}
else
{
base.CWND += this.ss_cwnd / base.CWND;
if (base.CWND >= this.ss_target)
{
this.ss_cwnd = 2 * this.ss_cwnd;
this.ss_target = base.CWND + this.ss_cwnd;
}
if (this.ss_cwnd >= this.Smax)
{
this.is_BITCP_ss = false;
}
}
}
internal override void OnTimeOut_UpdateWindow()
{
if (this.low_window <= base.CWND)
{
this.prev_max = this.max_win;
this.max_win = base.CWND;
base.CWND *= 1 - this.beta;
this.min_win = base.CWND;
if (this.prev_max > this.max_win)
{
this.max_win = (this.max_win + this.min_win) / 2;
}
this.target_win = (this.max_win + this.min_win) / 2;
}
else
{
base.CWND *= 0.5;
}
}
internal override void Reset()
{
base.Reset();
this.beta = 0.8;
this.low_window = 65536;
this.Smax = 65536;
this.Smin = 1024;
this.default_max_win = 262144;
this.max_win = this.default_max_win;
this.min_win = 16384;
this.is_BITCP_ss = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -