⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 congestionwindow.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace NCindy.Protocol.RUDP.Window.CUBIC
{
    using NCindy.Protocol.RUDP;
    using NCindy.Protocol.RUDP.Packet;
    using NCindy.Protocol.RUDP.Timer;
    using NCindy.Protocol.RUDP.Window;
    using System;

    internal sealed class CongestionWindow : AbstractWindow
    {
        private double b;
        private double c;
        private double cnt;
        private double cwnd_cnt;
        private double delay_min;
        private double epoch_start;
        private double K;
        private double last_max;
        private double loss_cwnd;
        private double origin_point;
        private double ssthresh;
        private double t;
        private double target;

        internal CongestionWindow(RUDPSocket rudp) : base(rudp)
        {
            base._rudp = rudp;
        }

        internal override void OnACK_UpdateWindow(RUDPOutgoingPacket packet)
        {
            this.delay_min = Math.Min(base._rudp._rtt, this.delay_min);
            if (base.CWND < this.ssthresh)
            {
                base.CWND += 1;
            }
            else
            {
                if (this.epoch_start == 0)
                {
                    this.epoch_start = HiResTimer.MicroSeconds;
                    this.K = Math.Max(0, Math.Pow(this.b * (this.last_max - base.CWND), 0.33333333333333331));
                    this.origin_point = Math.Max(base.CWND, this.last_max);
                }
                this.t = (HiResTimer.MicroSeconds + this.delay_min) - this.epoch_start;
                this.target = this.origin_point + (this.c * Math.Pow(this.t - this.K, 0.33333333333333331));
                if (this.target > base.CWND)
                {
                    this.cnt = base.CWND / (this.target - base.CWND);
                }
                else
                {
                    this.cnt = 100 * base.CWND;
                }
                if (this.delay_min > 0)
                {
                    this.cnt = Math.Max(this.cnt, (8 * base.CWND) / (20 * this.delay_min));
                }
                if (this.loss_cwnd == 0)
                {
                    this.cnt = 50;
                }
                if (this.cwnd_cnt > this.cnt)
                {
                    base.CWND += 1;
                    this.cwnd_cnt = 0;
                }
                else
                {
                    this.cwnd_cnt += 1;
                }
            }
        }

        internal override void OnTimeOut_UpdateWindow()
        {
            this.epoch_start = 0;
            if (base.CWND < this.last_max)
            {
                this.last_max = 0.9 * base.CWND;
            }
            else
            {
                this.last_max = base.CWND;
            }
            this.loss_cwnd = base.CWND;
            base.CWND = 0.8 * base.CWND;
        }

        internal override void Reset()
        {
            base.Reset();
            this.last_max = 0;
            this.loss_cwnd = 0;
            this.epoch_start = 0;
            this.ssthresh = 65536;
            this.b = 2.5;
            this.c = 0.4;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -