Lidgren.Network.NetConnection.ExpandMTU C# (CSharp) Method

ExpandMTU() private method

private ExpandMTU ( double now ) : void
now double
return void
        private void ExpandMTU(double now)
        {
            int tryMTU;

            // we've nevered encountered failure
            if (m_smallestFailedMTU == -1)
            {
                // we've never encountered failure; expand by 25% each time
                tryMTU = (int)((float)m_currentMTU * 1.25f);
                //m_peer.LogDebug("Trying MTU " + tryMTU);
            }
            else
            {
                // we HAVE encountered failure; so try in between
                tryMTU = (int)(((float)m_smallestFailedMTU + (float)m_largestSuccessfulMTU) / 2.0f);
                //m_peer.LogDebug("Trying MTU " + m_smallestFailedMTU + " <-> " + m_largestSuccessfulMTU + " = " + tryMTU);
            }

            if (tryMTU > c_protocolMaxMTU)
                tryMTU = c_protocolMaxMTU;

            if (tryMTU == m_largestSuccessfulMTU)
            {
                //m_peer.LogDebug("Found optimal MTU - exiting");
                FinalizeMTU(m_largestSuccessfulMTU);
                return;
            }

            SendExpandMTU(now, tryMTU);
        }