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

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

Issue 2163403002: Prepare for ICE-renomination (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Updated comments Created 4 years, 4 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/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/port.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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 friend class Connection; 410 friend class Connection;
411 }; 411 };
412 412
413 // Represents a communication link between a port on the local client and a 413 // Represents a communication link between a port on the local client and a
414 // port on the remote client. 414 // port on the remote client.
415 class Connection : public CandidatePairInterface, 415 class Connection : public CandidatePairInterface,
416 public rtc::MessageHandler, 416 public rtc::MessageHandler,
417 public sigslot::has_slots<> { 417 public sigslot::has_slots<> {
418 public: 418 public:
419 struct SentPing { 419 struct SentPing {
420 SentPing(const std::string id, int64_t sent_time) 420 SentPing(const std::string id, int64_t sent_time, uint32_t nomination)
421 : id(id), sent_time(sent_time) {} 421 : id(id), sent_time(sent_time), nomination(nomination) {}
422 422
423 std::string id; 423 std::string id;
424 int64_t sent_time; 424 int64_t sent_time;
425 uint32_t nomination;
425 }; 426 };
426 427
427 // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4 428 // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4
428 enum State { 429 enum State {
429 STATE_WAITING = 0, // Check has not been performed, Waiting pair on CL. 430 STATE_WAITING = 0, // Check has not been performed, Waiting pair on CL.
430 STATE_INPROGRESS, // Check has been sent, transaction is in progress. 431 STATE_INPROGRESS, // Check has been sent, transaction is in progress.
431 STATE_SUCCEEDED, // Check already done, produced a successful result. 432 STATE_SUCCEEDED, // Check already done, produced a successful result.
432 STATE_FAILED // Check for this connection failed. 433 STATE_FAILED // Check for this connection failed.
433 }; 434 };
434 435
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // Called when a connection is determined to be no longer useful to us. We 505 // Called when a connection is determined to be no longer useful to us. We
505 // still keep it around in case the other side wants to use it. But we can 506 // still keep it around in case the other side wants to use it. But we can
506 // safely stop pinging on it and we can allow it to time out if the other 507 // safely stop pinging on it and we can allow it to time out if the other
507 // side stops using it as well. 508 // side stops using it as well.
508 bool pruned() const { return pruned_; } 509 bool pruned() const { return pruned_; }
509 void Prune(); 510 void Prune();
510 511
511 bool use_candidate_attr() const { return use_candidate_attr_; } 512 bool use_candidate_attr() const { return use_candidate_attr_; }
512 void set_use_candidate_attr(bool enable); 513 void set_use_candidate_attr(bool enable);
513 514
514 bool nominated() const { return nominated_; } 515 void set_nomination(uint32_t value) { nomination_ = value; }
515 void set_nominated(bool nominated) { nominated_ = nominated; } 516
517 uint32_t remote_nomination() const { return remote_nomination_; }
518 bool nominated() const { return remote_nomination_ > 0; }
519 // Public for unit tests.
520 void set_remote_nomination(uint32_t remote_nomination) {
521 remote_nomination_ = remote_nomination;
522 }
523 // Public for unit tests.
524 uint32_t acked_nomination() const { return acked_nomination_; }
516 525
517 void set_remote_ice_mode(IceMode mode) { 526 void set_remote_ice_mode(IceMode mode) {
518 remote_ice_mode_ = mode; 527 remote_ice_mode_ = mode;
519 } 528 }
520 529
521 void set_receiving_timeout(int64_t receiving_timeout_ms) { 530 void set_receiving_timeout(int64_t receiving_timeout_ms) {
522 receiving_timeout_ = receiving_timeout_ms; 531 receiving_timeout_ = receiving_timeout_ms;
523 } 532 }
524 533
525 // Makes the connection go away. 534 // Makes the connection go away.
526 void Destroy(); 535 void Destroy();
527 536
528 // Makes the connection go away, in a failed state. 537 // Makes the connection go away, in a failed state.
529 void FailAndDestroy(); 538 void FailAndDestroy();
530 539
531 // Prunes the connection and sets its state to STATE_FAILED, 540 // Prunes the connection and sets its state to STATE_FAILED,
532 // It will not be used or send pings although it can still receive packets. 541 // It will not be used or send pings although it can still receive packets.
533 void FailAndPrune(); 542 void FailAndPrune();
534 543
535 // Checks that the state of this connection is up-to-date. The argument is 544 // Checks that the state of this connection is up-to-date. The argument is
536 // the current time, which is compared against various timeouts. 545 // the current time, which is compared against various timeouts.
537 void UpdateState(int64_t now); 546 void UpdateState(int64_t now);
538 547
539 // Called when this connection should try checking writability again. 548 // Called when this connection should try checking writability again.
540 int64_t last_ping_sent() const { return last_ping_sent_; } 549 int64_t last_ping_sent() const { return last_ping_sent_; }
541 void Ping(int64_t now); 550 void Ping(int64_t now);
542 void ReceivedPingResponse(int rtt); 551 void ReceivedPingResponse(int rtt, const std::string& request_id);
543 int64_t last_ping_response_received() const { 552 int64_t last_ping_response_received() const {
544 return last_ping_response_received_; 553 return last_ping_response_received_;
545 } 554 }
546 555
547 // Called whenever a valid ping is received on this connection. This is 556 // Called whenever a valid ping is received on this connection. This is
548 // public because the connection intercepts the first ping for us. 557 // public because the connection intercepts the first ping for us.
549 int64_t last_ping_received() const { return last_ping_received_; } 558 int64_t last_ping_received() const { return last_ping_received_; }
550 void ReceivedPing(); 559 void ReceivedPing();
551 // Handles the binding request; sends a response if this is a valid request. 560 // Handles the binding request; sends a response if this is a valid request.
552 void HandleBindingRequest(IceMessage* msg); 561 void HandleBindingRequest(IceMessage* msg);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 // If the response is not received within 2 * RTT, the response is assumed to 633 // If the response is not received within 2 * RTT, the response is assumed to
625 // be missing. 634 // be missing.
626 bool missing_responses(int64_t now) const; 635 bool missing_responses(int64_t now) const;
627 636
628 // Changes the state and signals if necessary. 637 // Changes the state and signals if necessary.
629 void set_write_state(WriteState value); 638 void set_write_state(WriteState value);
630 void UpdateReceiving(int64_t now); 639 void UpdateReceiving(int64_t now);
631 void set_state(State state); 640 void set_state(State state);
632 void set_connected(bool value); 641 void set_connected(bool value);
633 642
643 uint32_t nomination() const { return nomination_; }
644
634 void OnMessage(rtc::Message *pmsg); 645 void OnMessage(rtc::Message *pmsg);
635 646
636 Port* port_; 647 Port* port_;
637 size_t local_candidate_index_; 648 size_t local_candidate_index_;
638 Candidate remote_candidate_; 649 Candidate remote_candidate_;
650
651 ConnectionInfo stats_;
652 rtc::RateTracker recv_rate_tracker_;
653 rtc::RateTracker send_rate_tracker_;
654
655 private:
639 WriteState write_state_; 656 WriteState write_state_;
640 bool receiving_; 657 bool receiving_;
641 bool connected_; 658 bool connected_;
642 bool pruned_; 659 bool pruned_;
643 // By default |use_candidate_attr_| flag will be true, 660 // By default |use_candidate_attr_| flag will be true,
644 // as we will be using aggressive nomination. 661 // as we will be using aggressive nomination.
645 // But when peer is ice-lite, this flag "must" be initialized to false and 662 // But when peer is ice-lite, this flag "must" be initialized to false and
646 // turn on when connection becomes "best connection". 663 // turn on when connection becomes "best connection".
647 bool use_candidate_attr_; 664 bool use_candidate_attr_;
648 // Whether this connection has been nominated by the controlling side via 665 // Used by the controlling side to indicate that this connection will be
649 // the use_candidate attribute. 666 // selected for transmission if the peer supports ICE-renomination when this
650 bool nominated_; 667 // value is positive. A larger-value indicates that a connection is nominated
668 // later and should be selected by the controlled side with higher precedence.
669 // A zero-value indicates not nominating this connection.
670 uint32_t nomination_ = 0;
671 // The last nomination that has been acknowledged.
672 uint32_t acked_nomination_ = 0;
673 // Used by the controlled side to remember the nomination value received from
674 // the controlling side. When the peer does not support ICE re-nomination,
675 // its value will be 1 if the connection has been nominated.
676 uint32_t remote_nomination_ = 0;
677
651 IceMode remote_ice_mode_; 678 IceMode remote_ice_mode_;
652 StunRequestManager requests_; 679 StunRequestManager requests_;
653 int rtt_; 680 int rtt_;
654 int rtt_samples_ = 0; 681 int rtt_samples_ = 0;
655 int64_t last_ping_sent_; // last time we sent a ping to the other side 682 int64_t last_ping_sent_; // last time we sent a ping to the other side
656 int64_t last_ping_received_; // last time we received a ping from the other 683 int64_t last_ping_received_; // last time we received a ping from the other
657 // side 684 // side
658 int64_t last_data_received_; 685 int64_t last_data_received_;
659 int64_t last_ping_response_received_; 686 int64_t last_ping_response_received_;
660 int64_t receiving_unchanged_since_ = 0; 687 int64_t receiving_unchanged_since_ = 0;
661 std::vector<SentPing> pings_since_last_response_; 688 std::vector<SentPing> pings_since_last_response_;
662 689
663 rtc::RateTracker recv_rate_tracker_;
664 rtc::RateTracker send_rate_tracker_;
665
666 ConnectionInfo stats_;
667
668 private:
669 void MaybeAddPrflxCandidate(ConnectionRequest* request, 690 void MaybeAddPrflxCandidate(ConnectionRequest* request,
670 StunMessage* response); 691 StunMessage* response);
671 692
672 bool reported_; 693 bool reported_;
673 State state_; 694 State state_;
674 // Time duration to switch from receiving to not receiving. 695 // Time duration to switch from receiving to not receiving.
675 int receiving_timeout_; 696 int receiving_timeout_;
676 int64_t time_created_ms_; 697 int64_t time_created_ms_;
677 int num_pings_sent_ = 0; 698 int num_pings_sent_ = 0;
678 699
(...skipping 11 matching lines...) Expand all
690 const rtc::PacketOptions& options) override; 711 const rtc::PacketOptions& options) override;
691 int GetError() override { return error_; } 712 int GetError() override { return error_; }
692 713
693 private: 714 private:
694 int error_ = 0; 715 int error_ = 0;
695 }; 716 };
696 717
697 } // namespace cricket 718 } // namespace cricket
698 719
699 #endif // WEBRTC_P2P_BASE_PORT_H_ 720 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698