From d3578e2662a90fd04b011a745c1149df68c0954a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Sep 2014 23:42:57 +0100 Subject: Add "debug lludp data out" console command for logging outgoing data just before it's put on the wire. Unlike "debug lludp packet" which logs at the point where OpenSim first asks the clientstack to send a certain outgoing packet, this logs immediately before the actual send. For low-level debugging purposes. --- .../Region/ClientStack/Linden/UDP/LLUDPClient.cs | 6 +++ .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 47 +++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index c34bafa..9dc9e0d 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 e879e76..0393a29 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" @@ -700,6 +700,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP 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 ", "Drop all in or outbound packets that match the given name", @@ -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); -- cgit v1.1