aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP
diff options
context:
space:
mode:
authorMic Bowman2014-12-29 12:02:36 -0800
committerMic Bowman2014-12-29 12:02:36 -0800
commite71549a2cb01609f781667490f68dc2876c5c024 (patch)
treed8f354db435c6727f2970bc9ebaa6b03730bba26 /OpenSim/Region/ClientStack/Linden/UDP
parentAllow for richer semantics of object derez. Specifically, allow the existence... (diff)
downloadopensim-SC-e71549a2cb01609f781667490f68dc2876c5c024.zip
opensim-SC-e71549a2cb01609f781667490f68dc2876c5c024.tar.gz
opensim-SC-e71549a2cb01609f781667490f68dc2876c5c024.tar.bz2
opensim-SC-e71549a2cb01609f781667490f68dc2876c5c024.tar.xz
Add debugging code for simulating packet loss in outgoing UDP packets. The
algorithm for dropping packets is a modified two state algorithm for creating bursts of dropped packets. As configured there is about a 1.5% drop rate. Invocation of the packet loss code is commented out by default.
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs66
1 files changed, 66 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
index 94300f8..9bee3ad 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
@@ -107,6 +107,62 @@ namespace OpenMetaverse
107 /// </summary> 107 /// </summary>
108 public float AverageReceiveTicksForLastSamplePeriod { get; private set; } 108 public float AverageReceiveTicksForLastSamplePeriod { get; private set; }
109 109
110 #region PacketDropDebugging
111 /// <summary>
112 /// For debugging purposes only... random number generator for dropping
113 /// outbound packets.
114 /// </summary>
115 private Random m_dropRandomGenerator;
116
117 /// <summary>
118 /// For debugging purposes only... parameters for a simplified
119 /// model of packet loss with bursts, overall drop rate should
120 /// be roughly 1 - m_dropLengthProbability / (m_dropProbabiliy + m_dropLengthProbability)
121 /// which is about 1% for parameters 0.0015 and 0.15
122 /// </summary>
123 private double m_dropProbability = 0.0030;
124 private double m_dropLengthProbability = 0.15;
125 private bool m_dropState = false;
126
127 /// <summary>
128 /// For debugging purposes only... parameters to control the time
129 /// duration over which packet loss bursts can occur, if no packets
130 /// have been sent for m_dropResetTicks milliseconds, then reset the
131 /// state of the packet dropper to its default.
132 /// </summary>
133 private int m_dropLastTick = 0;
134 private int m_dropResetTicks = 500;
135
136 /// <summary>
137 /// Debugging code used to simulate dropped packets with bursts
138 /// </summary>
139 private bool DropOutgoingPacket()
140 {
141 double rnum = m_dropRandomGenerator.NextDouble();
142
143 // if the connection has been idle for awhile (more than m_dropResetTicks) then
144 // reset the state to the default state, don't continue a burst
145 int curtick = Util.EnvironmentTickCount();
146 if (Util.EnvironmentTickCountSubtract(curtick, m_dropLastTick) > m_dropResetTicks)
147 m_dropState = false;
148
149 m_dropLastTick = curtick;
150
151 // if we are dropping packets, then the probability of dropping
152 // this packet is the probability that we stay in the burst
153 if (m_dropState)
154 {
155 m_dropState = (rnum < (1.0 - m_dropLengthProbability)) ? true : false;
156 }
157 else
158 {
159 m_dropState = (rnum < m_dropProbability) ? true : false;
160 }
161
162 return m_dropState;
163 }
164 #endregion PacketDropDebugging
165
110 /// <summary> 166 /// <summary>
111 /// Default constructor 167 /// Default constructor
112 /// </summary> 168 /// </summary>
@@ -117,6 +173,10 @@ namespace OpenMetaverse
117 { 173 {
118 m_localBindAddress = bindAddress; 174 m_localBindAddress = bindAddress;
119 m_udpPort = port; 175 m_udpPort = port;
176
177 // for debugging purposes only, initializes the random number generator
178 // used for simulating packet loss
179 // m_dropRandomGenerator = new Random();
120 } 180 }
121 181
122 /// <summary> 182 /// <summary>
@@ -395,6 +455,12 @@ namespace OpenMetaverse
395 { 455 {
396// if (IsRunningOutbound) 456// if (IsRunningOutbound)
397// { 457// {
458
459 // This is strictly for debugging purposes to simulate dropped
460 // packets when testing throttles & retransmission code
461 // if (DropOutgoingPacket())
462 // return;
463
398 try 464 try
399 { 465 {
400 m_udpSocket.BeginSendTo( 466 m_udpSocket.BeginSendTo(