diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index c34bafa9b2..9dc9e0d7ac 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -76,6 +76,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// or removed, this number must also change const int THROTTLE_CATEGORY_COUNT = 8; + /// + /// Controls whether information is logged about each outbound packet immediately before it is sent. For debug purposes. + /// + /// Any level above 0 will turn on logging. + public int DebugDataOutLevel { get; set; } + /// Fired when updated networking stats are produced for this client public event PacketStats OnPacketStats; /// Fired when the queue for a packet category is empty. This event can be diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 8f8558d367..a90ea6cebe 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -686,7 +686,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP MainConsole.Instance.Commands.AddCommand( "Debug", false, "debug lludp packet", "debug lludp packet [--default | --all] [ ]", - "Turn on packet debugging", + "Turn on packet debugging. This logs information when the client stack hands a processed packet off to downstream code or when upstream code first requests that a certain packet be sent.", "If level > 255 then all incoming and outgoing packets are logged.\n" + "If level <= 255 then incoming AgentUpdate and outgoing SimStats and SimulatorViewerTimeMessage packets are not logged.\n" + "If level <= 200 then incoming RequestImage and outgoing ImagePacket, ImageData, LayerData and CoarseLocationUpdate packets are not logged.\n" @@ -699,6 +699,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP + "If an avatar name is given then only packets from that avatar are logged.", HandlePacketCommand); + MainConsole.Instance.Commands.AddCommand( + "Debug", false, "debug lludp data out", + "debug lludp data out \"", + "Turn on debugging for final outgoing data to the given user's client.", + "This operates at a much lower level than the packet command and prints out available details when the data is actually sent.\n" + + "If level > 0 then information about all outgoing UDP data for this avatar is logged.\n" + + "If level <= 0 then no information about outgoing UDP data for this avatar is logged.", + HandleDataCommand); + MainConsole.Instance.Commands.AddCommand( "Debug", false, "debug lludp drop", "debug lludp drop ", @@ -755,6 +764,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP HandleAgentUpdateCommand); } + private void HandleDataCommand(string module, string[] args) + { + if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != Scene) + return; + + if (args.Length != 7) + { + MainConsole.Instance.OutputFormat("Usage: debug lludp data out "); + return; + } + + int level; + if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out level)) + return; + + string firstName = args[5]; + string lastName = args[6]; + + Scene.ForEachScenePresence(sp => + { + if (sp.Firstname == firstName && sp.Lastname == lastName) + { + MainConsole.Instance.OutputFormat( + "Data debug for {0} ({1}) set to {2} in {3}", + sp.Name, sp.IsChildAgent ? "child" : "root", level, Scene.Name); + + ((LLClientView)sp.ControllingClient).UDPClient.DebugDataOutLevel = level; + } + }); + } + private void HandlePacketCommand(string module, string[] args) { if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != Scene) @@ -1360,6 +1400,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP // is 100% correct PacketsSentCount++; + if (udpClient.DebugDataOutLevel > 0) + m_log.DebugFormat( + "[LLUDPSERVER]: Sending packet #{0} (rel: {1}, res: {2}) to {3} from {4}", + outgoingPacket.SequenceNumber, isReliable, isResend, udpClient.AgentID, Scene.Name); + // Put the UDP payload on the wire AsyncBeginSend(buffer);