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