1
0

LLUDPServerCommands.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  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.OutputFormat("Throttles for {0}", 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.OutputFormat("{0}\n", 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.OutputFormat("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.OutputFormat(
  279. "Data debug for {0} ({1}) set to {2} in {3}",
  280. sp.Name, sp.IsChildAgent ? "child" : "root", level, m_udpServer.Scene.Name);
  281. ((LLClientView)sp.ControllingClient).UDPClient.DebugDataOutLevel = level;
  282. }
  283. });
  284. }
  285. private void HandleThrottleCommand(string module, string[] args)
  286. {
  287. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  288. return;
  289. bool all = args.Length == 5;
  290. bool one = args.Length == 7;
  291. if (!all && !one)
  292. {
  293. MainConsole.Instance.OutputFormat(
  294. "Usage: debug lludp throttles log <level> [<avatar-first-name> <avatar-last-name>]");
  295. return;
  296. }
  297. int level;
  298. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out level))
  299. return;
  300. string firstName = null;
  301. string lastName = null;
  302. if (one)
  303. {
  304. firstName = args[5];
  305. lastName = args[6];
  306. }
  307. m_udpServer.Scene.ForEachScenePresence(sp =>
  308. {
  309. if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
  310. {
  311. MainConsole.Instance.OutputFormat(
  312. "Throttle log level for {0} ({1}) set to {2} in {3}",
  313. sp.Name, sp.IsChildAgent ? "child" : "root", level, m_udpServer.Scene.Name);
  314. ((LLClientView)sp.ControllingClient).UDPClient.ThrottleDebugLevel = level;
  315. }
  316. });
  317. }
  318. private void HandleThrottleSetCommand(string module, string[] args)
  319. {
  320. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  321. return;
  322. bool all = args.Length == 6;
  323. bool one = args.Length == 8;
  324. if (!all && !one)
  325. {
  326. MainConsole.Instance.OutputFormat(
  327. "Usage: debug lludp throttles set <param> <value> [<avatar-first-name> <avatar-last-name>]");
  328. return;
  329. }
  330. string param = args[4];
  331. string rawValue = args[5];
  332. string firstName = null;
  333. string lastName = null;
  334. if (one)
  335. {
  336. firstName = args[6];
  337. lastName = args[7];
  338. }
  339. if (param == "adaptive")
  340. {
  341. bool newValue;
  342. if (!ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, rawValue, out newValue))
  343. return;
  344. m_udpServer.Scene.ForEachScenePresence(sp =>
  345. {
  346. if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
  347. {
  348. MainConsole.Instance.OutputFormat(
  349. "Setting param {0} to {1} for {2} ({3}) in {4}",
  350. param, newValue, sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
  351. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  352. udpClient.FlowThrottle.AdaptiveEnabled = newValue;
  353. // udpClient.FlowThrottle.MaxDripRate = 0;
  354. // udpClient.FlowThrottle.AdjustedDripRate = 0;
  355. }
  356. });
  357. }
  358. else if (param == "request")
  359. {
  360. int newValue;
  361. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
  362. return;
  363. int newCurrentThrottleKbps = newValue * 1000 / 8;
  364. m_udpServer.Scene.ForEachScenePresence(sp =>
  365. {
  366. if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
  367. {
  368. MainConsole.Instance.OutputFormat(
  369. "Setting param {0} to {1} for {2} ({3}) in {4}",
  370. param, newValue, sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
  371. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  372. udpClient.FlowThrottle.RequestedDripRate = newCurrentThrottleKbps;
  373. }
  374. });
  375. }
  376. else if (param == "max")
  377. {
  378. int newValue;
  379. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
  380. return;
  381. int newThrottleMaxKbps = newValue * 1000 / 8;
  382. m_udpServer.Scene.ForEachScenePresence(sp =>
  383. {
  384. if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
  385. {
  386. MainConsole.Instance.OutputFormat(
  387. "Setting param {0} to {1} for {2} ({3}) in {4}",
  388. param, newValue, sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
  389. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  390. udpClient.FlowThrottle.MaxDripRate = newThrottleMaxKbps;
  391. }
  392. });
  393. }
  394. }
  395. private void HandleThrottleGetCommand(string module, string[] args)
  396. {
  397. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  398. return;
  399. bool all = args.Length == 4;
  400. bool one = args.Length == 6;
  401. if (!all && !one)
  402. {
  403. MainConsole.Instance.OutputFormat(
  404. "Usage: debug lludp throttles get [<avatar-first-name> <avatar-last-name>]");
  405. return;
  406. }
  407. string firstName = null;
  408. string lastName = null;
  409. if (one)
  410. {
  411. firstName = args[4];
  412. lastName = args[5];
  413. }
  414. m_udpServer.Scene.ForEachScenePresence(sp =>
  415. {
  416. if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
  417. {
  418. m_console.OutputFormat(
  419. "Status for {0} ({1}) in {2}",
  420. sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
  421. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  422. ConsoleDisplayList cdl = new ConsoleDisplayList();
  423. cdl.AddRow("adaptive", udpClient.FlowThrottle.AdaptiveEnabled);
  424. cdl.AddRow("current", string.Format("{0} kbps", udpClient.FlowThrottle.DripRate * 8 / 1000));
  425. cdl.AddRow("request", string.Format("{0} kbps", udpClient.FlowThrottle.RequestedDripRate * 8 / 1000));
  426. cdl.AddRow("max", string.Format("{0} kbps", udpClient.FlowThrottle.MaxDripRate * 8 / 1000));
  427. m_console.Output(cdl.ToString());
  428. }
  429. });
  430. }
  431. private void HandleGetCommand(string module, string[] args)
  432. {
  433. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  434. return;
  435. m_console.OutputFormat("Debug settings for {0}", m_udpServer.Scene.Name);
  436. ConsoleDisplayList cdl = new ConsoleDisplayList();
  437. long maxSceneDripRate = (long)m_udpServer.Throttle.MaxDripRate;
  438. cdl.AddRow(
  439. "max-scene-throttle",
  440. maxSceneDripRate != 0 ? string.Format("{0} kbps", maxSceneDripRate * 8 / 1000) : "unset");
  441. int maxClientDripRate = m_udpServer.ThrottleRates.Total;
  442. cdl.AddRow(
  443. "max-new-client-throttle",
  444. maxClientDripRate != 0 ? string.Format("{0} kbps", maxClientDripRate * 8 / 1000) : "unset");
  445. m_console.Output(cdl.ToString());
  446. }
  447. private void HandleSetCommand(string module, string[] args)
  448. {
  449. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  450. return;
  451. if (args.Length != 5)
  452. {
  453. MainConsole.Instance.OutputFormat("Usage: debug lludp set <param> <value>");
  454. return;
  455. }
  456. string param = args[3];
  457. string rawValue = args[4];
  458. int newValue;
  459. if (param == "max-scene-throttle")
  460. {
  461. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
  462. return;
  463. m_udpServer.Throttle.MaxDripRate = newValue * 1000 / 8;
  464. }
  465. else if (param == "max-new-client-throttle")
  466. {
  467. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
  468. return;
  469. m_udpServer.ThrottleRates.Total = newValue * 1000 / 8;
  470. }
  471. else
  472. {
  473. return;
  474. }
  475. m_console.OutputFormat("{0} set to {1} in {2}", param, rawValue, m_udpServer.Scene.Name);
  476. }
  477. /* not in use, nothing to set/get from lludp
  478. private void HandleClientGetCommand(string module, string[] args)
  479. {
  480. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  481. return;
  482. if (args.Length != 4 && args.Length != 6)
  483. {
  484. MainConsole.Instance.OutputFormat("Usage: debug lludp client get [<avatar-first-name> <avatar-last-name>]");
  485. return;
  486. }
  487. string name = null;
  488. if (args.Length == 6)
  489. name = string.Format("{0} {1}", args[4], args[5]);
  490. m_udpServer.Scene.ForEachScenePresence(
  491. sp =>
  492. {
  493. if ((name == null || sp.Name == name) && sp.ControllingClient is LLClientView)
  494. {
  495. LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
  496. m_console.OutputFormat(
  497. "Client debug parameters for {0} ({1}) in {2}",
  498. sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
  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. // nothing here now
  517. }
  518. */
  519. private void HandlePacketCommand(string module, string[] args)
  520. {
  521. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  522. return;
  523. bool setAsDefaultLevel = false;
  524. bool setAll = false;
  525. OptionSet optionSet = new OptionSet()
  526. .Add("default", o => setAsDefaultLevel = (o != null))
  527. .Add("all", o => setAll = (o != null));
  528. List<string> filteredArgs = optionSet.Parse(args);
  529. string name = null;
  530. if (filteredArgs.Count == 6)
  531. {
  532. if (!(setAsDefaultLevel || setAll))
  533. {
  534. name = string.Format("{0} {1}", filteredArgs[4], filteredArgs[5]);
  535. }
  536. else
  537. {
  538. MainConsole.Instance.OutputFormat("ERROR: Cannot specify a user name when setting default/all logging level");
  539. return;
  540. }
  541. }
  542. if (filteredArgs.Count > 3)
  543. {
  544. int newDebug;
  545. if (int.TryParse(filteredArgs[3], out newDebug))
  546. {
  547. if (setAsDefaultLevel || setAll)
  548. {
  549. m_udpServer.DefaultClientPacketDebugLevel = newDebug;
  550. MainConsole.Instance.OutputFormat(
  551. "Packet debug for {0} clients set to {1} in {2}",
  552. (setAll ? "all" : "future"), m_udpServer.DefaultClientPacketDebugLevel, m_udpServer.Scene.Name);
  553. if (setAll)
  554. {
  555. m_udpServer.Scene.ForEachScenePresence(sp =>
  556. {
  557. MainConsole.Instance.OutputFormat(
  558. "Packet debug for {0} ({1}) set to {2} in {3}",
  559. sp.Name, sp.IsChildAgent ? "child" : "root", newDebug, m_udpServer.Scene.Name);
  560. sp.ControllingClient.DebugPacketLevel = newDebug;
  561. });
  562. }
  563. }
  564. else
  565. {
  566. m_udpServer.Scene.ForEachScenePresence(sp =>
  567. {
  568. if (name == null || sp.Name == name)
  569. {
  570. MainConsole.Instance.OutputFormat(
  571. "Packet debug for {0} ({1}) set to {2} in {3}",
  572. sp.Name, sp.IsChildAgent ? "child" : "root", newDebug, m_udpServer.Scene.Name);
  573. sp.ControllingClient.DebugPacketLevel = newDebug;
  574. }
  575. });
  576. }
  577. }
  578. else
  579. {
  580. MainConsole.Instance.Output("Usage: debug lludp packet [--default | --all] 0..255 [<first-name> <last-name>]");
  581. }
  582. }
  583. }
  584. private void HandleDropCommand(string module, string[] args)
  585. {
  586. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  587. return;
  588. if (args.Length != 6)
  589. {
  590. MainConsole.Instance.Output("Usage: debug lludp drop <in|out> <add|remove> <packet-name>");
  591. return;
  592. }
  593. string direction = args[3];
  594. string subCommand = args[4];
  595. string packetName = args[5];
  596. if (subCommand == "add")
  597. {
  598. MainConsole.Instance.OutputFormat(
  599. "Adding packet {0} to {1} drop list for all connections in {2}",
  600. direction, packetName, m_udpServer.Scene.Name);
  601. m_udpServer.Scene.ForEachScenePresence(
  602. sp =>
  603. {
  604. LLClientView llcv = (LLClientView)sp.ControllingClient;
  605. if (direction == "in")
  606. llcv.AddInPacketToDropSet(packetName);
  607. else if (direction == "out")
  608. llcv.AddOutPacketToDropSet(packetName);
  609. }
  610. );
  611. }
  612. else if (subCommand == "remove")
  613. {
  614. MainConsole.Instance.OutputFormat(
  615. "Removing packet {0} from {1} drop list for all connections in {2}",
  616. direction, packetName, m_udpServer.Scene.Name);
  617. m_udpServer.Scene.ForEachScenePresence(
  618. sp =>
  619. {
  620. LLClientView llcv = (LLClientView)sp.ControllingClient;
  621. if (direction == "in")
  622. llcv.RemoveInPacketFromDropSet(packetName);
  623. else if (direction == "out")
  624. llcv.RemoveOutPacketFromDropSet(packetName);
  625. }
  626. );
  627. }
  628. }
  629. private void HandleStartCommand(string module, string[] args)
  630. {
  631. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  632. return;
  633. if (args.Length != 4)
  634. {
  635. MainConsole.Instance.Output("Usage: debug lludp start <in|out|all>");
  636. return;
  637. }
  638. string subCommand = args[3];
  639. if (subCommand == "in" || subCommand == "all")
  640. m_udpServer.StartInbound();
  641. if (subCommand == "out" || subCommand == "all")
  642. m_udpServer.StartOutbound();
  643. }
  644. private void HandleStopCommand(string module, string[] args)
  645. {
  646. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  647. return;
  648. if (args.Length != 4)
  649. {
  650. MainConsole.Instance.Output("Usage: debug lludp stop <in|out|all>");
  651. return;
  652. }
  653. string subCommand = args[3];
  654. if (subCommand == "in" || subCommand == "all")
  655. m_udpServer.StopInbound();
  656. if (subCommand == "out" || subCommand == "all")
  657. m_udpServer.StopOutbound();
  658. }
  659. private void HandleAgentUpdateCommand(string module, string[] args)
  660. {
  661. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  662. return;
  663. m_udpServer.DiscardInboundAgentUpdates = !m_udpServer.DiscardInboundAgentUpdates;
  664. MainConsole.Instance.OutputFormat(
  665. "Discard AgentUpdates now {0} for {1}", m_udpServer.DiscardInboundAgentUpdates, m_udpServer.Scene.Name);
  666. }
  667. private void HandleStatusCommand(string module, string[] args)
  668. {
  669. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  670. return;
  671. MainConsole.Instance.OutputFormat(
  672. "IN LLUDP packet processing for {0} is {1}", m_udpServer.Scene.Name, m_udpServer.IsRunningInbound ? "enabled" : "disabled");
  673. MainConsole.Instance.OutputFormat(
  674. "OUT LLUDP packet processing for {0} is {1}", m_udpServer.Scene.Name, m_udpServer.IsRunningOutbound ? "enabled" : "disabled");
  675. MainConsole.Instance.OutputFormat(
  676. "Packet debug level for new clients is {0}", m_udpServer.DefaultClientPacketDebugLevel);
  677. }
  678. private void HandleOqreCommand(string module, string[] args)
  679. {
  680. if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
  681. return;
  682. if (args.Length != 4)
  683. {
  684. MainConsole.Instance.Output("Usage: debug lludp oqre <stop|start|status>");
  685. return;
  686. }
  687. string subCommand = args[3];
  688. if (subCommand == "stop")
  689. {
  690. m_udpServer.OqrEngine.Stop();
  691. MainConsole.Instance.OutputFormat("Stopped OQRE for {0}", m_udpServer.Scene.Name);
  692. }
  693. else if (subCommand == "start")
  694. {
  695. m_udpServer.OqrEngine.Start();
  696. MainConsole.Instance.OutputFormat("Started OQRE for {0}", m_udpServer.Scene.Name);
  697. }
  698. else if (subCommand == "status")
  699. {
  700. MainConsole.Instance.OutputFormat("OQRE in {0}", m_udpServer.Scene.Name);
  701. MainConsole.Instance.OutputFormat("Running: {0}", m_udpServer.OqrEngine.IsRunning);
  702. MainConsole.Instance.OutputFormat(
  703. "Requests waiting: {0}",
  704. m_udpServer.OqrEngine.IsRunning ? m_udpServer.OqrEngine.JobsWaiting.ToString() : "n/a");
  705. }
  706. else
  707. {
  708. MainConsole.Instance.OutputFormat("Unrecognized OQRE subcommand {0}", subCommand);
  709. }
  710. }
  711. }
  712. }