OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
ThrottleRates.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 OpenSim.Framework;
30 using Nini.Config;
31 
32 namespace OpenSim.Region.ClientStack.LindenUDP
33 {
39  public sealed class ThrottleRates
40  {
42  public int Resend;
44  public int Land;
46  public int Wind;
48  public int Cloud;
50  public int Task;
52  public int Texture;
54  public int Asset;
55 
57  public int Total;
58 
61 
68 
70  public double CannibalizeTextureRate;
71 
72  public int ClientMaxRate;
73  public float BrustTime;
74 
79  public ThrottleRates(IConfigSource config)
80  {
81  try
82  {
83  IConfig throttleConfig = config.Configs["ClientStack.LindenUDP"];
84 
85  // Current default total is 66750
86  Resend = throttleConfig.GetInt("resend_default", 6625);
87  Land = throttleConfig.GetInt("land_default", 9125);
88  Wind = throttleConfig.GetInt("wind_default", 1750);
89  Cloud = throttleConfig.GetInt("cloud_default", 1750);
90  Task = throttleConfig.GetInt("task_default", 18500);
91  Texture = throttleConfig.GetInt("texture_default", 18500);
92  Asset = throttleConfig.GetInt("asset_default", 10500);
93 
94  Total = Resend + Land + Wind + Cloud + Task + Texture + Asset;
95  // 3000000 bps default max
96  ClientMaxRate = throttleConfig.GetInt("client_throttle_max_bps", 375000);
97  if (ClientMaxRate > 1000000)
98  ClientMaxRate = 1000000; // no more than 8Mbps
99 
100  BrustTime = (float)throttleConfig.GetInt("client_throttle_burtsTimeMS", 10);
101  BrustTime *= 1e-3f;
102 
103  AdaptiveThrottlesEnabled = throttleConfig.GetBoolean("enable_adaptive_throttles", false);
104  MinimumAdaptiveThrottleRate = throttleConfig.GetInt("adaptive_throttle_min_bps", 32000);
105 
106  CannibalizeTextureRate = (double)throttleConfig.GetFloat("CannibalizeTextureRate", 0.0f);
107  CannibalizeTextureRate = Util.Clamp<double>(CannibalizeTextureRate,0.0, 0.9);
108  }
109  catch (Exception) { }
110  }
111 
113  {
114  switch (type)
115  {
116  case ThrottleOutPacketType.Resend:
117  return Resend;
118  case ThrottleOutPacketType.Land:
119  return Land;
120  case ThrottleOutPacketType.Wind:
121  return Wind;
122  case ThrottleOutPacketType.Cloud:
123  return Cloud;
124  case ThrottleOutPacketType.Task:
125  return Task;
126  case ThrottleOutPacketType.Texture:
127  return Texture;
128  case ThrottleOutPacketType.Asset:
129  return Asset;
130  case ThrottleOutPacketType.Unknown:
131  default:
132  return 0;
133  }
134  }
135  }
136 }
Int64 MinimumAdaptiveThrottleRate
Set the minimum rate that the adaptive throttles can set. The viewer can still throttle lower than th...
bool AdaptiveThrottlesEnabled
Flag used to enable adaptive throttles
ThrottleRates(IConfigSource config)
Default constructor
Any packets that do not fit into the other throttles
Non-texture assets
Holds drip rates and maximum burst rates for throttling with hierarchical token buckets. The maximum burst rates set here are hard limits and can not be overridden by client requests
Packets that are being resent
double CannibalizeTextureRate
Amount of the texture throttle to steal for the task throttle
int Texture
Drip rate for texture packets
int Total
Drip rate for the parent token bucket