| OLD | NEW |
| 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 Loading... |
| 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 current_round_trip_time_ms_ = rtc::Optional<uint32_t>( |
| 1269 static_cast<uint32_t>(rtt)); |
| 1270 if (!total_round_trip_time_ms_) { |
| 1271 total_round_trip_time_ms_ = rtc::Optional<uint64_t>( |
| 1272 static_cast<uint64_t>(rtt)); |
| 1273 } else { |
| 1274 total_round_trip_time_ms_ = rtc::Optional<uint64_t>( |
| 1275 *total_round_trip_time_ms_ + rtt); |
| 1276 } |
| 1277 |
| 1267 pings_since_last_response_.clear(); | 1278 pings_since_last_response_.clear(); |
| 1268 last_ping_response_received_ = rtc::TimeMillis(); | 1279 last_ping_response_received_ = rtc::TimeMillis(); |
| 1269 UpdateReceiving(last_ping_response_received_); | 1280 UpdateReceiving(last_ping_response_received_); |
| 1270 set_write_state(STATE_WRITABLE); | 1281 set_write_state(STATE_WRITABLE); |
| 1271 set_state(IceCandidatePairState::SUCCEEDED); | 1282 set_state(IceCandidatePairState::SUCCEEDED); |
| 1272 if (rtt_samples_ > 0) { | 1283 if (rtt_samples_ > 0) { |
| 1273 rtt_ = (RTT_RATIO * rtt_ + rtt) / (RTT_RATIO + 1); | 1284 rtt_ = (RTT_RATIO * rtt_ + rtt) / (RTT_RATIO + 1); |
| 1274 } else { | 1285 } else { |
| 1275 rtt_ = rtt; | 1286 rtt_ = rtt; |
| 1276 } | 1287 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 stats_.receiving = receiving_; | 1507 stats_.receiving = receiving_; |
| 1497 stats_.writable = write_state_ == STATE_WRITABLE; | 1508 stats_.writable = write_state_ == STATE_WRITABLE; |
| 1498 stats_.timeout = write_state_ == STATE_WRITE_TIMEOUT; | 1509 stats_.timeout = write_state_ == STATE_WRITE_TIMEOUT; |
| 1499 stats_.new_connection = !reported_; | 1510 stats_.new_connection = !reported_; |
| 1500 stats_.rtt = rtt_; | 1511 stats_.rtt = rtt_; |
| 1501 stats_.local_candidate = local_candidate(); | 1512 stats_.local_candidate = local_candidate(); |
| 1502 stats_.remote_candidate = remote_candidate(); | 1513 stats_.remote_candidate = remote_candidate(); |
| 1503 stats_.key = this; | 1514 stats_.key = this; |
| 1504 stats_.state = state_; | 1515 stats_.state = state_; |
| 1505 stats_.priority = priority(); | 1516 stats_.priority = priority(); |
| 1517 stats_.total_round_trip_time_ms = total_round_trip_time_ms_; |
| 1518 stats_.current_round_trip_time_ms = current_round_trip_time_ms_; |
| 1506 return stats_; | 1519 return stats_; |
| 1507 } | 1520 } |
| 1508 | 1521 |
| 1509 void Connection::MaybeUpdateLocalCandidate(ConnectionRequest* request, | 1522 void Connection::MaybeUpdateLocalCandidate(ConnectionRequest* request, |
| 1510 StunMessage* response) { | 1523 StunMessage* response) { |
| 1511 // RFC 5245 | 1524 // RFC 5245 |
| 1512 // The agent checks the mapped address from the STUN response. If the | 1525 // The agent checks the mapped address from the STUN response. If the |
| 1513 // transport address does not match any of the local candidates that the | 1526 // transport address does not match any of the local candidates that the |
| 1514 // agent knows about, the mapped address represents a new candidate -- a | 1527 // agent knows about, the mapped address represents a new candidate -- a |
| 1515 // peer reflexive candidate. | 1528 // peer reflexive candidate. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 RTC_DCHECK(sent < 0); | 1617 RTC_DCHECK(sent < 0); |
| 1605 error_ = port_->GetError(); | 1618 error_ = port_->GetError(); |
| 1606 stats_.sent_discarded_packets++; | 1619 stats_.sent_discarded_packets++; |
| 1607 } else { | 1620 } else { |
| 1608 send_rate_tracker_.AddSamples(sent); | 1621 send_rate_tracker_.AddSamples(sent); |
| 1609 } | 1622 } |
| 1610 return sent; | 1623 return sent; |
| 1611 } | 1624 } |
| 1612 | 1625 |
| 1613 } // namespace cricket | 1626 } // namespace cricket |
| OLD | NEW |