Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Unified Diff: webrtc/p2p/base/port.cc

Issue 1940493002: Add Stats to Stun ping. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Store ConnectionInfo to Connection to reduce duplication. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/port.cc
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index b08cc4c91039f8149fac115a17e70f70236698ff..95ecad1504a6251d92699d193139da5e007b8249 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -594,6 +594,8 @@ void Port::SendBindingResponse(StunMessage* request,
<< "Sent STUN ping response"
<< ", to=" << addr.ToSensitiveString()
<< ", id=" << rtc::hex_encode(response.transaction_id());
+
+ conn->connection_info_.sent_ping_responses++;
}
}
@@ -830,8 +832,6 @@ Connection::Connection(Port* port,
last_ping_response_received_(0),
recv_rate_tracker_(100, 10u),
send_rate_tracker_(100, 10u),
- sent_packets_discarded_(0),
- sent_packets_total_(0),
reported_(false),
state_(STATE_WAITING),
receiving_timeout_(WEAK_CONNECTION_RECEIVE_TIMEOUT),
@@ -1018,6 +1018,8 @@ void Connection::HandleBindingRequest(IceMessage* msg) {
return;
}
+ connection_info_.recv_ping_requests++;
+
// This is a validated stun request from remote peer.
port_->SendBindingResponse(msg, remote_addr);
@@ -1298,6 +1300,7 @@ void Connection::OnConnectionRequestResponse(ConnectionRequest* request,
}
rtt_ = (RTT_RATIO * rtt_ + rtt) / (RTT_RATIO + 1);
+ connection_info_.recv_ping_responses++;
MaybeAddPrflxCandidate(request, response);
}
@@ -1346,6 +1349,10 @@ void Connection::OnConnectionRequestSent(ConnectionRequest* request) {
LOG_JV(sev, this) << "Sent STUN ping"
<< ", id=" << rtc::hex_encode(request->id())
<< ", use_candidate=" << use_candidate;
+ connection_info_.sent_ping_requests_total++;
+ if (connection_info_.recv_ping_responses == 0) {
+ connection_info_.sent_ping_requests_before_first_response++;
+ }
}
void Connection::HandleRoleConflictFromPeer() {
@@ -1396,28 +1403,12 @@ int64_t Connection::last_received() const {
std::max(last_ping_received_, last_ping_response_received_));
}
-size_t Connection::recv_bytes_second() {
- return round(recv_rate_tracker_.ComputeRate());
-}
-
-size_t Connection::recv_total_bytes() {
- return recv_rate_tracker_.TotalSampleCount();
-}
-
-size_t Connection::sent_bytes_second() {
- return round(send_rate_tracker_.ComputeRate());
-}
-
-size_t Connection::sent_total_bytes() {
- return send_rate_tracker_.TotalSampleCount();
-}
-
-size_t Connection::sent_discarded_packets() {
- return sent_packets_discarded_;
-}
-
-size_t Connection::sent_total_packets() {
- return sent_packets_total_;
+ConnectionInfo Connection::connection_info() {
+ connection_info_.recv_bytes_second = round(recv_rate_tracker_.ComputeRate());
+ connection_info_.recv_total_bytes = recv_rate_tracker_.TotalSampleCount();
+ connection_info_.sent_bytes_second = round(send_rate_tracker_.ComputeRate());
+ connection_info_.sent_total_bytes = send_rate_tracker_.TotalSampleCount();
+ return connection_info_;
}
void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request,
@@ -1498,13 +1489,13 @@ int ProxyConnection::Send(const void* data, size_t size,
error_ = EWOULDBLOCK;
return SOCKET_ERROR;
}
- sent_packets_total_++;
+ connection_info_.sent_total_packets++;
int sent = port_->SendTo(data, size, remote_candidate_.address(),
options, true);
if (sent <= 0) {
ASSERT(sent < 0);
error_ = port_->GetError();
- sent_packets_discarded_++;
+ connection_info_.sent_discarded_packets++;
} else {
send_rate_tracker_.AddSamples(sent);
}

Powered by Google App Engine
This is Rietveld 408576698