From 6eccecbd6ea18370265affaa77c15ffc30fe11b3 Mon Sep 17 00:00:00 2001 From: Fletcher Dunn Date: Fri, 28 May 2021 16:21:43 -0700 Subject: [PATCH] Tweak P2P stats P4:6570979 --- src/common/steamnetworkingsockets_messages.proto | 6 ++++++ .../clientlib/steamnetworkingsockets_p2p_ice.cpp | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/common/steamnetworkingsockets_messages.proto b/src/common/steamnetworkingsockets_messages.proto index 3b0a1eb..2c14c0e 100644 --- a/src/common/steamnetworkingsockets_messages.proto +++ b/src/common/steamnetworkingsockets_messages.proto @@ -321,6 +321,12 @@ message CMsgSteamNetworkingICESessionSummary optional uint32 initial_score = 6; optional uint32 negotiation_ms = 5; // How long did it take to get a NAT traversal result (either success or failure) + // Best route and score we ever had over the life of the connection + optional uint32 best_route_kind = 16; // ESteamNetTransportKind + optional uint32 best_ping = 17; + optional uint32 best_score = 18; + optional uint32 best_time = 19; // seconds into the connections when this happened + // How long were we the selcted transport? optional uint32 selected_seconds = 12; diff --git a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p_ice.cpp b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p_ice.cpp index 0a2eb86..9a074a7 100644 --- a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p_ice.cpp +++ b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p_ice.cpp @@ -295,14 +295,24 @@ void CConnectionTransportP2PICE::P2PTransportUpdateRouteMetrics( SteamNetworking // Check for recording the initial scoring data used to make the initial decision CMsgSteamNetworkingICESessionSummary &ice_summary = Connection().m_msgICESessionSummary; + uint32 nScore = m_routeMetrics.m_nScoreCurrent + m_routeMetrics.m_nTotalPenalty; if ( ConnectionState() == k_ESteamNetworkingConnectionState_FindingRoute || !ice_summary.has_initial_ping() + || ( nScore < ice_summary.initial_score() && usecNow < Connection().m_usecWhenCreated + 15*k_nMillion ) ) { - ice_summary.set_initial_score( m_routeMetrics.m_nScoreCurrent + m_routeMetrics.m_nTotalPenalty ); + ice_summary.set_initial_score( nScore ); ice_summary.set_initial_ping( m_pingEndToEnd.m_nSmoothedPing ); ice_summary.set_initial_route_kind( m_eCurrentRouteKind ); } + + if ( !ice_summary.has_best_score() || nScore < ice_summary.best_score() ) + { + ice_summary.set_best_score( nScore ); + ice_summary.set_best_ping( m_pingEndToEnd.m_nSmoothedPing ); + ice_summary.set_best_route_kind( m_eCurrentRouteKind ); + ice_summary.set_best_time( ( usecNow - Connection().m_usecWhenCreated + 500*1000 ) / k_nMillion ); + } } #define ParseProtobufBody( pvMsg, cbMsg, CMsgCls, msgVar ) \