LLUDPServerCommands.cs 35 KB

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