removed a protocol breaking lludp debug option that no one should try, changed terrain send throotle to be by packets in queue, reduced odds of MTU violation on terrain send (still bad). Most UDP protocol implementations may not mind much, but our code still does

avinationmerge
UbitUmarov 2015-09-22 18:39:59 +01:00
parent 032958709b
commit a8dc07ff5c
5 changed files with 37 additions and 102 deletions

View File

@ -1209,8 +1209,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public virtual bool CanSendLayerData()
{
int n = m_udpClient.GetCatBytesInSendQueue(ThrottleOutPacketType.Land);
if ( n > 100000)
int n = m_udpClient.GetPacketsQueuedCount(ThrottleOutPacketType.Land);
if ( n > 256)
return false;
return true;
}
@ -1355,15 +1355,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
try
{
/* test code using the terrain compressor in libOpenMetaverse
int[] patchInd = new int[1];
patchInd[0] = px + (py * Constants.TerrainPatchSize);
LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(terrData.GetFloatsSerialized(), patchInd);
*/
// Many, many patches could have been passed to us. Since the patches will be compressed
// into variable sized blocks, we cannot pre-compute how many will fit into one
// packet. While some fancy packing algorithm is possible, 4 seems to always fit.
int PatchesAssumedToFit = 4;
int PatchesAssumedToFit = 3;
for (int pcnt = 0; pcnt < px.Length; pcnt += PatchesAssumedToFit)
{
int remaining = Math.Min(px.Length - pcnt, PatchesAssumedToFit);
@ -1377,10 +1369,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLandPacket(terrData, xPatches, yPatches);
// DebugSendingPatches("SendLayerDataInternal", xPatches, yPatches);
SendTheLayerPacket(layerpack);
OutPacket(layerpack, ThrottleOutPacketType.Land);
}
// LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLandPacket(terrData, px, py);
}
catch (Exception e)
{
@ -1388,11 +1378,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
private void SendTheLayerPacket(LayerDataPacket layerpack)
{
OutPacket(layerpack, ThrottleOutPacketType.Land);
}
/// <summary>
/// Send the wind matrix to the client
/// </summary>

View File

@ -122,11 +122,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <summary>Sequence numbers of packets we've received (for duplicate checking)</summary>
public readonly IncomingPacketHistoryCollection PacketArchive = new IncomingPacketHistoryCollection(200);
/// <summary>
/// If true then we take action in response to unacked reliably sent packets such as resending the packet.
/// </summary>
public bool ProcessUnackedSends { get; set; }
/// <summary>Packets we have sent that need to be ACKed by the client</summary>
public readonly UnackedPacketCollection NeedAcks = new UnackedPacketCollection();
@ -252,8 +247,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (maxRTO != 0)
m_maxRTO = maxRTO;
ProcessUnackedSends = true;
m_burstTime = rates.BrustTime;
float m_burst = rates.ClientMaxRate * m_burstTime;
@ -357,8 +350,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="throttleType"></param>
public int GetPacketsQueuedCount(ThrottleOutPacketType throttleType)
{
if ((int)throttleType > 0)
return m_packetOutboxes[(int)throttleType].Count;
int icat = (int)throttleType;
if (icat > 0 && icat < THROTTLE_CATEGORY_COUNT)
return m_packetOutboxes[icat].Count;
else
return 0;
}
@ -544,21 +538,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return data;
}
public int GetCatBytesInSendQueue(ThrottleOutPacketType cat)
{
;
int icat = (int)cat;
if (icat > 0 && icat < THROTTLE_CATEGORY_COUNT)
{
TokenBucket bucket = m_throttleCategories[icat];
return m_packetOutboxes[icat].Count;
}
else
return 0;
}
public int GetCatBytesCanSend(ThrottleOutPacketType cat, int timeMS)
{
int icat = (int)cat;

View File

@ -991,8 +991,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
bufferSize = dataLength;
buffer = new UDPPacketBuffer(udpClient.RemoteEndPoint, bufferSize);
// m_log.Error("[LLUDPSERVER]: Packet exceeded buffer size! This could be an indication of packet assembly not obeying the MTU. Type=" +
// type + ", DataLength=" + dataLength + ", BufferLength=" + buffer.Data.Length + ". Dropping packet");
m_log.Error("[LLUDPSERVER]: Packet exceeded buffer size! This could be an indication of packet assembly not obeying the MTU. Type=" +
type + ", DataLength=" + dataLength + ", BufferLength=" + buffer.Data.Length);
Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength);
}
}
@ -1200,7 +1200,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Utils.UIntToBytesBig(sequenceNumber, buffer.Data, 1);
outgoingPacket.SequenceNumber = sequenceNumber;
if (udpClient.ProcessUnackedSends && isReliable)
if (isReliable)
{
// Add this packet to the list of ACK responses we are waiting on from the server
udpClient.NeedAcks.Add(outgoingPacket);
@ -1418,37 +1418,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#region ACK Receiving
if (udpClient.ProcessUnackedSends)
// Handle appended ACKs
if (packet.Header.AppendedAcks && packet.Header.AckList != null)
{
// Handle appended ACKs
if (packet.Header.AppendedAcks && packet.Header.AckList != null)
{
// m_log.DebugFormat(
// "[LLUDPSERVER]: Handling {0} appended acks from {1} in {2}",
// packet.Header.AckList.Length, client.Name, m_scene.Name);
// m_log.DebugFormat(
// "[LLUDPSERVER]: Handling {0} appended acks from {1} in {2}",
// packet.Header.AckList.Length, client.Name, m_scene.Name);
for (int i = 0; i < packet.Header.AckList.Length; i++)
udpClient.NeedAcks.Acknowledge(packet.Header.AckList[i], now, packet.Header.Resent);
}
// Handle PacketAck packets
if (packet.Type == PacketType.PacketAck)
{
PacketAckPacket ackPacket = (PacketAckPacket)packet;
// m_log.DebugFormat(
// "[LLUDPSERVER]: Handling {0} packet acks for {1} in {2}",
// ackPacket.Packets.Length, client.Name, m_scene.Name);
for (int i = 0; i < ackPacket.Packets.Length; i++)
udpClient.NeedAcks.Acknowledge(ackPacket.Packets[i].ID, now, packet.Header.Resent);
// We don't need to do anything else with PacketAck packets
return;
}
for (int i = 0; i < packet.Header.AckList.Length; i++)
udpClient.NeedAcks.Acknowledge(packet.Header.AckList[i], now, packet.Header.Resent);
}
else if (packet.Type == PacketType.PacketAck)
// Handle PacketAck packets
if (packet.Type == PacketType.PacketAck)
{
PacketAckPacket ackPacket = (PacketAckPacket)packet;
// m_log.DebugFormat(
// "[LLUDPSERVER]: Handling {0} packet acks for {1} in {2}",
// ackPacket.Packets.Length, client.Name, m_scene.Name);
for (int i = 0; i < ackPacket.Packets.Length; i++)
udpClient.NeedAcks.Acknowledge(ackPacket.Packets[i].ID, now, packet.Header.Resent);
// We don't need to do anything else with PacketAck packets
return;
}
@ -1510,7 +1503,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion BinaryStats
//Ubit AgentUpdate mess removed from here
//AgentUpdate removed from here
#region Ping Check Handling
@ -2168,7 +2161,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (udpClient.IsConnected)
{
if (udpClient.ProcessUnackedSends && m_resendUnacked)
if (m_resendUnacked)
HandleUnacked(llClient);
if (m_sendAcks)

View File

@ -558,6 +558,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_console.OutputFormat("{0} set to {1} in {2}", param, rawValue, m_udpServer.Scene.Name);
}
/* not in use, nothing to set/get from lludp
private void HandleClientGetCommand(string module, string[] args)
{
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
@ -584,11 +585,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_console.OutputFormat(
"Client debug parameters for {0} ({1}) in {2}",
sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
ConsoleDisplayList cdl = new ConsoleDisplayList();
cdl.AddRow("process-unacked-sends", udpClient.ProcessUnackedSends);
m_console.Output(cdl.ToString());
}
});
}
@ -611,28 +607,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (args.Length == 8)
name = string.Format("{0} {1}", args[6], args[7]);
if (param == "process-unacked-sends")
{
bool newValue;
if (!ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, rawValue, out newValue))
return;
m_udpServer.Scene.ForEachScenePresence(
sp =>
{
if ((name == null || sp.Name == name) && sp.ControllingClient is LLClientView)
{
LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
udpClient.ProcessUnackedSends = newValue;
m_console.OutputFormat("{0} set to {1} for {2} in {3}", param, newValue, sp.Name, m_udpServer.Scene.Name);
}
});
}
// nothing here now
}
*/
private void HandlePacketCommand(string module, string[] args)
{
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)

View File

@ -289,7 +289,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public int GetCatBytesCanSend(int timeMS)
{
// return (int)(m_tokenCount + timeMS * m_dripRate * 1e-3);
return (int)(timeMS * m_dripRate * 1e-3);
return (int)(timeMS * DripRate * 1e-3);
}
/// <summary>