From fa3bd2646fc7c8247871de6708fe2e1592f61f05 Mon Sep 17 00:00:00 2001 From: lidgren Date: Tue, 7 Sep 2010 06:35:09 +0000 Subject: [PATCH] Tweaks + debug messages --- Lidgren.Network/NetConnection.Latency.cs | 4 +++- Lidgren.Network/NetConnection.cs | 2 +- Lidgren.Network/NetPeer.LatencySimulation.cs | 8 ++++++++ Lidgren.Network/NetPeerConfiguration.cs | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Lidgren.Network/NetConnection.Latency.cs b/Lidgren.Network/NetConnection.Latency.cs index 9e9ffb6..2b459a8 100644 --- a/Lidgren.Network/NetConnection.Latency.cs +++ b/Lidgren.Network/NetConnection.Latency.cs @@ -90,7 +90,8 @@ namespace Lidgren.Network double now = NetTime.Now; // need exact number m_lastHeardFrom = now; - m_lastSendRespondedTo = m_lastPingSendTime; + if (m_lastPingSendTime > m_lastSendRespondedTo) + m_lastSendRespondedTo = m_lastPingSendTime; double rtt = now - m_lastPingSendTime; @@ -126,6 +127,7 @@ namespace Lidgren.Network // timeout if (now > m_lastSendRespondedTo + m_peerConfiguration.m_connectionTimeout) { + m_owner.LogDebug(this + " timed out; now is " + now + " last responded to is: " + m_lastSendRespondedTo); Disconnect("Timed out after " + (now - m_lastSendRespondedTo) + " seconds"); return; } diff --git a/Lidgren.Network/NetConnection.cs b/Lidgren.Network/NetConnection.cs index 03eb06a..3b29af0 100644 --- a/Lidgren.Network/NetConnection.cs +++ b/Lidgren.Network/NetConnection.cs @@ -357,7 +357,7 @@ namespace Lidgren.Network // Reliable delivery methods below // - // queue ack + // queue ack; regardless if this is a duplicate or not m_acknowledgesToSend.Enqueue((int)channelSequenceNumber | ((int)mtp << 16)); if (m_nextForceAckTime == double.MaxValue) m_nextForceAckTime = now + m_peerConfiguration.m_maxAckDelayTime; diff --git a/Lidgren.Network/NetPeer.LatencySimulation.cs b/Lidgren.Network/NetPeer.LatencySimulation.cs index 90cd5d4..c978f1c 100644 --- a/Lidgren.Network/NetPeer.LatencySimulation.cs +++ b/Lidgren.Network/NetPeer.LatencySimulation.cs @@ -113,6 +113,9 @@ namespace Lidgren.Network connectionReset = false; try { + if (target.Address == IPAddress.Broadcast) + m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); + int bytesSent = m_socket.SendTo(data, 0, numBytes, SocketFlags.None, target); if (numBytes != bytesSent) LogWarning("Failed to send the full " + numBytes + "; only " + bytesSent + " bytes sent in packet!"); @@ -131,6 +134,11 @@ namespace Lidgren.Network { LogError("Failed to send packet: " + ex); } + finally + { + if (target.Address == IPAddress.Broadcast) + m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, false); + } } #else diff --git a/Lidgren.Network/NetPeerConfiguration.cs b/Lidgren.Network/NetPeerConfiguration.cs index 1f2627c..065d8a8 100644 --- a/Lidgren.Network/NetPeerConfiguration.cs +++ b/Lidgren.Network/NetPeerConfiguration.cs @@ -76,7 +76,7 @@ namespace Lidgren.Network m_maximumConnections = 16; m_defaultOutgoingMessageCapacity = 8; m_pingFrequency = 6.0f; - m_throttleBytesPerSecond = 1024 * 512; + m_throttleBytesPerSecond = 1024 * 256; m_throttlePeakBytes = 8192; m_maxAckDelayTime = 0.01f; m_handshakeAttemptDelay = 1.0f;