public void ResendUnacked(LLUDPClient udpClient) { if (!udpClient.IsConnected) { return; } // Disconnect an agent if no packets are received for some time //FIXME: Make 60 an .ini setting if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60) { m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); RemoveClient(udpClient); return; } // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO List <OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO); if (expiredPackets != null) { //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); // Exponential backoff of the retransmission timeout udpClient.BackoffRTO(); // Resend packets for (int i = 0; i < expiredPackets.Count; i++) { OutgoingPacket outgoingPacket = expiredPackets[i]; //m_log.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed", // outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount); // Set the resent flag outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT); outgoingPacket.Category = ThrottleOutPacketType.Resend; // Bump up the resend count on this packet Interlocked.Increment(ref outgoingPacket.ResendCount); //Interlocked.Increment(ref Stats.ResentPackets); // Requeue or resend the packet if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) { SendPacketFinal(outgoingPacket); } } } }
public void ResendUnacked(LLUDPClient udpClient) { if (!udpClient.IsConnected) return; // Disconnect an agent if no packets are received for some time if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * ClientTimeOut && !udpClient.IsPaused) { m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); ILoginMonitor monitor = (ILoginMonitor)m_scene.RequestModuleInterface<IMonitorModule>().GetMonitor("", MonitorModuleHelper.LoginMonitor); if (monitor != null) { monitor.AddAbnormalClientThreadTermination(); } RemoveClient(udpClient); return; } // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO); if (expiredPackets != null) { //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); // Exponential backoff of the retransmission timeout udpClient.BackoffRTO(); for (int i = 0; i < expiredPackets.Count; ++i) { if (expiredPackets[i].UnackedMethod != null) expiredPackets[i].UnackedMethod(expiredPackets[i]); } // Resend packets for (int i = 0; i < expiredPackets.Count; i++) { if (expiredPackets[i].UnackedMethod != null) continue; //If its not null, it has taken care of the packet sending on its own OutgoingPacket outgoingPacket = expiredPackets[i]; //m_log.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed", // outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount); // Set the resent flag outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT); // resend in its original category outgoingPacket.Category = ThrottleOutPacketType.Resend; // Bump up the resend count on this packet Interlocked.Increment(ref outgoingPacket.ResendCount); //Interlocked.Increment(ref Stats.ResentPackets); // Requeue or resend the packet if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) SendPacketFinal(outgoingPacket); } } }
public void ResendUnacked(LLUDPClient udpClient) { if (!udpClient.IsConnected) return; // Disconnect an agent if no packets are received for some time if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * ClientTimeOut && !udpClient.IsPaused) { m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); if (m_scene.Stats is OpenSim.Framework.Statistics.SimExtraStatsCollector) { OpenSim.Framework.Statistics.SimExtraStatsCollector stats = m_scene.Stats as OpenSim.Framework.Statistics.SimExtraStatsCollector; stats.AddAbnormalClientThreadTermination(); } RemoveClient(udpClient); return; } // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO); if (expiredPackets != null) { //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); // Exponential backoff of the retransmission timeout udpClient.BackoffRTO(); // Resend packets for (int i = 0; i < expiredPackets.Count; i++) { OutgoingPacket outgoingPacket = expiredPackets[i]; //m_log.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed", // outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount); // Set the resent flag outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT); outgoingPacket.Category = ThrottleOutPacketType.Resend; // Bump up the resend count on this packet Interlocked.Increment(ref outgoingPacket.ResendCount); //Interlocked.Increment(ref Stats.ResentPackets); // Requeue or resend the packet if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) SendPacketFinal(outgoingPacket); } } }
public void HandleUnacked(LLUDPClient udpClient) { if (!udpClient.IsConnected) return; // Disconnect an agent if no packets are received for some time //FIXME: Make 60 an .ini setting if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60) { m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); StatsManager.SimExtraStats.AddAbnormalClientThreadTermination(); RemoveClient(udpClient); return; } // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO); if (expiredPackets != null) { //m_log.Debug("[LLUDPSERVER]: Handling " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); // Exponential backoff of the retransmission timeout udpClient.BackoffRTO(); for (int i = 0; i < expiredPackets.Count; ++i) expiredPackets[i].UnackedMethod(expiredPackets[i]); } }
public void ResendUnacked(LLUDPClient udpClient) { if (!udpClient.IsConnected) return; // Disconnect an agent if no packets are received for some time //FIXME: Make 60 an .ini setting if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60) { IClientAPI client; if (m_scene.TryGetClient(udpClient.AgentID, out client)) { if (client.IsActive) // to prevent duplicate reporting m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); RemoveClient(client); } return; } // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO KeyValuePair<UnackedPacketCollection.ResendReason, List<OutgoingPacket>> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO); if (expiredPackets.Key != UnackedPacketCollection.ResendReason.None) { //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); // Exponential backoff of the retransmission timeout if ((expiredPackets.Key & UnackedPacketCollection.ResendReason.TimeoutExpired) != 0) udpClient.BackoffRTO(); var packetList = expiredPackets.Value; // Resend packets for (int i = 0; i < packetList.Count; i++) { OutgoingPacket outgoingPacket = packetList[i]; /*m_log.DebugFormat("[LLUDPSERVER]: {0} Resending packet #{1} (attempt {2}), {3}ms have passed", (expiredPackets.Key & UnackedPacketCollection.ResendReason.FastRetransmit) != 0 ? "(Fast)" : "", outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount); */ // Set the resent flag outgoingPacket.Buffer[0] = (byte)(outgoingPacket.Buffer[0] | Helpers.MSG_RESENT); outgoingPacket.Category = (int) ThrottleOutPacketType.Resend; // Bump up the resend count on this packet Interlocked.Increment(ref outgoingPacket.ResendCount); //Interlocked.Increment(ref Stats.ResentPackets); // Requeue or resend the packet if (!udpClient.EnqueueOutgoing(outgoingPacket)) SendPacketFinal(outgoingPacket); } /* if (packetList.Count != 0) { m_log.DebugFormat("[LLUDPSERVER]: {0} Resent {1} packet(s) for {2}", (expiredPackets.Key & UnackedPacketCollection.ResendReason.FastRetransmit) != 0 ? "(Fast)" : "", packetList.Count, udpClient.AgentID); }*/ } }
public void ResendUnacked(LLUDPClient udpClient) { if (!udpClient.IsConnected) return; // Disconnect an agent if no packets are received for some time if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000*ClientTimeOut && !udpClient.IsPaused) { MainConsole.Instance.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); ILoginMonitor monitor = (ILoginMonitor) m_scene.RequestModuleInterface<IMonitorModule>().GetMonitor("", MonitorModuleHelper.LoginMonitor); if (monitor != null) monitor.AddAbnormalClientThreadTermination(); RemoveClient(udpClient); return; } // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO); if (expiredPackets != null) { //uncomment one line below for added debuging -VS MainConsole.Instance.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); // Exponential backoff of the retransmission timeout udpClient.BackoffRTO(); #if (!ISWIN) foreach (OutgoingPacket t in expiredPackets) { if (t.UnackedMethod != null) { t.UnackedMethod(t); } } #else foreach (OutgoingPacket t in expiredPackets.Where(t => t.UnackedMethod != null)) { t.UnackedMethod(t); } #endif // Resend packets #if (!ISWIN) foreach (OutgoingPacket outgoingPacket in expiredPackets) { if (outgoingPacket.UnackedMethod == null) { //MainConsole.Instance.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed", // outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount); // Set the resent flag outgoingPacket.Buffer.Data[0] = (byte) (outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT); // resend in its original category outgoingPacket.Category = ThrottleOutPacketType.Resend; // Bump up the resend count on this packet Interlocked.Increment(ref outgoingPacket.ResendCount); //Interlocked.Increment(ref Stats.ResentPackets); // Requeue or resend the packet if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) SendPacketFinal(outgoingPacket); } } #else foreach (OutgoingPacket outgoingPacket in expiredPackets.Where(t => t.UnackedMethod == null)) { //MainConsole.Instance.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed", // outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount); // Set the resent flag outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT); // resend in its original category outgoingPacket.Category = ThrottleOutPacketType.Resend; // Bump up the resend count on this packet Interlocked.Increment(ref outgoingPacket.ResendCount); //Interlocked.Increment(ref Stats.ResentPackets); // Requeue or resend the packet if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) SendPacketFinal(outgoingPacket); } #endif } }
public void ResendUnacked(LLUDPClient udpClient) { if (!udpClient.IsConnected) { return; } // Disconnect an agent if no packets are received for some time if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * ClientTimeOut && !udpClient.IsPaused) { m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); ILoginMonitor monitor = (ILoginMonitor)m_scene.RequestModuleInterface <IMonitorModule>().GetMonitor("", "LoginMonitor"); if (monitor != null) { monitor.AddAbnormalClientThreadTermination(); } RemoveClient(udpClient); return; } // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO List <OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO); if (expiredPackets != null) { //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); // Exponential backoff of the retransmission timeout udpClient.BackoffRTO(); lock (udpClient) { udpClient.SlowDownSend(); } // Resend packets for (int i = 0; i < expiredPackets.Count; i++) { OutgoingPacket outgoingPacket = expiredPackets[i]; //m_log.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed", // outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount); // Set the resent flag outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT); // resend in its original category // outgoingPacket.Category = ThrottleOutPacketType.Resend; // Bump up the resend count on this packet Interlocked.Increment(ref outgoingPacket.ResendCount); //Interlocked.Increment(ref Stats.ResentPackets); // Requeue or resend the packet if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) { SendPacketFinal(outgoingPacket); } } } }