aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorSean Dague2007-11-30 21:29:21 +0000
committerSean Dague2007-11-30 21:29:21 +0000
commit174a3d2ca1b666affce5ae80b4b0747b88c8a902 (patch)
treeb68b314f0ba309e8961fdefbd9990f6a54c5497e
parentstarting to fill out PacketQueue, refactoring as I go. This (diff)
downloadopensim-SC_OLD-174a3d2ca1b666affce5ae80b4b0747b88c8a902.zip
opensim-SC_OLD-174a3d2ca1b666affce5ae80b4b0747b88c8a902.tar.gz
opensim-SC_OLD-174a3d2ca1b666affce5ae80b4b0747b88c8a902.tar.bz2
opensim-SC_OLD-174a3d2ca1b666affce5ae80b4b0747b88c8a902.tar.xz
the packet throttle stuff is duped enough that a
seperate container for this probably makes the limits easier to understand
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/PacketThrottle.cs95
1 files changed, 95 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/PacketThrottle.cs b/OpenSim/Region/ClientStack/PacketThrottle.cs
new file mode 100644
index 0000000..30d7c25
--- /dev/null
+++ b/OpenSim/Region/ClientStack/PacketThrottle.cs
@@ -0,0 +1,95 @@
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 OpenSim 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*/
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Net.Sockets;
32using System.Text;
33using System.Threading;
34using System.Timers;
35using Axiom.Math;
36using libsecondlife;
37using libsecondlife.Packets;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Console;
41using Timer=System.Timers.Timer;
42
43namespace OpenSim.Region.ClientStack
44{
45 public class PacketThrottle
46 {
47
48 private int max; // max allowable throttle
49 private int min; // min allowable throttle
50 private int throttle; // current throttle setting
51 private static int divisor = 7; // the throttle time divisor, this probably should factor out
52 private int sent; // current number of bytes sent
53
54 public PacketThrottle(int Min, int Max, int Throttle)
55 {
56 max = Max;
57 min = Min;
58 throttle = Throttle;
59 sent = 0;
60 }
61
62 public void Reset()
63 {
64 sent = 0;
65 }
66
67 public bool UnderLimit()
68 {
69 return (sent < (throttle / divisor));
70 }
71
72 public int Add(int bytes)
73 {
74 sent += bytes;
75 return sent;
76 }
77
78 // Properties
79 public int Max
80 {
81 get {return max;}
82 }
83
84 public int Min
85 {
86 get {return min;}
87 }
88
89 public int Throttle
90 {
91 get {return throttle;}
92 set {throttle = value;}
93 }
94 }
95} \ No newline at end of file