Ejemplo n.º 1
0
        private void SendExpandMTU(TimeSpan now, int size)
        {
            NetOutgoingMessage om = Peer.CreateMessage();

            om.WritePadBytes(size);
            om._messageType = NetMessageType.ExpandMTURequest;
            int length = 0;

            om.Encode(Peer._sendBuffer, ref length, 0);
            Peer.Recycle(om);

            if (!Peer.SendMTUPacket(length, RemoteEndPoint))
            {
                //m_peer.LogDebug("Send MTU failed for size " + size);

                // failure
                if (_smallestFailedMTU == -1 || size < _smallestFailedMTU)
                {
                    _smallestFailedMTU = size;
                    _mtuAttemptFails++;
                    if (_mtuAttemptFails >= _peerConfiguration.ExpandMTUFailAttempts)
                    {
                        FinalizeMTU(_largestSuccessfulMTU);
                        return;
                    }
                }
                ExpandMTU(now);
                return;
            }

            _lastSentMTUAttemptSize = size;
            _lastSentMTUAttemptTime = now;
        }