add a estimator of client ping time, and painfully make it visible in show

connections console command
avinationmerge
UbitUmarov 2014-08-14 20:41:36 +01:00
parent d64fb216d2
commit 8c657e4837
8 changed files with 52 additions and 6 deletions

View File

@ -755,6 +755,8 @@ namespace OpenSim.Framework
/// </summary> /// </summary>
bool IsActive { get; set; } bool IsActive { get; set; }
int PingTimeMS { get; }
/// <summary> /// <summary>
/// Set if the client is closing due to a logout request /// Set if the client is closing due to a logout request
/// </summary> /// </summary>

View File

@ -978,6 +978,7 @@ namespace OpenSim
cdt.AddColumn("Circuit code", 12); cdt.AddColumn("Circuit code", 12);
cdt.AddColumn("Endpoint", 23); cdt.AddColumn("Endpoint", 23);
cdt.AddColumn("Active?", 7); cdt.AddColumn("Active?", 7);
cdt.AddColumn("ping(ms)", 8);
SceneManager.ForEachScene( SceneManager.ForEachScene(
s => s.ForEachClient( s => s.ForEachClient(
@ -986,7 +987,8 @@ namespace OpenSim
c.Name, c.Name,
c.CircuitCode.ToString(), c.CircuitCode.ToString(),
c.RemoteEndPoint.ToString(), c.RemoteEndPoint.ToString(),
c.IsActive.ToString()))); c.IsActive.ToString(),
c.PingTimeMS)));
MainConsole.Instance.Output(cdt.ToString()); MainConsole.Instance.Output(cdt.ToString());
} }

View File

@ -419,6 +419,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } } public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); } public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
public int PingTimeMS
{
get
{
if (UDPClient != null)
return UDPClient.PingTimeMS;
return 0;
}
}
/// <summary> /// <summary>
/// Entity update queues /// Entity update queues
/// </summary> /// </summary>
@ -461,6 +471,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
set { m_disableFacelights = value; } set { m_disableFacelights = value; }
} }
public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } } public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
@ -1638,6 +1649,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
pc.PingID.OldestUnacked = 0; pc.PingID.OldestUnacked = 0;
OutPacket(pc, ThrottleOutPacketType.Unknown); OutPacket(pc, ThrottleOutPacketType.Unknown);
UDPClient.m_lastStartpingTimeMS = Util.EnvironmentTickCount();
} }
public void SendKillObject(List<uint> localIDs) public void SendKillObject(List<uint> localIDs)

View File

@ -163,6 +163,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private int m_maxRTO = 60000; private int m_maxRTO = 60000;
public bool m_deliverPackets = true; 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> /// <summary>
/// This is the percentage of the udp texture queue to add to the task queue since /// This is the percentage of the udp texture queue to add to the task queue since
/// textures are now generally handled through http. /// 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 // Initialize this to a sane value to prevent early disconnects
TickLastPacketReceived = Environment.TickCount & Int32.MaxValue; TickLastPacketReceived = Environment.TickCount & Int32.MaxValue;
m_pingMS = (int)(3.0 * server.TickCountResolution); // so filter doesnt start at 0;
} }
/// <summary> /// <summary>

View File

@ -293,6 +293,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <summary>Flag to signal when clients should send pings</summary> /// <summary>Flag to signal when clients should send pings</summary>
protected bool m_sendPing; protected bool m_sendPing;
private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>();
/// <summary> /// <summary>
@ -369,16 +370,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Measure the resolution of Environment.TickCount // Measure the resolution of Environment.TickCount
TickCountResolution = 0f; TickCountResolution = 0f;
for (int i = 0; i < 5; i++) for (int i = 0; i < 10; i++)
{ {
int start = Environment.TickCount; int start = Environment.TickCount;
int now = start; int now = start;
while (now == start) while (now == start)
now = Environment.TickCount; 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); TickCountResolution = (float)Math.Ceiling(TickCountResolution);
m_log.Info("[LLUDPSERVER]: Average Environment.TickCount resolution: " + TickCountResolution + "ms");
#endregion Environment.TickCount Measurement #endregion Environment.TickCount Measurement
@ -386,6 +387,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
int sceneThrottleBps = 0; int sceneThrottleBps = 0;
bool usePools = false; bool usePools = false;
IConfig config = configSource.Configs["ClientStack.LindenUDP"]; IConfig config = configSource.Configs["ClientStack.LindenUDP"];
if (config != null) if (config != null)
{ {
@ -1128,6 +1131,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
pc.PingID.OldestUnacked = 0; pc.PingID.OldestUnacked = 0;
SendPacket(udpClient, pc, ThrottleOutPacketType.Unknown, false, null); SendPacket(udpClient, pc, ThrottleOutPacketType.Unknown, false, null);
udpClient.m_lastStartpingTimeMS = Util.EnvironmentTickCount();
} }
public void CompletePing(LLUDPClient udpClient, byte pingID) 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 // We don't need to do anything else with ping checks
StartPingCheckPacket startPing = (StartPingCheckPacket)packet; StartPingCheckPacket startPing = (StartPingCheckPacket)packet;
CompletePing(udpClient, startPing.PingID.PingID); CompletePing(udpClient, startPing.PingID.PingID);
if ((Environment.TickCount - m_elapsedMSSinceLastStatReport) >= 3000) if ((Environment.TickCount - m_elapsedMSSinceLastStatReport) >= 3000)
{ {
udpClient.SendPacketStats(); udpClient.SendPacketStats();
@ -1577,7 +1581,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
else if (packet.Type == PacketType.CompletePingCheck) 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; return;
} }

View File

@ -58,6 +58,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public ISceneAgent SceneAgent { get; set; } public ISceneAgent SceneAgent { get; set; }
public int PingTimeMS { get { return 0; } }
private string m_username; private string m_username;
private string m_nick; private string m_nick;

View File

@ -81,6 +81,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
get { return m_scene; } get { return m_scene; }
} }
public int PingTimeMS { get { return 0; } }
public UUID OwnerID public UUID OwnerID
{ {
get { return m_ownerID; } get { return m_ownerID; }

View File

@ -379,6 +379,8 @@ namespace OpenSim.Tests.Common.Mock
get { return FirstName + " " + LastName; } get { return FirstName + " " + LastName; }
} }
public int PingTimeMS { get { return 0; } }
public bool IsActive public bool IsActive
{ {
get { return true; } get { return true; }