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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 connected_(true), | 887 connected_(true), |
888 pruned_(false), | 888 pruned_(false), |
889 use_candidate_attr_(false), | 889 use_candidate_attr_(false), |
890 remote_ice_mode_(ICEMODE_FULL), | 890 remote_ice_mode_(ICEMODE_FULL), |
891 requests_(port->thread()), | 891 requests_(port->thread()), |
892 rtt_(DEFAULT_RTT), | 892 rtt_(DEFAULT_RTT), |
893 last_ping_sent_(0), | 893 last_ping_sent_(0), |
894 last_ping_received_(0), | 894 last_ping_received_(0), |
895 last_data_received_(0), | 895 last_data_received_(0), |
896 last_ping_response_received_(0), | 896 last_ping_response_received_(0), |
| 897 recv_rate_tracker_(100u, 10u), |
| 898 send_rate_tracker_(100u, 10u), |
897 sent_packets_discarded_(0), | 899 sent_packets_discarded_(0), |
898 sent_packets_total_(0), | 900 sent_packets_total_(0), |
899 reported_(false), | 901 reported_(false), |
900 state_(STATE_WAITING) { | 902 state_(STATE_WAITING) { |
901 // All of our connections start in WAITING state. | 903 // All of our connections start in WAITING state. |
902 // TODO(mallinath) - Start connections from STATE_FROZEN. | 904 // TODO(mallinath) - Start connections from STATE_FROZEN. |
903 // Wire up to send stun packets | 905 // Wire up to send stun packets |
904 requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket); | 906 requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket); |
905 LOG_J(LS_INFO, this) << "Connection created"; | 907 LOG_J(LS_INFO, this) << "Connection created"; |
906 } | 908 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 std::string remote_ufrag; | 1000 std::string remote_ufrag; |
999 const rtc::SocketAddress& addr(remote_candidate_.address()); | 1001 const rtc::SocketAddress& addr(remote_candidate_.address()); |
1000 if (!port_->GetStunMessage(data, size, addr, msg.accept(), &remote_ufrag)) { | 1002 if (!port_->GetStunMessage(data, size, addr, msg.accept(), &remote_ufrag)) { |
1001 // The packet did not parse as a valid STUN message | 1003 // The packet did not parse as a valid STUN message |
1002 | 1004 |
1003 // If this connection is readable, then pass along the packet. | 1005 // If this connection is readable, then pass along the packet. |
1004 if (read_state_ == STATE_READABLE) { | 1006 if (read_state_ == STATE_READABLE) { |
1005 // readable means data from this address is acceptable | 1007 // readable means data from this address is acceptable |
1006 // Send it on! | 1008 // Send it on! |
1007 last_data_received_ = rtc::Time(); | 1009 last_data_received_ = rtc::Time(); |
1008 recv_rate_tracker_.Update(size); | 1010 recv_rate_tracker_.AddSamples(size); |
1009 SignalReadPacket(this, data, size, packet_time); | 1011 SignalReadPacket(this, data, size, packet_time); |
1010 | 1012 |
1011 // If timed out sending writability checks, start up again | 1013 // If timed out sending writability checks, start up again |
1012 if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) { | 1014 if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) { |
1013 LOG(LS_WARNING) << "Received a data packet on a timed-out Connection. " | 1015 LOG(LS_WARNING) << "Received a data packet on a timed-out Connection. " |
1014 << "Resetting state to STATE_WRITE_INIT."; | 1016 << "Resetting state to STATE_WRITE_INIT."; |
1015 set_write_state(STATE_WRITE_INIT); | 1017 set_write_state(STATE_WRITE_INIT); |
1016 } | 1018 } |
1017 } else { | 1019 } else { |
1018 // Not readable means the remote address hasn't sent a valid | 1020 // Not readable means the remote address hasn't sent a valid |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 SignalDestroyed(this); | 1445 SignalDestroyed(this); |
1444 delete this; | 1446 delete this; |
1445 } | 1447 } |
1446 | 1448 |
1447 uint32 Connection::last_received() { | 1449 uint32 Connection::last_received() { |
1448 return std::max(last_data_received_, | 1450 return std::max(last_data_received_, |
1449 std::max(last_ping_received_, last_ping_response_received_)); | 1451 std::max(last_ping_received_, last_ping_response_received_)); |
1450 } | 1452 } |
1451 | 1453 |
1452 size_t Connection::recv_bytes_second() { | 1454 size_t Connection::recv_bytes_second() { |
1453 return recv_rate_tracker_.units_second(); | 1455 return recv_rate_tracker_.ComputeRate(); |
1454 } | 1456 } |
1455 | 1457 |
1456 size_t Connection::recv_total_bytes() { | 1458 size_t Connection::recv_total_bytes() { |
1457 return recv_rate_tracker_.total_units(); | 1459 return recv_rate_tracker_.TotalSampleCount(); |
1458 } | 1460 } |
1459 | 1461 |
1460 size_t Connection::sent_bytes_second() { | 1462 size_t Connection::sent_bytes_second() { |
1461 return send_rate_tracker_.units_second(); | 1463 return send_rate_tracker_.ComputeRate(); |
1462 } | 1464 } |
1463 | 1465 |
1464 size_t Connection::sent_total_bytes() { | 1466 size_t Connection::sent_total_bytes() { |
1465 return send_rate_tracker_.total_units(); | 1467 return send_rate_tracker_.TotalSampleCount(); |
1466 } | 1468 } |
1467 | 1469 |
1468 size_t Connection::sent_discarded_packets() { | 1470 size_t Connection::sent_discarded_packets() { |
1469 return sent_packets_discarded_; | 1471 return sent_packets_discarded_; |
1470 } | 1472 } |
1471 | 1473 |
1472 size_t Connection::sent_total_packets() { | 1474 size_t Connection::sent_total_packets() { |
1473 return sent_packets_total_; | 1475 return sent_packets_total_; |
1474 } | 1476 } |
1475 | 1477 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 return SOCKET_ERROR; | 1552 return SOCKET_ERROR; |
1551 } | 1553 } |
1552 sent_packets_total_++; | 1554 sent_packets_total_++; |
1553 int sent = port_->SendTo(data, size, remote_candidate_.address(), | 1555 int sent = port_->SendTo(data, size, remote_candidate_.address(), |
1554 options, true); | 1556 options, true); |
1555 if (sent <= 0) { | 1557 if (sent <= 0) { |
1556 ASSERT(sent < 0); | 1558 ASSERT(sent < 0); |
1557 error_ = port_->GetError(); | 1559 error_ = port_->GetError(); |
1558 sent_packets_discarded_++; | 1560 sent_packets_discarded_++; |
1559 } else { | 1561 } else { |
1560 send_rate_tracker_.Update(sent); | 1562 send_rate_tracker_.AddSamples(sent); |
1561 } | 1563 } |
1562 return sent; | 1564 return sent; |
1563 } | 1565 } |
1564 | 1566 |
1565 } // namespace cricket | 1567 } // namespace cricket |
OLD | NEW |