Skip to content

Commit 6eccecb

Browse files
committed
Tweak P2P stats
P4:6570979
1 parent a4cb590 commit 6eccecb

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/common/steamnetworkingsockets_messages.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ message CMsgSteamNetworkingICESessionSummary
321321
optional uint32 initial_score = 6;
322322
optional uint32 negotiation_ms = 5; // How long did it take to get a NAT traversal result (either success or failure)
323323

324+
// Best route and score we ever had over the life of the connection
325+
optional uint32 best_route_kind = 16; // ESteamNetTransportKind
326+
optional uint32 best_ping = 17;
327+
optional uint32 best_score = 18;
328+
optional uint32 best_time = 19; // seconds into the connections when this happened
329+
324330
// How long were we the selcted transport?
325331
optional uint32 selected_seconds = 12;
326332

src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p_ice.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,24 @@ void CConnectionTransportP2PICE::P2PTransportUpdateRouteMetrics( SteamNetworking
295295

296296
// Check for recording the initial scoring data used to make the initial decision
297297
CMsgSteamNetworkingICESessionSummary &ice_summary = Connection().m_msgICESessionSummary;
298+
uint32 nScore = m_routeMetrics.m_nScoreCurrent + m_routeMetrics.m_nTotalPenalty;
298299
if (
299300
ConnectionState() == k_ESteamNetworkingConnectionState_FindingRoute
300301
|| !ice_summary.has_initial_ping()
302+
|| ( nScore < ice_summary.initial_score() && usecNow < Connection().m_usecWhenCreated + 15*k_nMillion )
301303
) {
302-
ice_summary.set_initial_score( m_routeMetrics.m_nScoreCurrent + m_routeMetrics.m_nTotalPenalty );
304+
ice_summary.set_initial_score( nScore );
303305
ice_summary.set_initial_ping( m_pingEndToEnd.m_nSmoothedPing );
304306
ice_summary.set_initial_route_kind( m_eCurrentRouteKind );
305307
}
308+
309+
if ( !ice_summary.has_best_score() || nScore < ice_summary.best_score() )
310+
{
311+
ice_summary.set_best_score( nScore );
312+
ice_summary.set_best_ping( m_pingEndToEnd.m_nSmoothedPing );
313+
ice_summary.set_best_route_kind( m_eCurrentRouteKind );
314+
ice_summary.set_best_time( ( usecNow - Connection().m_usecWhenCreated + 500*1000 ) / k_nMillion );
315+
}
306316
}
307317

308318
#define ParseProtobufBody( pvMsg, cbMsg, CMsgCls, msgVar ) \

0 commit comments

Comments
 (0)