mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Implement missing candidate pair packets/bytes sent/received stats.
Specifically: * packetsSent * packetsReceived * packetsDiscardedOnSend * bytesDiscardedOnSend Bug: webrtc:10569 Change-Id: Id92c20b93dea57637239a6321bd8aa644867f272 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232961 Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org> Reviewed-by: Jonas Oreland <jonaso@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35113}
This commit is contained in:
parent
cc4deae951
commit
79326eaca7
9 changed files with 62 additions and 7 deletions
|
@ -170,6 +170,8 @@ class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
|
|||
RTCStatsMember<bool> writable;
|
||||
// TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
|
||||
RTCStatsMember<bool> readable;
|
||||
RTCStatsMember<uint64_t> packets_sent;
|
||||
RTCStatsMember<uint64_t> packets_received;
|
||||
RTCStatsMember<uint64_t> bytes_sent;
|
||||
RTCStatsMember<uint64_t> bytes_received;
|
||||
RTCStatsMember<double> total_round_trip_time;
|
||||
|
@ -194,6 +196,8 @@ class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
|
|||
RTCStatsMember<uint64_t> consent_responses_received;
|
||||
// TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
|
||||
RTCStatsMember<uint64_t> consent_responses_sent;
|
||||
RTCStatsMember<uint64_t> packets_discarded_on_send;
|
||||
RTCStatsMember<uint64_t> bytes_discarded_on_send;
|
||||
};
|
||||
|
||||
// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
|
||||
|
|
|
@ -1374,6 +1374,7 @@ int ProxyConnection::Send(const void* data,
|
|||
RTC_DCHECK(sent < 0);
|
||||
error_ = port_->GetError();
|
||||
stats_.sent_discarded_packets++;
|
||||
stats_.sent_discarded_bytes += size;
|
||||
} else {
|
||||
send_rate_tracker_.AddSamplesAtTime(now, sent);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ ConnectionInfo::ConnectionInfo()
|
|||
timeout(false),
|
||||
new_connection(false),
|
||||
rtt(0),
|
||||
sent_discarded_bytes(0),
|
||||
sent_total_bytes(0),
|
||||
sent_bytes_second(0),
|
||||
sent_discarded_packets(0),
|
||||
|
|
|
@ -41,12 +41,15 @@ struct ConnectionInfo {
|
|||
bool timeout; // Has this connection timed out?
|
||||
bool new_connection; // Is this a newly created connection?
|
||||
size_t rtt; // The STUN RTT for this connection.
|
||||
size_t sent_total_bytes; // Total bytes sent on this connection.
|
||||
size_t sent_discarded_bytes; // Number of outgoing bytes discarded due to
|
||||
// socket errors.
|
||||
size_t sent_total_bytes; // Total bytes sent on this connection. Does not
|
||||
// include discarded bytes.
|
||||
size_t sent_bytes_second; // Bps over the last measurement interval.
|
||||
size_t sent_discarded_packets; // Number of outgoing packets discarded due to
|
||||
// socket errors.
|
||||
size_t sent_total_packets; // Number of total outgoing packets attempted for
|
||||
// sending.
|
||||
// sending, including discarded packets.
|
||||
size_t sent_ping_requests_total; // Number of STUN ping request sent.
|
||||
size_t sent_ping_requests_before_first_response; // Number of STUN ping
|
||||
// sent before receiving the first response.
|
||||
|
|
|
@ -1338,6 +1338,13 @@ TEST_F(P2PTransportChannelTest, GetStats) {
|
|||
kMediumTimeout, clock);
|
||||
// Sends and receives 10 packets.
|
||||
TestSendRecv(&clock);
|
||||
|
||||
// Try sending a packet which is discarded due to the socket being blocked.
|
||||
virtual_socket_server()->SetSendingBlocked(true);
|
||||
const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
int len = static_cast<int>(strlen(data));
|
||||
EXPECT_EQ(-1, SendData(ep1_ch1(), data, len));
|
||||
|
||||
IceTransportStats ice_transport_stats;
|
||||
ASSERT_TRUE(ep1_ch1()->GetStats(&ice_transport_stats));
|
||||
ASSERT_GE(ice_transport_stats.connection_infos.size(), 1u);
|
||||
|
@ -1355,9 +1362,12 @@ TEST_F(P2PTransportChannelTest, GetStats) {
|
|||
EXPECT_TRUE(best_conn_info->receiving);
|
||||
EXPECT_TRUE(best_conn_info->writable);
|
||||
EXPECT_FALSE(best_conn_info->timeout);
|
||||
EXPECT_EQ(10U, best_conn_info->sent_total_packets);
|
||||
EXPECT_EQ(0U, best_conn_info->sent_discarded_packets);
|
||||
// Note that discarded packets are counted in sent_total_packets but not
|
||||
// sent_total_bytes.
|
||||
EXPECT_EQ(11U, best_conn_info->sent_total_packets);
|
||||
EXPECT_EQ(1U, best_conn_info->sent_discarded_packets);
|
||||
EXPECT_EQ(10 * 36U, best_conn_info->sent_total_bytes);
|
||||
EXPECT_EQ(36U, best_conn_info->sent_discarded_bytes);
|
||||
EXPECT_EQ(10 * 36U, best_conn_info->recv_total_bytes);
|
||||
EXPECT_EQ(10U, best_conn_info->packets_received);
|
||||
DestroyChannels();
|
||||
|
|
|
@ -1552,8 +1552,18 @@ void RTCStatsCollector::ProduceIceCandidateAndPairStats_n(
|
|||
// false after a certain amount of time without a response passes.
|
||||
// https://crbug.com/633550
|
||||
candidate_pair_stats->writable = info.writable;
|
||||
// Note that sent_total_packets includes discarded packets but
|
||||
// sent_total_bytes does not.
|
||||
candidate_pair_stats->packets_sent = static_cast<uint64_t>(
|
||||
info.sent_total_packets - info.sent_discarded_packets);
|
||||
candidate_pair_stats->packets_discarded_on_send =
|
||||
static_cast<uint64_t>(info.sent_discarded_packets);
|
||||
candidate_pair_stats->packets_received =
|
||||
static_cast<uint64_t>(info.packets_received);
|
||||
candidate_pair_stats->bytes_sent =
|
||||
static_cast<uint64_t>(info.sent_total_bytes);
|
||||
candidate_pair_stats->bytes_discarded_on_send =
|
||||
static_cast<uint64_t>(info.sent_discarded_bytes);
|
||||
candidate_pair_stats->bytes_received =
|
||||
static_cast<uint64_t>(info.recv_total_bytes);
|
||||
candidate_pair_stats->total_round_trip_time =
|
||||
|
|
|
@ -1421,6 +1421,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
|
|||
connection_info.local_candidate = *local_candidate.get();
|
||||
connection_info.remote_candidate = *remote_candidate.get();
|
||||
connection_info.writable = true;
|
||||
connection_info.sent_discarded_packets = 3;
|
||||
connection_info.sent_total_packets = 10;
|
||||
connection_info.packets_received = 51;
|
||||
connection_info.sent_discarded_bytes = 7;
|
||||
connection_info.sent_total_bytes = 42;
|
||||
connection_info.recv_total_bytes = 1234;
|
||||
connection_info.total_round_trip_time_ms = 0;
|
||||
|
@ -1458,8 +1462,12 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
|
|||
expected_pair.priority = 5555;
|
||||
expected_pair.nominated = false;
|
||||
expected_pair.writable = true;
|
||||
expected_pair.packets_sent = 7;
|
||||
expected_pair.packets_received = 51;
|
||||
expected_pair.packets_discarded_on_send = 3;
|
||||
expected_pair.bytes_sent = 42;
|
||||
expected_pair.bytes_received = 1234;
|
||||
expected_pair.bytes_discarded_on_send = 7;
|
||||
expected_pair.total_round_trip_time = 0.0;
|
||||
expected_pair.requests_received = 2020;
|
||||
expected_pair.requests_sent = 2000;
|
||||
|
|
|
@ -489,7 +489,13 @@ class RTCStatsReportVerifier {
|
|||
verifier.TestMemberIsDefined(candidate_pair.nominated);
|
||||
verifier.TestMemberIsDefined(candidate_pair.writable);
|
||||
verifier.TestMemberIsUndefined(candidate_pair.readable);
|
||||
verifier.TestMemberIsNonNegative<uint64_t>(candidate_pair.packets_sent);
|
||||
verifier.TestMemberIsNonNegative<uint64_t>(
|
||||
candidate_pair.packets_discarded_on_send);
|
||||
verifier.TestMemberIsNonNegative<uint64_t>(candidate_pair.packets_received);
|
||||
verifier.TestMemberIsNonNegative<uint64_t>(candidate_pair.bytes_sent);
|
||||
verifier.TestMemberIsNonNegative<uint64_t>(
|
||||
candidate_pair.bytes_discarded_on_send);
|
||||
verifier.TestMemberIsNonNegative<uint64_t>(candidate_pair.bytes_received);
|
||||
verifier.TestMemberIsNonNegative<double>(
|
||||
candidate_pair.total_round_trip_time);
|
||||
|
|
|
@ -173,6 +173,8 @@ WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair",
|
|||
&nominated,
|
||||
&writable,
|
||||
&readable,
|
||||
&packets_sent,
|
||||
&packets_received,
|
||||
&bytes_sent,
|
||||
&bytes_received,
|
||||
&total_round_trip_time,
|
||||
|
@ -188,7 +190,9 @@ WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair",
|
|||
&consent_requests_received,
|
||||
&consent_requests_sent,
|
||||
&consent_responses_received,
|
||||
&consent_responses_sent)
|
||||
&consent_responses_sent,
|
||||
&packets_discarded_on_send,
|
||||
&bytes_discarded_on_send)
|
||||
// clang-format on
|
||||
|
||||
RTCIceCandidatePairStats::RTCIceCandidatePairStats(const std::string& id,
|
||||
|
@ -206,6 +210,8 @@ RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string&& id,
|
|||
nominated("nominated"),
|
||||
writable("writable"),
|
||||
readable("readable"),
|
||||
packets_sent("packetsSent"),
|
||||
packets_received("packetsReceived"),
|
||||
bytes_sent("bytesSent"),
|
||||
bytes_received("bytesReceived"),
|
||||
total_round_trip_time("totalRoundTripTime"),
|
||||
|
@ -221,7 +227,9 @@ RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string&& id,
|
|||
consent_requests_received("consentRequestsReceived"),
|
||||
consent_requests_sent("consentRequestsSent"),
|
||||
consent_responses_received("consentResponsesReceived"),
|
||||
consent_responses_sent("consentResponsesSent") {}
|
||||
consent_responses_sent("consentResponsesSent"),
|
||||
packets_discarded_on_send("packetsDiscardedOnSend"),
|
||||
bytes_discarded_on_send("bytesDiscardedOnSend") {}
|
||||
|
||||
RTCIceCandidatePairStats::RTCIceCandidatePairStats(
|
||||
const RTCIceCandidatePairStats& other)
|
||||
|
@ -234,6 +242,8 @@ RTCIceCandidatePairStats::RTCIceCandidatePairStats(
|
|||
nominated(other.nominated),
|
||||
writable(other.writable),
|
||||
readable(other.readable),
|
||||
packets_sent(other.packets_sent),
|
||||
packets_received(other.packets_received),
|
||||
bytes_sent(other.bytes_sent),
|
||||
bytes_received(other.bytes_received),
|
||||
total_round_trip_time(other.total_round_trip_time),
|
||||
|
@ -249,7 +259,9 @@ RTCIceCandidatePairStats::RTCIceCandidatePairStats(
|
|||
consent_requests_received(other.consent_requests_received),
|
||||
consent_requests_sent(other.consent_requests_sent),
|
||||
consent_responses_received(other.consent_responses_received),
|
||||
consent_responses_sent(other.consent_responses_sent) {}
|
||||
consent_responses_sent(other.consent_responses_sent),
|
||||
packets_discarded_on_send(other.packets_discarded_on_send),
|
||||
bytes_discarded_on_send(other.bytes_discarded_on_send) {}
|
||||
|
||||
RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue