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

Side by Side Diff: webrtc/p2p/base/port.cc

Issue 2719523002: RTCIceCandidatePairStats.[total/current]RoundTripTime collected. (Closed)
Patch Set: EXPECT_EQ(expected, actual) Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 state_ = IceCandidatePairState::IN_PROGRESS; 1244 state_ = IceCandidatePairState::IN_PROGRESS;
1245 num_pings_sent_++; 1245 num_pings_sent_++;
1246 } 1246 }
1247 1247
1248 void Connection::ReceivedPing() { 1248 void Connection::ReceivedPing() {
1249 last_ping_received_ = rtc::TimeMillis(); 1249 last_ping_received_ = rtc::TimeMillis();
1250 UpdateReceiving(last_ping_received_); 1250 UpdateReceiving(last_ping_received_);
1251 } 1251 }
1252 1252
1253 void Connection::ReceivedPingResponse(int rtt, const std::string& request_id) { 1253 void Connection::ReceivedPingResponse(int rtt, const std::string& request_id) {
1254 RTC_DCHECK_GE(rtt, 0);
1254 // We've already validated that this is a STUN binding response with 1255 // We've already validated that this is a STUN binding response with
1255 // the correct local and remote username for this connection. 1256 // the correct local and remote username for this connection.
1256 // So if we're not already, become writable. We may be bringing a pruned 1257 // So if we're not already, become writable. We may be bringing a pruned
1257 // connection back to life, but if we don't really want it, we can always 1258 // connection back to life, but if we don't really want it, we can always
1258 // prune it again. 1259 // prune it again.
1259 auto iter = std::find_if( 1260 auto iter = std::find_if(
1260 pings_since_last_response_.begin(), pings_since_last_response_.end(), 1261 pings_since_last_response_.begin(), pings_since_last_response_.end(),
1261 [request_id](const SentPing& ping) { return ping.id == request_id; }); 1262 [request_id](const SentPing& ping) { return ping.id == request_id; });
1262 if (iter != pings_since_last_response_.end() && 1263 if (iter != pings_since_last_response_.end() &&
1263 iter->nomination > acked_nomination_) { 1264 iter->nomination > acked_nomination_) {
1264 acked_nomination_ = iter->nomination; 1265 acked_nomination_ = iter->nomination;
1265 } 1266 }
1266 1267
1268 total_round_trip_time_ms_ += rtt;
1269 current_round_trip_time_ms_ = rtc::Optional<uint32_t>(
1270 static_cast<uint32_t>(rtt));
1271
1267 pings_since_last_response_.clear(); 1272 pings_since_last_response_.clear();
1268 last_ping_response_received_ = rtc::TimeMillis(); 1273 last_ping_response_received_ = rtc::TimeMillis();
1269 UpdateReceiving(last_ping_response_received_); 1274 UpdateReceiving(last_ping_response_received_);
1270 set_write_state(STATE_WRITABLE); 1275 set_write_state(STATE_WRITABLE);
1271 set_state(IceCandidatePairState::SUCCEEDED); 1276 set_state(IceCandidatePairState::SUCCEEDED);
1272 if (rtt_samples_ > 0) { 1277 if (rtt_samples_ > 0) {
1273 rtt_ = (RTT_RATIO * rtt_ + rtt) / (RTT_RATIO + 1); 1278 rtt_ = (RTT_RATIO * rtt_ + rtt) / (RTT_RATIO + 1);
1274 } else { 1279 } else {
1275 rtt_ = rtt; 1280 rtt_ = rtt;
1276 } 1281 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 stats_.writable = write_state_ == STATE_WRITABLE; 1502 stats_.writable = write_state_ == STATE_WRITABLE;
1498 stats_.timeout = write_state_ == STATE_WRITE_TIMEOUT; 1503 stats_.timeout = write_state_ == STATE_WRITE_TIMEOUT;
1499 stats_.new_connection = !reported_; 1504 stats_.new_connection = !reported_;
1500 stats_.rtt = rtt_; 1505 stats_.rtt = rtt_;
1501 stats_.local_candidate = local_candidate(); 1506 stats_.local_candidate = local_candidate();
1502 stats_.remote_candidate = remote_candidate(); 1507 stats_.remote_candidate = remote_candidate();
1503 stats_.key = this; 1508 stats_.key = this;
1504 stats_.state = state_; 1509 stats_.state = state_;
1505 stats_.priority = priority(); 1510 stats_.priority = priority();
1506 stats_.nominated = nominated(); 1511 stats_.nominated = nominated();
1512 stats_.total_round_trip_time_ms = total_round_trip_time_ms_;
1513 stats_.current_round_trip_time_ms = current_round_trip_time_ms_;
1507 return stats_; 1514 return stats_;
1508 } 1515 }
1509 1516
1510 void Connection::MaybeUpdateLocalCandidate(ConnectionRequest* request, 1517 void Connection::MaybeUpdateLocalCandidate(ConnectionRequest* request,
1511 StunMessage* response) { 1518 StunMessage* response) {
1512 // RFC 5245 1519 // RFC 5245
1513 // The agent checks the mapped address from the STUN response. If the 1520 // The agent checks the mapped address from the STUN response. If the
1514 // transport address does not match any of the local candidates that the 1521 // transport address does not match any of the local candidates that the
1515 // agent knows about, the mapped address represents a new candidate -- a 1522 // agent knows about, the mapped address represents a new candidate -- a
1516 // peer reflexive candidate. 1523 // peer reflexive candidate.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 RTC_DCHECK(sent < 0); 1612 RTC_DCHECK(sent < 0);
1606 error_ = port_->GetError(); 1613 error_ = port_->GetError();
1607 stats_.sent_discarded_packets++; 1614 stats_.sent_discarded_packets++;
1608 } else { 1615 } else {
1609 send_rate_tracker_.AddSamples(sent); 1616 send_rate_tracker_.AddSamples(sent);
1610 } 1617 }
1611 return sent; 1618 return sent;
1612 } 1619 }
1613 1620
1614 } // namespace cricket 1621 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698