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

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

Issue 2722933002: Measure packet loss so we can use it to select ICE candidate pairs. (Closed)
Patch Set: better comments and test names 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 | « no previous file | webrtc/p2p/base/port.cc » ('j') | webrtc/p2p/base/port.cc » ('J')
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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 // A virtual cost perceived by the user, usually based on the network type 426 // A virtual cost perceived by the user, usually based on the network type
427 // (WiFi. vs. Cellular). It takes precedence over the priority when 427 // (WiFi. vs. Cellular). It takes precedence over the priority when
428 // comparing two connections. 428 // comparing two connections.
429 uint16_t network_cost_; 429 uint16_t network_cost_;
430 State state_ = State::INIT; 430 State state_ = State::INIT;
431 int64_t last_time_all_connections_removed_ = 0; 431 int64_t last_time_all_connections_removed_ = 0;
432 432
433 friend class Connection; 433 friend class Connection;
434 }; 434 };
435 435
436 class PacketLossEstimator {
Taylor Brandstetter 2017/03/01 02:26:12 Some comments around this class may be helpful. Su
Zach Stein 2017/03/02 00:02:23 Done.
437 public:
438 struct PacketInfo {
Taylor Brandstetter 2017/03/01 02:26:12 It looks like this struct can be private.
Zach Stein 2017/03/02 00:02:23 Don't need this now that outstanding_packets_ is a
439 PacketInfo(const std::string id, int64_t sent_time)
440 : id(id), sent_time(sent_time) {}
441
442 std::string id;
443 int64_t sent_time;
444 };
445
446 PacketLossEstimator(int64_t expire_after);
Taylor Brandstetter 2017/03/01 02:26:12 Doesn't have to be in this CL, but it may be usefu
Zach Stein 2017/03/02 00:02:23 I like this idea but will leave it for another CL.
447
448 void ExpectResponse(std::string id, int64_t sent_time);
449
450 void ReceivedResponse(std::string id, int64_t received_time);
451
452 void RemoveExpiredPackets(int64_t now);
453
454 // This is updated during ReceivedResponse and RemoveExpiredPackets.
Taylor Brandstetter 2017/03/01 02:26:12 The code may be more readable if only "RemoveExpir
Zach Stein 2017/03/02 00:02:23 Good suggestion, I think this will be cleaner.
455 // You may want to call RemoveExpiredPackets to ensure the data is up to date.
456 double get_response_rate() const { return response_rate_; }
457
458 protected:
459 // for unittests
460 int64_t get_responses_expected() const { return responses_expected_; }
461 // for unittests
462 int64_t get_responses_received() const { return responses_received_; }
Taylor Brandstetter 2017/03/01 02:26:13 I'd prefer not having "for test" methods unless ab
Zach Stein 2017/03/02 00:02:23 I think this gives better coverage (ResponseLost/R
Taylor Brandstetter 2017/03/02 03:09:57 ResponseLate and ResponseLost could be updated to
463
464 private:
465 void UpdateResponseRate();
466
467 bool IsExpired(const PacketInfo& packet, int64_t received_time) const;
468
469 int64_t expire_after_; // in milliseconds
470
471 std::vector<PacketInfo> outstanding_packets_;
Taylor Brandstetter 2017/03/01 02:26:12 nit: Probably doesn't matter, but would an unorder
Zach Stein 2017/03/02 00:02:23 Maybe. Thinking about this did make me realize tha
472 int64_t responses_expected_ = 0;
473 int64_t responses_received_ = 0;
474 double response_rate_ = 1.0;
475 };
Taylor Brandstetter 2017/03/01 02:26:12 I think we can move this to its own file; port.h a
Zach Stein 2017/03/02 00:02:23 Acknowledged. I will do this in a separate upload
Taylor Brandstetter 2017/03/02 03:09:57 Thanks; that does help a lot.
476
436 // Represents a communication link between a port on the local client and a 477 // Represents a communication link between a port on the local client and a
437 // port on the remote client. 478 // port on the remote client.
438 class Connection : public CandidatePairInterface, 479 class Connection : public CandidatePairInterface,
439 public rtc::MessageHandler, 480 public rtc::MessageHandler,
440 public sigslot::has_slots<> { 481 public sigslot::has_slots<> {
441 public: 482 public:
442 struct SentPing { 483 struct SentPing {
443 SentPing(const std::string id, int64_t sent_time, uint32_t nomination) 484 SentPing(const std::string id, int64_t sent_time, uint32_t nomination)
444 : id(id), sent_time(sent_time), nomination(nomination) {} 485 : id(id), sent_time(sent_time), nomination(nomination) {}
445 486
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-currentrou ndtriptime 753 // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-currentrou ndtriptime
713 rtc::Optional<uint32_t> current_round_trip_time_ms_; 754 rtc::Optional<uint32_t> current_round_trip_time_ms_;
714 int64_t last_ping_sent_; // last time we sent a ping to the other side 755 int64_t last_ping_sent_; // last time we sent a ping to the other side
715 int64_t last_ping_received_; // last time we received a ping from the other 756 int64_t last_ping_received_; // last time we received a ping from the other
716 // side 757 // side
717 int64_t last_data_received_; 758 int64_t last_data_received_;
718 int64_t last_ping_response_received_; 759 int64_t last_ping_response_received_;
719 int64_t receiving_unchanged_since_ = 0; 760 int64_t receiving_unchanged_since_ = 0;
720 std::vector<SentPing> pings_since_last_response_; 761 std::vector<SentPing> pings_since_last_response_;
721 762
763 PacketLossEstimator packet_loss_estimator_;
764
722 bool reported_; 765 bool reported_;
723 IceCandidatePairState state_; 766 IceCandidatePairState state_;
724 // Time duration to switch from receiving to not receiving. 767 // Time duration to switch from receiving to not receiving.
725 int receiving_timeout_; 768 int receiving_timeout_;
726 int64_t time_created_ms_; 769 int64_t time_created_ms_;
727 int num_pings_sent_ = 0; 770 int num_pings_sent_ = 0;
728 771
729 friend class Port; 772 friend class Port;
730 friend class ConnectionRequest; 773 friend class ConnectionRequest;
731 }; 774 };
732 775
733 // ProxyConnection defers all the interesting work to the port. 776 // ProxyConnection defers all the interesting work to the port.
734 class ProxyConnection : public Connection { 777 class ProxyConnection : public Connection {
735 public: 778 public:
736 ProxyConnection(Port* port, size_t index, const Candidate& remote_candidate); 779 ProxyConnection(Port* port, size_t index, const Candidate& remote_candidate);
737 780
738 int Send(const void* data, 781 int Send(const void* data,
739 size_t size, 782 size_t size,
740 const rtc::PacketOptions& options) override; 783 const rtc::PacketOptions& options) override;
741 int GetError() override { return error_; } 784 int GetError() override { return error_; }
742 785
743 private: 786 private:
744 int error_ = 0; 787 int error_ = 0;
745 }; 788 };
746 789
747 } // namespace cricket 790 } // namespace cricket
748 791
749 #endif // WEBRTC_P2P_BASE_PORT_H_ 792 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/port.cc » ('j') | webrtc/p2p/base/port.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698