Skip to content

Commit 6c0c4e4

Browse files
committed
ICE client: add counters for retry
1 parent 3a3dfb8 commit 6c0c4e4

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/steamnetworkingsockets/clientlib/steamnetworkingsockets_ice_client.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,10 @@ int TEST_ICE_ctr_binding_req_recv = 0; // binding requests received from peer
849849
int TEST_ICE_ctr_binding_resp_send = 0; // binding responses we sent
850850
int TEST_ICE_ctr_binding_resp_recv = 0; // binding responses we received
851851
int TEST_ICE_ctr_allocate_send = 0; // TURN allocate requests sent
852-
int TEST_ICE_ctr_send_ind_send = 0; // TURN send indications sent (data out via relay)
853-
int TEST_ICE_ctr_data_ind_recv = 0; // TURN data indications received (data in via relay)
852+
int TEST_ICE_ctr_send_ind_send = 0; // TURN send indications sent (data out via relay)
853+
int TEST_ICE_ctr_data_ind_recv = 0; // TURN data indications received (data in via relay)
854+
int TEST_ICE_ctr_binding_req_retx = 0; // binding request retransmissions (not counting initial send)
855+
int TEST_ICE_ctr_allocate_retx = 0; // TURN allocate request retransmissions
854856

855857
void TEST_ICE_ctr_Reset()
856858
{
@@ -860,8 +862,10 @@ void TEST_ICE_ctr_Reset()
860862
TEST_ICE_ctr_binding_resp_send = 0;
861863
TEST_ICE_ctr_binding_resp_recv = 0;
862864
TEST_ICE_ctr_allocate_send = 0;
863-
TEST_ICE_ctr_send_ind_send = 0;
864-
TEST_ICE_ctr_data_ind_recv = 0;
865+
TEST_ICE_ctr_send_ind_send = 0;
866+
TEST_ICE_ctr_data_ind_recv = 0;
867+
TEST_ICE_ctr_binding_req_retx = 0;
868+
TEST_ICE_ctr_allocate_retx = 0;
865869
}
866870

867871
void TEST_ICE_ctr_Print()
@@ -873,6 +877,8 @@ void TEST_ICE_ctr_Print()
873877
SpewMsg( "TEST_ICE_ctr_allocate_send=%d\n", TEST_ICE_ctr_allocate_send );
874878
SpewMsg( "TEST_ICE_ctr_send_ind_send=%d\n", TEST_ICE_ctr_send_ind_send );
875879
SpewMsg( "TEST_ICE_ctr_data_ind_recv=%d\n", TEST_ICE_ctr_data_ind_recv );
880+
SpewMsg( "TEST_ICE_ctr_binding_req_retx=%d\n", TEST_ICE_ctr_binding_req_retx );
881+
SpewMsg( "TEST_ICE_ctr_allocate_retx=%d\n", TEST_ICE_ctr_allocate_retx );
876882
}
877883

878884
// Compare IP addresses, ignoring the port.
@@ -973,7 +979,19 @@ void CSteamNetworkingSocketsSTUNRequest::Think( SteamNetworkingMicroseconds usec
973979
if ( m_pInterface->SendPacketGather( 1, &temp, m_cbPacketSize, m_remoteAddr, m_addrRelay ) )
974980
{
975981
m_usecLastSentTime = usecNow;
976-
SetNextThinkTime( usecNow + retryTimeout );
982+
if ( m_nRetryCount > 1 )
983+
{
984+
// Decode message type from the packet header (type occupies the top 16 bits
985+
// of the first word) and tally by type so tests can verify the retry schedule.
986+
const uint32 nMsgType = ntohl( m_packet[0] ) >> 16;
987+
if ( nMsgType == k_nSTUN_BindingRequest )
988+
++TEST_ICE_ctr_binding_req_retx;
989+
else if ( nMsgType == k_nTURN_AllocateRequest )
990+
++TEST_ICE_ctr_allocate_retx;
991+
else
992+
AssertMsg( false, "Untracked STUN retransmit type 0x%x", nMsgType );
993+
}
994+
SetNextThinkTime( usecNow + usecInterval );
977995
return;
978996
}
979997

tests/test_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ namespace SteamNetworkingSocketsLib {
4141
extern int TEST_ICE_ctr_allocate_send;
4242
extern int TEST_ICE_ctr_send_ind_send;
4343
extern int TEST_ICE_ctr_data_ind_recv;
44+
extern int TEST_ICE_ctr_binding_req_retx;
45+
extern int TEST_ICE_ctr_allocate_retx;
4446
extern void TEST_ICE_ctr_Reset();
4547
extern void TEST_ICE_ctr_Print();
4648
}

0 commit comments

Comments
 (0)