LLUDPServerCommands.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Text;
  30. using NDesk.Options;
  31. using OpenSim.Framework;
  32. using OpenSim.Framework.Console;
  33. using OpenSim.Region.Framework.Scenes;
  34. namespace OpenSim.Region.ClientStack.LindenUDP
  35. {
  36. public class LLUDPServerCommands
  37. {
  38. private ICommandConsole m_console;
  39. private LLUDPServer m_udpServer;
  40. public LLUDPServerCommands(ICommandConsole console, LLUDPServer udpServer)
  41. {
  42. m_console = console;
  43. m_udpServer = udpServer;
  44. }
  45. public void Register()
  46. {
  47. m_console.Commands.AddCommand(
  48. "Comms", false, "show server throttles",
  49. "show server throttles",
  50. "Show information about server throttles",
  51. HandleShowServerThrottlesCommand);
  52. m_console.Commands.AddCommand(
  53. "Debug", false, "debug lludp packet",
  54. "debug lludp packet [--default | --all] <level> [<avatar-first-name> <avatar-last-name>]",
  55. "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.",
  56. "If level > 255 then all incoming and outgoing packets are logged.\n"
  57. + "If level <= 255 then incoming AgentUpdate and outgoing SimStats and SimulatorViewerTimeMessage packets are not logged.\n"
  58. + "If level <= 200 then incoming RequestImage and outgoing ImagePacket, ImageData, LayerData and CoarseLocationUpdate packets are not logged.\n"
  59. + "If level <= 100 then incoming ViewerEffect and AgentAnimation and outgoing ViewerEffect and AvatarAnimation packets are not logged.\n"
  60. + "If level <= 50 then outgoing ImprovedTerseObjectUpdate packets are not logged.\n"
  61. + "If level <= 0 then no packets are logged.\n"
  62. + "If --default is specified then the level becomes the default logging level for all subsequent agents.\n"
  63. + "If --all is specified then the level becomes the default logging level for all current and subsequent agents.\n"
  64. + "In these cases, you cannot also specify an avatar name.\n"
  65. + "If an avatar name is given then only packets from that avatar are logged.",
  66. HandlePacketCommand);
  67. m_console.Commands.AddCommand(
  68. "Debug", false, "debug lludp data out",
  69. "debug lludp data out <level> <avatar-first-name> <avatar-last-name>\"",
  70. "Turn on debugging for final outgoing data to the given user's client.",
  71. "This operates at a much lower level than the packet command and prints out available details when the data is actually sent.\n"
  72. + "If level > 0 then information about all outgoing UDP data for this avatar is logged.\n"
  73. + "If level <= 0 then no information about outgoing UDP data for this avatar is logged.",
  74. HandleDataCommand);
  75. m_console.Commands.AddCommand(
  76. "Debug", false, "debug lludp drop",
  77. "debug lludp drop <in|out> <add|remove> <packet-name>",
  78. "Drop all in or outbound packets that match the given name",
  79. "For test purposes.",
  80. HandleDropCommand);
  81. m_console.Commands.AddCommand(
  82. "Debug",
  83. false,
  84. "debug lludp start",
  85. "debug lludp start <in|out|all>",
  86. "Control LLUDP packet processing.",
  87. "No effect if packet processing has already started.\n"
  88. + "in - start inbound processing.\n"
  89. + "out - start outbound processing.\n"
  90. + "all - start in and outbound processing.\n",
  91. HandleStartCommand);
  92. m_console.Commands.AddCommand(
  93. "Debug",
  94. false,
  95. "debug lludp stop",
  96. "debug lludp stop <in|out|all>",
  97. "Stop LLUDP packet processing.",
  98. "No effect if packet processing has already stopped.\n"
  99. + "in - stop inbound processing.\n"
  100. + "out - stop outbound processing.\n"
  101. + "all - stop in and outbound processing.\n",
  102. HandleStopCommand);
  103. m_console.Commands.AddCommand(
  104. "Debug",
  105. false,
  106. "debug lludp pool",
  107. "debug lludp pool <on|off>",
  108. "Turn object pooling within the lludp component on or off.",
  109. HandlePoolCommand);
  110. m_console.Commands.AddCommand(
  111. "Debug",
  112. false,
  113. "debug lludp status",
  114. "debug lludp status",
  115. "Return status of LLUDP packet processing.",
  116. HandleStatusCommand);
  117. m_console.Commands.AddCommand(
  118. "Debug",
  119. false,
  120. "debug lludp throttles log",
  121. "debug lludp throttles log <level> [<avatar-first-name> <avatar-last-name>]",
  122. "Change debug logging level for throttles.",
  123. "If level >= 0 then throttle debug logging is performed.\n"
  124. + "If level <= 0 then no throttle debug logging is performed.",
  125. HandleThrottleCommand);
  126. m_console.Commands.AddCommand(
  127. "Debug",
  128. false,
  129. "debug lludp throttles get",
  130. "debug lludp throttles get [<avatar-first-name> <avatar-last-name>]",
  131. "Return debug settings for throttles.",
  132. "adaptive - true/false, controls adaptive throttle setting.\n"
  133. + "request - request drip rate in kbps.\n"
  134. + "max - the max kbps throttle allowed for the specified existing clients. Use 'debug lludp get new-client-throttle-max' to see the setting for new clients.\n",
  135. HandleThrottleGetCommand);
  136. m_console.Commands.AddCommand(
  137. "Debug",
  138. false,
  139. "debug lludp throttles set",
  140. "debug lludp throttles set <param> <value> [<avatar-first-name> <avatar-last-name>]",
  141. "Set a throttle parameter for the given client.",
  142. "adaptive - true/false, controls adaptive throttle setting.\n"
  143. + "current - current drip rate in kbps.\n"
  144. + "request - requested drip rate in kbps.\n"
  145. + "max - the max kbps throttle allowed for the specified existing clients. Use 'debug lludp set new-client-throttle-max' to change the settings for new clients.\n",
  146. HandleThrottleSetCommand);
  147. m_console.Commands.AddCommand(
  148. "Debug",
  149. false,
  150. "debug lludp get",
  151. "debug lludp get",
  152. "Get debug parameters for the server.",
  153. "max-scene-throttle - the current max cumulative kbps provided for this scene to clients.\n"
  154. + "max-new-client-throttle - the max kbps throttle allowed to new clients. Use 'debug lludp throttles get max' to see the settings for existing clients.",
  155. HandleGetCommand);
  156. m_console.Commands.AddCommand(
  157. "Debug",
  158. false,
  159. "debug lludp set",
  160. "debug lludp set <param> <value>",
  161. "Set a parameter for the server.",
  162. "max-scene-throttle - the current max cumulative kbps provided for this scene to clients.\n"
  163. + "max-new-client-throttle - the max kbps throttle allowed to each new client. Use 'debug lludp throttles set max' to set for existing clients.",
  164. HandleSetCommand);
  165. m_console.Commands.AddCommand(
  166. "Debug",
  167. false,
  168. "debug lludp toggle agentupdate",
  169. "debug lludp toggle agentupdate",
  170. "Toggle whether agentupdate packets are processed or simply discarded.",
  171. HandleAgentUpdateCommand);
  172. MainConsole.Instance.Commands.AddCommand(
  173. "Debug",
  174. false,
  175. "debug lludp oqre",
  176. "debug lludp oqre <start|stop|status>",
  177. "Start, stop or get status of OutgoingQueueRefillEngine.",
  178. "If stopped then refill requests are processed directly via the threadpool.",
  179. HandleOqreCommand);
  180. m_console.Commands.AddCommand(
  181. "Debug",
  182. false,
  183. "debug lludp client get",
  184. "debug lludp client get [<avatar-first-name> <avatar-last-name>]",
  185. "Get debug parameters for the client. If no name is given then all client information is returned.",
  186. "process-unacked-sends - Do we take action if a sent reliable packet has not been acked.",
  187. HandleClientGetCommand);
  188. m_console.Commands.AddCommand(
  189. "Debug",
  190. false,
  191. "debug lludp client set",
  192. "debug lludp client set <param> <value> [<avatar-first-name> <avatar-last-name>]",
  193. "Set a debug parameter for a particular client. If no name is given then the value is set on all clients.",
  194. "process-unacked-sends - Do we take action if a sent reliable packet has not been acked.",
  195. HandleClientSetCommand);
  196. }
  197. private void HandleShowServerThrottlesCommand(string module, string[] args)
  198. {
  199. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  200. return;
  201. m_console.OutputFormat("Throttles for {0}", m_udpServer.Scene.Name);
  202. ConsoleDisplayList cdl = new ConsoleDisplayList();
  203. cdl.AddRow("Adaptive throttles", m_udpServer.ThrottleRates.AdaptiveThrottlesEnabled);
  204. long maxSceneDripRate = m_udpServer.Throttle.MaxDripRate;
  205. cdl.AddRow(
  206. "Max scene throttle",
  207. maxSceneDripRate != 0 ? string.Format("{0} kbps", maxSceneDripRate * 8 / 1000) : "unset");
  208. int maxClientDripRate = m_udpServer.ThrottleRates.Total;
  209. cdl.AddRow(
  210. "Max new client throttle",
  211. maxClientDripRate != 0 ? string.Format("{0} kbps", maxClientDripRate * 8 / 1000) : "unset");
  212. m_console.Output(cdl.ToString());
  213. m_console.OutputFormat("{0}\n", GetServerThrottlesReport(m_udpServer));
  214. }
  215. private string GetServerThrottlesReport(LLUDPServer udpServer)
  216. {
  217. StringBuilder report = new StringBuilder();
  218. report.AppendFormat(
  219. "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}\n",
  220. "Total",
  221. "Resend",
  222. "Land",
  223. "Wind",
  224. "Cloud",
  225. "Task",
  226. "Texture",
  227. "Asset");
  228. report.AppendFormat(
  229. "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}\n",
  230. "kb/s",
  231. "kb/s",
  232. "kb/s",
  233. "kb/s",
  234. "kb/s",
  235. "kb/s",
  236. "kb/s",
  237. "kb/s");
  238. ThrottleRates throttleRates = udpServer.ThrottleRates;
  239. report.AppendFormat(
  240. "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}",
  241. (throttleRates.Total * 8) / 1000,
  242. (throttleRates.Resend * 8) / 1000,
  243. (throttleRates.Land * 8) / 1000,
  244. (throttleRates.Wind * 8) / 1000,
  245. (throttleRates.Cloud * 8) / 1000,
  246. (throttleRates.Task * 8) / 1000,
  247. (throttleRates.Texture * 8) / 1000,
  248. (throttleRates.Asset * 8) / 1000);
  249. return report.ToString();
  250. }
  251. protected string GetColumnEntry(string entry, int maxLength, int columnPadding)
  252. {
  253. return string.Format(
  254. "{0,-" + maxLength + "}{1,-" + columnPadding + "}",
  255. entry.Length > maxLength ? entry.Substring(0, maxLength) : entry,
  256. "");
  257. }
  258. private void HandleDataCommand(string module, string[] args)
  259. {
  260. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  261. return;
  262. if (args.Length != 7)
  263. {
  264. MainConsole.Instance.OutputFormat("Usage: debug lludp data out <true|false> <avatar-first-name> <avatar-last-name>");
  265. return;
  266. }
  267. int level;
  268. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out level))
  269. return;
  270. string firstName = args[5];
  271. string lastName = args[6];
  272. m_udpServer.Scene.ForEachScenePresence(sp =>
  273. {
  274. if (sp.Firstname == firstName && sp.Lastname == lastName)
  275. {
  276. MainConsole.Instance.OutputFormat(
  277. "Data debug for {0} ({1}) set to {2} in {3}",
  278. sp.Name, sp.IsChildAgent ? "child" : "root", level, m_udpServer.Scene.Name);
  279. ((LLClientView)sp.ControllingClient).UDPClient.DebugDataOutLevel = level;
  280. }
  281. });
  282. }
  283. private void HandleThrottleCommand(string module, string[] args)
  284. {
  285. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  286. return;
  287. bool all = args.Length == 5;
  288. bool one = args.Length == 7;
  289. if (!all && !one)
  290. {
  291. MainConsole.Instance.OutputFormat(
  292. "Usage: debug lludp throttles log <level> [<avatar-first-name> <avatar-last-name>]");
  293. return;
  294. }
  295. int level;
  296. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out level))
  297. return;
  298. string firstName = null;
  299. string lastName = null;
  300. if (one)
  301. {
  302. firstName = args[5];
  303. lastName = args[6];
  304. }
  305. m_udpServer.Scene.ForEachScenePresence(sp =>
  306. {
  307. if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
  308. {
  309. MainConsole.Instance.OutputFormat(
  310. "Throttle log level for {0} ({1}) set to {2} in {3}",
  311. sp.Name, sp.IsChildAgent ? "child" : "root", level, m_udpServer.Scene.Name);
  312. ((LLClientView)sp.ControllingClient).UDPClient.ThrottleDebugLevel = level;
  313. }
  314. });
  315. }
  316. private void HandleThrottleSetCommand(string module, string[] args)
  317. {
  318. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  319. return;
  320. bool all = args.Length == 6;
  321. bool one = args.Length == 8;
  322. if (!all && !one)
  323. {
  324. MainConsole.Instance.OutputFormat(
  325. "Usage: debug lludp throttles set <param> <value> [<avatar-first-name> <avatar-last-name>]");
  326. return;
  327. }
  328. string param = args[4];
  329. string rawValue = args[5];
  330. string firstName = null;
  331. string lastName = null;
  332. if (one)
  333. {
  334. firstName = args[6];
  335. lastName = args[7];
  336. }
  337. if (param == "adaptive")
  338. {
  339. bool newValue;
  340. if (!ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, rawValue, out newValue))
  341. return;
  342. m_udpServer.Scene.ForEachScenePresence(sp =>
  343. {
  344. if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
  345. {
  346. MainConsole.Instance.OutputFormat(
  347. "Setting param {0} to {1} for {2} ({3}) in {4}",
  348. param, newValue, sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
  349. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  350. udpClient.FlowThrottle.AdaptiveEnabled = newValue;
  351. // udpClient.FlowThrottle.MaxDripRate = 0;
  352. // udpClient.FlowThrottle.AdjustedDripRate = 0;
  353. }
  354. });
  355. }
  356. else if (param == "request")
  357. {
  358. int newValue;
  359. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
  360. return;
  361. int newCurrentThrottleKbps = newValue * 1000 / 8;
  362. m_udpServer.Scene.ForEachScenePresence(sp =>
  363. {
  364. if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
  365. {
  366. MainConsole.Instance.OutputFormat(
  367. "Setting param {0} to {1} for {2} ({3}) in {4}",
  368. param, newValue, sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
  369. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  370. udpClient.FlowThrottle.RequestedDripRate = newCurrentThrottleKbps;
  371. }
  372. });
  373. }
  374. else if (param == "max")
  375. {
  376. int newValue;
  377. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
  378. return;
  379. int newThrottleMaxKbps = newValue * 1000 / 8;
  380. m_udpServer.Scene.ForEachScenePresence(sp =>
  381. {
  382. if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
  383. {
  384. MainConsole.Instance.OutputFormat(
  385. "Setting param {0} to {1} for {2} ({3}) in {4}",
  386. param, newValue, sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
  387. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  388. udpClient.FlowThrottle.MaxDripRate = newThrottleMaxKbps;
  389. }
  390. });
  391. }
  392. }
  393. private void HandleThrottleGetCommand(string module, string[] args)
  394. {
  395. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  396. return;
  397. bool all = args.Length == 4;
  398. bool one = args.Length == 6;
  399. if (!all && !one)
  400. {
  401. MainConsole.Instance.OutputFormat(
  402. "Usage: debug lludp throttles get [<avatar-first-name> <avatar-last-name>]");
  403. return;
  404. }
  405. string firstName = null;
  406. string lastName = null;
  407. if (one)
  408. {
  409. firstName = args[4];
  410. lastName = args[5];
  411. }
  412. m_udpServer.Scene.ForEachScenePresence(sp =>
  413. {
  414. if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
  415. {
  416. m_console.OutputFormat(
  417. "Status for {0} ({1}) in {2}",
  418. sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
  419. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  420. ConsoleDisplayList cdl = new ConsoleDisplayList();
  421. cdl.AddRow("adaptive", udpClient.FlowThrottle.AdaptiveEnabled);
  422. cdl.AddRow("current", string.Format("{0} kbps", udpClient.FlowThrottle.DripRate * 8 / 1000));
  423. cdl.AddRow("request", string.Format("{0} kbps", udpClient.FlowThrottle.RequestedDripRate * 8 / 1000));
  424. cdl.AddRow("max", string.Format("{0} kbps", udpClient.FlowThrottle.MaxDripRate * 8 / 1000));
  425. m_console.Output(cdl.ToString());
  426. }
  427. });
  428. }
  429. private void HandleGetCommand(string module, string[] args)
  430. {
  431. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  432. return;
  433. m_console.OutputFormat("Debug settings for {0}", m_udpServer.Scene.Name);
  434. ConsoleDisplayList cdl = new ConsoleDisplayList();
  435. long maxSceneDripRate = m_udpServer.Throttle.MaxDripRate;
  436. cdl.AddRow(
  437. "max-scene-throttle",
  438. maxSceneDripRate != 0 ? string.Format("{0} kbps", maxSceneDripRate * 8 / 1000) : "unset");
  439. int maxClientDripRate = m_udpServer.ThrottleRates.Total;
  440. cdl.AddRow(
  441. "max-new-client-throttle",
  442. maxClientDripRate != 0 ? string.Format("{0} kbps", maxClientDripRate * 8 / 1000) : "unset");
  443. m_console.Output(cdl.ToString());
  444. }
  445. private void HandleSetCommand(string module, string[] args)
  446. {
  447. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  448. return;
  449. if (args.Length != 5)
  450. {
  451. MainConsole.Instance.OutputFormat("Usage: debug lludp set <param> <value>");
  452. return;
  453. }
  454. string param = args[3];
  455. string rawValue = args[4];
  456. int newValue;
  457. if (param == "max-scene-throttle")
  458. {
  459. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
  460. return;
  461. m_udpServer.Throttle.MaxDripRate = newValue * 1000 / 8;
  462. }
  463. else if (param == "max-new-client-throttle")
  464. {
  465. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
  466. return;
  467. m_udpServer.ThrottleRates.Total = newValue * 1000 / 8;
  468. }
  469. else
  470. {
  471. return;
  472. }
  473. m_console.OutputFormat("{0} set to {1} in {2}", param, rawValue, m_udpServer.Scene.Name);
  474. }
  475. private void HandleClientGetCommand(string module, string[] args)
  476. {
  477. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  478. return;
  479. if (args.Length != 4 && args.Length != 6)
  480. {
  481. MainConsole.Instance.OutputFormat("Usage: debug lludp client get [<avatar-first-name> <avatar-last-name>]");
  482. return;
  483. }
  484. string name = null;
  485. if (args.Length == 6)
  486. name = string.Format("{0} {1}", args[4], args[5]);
  487. m_udpServer.Scene.ForEachScenePresence(
  488. sp =>
  489. {
  490. if ((name == null || sp.Name == name) && sp.ControllingClient is LLClientView)
  491. {
  492. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  493. m_console.OutputFormat(
  494. "Client debug parameters for {0} ({1}) in {2}",
  495. sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
  496. ConsoleDisplayList cdl = new ConsoleDisplayList();
  497. cdl.AddRow("process-unacked-sends", udpClient.ProcessUnackedSends);
  498. m_console.Output(cdl.ToString());
  499. }
  500. });
  501. }
  502. private void HandleClientSetCommand(string module, string[] args)
  503. {
  504. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  505. return;
  506. if (args.Length != 6 && args.Length != 8)
  507. {
  508. MainConsole.Instance.OutputFormat("Usage: debug lludp client set <param> <value> [<avatar-first-name> <avatar-last-name>]");
  509. return;
  510. }
  511. string param = args[4];
  512. string rawValue = args[5];
  513. string name = null;
  514. if (args.Length == 8)
  515. name = string.Format("{0} {1}", args[6], args[7]);
  516. if (param == "process-unacked-sends")
  517. {
  518. bool newValue;
  519. if (!ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, rawValue, out newValue))
  520. return;
  521. m_udpServer.Scene.ForEachScenePresence(
  522. sp =>
  523. {
  524. if ((name == null || sp.Name == name) && sp.ControllingClient is LLClientView)
  525. {
  526. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  527. udpClient.ProcessUnackedSends = newValue;
  528. m_console.OutputFormat("{0} set to {1} for {2} in {3}", param, newValue, sp.Name, m_udpServer.Scene.Name);
  529. }
  530. });
  531. }
  532. }
  533. private void HandlePacketCommand(string module, string[] args)
  534. {
  535. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  536. return;
  537. bool setAsDefaultLevel = false;
  538. bool setAll = false;
  539. OptionSet optionSet = new OptionSet()
  540. .Add("default", o => setAsDefaultLevel = (o != null))
  541. .Add("all", o => setAll = (o != null));
  542. List<string> filteredArgs = optionSet.Parse(args);
  543. string name = null;
  544. if (filteredArgs.Count == 6)
  545. {
  546. if (!(setAsDefaultLevel || setAll))
  547. {
  548. name = string.Format("{0} {1}", filteredArgs[4], filteredArgs[5]);
  549. }
  550. else
  551. {
  552. MainConsole.Instance.OutputFormat("ERROR: Cannot specify a user name when setting default/all logging level");
  553. return;
  554. }
  555. }
  556. if (filteredArgs.Count > 3)
  557. {
  558. int newDebug;
  559. if (int.TryParse(filteredArgs[3], out newDebug))
  560. {
  561. if (setAsDefaultLevel || setAll)
  562. {
  563. m_udpServer.DefaultClientPacketDebugLevel = newDebug;
  564. MainConsole.Instance.OutputFormat(
  565. "Packet debug for {0} clients set to {1} in {2}",
  566. (setAll ? "all" : "future"), m_udpServer.DefaultClientPacketDebugLevel, m_udpServer.Scene.Name);
  567. if (setAll)
  568. {
  569. m_udpServer.Scene.ForEachScenePresence(sp =>
  570. {
  571. MainConsole.Instance.OutputFormat(
  572. "Packet debug for {0} ({1}) set to {2} in {3}",
  573. sp.Name, sp.IsChildAgent ? "child" : "root", newDebug, m_udpServer.Scene.Name);
  574. sp.ControllingClient.DebugPacketLevel = newDebug;
  575. });
  576. }
  577. }
  578. else
  579. {
  580. m_udpServer.Scene.ForEachScenePresence(sp =>
  581. {
  582. if (name == null || sp.Name == name)
  583. {
  584. MainConsole.Instance.OutputFormat(
  585. "Packet debug for {0} ({1}) set to {2} in {3}",
  586. sp.Name, sp.IsChildAgent ? "child" : "root", newDebug, m_udpServer.Scene.Name);
  587. sp.ControllingClient.DebugPacketLevel = newDebug;
  588. }
  589. });
  590. }
  591. }
  592. else
  593. {
  594. MainConsole.Instance.Output("Usage: debug lludp packet [--default | --all] 0..255 [<first-name> <last-name>]");
  595. }
  596. }
  597. }
  598. private void HandleDropCommand(string module, string[] args)
  599. {
  600. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  601. return;
  602. if (args.Length != 6)
  603. {
  604. MainConsole.Instance.Output("Usage: debug lludp drop <in|out> <add|remove> <packet-name>");
  605. return;
  606. }
  607. string direction = args[3];
  608. string subCommand = args[4];
  609. string packetName = args[5];
  610. if (subCommand == "add")
  611. {
  612. MainConsole.Instance.OutputFormat(
  613. "Adding packet {0} to {1} drop list for all connections in {2}",
  614. direction, packetName, m_udpServer.Scene.Name);
  615. m_udpServer.Scene.ForEachScenePresence(
  616. sp =>
  617. {
  618. LLClientView llcv = (LLClientView)sp.ControllingClient;
  619. if (direction == "in")
  620. llcv.AddInPacketToDropSet(packetName);
  621. else if (direction == "out")
  622. llcv.AddOutPacketToDropSet(packetName);
  623. }
  624. );
  625. }
  626. else if (subCommand == "remove")
  627. {
  628. MainConsole.Instance.OutputFormat(
  629. "Removing packet {0} from {1} drop list for all connections in {2}",
  630. direction, packetName, m_udpServer.Scene.Name);
  631. m_udpServer.Scene.ForEachScenePresence(
  632. sp =>
  633. {
  634. LLClientView llcv = (LLClientView)sp.ControllingClient;
  635. if (direction == "in")
  636. llcv.RemoveInPacketFromDropSet(packetName);
  637. else if (direction == "out")
  638. llcv.RemoveOutPacketFromDropSet(packetName);
  639. }
  640. );
  641. }
  642. }
  643. private void HandleStartCommand(string module, string[] args)
  644. {
  645. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  646. return;
  647. if (args.Length != 4)
  648. {
  649. MainConsole.Instance.Output("Usage: debug lludp start <in|out|all>");
  650. return;
  651. }
  652. string subCommand = args[3];
  653. if (subCommand == "in" || subCommand == "all")
  654. m_udpServer.StartInbound();
  655. if (subCommand == "out" || subCommand == "all")
  656. m_udpServer.StartOutbound();
  657. }
  658. private void HandleStopCommand(string module, string[] args)
  659. {
  660. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  661. return;
  662. if (args.Length != 4)
  663. {
  664. MainConsole.Instance.Output("Usage: debug lludp stop <in|out|all>");
  665. return;
  666. }
  667. string subCommand = args[3];
  668. if (subCommand == "in" || subCommand == "all")
  669. m_udpServer.StopInbound();
  670. if (subCommand == "out" || subCommand == "all")
  671. m_udpServer.StopOutbound();
  672. }
  673. private void HandlePoolCommand(string module, string[] args)
  674. {
  675. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  676. return;
  677. if (args.Length != 4)
  678. {
  679. MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
  680. return;
  681. }
  682. string enabled = args[3];
  683. if (enabled == "on")
  684. {
  685. if (m_udpServer.EnablePools())
  686. {
  687. m_udpServer.EnablePoolStats();
  688. MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_udpServer.Scene.Name);
  689. }
  690. }
  691. else if (enabled == "off")
  692. {
  693. if (m_udpServer.DisablePools())
  694. {
  695. m_udpServer.DisablePoolStats();
  696. MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_udpServer.Scene.Name);
  697. }
  698. }
  699. else
  700. {
  701. MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
  702. }
  703. }
  704. private void HandleAgentUpdateCommand(string module, string[] args)
  705. {
  706. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  707. return;
  708. m_udpServer.DiscardInboundAgentUpdates = !m_udpServer.DiscardInboundAgentUpdates;
  709. MainConsole.Instance.OutputFormat(
  710. "Discard AgentUpdates now {0} for {1}", m_udpServer.DiscardInboundAgentUpdates, m_udpServer.Scene.Name);
  711. }
  712. private void HandleStatusCommand(string module, string[] args)
  713. {
  714. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  715. return;
  716. MainConsole.Instance.OutputFormat(
  717. "IN LLUDP packet processing for {0} is {1}", m_udpServer.Scene.Name, m_udpServer.IsRunningInbound ? "enabled" : "disabled");
  718. MainConsole.Instance.OutputFormat(
  719. "OUT LLUDP packet processing for {0} is {1}", m_udpServer.Scene.Name, m_udpServer.IsRunningOutbound ? "enabled" : "disabled");
  720. MainConsole.Instance.OutputFormat("LLUDP pools in {0} are {1}", m_udpServer.Scene.Name, m_udpServer.UsePools ? "on" : "off");
  721. MainConsole.Instance.OutputFormat(
  722. "Packet debug level for new clients is {0}", m_udpServer.DefaultClientPacketDebugLevel);
  723. }
  724. private void HandleOqreCommand(string module, string[] args)
  725. {
  726. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  727. return;
  728. if (args.Length != 4)
  729. {
  730. MainConsole.Instance.Output("Usage: debug lludp oqre <stop|start|status>");
  731. return;
  732. }
  733. string subCommand = args[3];
  734. if (subCommand == "stop")
  735. {
  736. m_udpServer.OqrEngine.Stop();
  737. MainConsole.Instance.OutputFormat("Stopped OQRE for {0}", m_udpServer.Scene.Name);
  738. }
  739. else if (subCommand == "start")
  740. {
  741. m_udpServer.OqrEngine.Start();
  742. MainConsole.Instance.OutputFormat("Started OQRE for {0}", m_udpServer.Scene.Name);
  743. }
  744. else if (subCommand == "status")
  745. {
  746. MainConsole.Instance.OutputFormat("OQRE in {0}", m_udpServer.Scene.Name);
  747. MainConsole.Instance.OutputFormat("Running: {0}", m_udpServer.OqrEngine.IsRunning);
  748. MainConsole.Instance.OutputFormat(
  749. "Requests waiting: {0}",
  750. m_udpServer.OqrEngine.IsRunning ? m_udpServer.OqrEngine.JobsWaiting.ToString() : "n/a");
  751. }
  752. else
  753. {
  754. MainConsole.Instance.OutputFormat("Unrecognized OQRE subcommand {0}", subCommand);
  755. }
  756. }
  757. }
  758. }