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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 requests_(port->thread()), | 786 requests_(port->thread()), |
787 rtt_(DEFAULT_RTT), | 787 rtt_(DEFAULT_RTT), |
788 last_ping_sent_(0), | 788 last_ping_sent_(0), |
789 last_ping_received_(0), | 789 last_ping_received_(0), |
790 last_data_received_(0), | 790 last_data_received_(0), |
791 last_ping_response_received_(0), | 791 last_ping_response_received_(0), |
792 recv_rate_tracker_(100u, 10u), | 792 recv_rate_tracker_(100u, 10u), |
793 send_rate_tracker_(100u, 10u), | 793 send_rate_tracker_(100u, 10u), |
794 sent_packets_discarded_(0), | 794 sent_packets_discarded_(0), |
795 sent_packets_total_(0), | 795 sent_packets_total_(0), |
| 796 sent_ping_requests_(0), |
| 797 recv_ping_responses_(0), |
796 reported_(false), | 798 reported_(false), |
797 state_(STATE_WAITING), | 799 state_(STATE_WAITING), |
798 receiving_timeout_(WEAK_CONNECTION_RECEIVE_TIMEOUT), | 800 receiving_timeout_(WEAK_CONNECTION_RECEIVE_TIMEOUT), |
799 time_created_ms_(rtc::Time64()) { | 801 time_created_ms_(rtc::Time64()) { |
800 // All of our connections start in WAITING state. | 802 // All of our connections start in WAITING state. |
801 // TODO(mallinath) - Start connections from STATE_FROZEN. | 803 // TODO(mallinath) - Start connections from STATE_FROZEN. |
802 // Wire up to send stun packets | 804 // Wire up to send stun packets |
803 requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket); | 805 requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket); |
804 LOG_J(LS_INFO, this) << "Connection created"; | 806 LOG_J(LS_INFO, this) << "Connection created"; |
805 } | 807 } |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 PrintPingsSinceLastResponse(&pings, 5); | 1238 PrintPingsSinceLastResponse(&pings, 5); |
1237 LOG_JV(sev, this) << "Received STUN ping response" | 1239 LOG_JV(sev, this) << "Received STUN ping response" |
1238 << ", id=" << rtc::hex_encode(request->id()) | 1240 << ", id=" << rtc::hex_encode(request->id()) |
1239 << ", code=0" // Makes logging easier to parse. | 1241 << ", code=0" // Makes logging easier to parse. |
1240 << ", rtt=" << rtt | 1242 << ", rtt=" << rtt |
1241 << ", use_candidate=" << use_candidate | 1243 << ", use_candidate=" << use_candidate |
1242 << ", pings_since_last_response=" << pings; | 1244 << ", pings_since_last_response=" << pings; |
1243 } | 1245 } |
1244 | 1246 |
1245 rtt_ = (RTT_RATIO * rtt_ + rtt) / (RTT_RATIO + 1); | 1247 rtt_ = (RTT_RATIO * rtt_ + rtt) / (RTT_RATIO + 1); |
| 1248 recv_ping_responses_++; |
1246 | 1249 |
1247 MaybeAddPrflxCandidate(request, response); | 1250 MaybeAddPrflxCandidate(request, response); |
1248 } | 1251 } |
1249 | 1252 |
1250 void Connection::OnConnectionRequestErrorResponse(ConnectionRequest* request, | 1253 void Connection::OnConnectionRequestErrorResponse(ConnectionRequest* request, |
1251 StunMessage* response) { | 1254 StunMessage* response) { |
1252 const StunErrorCodeAttribute* error_attr = response->GetErrorCode(); | 1255 const StunErrorCodeAttribute* error_attr = response->GetErrorCode(); |
1253 int error_code = STUN_ERROR_GLOBAL_FAILURE; | 1256 int error_code = STUN_ERROR_GLOBAL_FAILURE; |
1254 if (error_attr) { | 1257 if (error_attr) { |
1255 error_code = error_attr->code(); | 1258 error_code = error_attr->code(); |
(...skipping 28 matching lines...) Expand all Loading... |
1284 << " after " << request->Elapsed() << " ms"; | 1287 << " after " << request->Elapsed() << " ms"; |
1285 } | 1288 } |
1286 | 1289 |
1287 void Connection::OnConnectionRequestSent(ConnectionRequest* request) { | 1290 void Connection::OnConnectionRequestSent(ConnectionRequest* request) { |
1288 // Log at LS_INFO if we send a ping on an unwritable connection. | 1291 // Log at LS_INFO if we send a ping on an unwritable connection. |
1289 rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; | 1292 rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; |
1290 bool use_candidate = use_candidate_attr(); | 1293 bool use_candidate = use_candidate_attr(); |
1291 LOG_JV(sev, this) << "Sent STUN ping" | 1294 LOG_JV(sev, this) << "Sent STUN ping" |
1292 << ", id=" << rtc::hex_encode(request->id()) | 1295 << ", id=" << rtc::hex_encode(request->id()) |
1293 << ", use_candidate=" << use_candidate; | 1296 << ", use_candidate=" << use_candidate; |
| 1297 sent_ping_requests_++; |
1294 } | 1298 } |
1295 | 1299 |
1296 void Connection::HandleRoleConflictFromPeer() { | 1300 void Connection::HandleRoleConflictFromPeer() { |
1297 port_->SignalRoleConflict(port_); | 1301 port_->SignalRoleConflict(port_); |
1298 } | 1302 } |
1299 | 1303 |
1300 void Connection::MaybeSetRemoteIceCredentialsAndGeneration( | 1304 void Connection::MaybeSetRemoteIceCredentialsAndGeneration( |
1301 const std::string& ice_ufrag, | 1305 const std::string& ice_ufrag, |
1302 const std::string& ice_pwd, | 1306 const std::string& ice_pwd, |
1303 int generation) { | 1307 int generation) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 } | 1361 } |
1358 | 1362 |
1359 size_t Connection::sent_discarded_packets() { | 1363 size_t Connection::sent_discarded_packets() { |
1360 return sent_packets_discarded_; | 1364 return sent_packets_discarded_; |
1361 } | 1365 } |
1362 | 1366 |
1363 size_t Connection::sent_total_packets() { | 1367 size_t Connection::sent_total_packets() { |
1364 return sent_packets_total_; | 1368 return sent_packets_total_; |
1365 } | 1369 } |
1366 | 1370 |
| 1371 size_t Connection::sent_ping_requests() { |
| 1372 return sent_ping_requests_; |
| 1373 } |
| 1374 |
| 1375 size_t Connection::recv_ping_responses() { |
| 1376 return recv_ping_responses_; |
| 1377 } |
| 1378 |
1367 void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request, | 1379 void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request, |
1368 StunMessage* response) { | 1380 StunMessage* response) { |
1369 // RFC 5245 | 1381 // RFC 5245 |
1370 // The agent checks the mapped address from the STUN response. If the | 1382 // The agent checks the mapped address from the STUN response. If the |
1371 // transport address does not match any of the local candidates that the | 1383 // transport address does not match any of the local candidates that the |
1372 // agent knows about, the mapped address represents a new candidate -- a | 1384 // agent knows about, the mapped address represents a new candidate -- a |
1373 // peer reflexive candidate. | 1385 // peer reflexive candidate. |
1374 const StunAddressAttribute* addr = | 1386 const StunAddressAttribute* addr = |
1375 response->GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); | 1387 response->GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); |
1376 if (!addr) { | 1388 if (!addr) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 ASSERT(sent < 0); | 1461 ASSERT(sent < 0); |
1450 error_ = port_->GetError(); | 1462 error_ = port_->GetError(); |
1451 sent_packets_discarded_++; | 1463 sent_packets_discarded_++; |
1452 } else { | 1464 } else { |
1453 send_rate_tracker_.AddSamples(sent); | 1465 send_rate_tracker_.AddSamples(sent); |
1454 } | 1466 } |
1455 return sent; | 1467 return sent; |
1456 } | 1468 } |
1457 | 1469 |
1458 } // namespace cricket | 1470 } // namespace cricket |
OLD | NEW |