Squishy.Network.Throttle.CalculateBufferSize C# (CSharp) Method

CalculateBufferSize() private method

private CalculateBufferSize ( int maxSpeed ) : int
maxSpeed int
return int
        private int CalculateBufferSize(int maxSpeed)
        {
            // TODO: improve buffersize calculation
            // first calculate the byte count per second per connection
            var s = (int) Math.Round(maxSpeed*TrafficWatch.PollSpan.TotalSeconds/cons.Count);

            /*
             * Find a good value for the buffer size that is not too small, not too big
             * and -if possible- is a nominator of the speed.
             */
            if (s > 100000)
                s = 8192; // not greater than 8 kb
            else if (s < 1024)
                s = 256; // not smaller than 256b
            else
                s /= 5;
            return s;
        }