mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 17:05:55 +08:00
add a estimator of client ping time, and painfully make it visible in show
connections console command
This commit is contained in:
@@ -419,6 +419,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
|
||||
public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
|
||||
|
||||
public int PingTimeMS
|
||||
{
|
||||
get
|
||||
{
|
||||
if (UDPClient != null)
|
||||
return UDPClient.PingTimeMS;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Entity update queues
|
||||
/// </summary>
|
||||
@@ -461,6 +471,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
set { m_disableFacelights = value; }
|
||||
}
|
||||
|
||||
|
||||
public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
|
||||
|
||||
|
||||
@@ -1638,6 +1649,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
pc.PingID.OldestUnacked = 0;
|
||||
|
||||
OutPacket(pc, ThrottleOutPacketType.Unknown);
|
||||
UDPClient.m_lastStartpingTimeMS = Util.EnvironmentTickCount();
|
||||
}
|
||||
|
||||
public void SendKillObject(List<uint> localIDs)
|
||||
|
||||
@@ -163,6 +163,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
private int m_maxRTO = 60000;
|
||||
public bool m_deliverPackets = true;
|
||||
|
||||
public int m_lastStartpingTimeMS;
|
||||
public int m_pingMS;
|
||||
|
||||
public int PingTimeMS
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_pingMS < 20)
|
||||
return 20;
|
||||
if(m_pingMS > 2000)
|
||||
return 2000;
|
||||
return m_pingMS;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the percentage of the udp texture queue to add to the task queue since
|
||||
/// textures are now generally handled through http.
|
||||
@@ -225,6 +240,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
// Initialize this to a sane value to prevent early disconnects
|
||||
TickLastPacketReceived = Environment.TickCount & Int32.MaxValue;
|
||||
m_pingMS = (int)(3.0 * server.TickCountResolution); // so filter doesnt start at 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -293,6 +293,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// <summary>Flag to signal when clients should send pings</summary>
|
||||
protected bool m_sendPing;
|
||||
|
||||
|
||||
private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>();
|
||||
|
||||
/// <summary>
|
||||
@@ -369,16 +370,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
// Measure the resolution of Environment.TickCount
|
||||
TickCountResolution = 0f;
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int start = Environment.TickCount;
|
||||
int now = start;
|
||||
while (now == start)
|
||||
now = Environment.TickCount;
|
||||
TickCountResolution += (float)(now - start) * 0.2f;
|
||||
TickCountResolution += (float)(now - start) * 0.1f;
|
||||
}
|
||||
m_log.Info("[LLUDPSERVER]: Average Environment.TickCount resolution: " + TickCountResolution + "ms");
|
||||
TickCountResolution = (float)Math.Ceiling(TickCountResolution);
|
||||
m_log.Info("[LLUDPSERVER]: Average Environment.TickCount resolution: " + TickCountResolution + "ms");
|
||||
|
||||
#endregion Environment.TickCount Measurement
|
||||
|
||||
@@ -386,6 +387,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
int sceneThrottleBps = 0;
|
||||
bool usePools = false;
|
||||
|
||||
|
||||
|
||||
IConfig config = configSource.Configs["ClientStack.LindenUDP"];
|
||||
if (config != null)
|
||||
{
|
||||
@@ -1128,6 +1131,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
pc.PingID.OldestUnacked = 0;
|
||||
|
||||
SendPacket(udpClient, pc, ThrottleOutPacketType.Unknown, false, null);
|
||||
udpClient.m_lastStartpingTimeMS = Util.EnvironmentTickCount();
|
||||
}
|
||||
|
||||
public void CompletePing(LLUDPClient udpClient, byte pingID)
|
||||
@@ -1567,7 +1571,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
// We don't need to do anything else with ping checks
|
||||
StartPingCheckPacket startPing = (StartPingCheckPacket)packet;
|
||||
CompletePing(udpClient, startPing.PingID.PingID);
|
||||
|
||||
|
||||
if ((Environment.TickCount - m_elapsedMSSinceLastStatReport) >= 3000)
|
||||
{
|
||||
udpClient.SendPacketStats();
|
||||
@@ -1577,7 +1581,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
}
|
||||
else if (packet.Type == PacketType.CompletePingCheck)
|
||||
{
|
||||
// We don't currently track client ping times
|
||||
int t = Util.EnvironmentTickCountSubtract(udpClient.m_lastStartpingTimeMS);
|
||||
int c = udpClient.m_pingMS;
|
||||
c = 900 * c + 100 * t;
|
||||
c /= 1000;
|
||||
udpClient.m_pingMS = c;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user