1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-18 08:06:33 +09:00

Crude Path MTU detection added

This commit is contained in:
lidgren
2010-12-12 19:07:55 +00:00
parent 55cdf75c5f
commit 772d80835b
12 changed files with 336 additions and 10 deletions

View File

@@ -44,7 +44,7 @@ namespace Lidgren.Network
throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently");
int len = msg.LengthBytes;
if (len <= m_configuration.MaximumTransmissionUnit)
if (len <= recipient.m_currentMTU)
{
Interlocked.Increment(ref msg.m_recyclingCount);
return recipient.EnqueueMessage(msg, method, sequenceChannel);
@@ -57,6 +57,18 @@ namespace Lidgren.Network
}
}
internal int GetMTU(IList<NetConnection> recipients)
{
int mtu = int.MaxValue;
foreach (NetConnection conn in recipients)
{
int cmtu = conn.m_currentMTU;
if (cmtu < mtu)
mtu = cmtu;
}
return mtu;
}
public void SendMessage(NetOutgoingMessage msg, IList<NetConnection> recipients, NetDeliveryMethod method, int sequenceChannel)
{
if (msg == null)
@@ -68,6 +80,8 @@ namespace Lidgren.Network
if (msg.m_isSent)
throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently");
int mtu = GetMTU(recipients);
int len = msg.LengthBytes;
if (len <= m_configuration.MaximumTransmissionUnit)
{