New AzNetworking metrics display plus connection quality debug widgets using ImGui
Signed-off-by: kberg-amzn <karlberg@amazon.com>
This commit is contained in:
@@ -152,7 +152,7 @@ namespace AzNetworking
|
||||
|
||||
void UdpConnection::ProcessAcked(PacketId packetId, AZ::TimeMs currentTimeMs)
|
||||
{
|
||||
GetMetrics().m_packetsAcked++;
|
||||
GetMetrics().LogPacketAcked();
|
||||
m_reliableQueue.OnPacketAcked(m_networkInterface, *this, packetId);
|
||||
|
||||
// Compute Rtt adjustments
|
||||
@@ -172,8 +172,7 @@ namespace AzNetworking
|
||||
GetMetrics().m_connectionRtt.LogPacketSent(packetId, currentTimeMs);
|
||||
}
|
||||
|
||||
GetMetrics().m_packetsSent++;
|
||||
GetMetrics().m_sendDatarate.LogPacket(packetSize, currentTimeMs);
|
||||
GetMetrics().LogPacketSent(packetSize, currentTimeMs);
|
||||
m_lastSentPacketMs = currentTimeMs;
|
||||
m_unackedPacketCount = 0;
|
||||
}
|
||||
@@ -193,7 +192,7 @@ namespace AzNetworking
|
||||
return PacketTimeoutResult::Acked;
|
||||
|
||||
case PacketAckState::Nacked:
|
||||
GetMetrics().m_packetsLost++;
|
||||
GetMetrics().LogPacketLost();
|
||||
if (reliability == ReliabilityType::Reliable)
|
||||
{
|
||||
m_reliableQueue.OnPacketLost(m_networkInterface, *this, packetId);
|
||||
@@ -224,8 +223,7 @@ namespace AzNetworking
|
||||
return false;
|
||||
}
|
||||
|
||||
GetMetrics().m_packetsRecv++;
|
||||
GetMetrics().m_recvDatarate.LogPacket(packetSize, currentTimeMs);
|
||||
GetMetrics().LogPacketRecv(packetSize, currentTimeMs);
|
||||
|
||||
if (header.GetIsReliable() && !m_reliableQueue.OnPacketReceived(header))
|
||||
{
|
||||
|
||||
@@ -66,13 +66,8 @@ namespace AzNetworking
|
||||
bool Disconnect(DisconnectReason reason, TerminationEndpoint endpoint) override;
|
||||
void SetConnectionMtu(uint32_t connectionMtu) override;
|
||||
uint32_t GetConnectionMtu() const override;
|
||||
void SetConnectionQuality(const ConnectionQuality& connectionQuality) override;
|
||||
// @}
|
||||
|
||||
//! Gets connection quality values for testing poor connection conditions.
|
||||
//! @return connection quality values for this IConnection instance
|
||||
const ConnectionQuality& GetConnectionQuality() const;
|
||||
|
||||
//! Returns a suitable encryption endpoint for this connection type.
|
||||
//! @return reference to the connections encryption endpoint
|
||||
DtlsEndpoint& GetDtlsEndpoint();
|
||||
@@ -146,8 +141,6 @@ namespace AzNetworking
|
||||
UdpFragmentQueue m_fragmentQueue;
|
||||
ConnectionState m_state = ConnectionState::Disconnected;
|
||||
ConnectionRole m_connectionRole = ConnectionRole::Connector;
|
||||
|
||||
ConnectionQuality m_connectionQuality;
|
||||
DtlsEndpoint m_dtlsEndpoint;
|
||||
|
||||
AZ::TimeMs m_lastSentPacketMs;
|
||||
@@ -160,4 +153,3 @@ namespace AzNetworking
|
||||
}
|
||||
|
||||
#include <AzNetworking/UdpTransport/UdpConnection.inl>
|
||||
|
||||
|
||||
@@ -10,16 +10,6 @@
|
||||
|
||||
namespace AzNetworking
|
||||
{
|
||||
inline void UdpConnection::SetConnectionQuality(const ConnectionQuality& connectionQuality)
|
||||
{
|
||||
m_connectionQuality = connectionQuality;
|
||||
}
|
||||
|
||||
inline const ConnectionQuality& UdpConnection::GetConnectionQuality() const
|
||||
{
|
||||
return m_connectionQuality;
|
||||
}
|
||||
|
||||
inline DtlsEndpoint& UdpConnection::GetDtlsEndpoint()
|
||||
{
|
||||
return m_dtlsEndpoint;
|
||||
|
||||
@@ -224,8 +224,7 @@ namespace AzNetworking
|
||||
continue;
|
||||
}
|
||||
|
||||
connection->GetMetrics().m_recvDatarate.LogPacket(packet.m_receivedBytes + UdpPacketHeaderSize, currentTimeMs);
|
||||
connection->GetMetrics().m_packetsRecv++;
|
||||
connection->GetMetrics().LogPacketRecv(packet.m_receivedBytes + UdpPacketHeaderSize, currentTimeMs);
|
||||
|
||||
// Decode the packet flag bitset first since it's always uncompressed
|
||||
UdpPacketHeader header;
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace AzNetworking
|
||||
#ifdef ENABLE_LATENCY_DEBUG
|
||||
if (connectionQuality.m_lossPercentage > 0)
|
||||
{
|
||||
if (int32_t(m_random.GetRandom() % 100) < (connectionQuality.m_lossPercentage / 2))
|
||||
if (int32_t(m_random.GetRandom() % 100) < (connectionQuality.m_lossPercentage))
|
||||
{
|
||||
// Pretend we sent, but don't actually send
|
||||
return true;
|
||||
@@ -157,9 +157,11 @@ namespace AzNetworking
|
||||
#ifdef ENABLE_LATENCY_DEBUG
|
||||
else if ((connectionQuality.m_latencyMs > AZ::TimeMs{ 0 }) || (connectionQuality.m_varianceMs > AZ::TimeMs{ 0 }))
|
||||
{
|
||||
const AZ::TimeMs jitterMs = aznumeric_cast<AZ::TimeMs>(m_random.GetRandom()) % (connectionQuality.m_varianceMs / aznumeric_cast<AZ::TimeMs>(2));
|
||||
const AZ::TimeMs jitterMs = aznumeric_cast<AZ::TimeMs>(m_random.GetRandom()) % (connectionQuality.m_varianceMs > AZ::TimeMs{ 0 }
|
||||
? connectionQuality.m_varianceMs
|
||||
: AZ::TimeMs{ 1 });
|
||||
const AZ::TimeMs currTimeMs = AZ::GetElapsedTimeMs();
|
||||
const AZ::TimeMs deferTimeMs = (connectionQuality.m_latencyMs / aznumeric_cast<AZ::TimeMs>(2)) + jitterMs;
|
||||
const AZ::TimeMs deferTimeMs = (connectionQuality.m_latencyMs) + jitterMs;
|
||||
|
||||
DeferredData deferred = DeferredData(address, data, size, encrypt, dtlsEndpoint);
|
||||
AZ::Interface<AZ::IEventScheduler>::Get()->AddCallback([&, deferredData = deferred]
|
||||
|
||||
Reference in New Issue
Block a user