* Added Packets In/s, Packets Out/s and Current un_acked Packets to the SimStatsReporter

* This doesn't take into account the throttler, it just assumes the throttle limit isn't reached.
ThreadPoolClientBranch
Teravus Ovares 2008-01-16 03:33:46 +00:00
parent 314c554ed4
commit 5958192398
4 changed files with 42 additions and 0 deletions

View File

@ -398,6 +398,8 @@ namespace OpenSim.Framework
public delegate void FriendActionDelegate(IClientAPI remoteClient,LLUUID agentID,LLUUID transactionID,List<LLUUID> callingCardFolders); public delegate void FriendActionDelegate(IClientAPI remoteClient,LLUUID agentID,LLUUID transactionID,List<LLUUID> callingCardFolders);
public delegate void FriendshipTermination(IClientAPI remoteClient,LLUUID agentID, LLUUID ExID); public delegate void FriendshipTermination(IClientAPI remoteClient,LLUUID agentID, LLUUID ExID);
public delegate void PacketStats(int inPackets, int outPackets, int unAckedBytes);
@ -501,6 +503,7 @@ namespace OpenSim.Framework
event FriendActionDelegate OnApproveFriendRequest; event FriendActionDelegate OnApproveFriendRequest;
event FriendActionDelegate OnDenyFriendRequest; event FriendActionDelegate OnDenyFriendRequest;
event FriendshipTermination OnTerminateFriendship; event FriendshipTermination OnTerminateFriendship;
event PacketStats OnPacketStats;
LLVector3 StartPos { get; set; } LLVector3 StartPos { get; set; }

View File

@ -63,7 +63,14 @@ namespace OpenSim.Region.ClientStack
// private InventoryCache m_inventoryCache; // private InventoryCache m_inventoryCache;
private int m_cachedTextureSerial = 0; private int m_cachedTextureSerial = 0;
private Timer m_clientPingTimer; private Timer m_clientPingTimer;
private int m_packetsReceived = 0; private int m_packetsReceived = 0;
private int m_lastpacketsSentToScene = 0;
private int m_unAckedBytes = 0;
private int m_packetsSent = 0;
private int m_lastPacketsSent = 0;
private int m_probesWithNoIngressPackets = 0; private int m_probesWithNoIngressPackets = 0;
private int m_lastPacketsReceived = 0; private int m_lastPacketsReceived = 0;
private byte[] ZeroOutBuffer = new byte[4096]; private byte[] ZeroOutBuffer = new byte[4096];
@ -409,6 +416,7 @@ namespace OpenSim.Region.ClientStack
{ {
// this will normally trigger at least one packet (ping response) // this will normally trigger at least one packet (ping response)
SendStartPingCheck(0); SendStartPingCheck(0);
} }
} }
else else
@ -416,6 +424,7 @@ namespace OpenSim.Region.ClientStack
// Something received in the meantime - we can reset the counters // Something received in the meantime - we can reset the counters
m_probesWithNoIngressPackets = 0; m_probesWithNoIngressPackets = 0;
m_lastPacketsReceived = m_packetsReceived; m_lastPacketsReceived = m_packetsReceived;
} }
} }
@ -566,6 +575,9 @@ namespace OpenSim.Region.ClientStack
public event FriendActionDelegate OnDenyFriendRequest; public event FriendActionDelegate OnDenyFriendRequest;
public event FriendshipTermination OnTerminateFriendship; public event FriendshipTermination OnTerminateFriendship;
public event PacketStats OnPacketStats;
#region Scene/Avatar to Client #region Scene/Avatar to Client
/// <summary> /// <summary>
@ -2245,6 +2257,7 @@ namespace OpenSim.Region.ClientStack
try try
{ {
m_needAck.Add(Pack.Header.Sequence, Pack); m_needAck.Add(Pack.Header.Sequence, Pack);
m_unAckedBytes += Pack.ToBytes().Length;
} }
catch (Exception) // HACKY catch (Exception) // HACKY
{ {
@ -2298,6 +2311,7 @@ namespace OpenSim.Region.ClientStack
if (Pack.Header.Reliable) //DIRTY HACK if (Pack.Header.Reliable) //DIRTY HACK
{ {
AddAck(Pack); // this adds the need to ack this packet later AddAck(Pack); // this adds the need to ack this packet later
if (Pack.Type != PacketType.PacketAck && Pack.Type != PacketType.LogoutRequest) if (Pack.Type != PacketType.PacketAck && Pack.Type != PacketType.LogoutRequest)
{ {
@ -2343,6 +2357,7 @@ namespace OpenSim.Region.ClientStack
{ {
foreach (uint ack in NewPack.Header.AckList) foreach (uint ack in NewPack.Header.AckList)
{ {
m_unAckedBytes -= m_needAck[ack].ToBytes().Length;
m_needAck.Remove(ack); m_needAck.Remove(ack);
} }
} }
@ -2358,6 +2373,7 @@ namespace OpenSim.Region.ClientStack
{ {
foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
{ {
m_unAckedBytes -= m_needAck[block.ID].ToBytes().Length;
m_needAck.Remove(block.ID); m_needAck.Remove(block.ID);
} }
} }
@ -2387,6 +2403,7 @@ namespace OpenSim.Region.ClientStack
item.Incoming = false; item.Incoming = false;
item.throttleType = throttlePacketType; // Packet throttle type item.throttleType = throttlePacketType; // Packet throttle type
m_packetQueue.Enqueue(item); m_packetQueue.Enqueue(item);
m_packetsSent++;
} }
# region Low Level Packet Methods # region Low Level Packet Methods
@ -2472,8 +2489,21 @@ namespace OpenSim.Region.ClientStack
protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea)
{ {
SendAcks(); SendAcks();
ResendUnacked(); ResendUnacked();
SendPacketStats();
}
protected void SendPacketStats()
{
if (OnPacketStats != null)
{
OnPacketStats(m_packetsReceived - m_lastPacketsReceived, m_packetsSent - m_lastPacketsSent, m_unAckedBytes);
m_lastPacketsReceived = m_packetsReceived;
m_lastPacketsSent = m_packetsSent;
}
} }
#endregion #endregion

View File

@ -1228,6 +1228,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnGrabObject += ProcessObjectGrab; client.OnGrabObject += ProcessObjectGrab;
client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; client.OnAvatarPickerRequest += ProcessAvatarPickerRequest;
client.OnPacketStats += AddPacketStats;
EventManager.TriggerOnNewClient(client); EventManager.TriggerOnNewClient(client);
} }
@ -1759,6 +1760,13 @@ namespace OpenSim.Region.Environment.Scenes
return CommsManager.GetUserFriendList(ownerID); return CommsManager.GetUserFriendList(ownerID);
} }
public void AddPacketStats(int inPackets, int outPackets, int unAckedBytes)
{
m_statsReporter.AddInPackets(inPackets);
m_statsReporter.AddOutPackets(outPackets);
m_statsReporter.AddunAckedBytes(unAckedBytes);
}
#endregion #endregion
#region Console Commands #region Console Commands

View File

@ -142,6 +142,7 @@ namespace SimpleApp
public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnApproveFriendRequest;
public event FriendActionDelegate OnDenyFriendRequest; public event FriendActionDelegate OnDenyFriendRequest;
public event FriendshipTermination OnTerminateFriendship; public event FriendshipTermination OnTerminateFriendship;
public event PacketStats OnPacketStats;
#pragma warning restore 67 #pragma warning restore 67