29 using System.Collections.Generic;
32 using OpenSim.Framework;
33 using OpenSim.Framework.Console;
34 using OpenSim.Region.Framework.Scenes;
36 namespace OpenSim.
Region.ClientStack.LindenUDP
46 m_udpServer = udpServer;
220 private void HandleShowServerThrottlesCommand(
string module,
string[] args)
225 m_console.OutputFormat(
"Throttles for {0}", m_udpServer.Scene.Name);
227 cdl.AddRow(
"Adaptive throttles", m_udpServer.ThrottleRates.AdaptiveThrottlesEnabled);
229 long maxSceneDripRate = (long)m_udpServer.Throttle.MaxDripRate;
231 "Max scene throttle",
232 maxSceneDripRate != 0 ?
string.Format(
"{0} kbps", maxSceneDripRate * 8 / 1000) :
"unset");
234 int maxClientDripRate = m_udpServer.ThrottleRates.Total;
236 "Max new client throttle",
237 maxClientDripRate != 0 ? string.Format(
"{0} kbps", maxClientDripRate * 8 / 1000) :
"unset");
239 m_console.Output(cdl.ToString());
241 m_console.OutputFormat(
"{0}\n", GetServerThrottlesReport(m_udpServer));
244 private string GetServerThrottlesReport(LLUDPServer udpServer)
246 StringBuilder report =
new StringBuilder();
249 "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}\n",
260 "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}\n",
270 ThrottleRates throttleRates = udpServer.ThrottleRates;
272 "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}",
273 (throttleRates.Total * 8) / 1000,
274 (throttleRates.Resend * 8) / 1000,
275 (throttleRates.Land * 8) / 1000,
276 (throttleRates.Wind * 8) / 1000,
277 (throttleRates.Cloud * 8) / 1000,
278 (throttleRates.Task * 8) / 1000,
279 (throttleRates.Texture * 8) / 1000,
280 (throttleRates.Asset * 8) / 1000);
282 return report.ToString();
287 return string.Format(
288 "{0,-" + maxLength +
"}{1,-" + columnPadding +
"}",
289 entry.Length > maxLength ? entry.Substring(0, maxLength) : entry,
293 private void HandleDataCommand(
string module,
string[] args)
298 if (args.Length != 7)
300 MainConsole.Instance.OutputFormat(
"Usage: debug lludp data out <true|false> <avatar-first-name> <avatar-last-name>");
308 string firstName = args[5];
309 string lastName = args[6];
311 m_udpServer.Scene.ForEachScenePresence(sp =>
313 if (sp.Firstname == firstName && sp.Lastname == lastName)
315 MainConsole.Instance.OutputFormat(
316 "Data debug for {0} ({1}) set to {2} in {3}",
317 sp.Name, sp.IsChildAgent ?
"child" :
"root", level, m_udpServer.Scene.Name);
319 ((LLClientView)sp.ControllingClient).UDPClient.DebugDataOutLevel = level;
324 private void HandleThrottleCommand(
string module,
string[] args)
329 bool all = args.Length == 5;
330 bool one = args.Length == 7;
334 MainConsole.Instance.OutputFormat(
335 "Usage: debug lludp throttles log <level> [<avatar-first-name> <avatar-last-name>]");
343 string firstName = null;
344 string lastName = null;
352 m_udpServer.Scene.ForEachScenePresence(sp =>
354 if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
356 MainConsole.Instance.OutputFormat(
357 "Throttle log level for {0} ({1}) set to {2} in {3}",
358 sp.Name, sp.IsChildAgent ?
"child" :
"root", level, m_udpServer.Scene.Name);
360 ((LLClientView)sp.ControllingClient).UDPClient.ThrottleDebugLevel = level;
365 private void HandleThrottleSetCommand(
string module,
string[] args)
370 bool all = args.Length == 6;
371 bool one = args.Length == 8;
375 MainConsole.Instance.OutputFormat(
376 "Usage: debug lludp throttles set <param> <value> [<avatar-first-name> <avatar-last-name>]");
380 string param = args[4];
381 string rawValue = args[5];
383 string firstName = null;
384 string lastName = null;
392 if (param ==
"adaptive")
398 m_udpServer.Scene.ForEachScenePresence(sp =>
400 if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
402 MainConsole.Instance.OutputFormat(
403 "Setting param {0} to {1} for {2} ({3}) in {4}",
404 param, newValue, sp.Name, sp.IsChildAgent ?
"child" :
"root", m_udpServer.Scene.Name);
406 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
407 udpClient.FlowThrottle.AdaptiveEnabled = newValue;
413 else if (param ==
"request")
419 int newCurrentThrottleKbps = newValue * 1000 / 8;
421 m_udpServer.Scene.ForEachScenePresence(sp =>
423 if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
425 MainConsole.Instance.OutputFormat(
426 "Setting param {0} to {1} for {2} ({3}) in {4}",
427 param, newValue, sp.Name, sp.IsChildAgent ?
"child" :
"root", m_udpServer.Scene.Name);
429 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
430 udpClient.FlowThrottle.RequestedDripRate = newCurrentThrottleKbps;
434 else if (param ==
"max")
440 int newThrottleMaxKbps = newValue * 1000 / 8;
442 m_udpServer.Scene.ForEachScenePresence(sp =>
444 if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
446 MainConsole.Instance.OutputFormat(
447 "Setting param {0} to {1} for {2} ({3}) in {4}",
448 param, newValue, sp.Name, sp.IsChildAgent ?
"child" :
"root", m_udpServer.Scene.Name);
450 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
451 udpClient.FlowThrottle.MaxDripRate = newThrottleMaxKbps;
457 private void HandleThrottleGetCommand(
string module,
string[] args)
462 bool all = args.Length == 4;
463 bool one = args.Length == 6;
467 MainConsole.Instance.OutputFormat(
468 "Usage: debug lludp throttles get [<avatar-first-name> <avatar-last-name>]");
472 string firstName = null;
473 string lastName = null;
481 m_udpServer.Scene.ForEachScenePresence(sp =>
483 if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
485 m_console.OutputFormat(
486 "Status for {0} ({1}) in {2}",
487 sp.Name, sp.IsChildAgent ?
"child" :
"root", m_udpServer.Scene.Name);
489 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
492 cdl.AddRow(
"adaptive", udpClient.FlowThrottle.AdaptiveEnabled);
493 cdl.AddRow(
"current", string.Format(
"{0} kbps", udpClient.FlowThrottle.DripRate * 8 / 1000));
494 cdl.AddRow(
"request", string.Format(
"{0} kbps", udpClient.FlowThrottle.RequestedDripRate * 8 / 1000));
495 cdl.AddRow(
"max", string.Format(
"{0} kbps", udpClient.FlowThrottle.MaxDripRate * 8 / 1000));
497 m_console.Output(cdl.ToString());
502 private void HandleGetCommand(
string module,
string[] args)
507 m_console.OutputFormat(
"Debug settings for {0}", m_udpServer.Scene.Name);
510 long maxSceneDripRate = (long)m_udpServer.Throttle.MaxDripRate;
512 "max-scene-throttle",
513 maxSceneDripRate != 0 ?
string.Format(
"{0} kbps", maxSceneDripRate * 8 / 1000) :
"unset");
515 int maxClientDripRate = m_udpServer.ThrottleRates.Total;
517 "max-new-client-throttle",
518 maxClientDripRate != 0 ? string.Format(
"{0} kbps", maxClientDripRate * 8 / 1000) :
"unset");
520 m_console.Output(cdl.ToString());
523 private void HandleSetCommand(
string module,
string[] args)
528 if (args.Length != 5)
530 MainConsole.Instance.OutputFormat(
"Usage: debug lludp set <param> <value>");
534 string param = args[3];
535 string rawValue = args[4];
539 if (param ==
"max-scene-throttle")
544 m_udpServer.Throttle.MaxDripRate = newValue * 1000 / 8;
546 else if (param ==
"max-new-client-throttle")
551 m_udpServer.ThrottleRates.Total = newValue * 1000 / 8;
558 m_console.OutputFormat(
"{0} set to {1} in {2}", param, rawValue, m_udpServer.Scene.Name);
613 private void HandlePacketCommand(
string module,
string[] args)
618 bool setAsDefaultLevel =
false;
620 OptionSet optionSet =
new OptionSet()
621 .Add(
"default", o => setAsDefaultLevel = (o != null))
622 .Add(
"all", o => setAll = (o != null));
623 List<string> filteredArgs = optionSet.Parse(args);
627 if (filteredArgs.Count == 6)
629 if (!(setAsDefaultLevel || setAll))
631 name = string.Format(
"{0} {1}", filteredArgs[4], filteredArgs[5]);
635 MainConsole.Instance.OutputFormat(
"ERROR: Cannot specify a user name when setting default/all logging level");
640 if (filteredArgs.Count > 3)
643 if (
int.TryParse(filteredArgs[3], out newDebug))
645 if (setAsDefaultLevel || setAll)
647 m_udpServer.DefaultClientPacketDebugLevel = newDebug;
649 MainConsole.Instance.OutputFormat(
650 "Packet debug for {0} clients set to {1} in {2}",
651 (setAll ?
"all" :
"future"), m_udpServer.DefaultClientPacketDebugLevel, m_udpServer.Scene.Name);
655 m_udpServer.Scene.ForEachScenePresence(sp =>
657 MainConsole.Instance.OutputFormat(
658 "Packet debug for {0} ({1}) set to {2} in {3}",
659 sp.Name, sp.IsChildAgent ?
"child" :
"root", newDebug, m_udpServer.Scene.Name);
661 sp.ControllingClient.DebugPacketLevel = newDebug;
667 m_udpServer.Scene.ForEachScenePresence(sp =>
669 if (name == null || sp.Name == name)
671 MainConsole.Instance.OutputFormat(
672 "Packet debug for {0} ({1}) set to {2} in {3}",
673 sp.Name, sp.IsChildAgent ?
"child" :
"root", newDebug, m_udpServer.Scene.Name);
675 sp.ControllingClient.DebugPacketLevel = newDebug;
682 MainConsole.Instance.Output(
"Usage: debug lludp packet [--default | --all] 0..255 [<first-name> <last-name>]");
687 private void HandleDropCommand(
string module,
string[] args)
692 if (args.Length != 6)
694 MainConsole.Instance.Output(
"Usage: debug lludp drop <in|out> <add|remove> <packet-name>");
698 string direction = args[3];
699 string subCommand = args[4];
700 string packetName = args[5];
702 if (subCommand ==
"add")
704 MainConsole.Instance.OutputFormat(
705 "Adding packet {0} to {1} drop list for all connections in {2}",
706 direction, packetName, m_udpServer.Scene.Name);
708 m_udpServer.Scene.ForEachScenePresence(
711 LLClientView llcv = (LLClientView)sp.ControllingClient;
713 if (direction ==
"in")
714 llcv.AddInPacketToDropSet(packetName);
715 else if (direction ==
"out")
716 llcv.AddOutPacketToDropSet(packetName);
720 else if (subCommand ==
"remove")
722 MainConsole.Instance.OutputFormat(
723 "Removing packet {0} from {1} drop list for all connections in {2}",
724 direction, packetName, m_udpServer.Scene.Name);
726 m_udpServer.Scene.ForEachScenePresence(
729 LLClientView llcv = (LLClientView)sp.ControllingClient;
731 if (direction ==
"in")
732 llcv.RemoveInPacketFromDropSet(packetName);
733 else if (direction ==
"out")
734 llcv.RemoveOutPacketFromDropSet(packetName);
740 private void HandleStartCommand(
string module,
string[] args)
745 if (args.Length != 4)
747 MainConsole.Instance.Output(
"Usage: debug lludp start <in|out|all>");
751 string subCommand = args[3];
753 if (subCommand ==
"in" || subCommand ==
"all")
754 m_udpServer.StartInbound();
756 if (subCommand ==
"out" || subCommand ==
"all")
757 m_udpServer.StartOutbound();
760 private void HandleStopCommand(
string module,
string[] args)
765 if (args.Length != 4)
767 MainConsole.Instance.Output(
"Usage: debug lludp stop <in|out|all>");
771 string subCommand = args[3];
773 if (subCommand ==
"in" || subCommand ==
"all")
774 m_udpServer.StopInbound();
776 if (subCommand ==
"out" || subCommand ==
"all")
777 m_udpServer.StopOutbound();
780 private void HandlePoolCommand(
string module,
string[] args)
785 if (args.Length != 4)
787 MainConsole.Instance.Output(
"Usage: debug lludp pool <on|off>");
791 string enabled = args[3];
795 if (m_udpServer.EnablePools())
797 m_udpServer.EnablePoolStats();
798 MainConsole.Instance.OutputFormat(
"Packet pools enabled on {0}", m_udpServer.Scene.Name);
801 else if (enabled ==
"off")
803 if (m_udpServer.DisablePools())
805 m_udpServer.DisablePoolStats();
806 MainConsole.Instance.OutputFormat(
"Packet pools disabled on {0}", m_udpServer.Scene.Name);
811 MainConsole.Instance.Output(
"Usage: debug lludp pool <on|off>");
815 private void HandleAgentUpdateCommand(
string module,
string[] args)
820 m_udpServer.DiscardInboundAgentUpdates = !m_udpServer.DiscardInboundAgentUpdates;
822 MainConsole.Instance.OutputFormat(
823 "Discard AgentUpdates now {0} for {1}", m_udpServer.DiscardInboundAgentUpdates, m_udpServer.Scene.Name);
826 private void HandleStatusCommand(
string module,
string[] args)
831 MainConsole.Instance.OutputFormat(
832 "IN LLUDP packet processing for {0} is {1}", m_udpServer.Scene.Name, m_udpServer.IsRunningInbound ?
"enabled" :
"disabled");
834 MainConsole.Instance.OutputFormat(
835 "OUT LLUDP packet processing for {0} is {1}", m_udpServer.Scene.Name, m_udpServer.IsRunningOutbound ?
"enabled" :
"disabled");
837 MainConsole.Instance.OutputFormat(
"LLUDP pools in {0} are {1}", m_udpServer.Scene.Name, m_udpServer.UsePools ?
"on" :
"off");
839 MainConsole.Instance.OutputFormat(
840 "Packet debug level for new clients is {0}", m_udpServer.DefaultClientPacketDebugLevel);
843 private void HandleOqreCommand(
string module,
string[] args)
848 if (args.Length != 4)
850 MainConsole.Instance.Output(
"Usage: debug lludp oqre <stop|start|status>");
854 string subCommand = args[3];
856 if (subCommand ==
"stop")
858 m_udpServer.OqrEngine.Stop();
859 MainConsole.Instance.OutputFormat(
"Stopped OQRE for {0}", m_udpServer.Scene.Name);
861 else if (subCommand ==
"start")
863 m_udpServer.OqrEngine.Start();
864 MainConsole.Instance.OutputFormat(
"Started OQRE for {0}", m_udpServer.Scene.Name);
866 else if (subCommand ==
"status")
868 MainConsole.Instance.OutputFormat(
"OQRE in {0}", m_udpServer.Scene.Name);
869 MainConsole.Instance.OutputFormat(
"Running: {0}", m_udpServer.OqrEngine.IsRunning);
870 MainConsole.Instance.OutputFormat(
871 "Requests waiting: {0}",
872 m_udpServer.OqrEngine.IsRunning ? m_udpServer.OqrEngine.JobsWaiting.ToString() :
"n/a");
876 MainConsole.Instance.OutputFormat(
"Unrecognized OQRE subcommand {0}", subCommand);
Used to generated a formatted table for the console.
static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i)
Convert a console input to an int, automatically complaining if a console is given.
static SceneManager Instance
static bool TryParseConsoleBool(ICommandConsole console, string rawConsoleString, out bool b)
Convert a console input to a bool, automatically complaining if a console is given.
LLUDPServerCommands(ICommandConsole console, LLUDPServer udpServer)
static ICommandConsole Instance
Manager for adding, closing and restarting scenes.
string GetColumnEntry(string entry, int maxLength, int columnPadding)
The LLUDP server for a region. This handles incoming and outgoing packets for all UDP connections to ...
Scene CurrentScene
Scene selected from the console.
Scene(RegionInfo regInfo, AgentCircuitManager authen, ISimulationDataService simDataService, IEstateDataService estateDataService, IConfigSource config, string simulatorVersion)