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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 // If a connection does not receive anything for this long, it is considered | 53 // If a connection does not receive anything for this long, it is considered |
54 // dead. | 54 // dead. |
55 const uint32 DEAD_CONNECTION_RECEIVE_TIMEOUT = 30 * 1000; // 30 seconds. | 55 const uint32 DEAD_CONNECTION_RECEIVE_TIMEOUT = 30 * 1000; // 30 seconds. |
56 | 56 |
57 // The timeout duration when a connection does not receive anything. | 57 // The timeout duration when a connection does not receive anything. |
58 const uint32 WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds | 58 const uint32 WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds |
59 | 59 |
60 // The length of time we wait before timing out writability on a connection. | 60 // The length of time we wait before timing out writability on a connection. |
61 const uint32 CONNECTION_WRITE_TIMEOUT = 15 * 1000; // 15 seconds | 61 const uint32 CONNECTION_WRITE_TIMEOUT = 15 * 1000; // 15 seconds |
62 | 62 |
63 // The length of time we wait before the write state become stale. | |
64 const uint32 CONNECTION_WRITE_STALE_TIMEOUT = 10 * 1000; // 10 seconds | |
65 | |
63 // The length of time we wait before we become unwritable. | 66 // The length of time we wait before we become unwritable. |
64 const uint32 CONNECTION_WRITE_CONNECT_TIMEOUT = 5 * 1000; // 5 seconds | 67 const uint32 CONNECTION_WRITE_CONNECT_TIMEOUT = 5 * 1000; // 5 seconds |
65 | 68 |
66 // The number of pings that must fail to respond before we become unwritable. | 69 // The number of pings that must fail to respond before we become unwritable. |
67 const uint32 CONNECTION_WRITE_CONNECT_FAILURES = 5; | 70 const uint32 CONNECTION_WRITE_CONNECT_FAILURES = 5; |
68 | 71 |
69 // This is the length of time that we wait for a ping response to come back. | 72 // This is the length of time that we wait for a ping response to come back. |
70 const int CONNECTION_RESPONSE_TIMEOUT = 5 * 1000; // 5 seconds | 73 const int CONNECTION_RESPONSE_TIMEOUT = 5 * 1000; // 5 seconds |
71 | 74 |
72 enum RelayType { | 75 enum RelayType { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 virtual const Candidate& local_candidate() const; | 419 virtual const Candidate& local_candidate() const; |
417 | 420 |
418 // Returns the description of the remote port to which we communicate. | 421 // Returns the description of the remote port to which we communicate. |
419 const Candidate& remote_candidate() const { return remote_candidate_; } | 422 const Candidate& remote_candidate() const { return remote_candidate_; } |
420 | 423 |
421 // Returns the pair priority. | 424 // Returns the pair priority. |
422 uint64 priority() const; | 425 uint64 priority() const; |
423 | 426 |
424 enum WriteState { | 427 enum WriteState { |
425 STATE_WRITABLE = 0, // we have received ping responses recently | 428 STATE_WRITABLE = 0, // we have received ping responses recently |
426 STATE_WRITE_UNRELIABLE = 1, // we have had a few ping failures | 429 STATE_WRITE_STALE = 1, // we have not sent ping recently. |
427 STATE_WRITE_INIT = 2, // we have yet to receive a ping response | 430 STATE_WRITE_UNRELIABLE = 2, // we have had a few ping failures |
428 STATE_WRITE_TIMEOUT = 3, // we have had a large number of ping failures | 431 STATE_WRITE_INIT = 3, // we have yet to receive a ping response |
432 STATE_WRITE_TIMEOUT = 4, // we have had a large number of ping failures | |
pthatcher1
2015/09/21 23:49:18
So the only difference between STALE and UNRELIABL
honghaiz3
2015/09/22 19:35:08
Dropped this change now.
| |
429 }; | 433 }; |
430 | 434 |
431 WriteState write_state() const { return write_state_; } | 435 WriteState write_state() const { return write_state_; } |
432 bool writable() const { return write_state_ == STATE_WRITABLE; } | 436 bool writable() const { return write_state_ == STATE_WRITABLE; } |
437 bool write_timed_out() const { return write_state_ == STATE_WRITE_TIMEOUT; } | |
433 bool receiving() const { return receiving_; } | 438 bool receiving() const { return receiving_; } |
434 | 439 |
435 // Determines whether the connection has finished connecting. This can only | 440 // Determines whether the connection has finished connecting. This can only |
436 // be false for TCP connections. | 441 // be false for TCP connections. |
437 bool connected() const { return connected_; } | 442 bool connected() const { return connected_; } |
438 | 443 |
439 // Estimate of the round-trip time over this connection. | 444 // Estimate of the round-trip time over this connection. |
440 uint32 rtt() const { return rtt_; } | 445 uint32 rtt() const { return rtt_; } |
441 | 446 |
442 size_t sent_total_bytes(); | 447 size_t sent_total_bytes(); |
(...skipping 30 matching lines...) Expand all Loading... | |
473 | 478 |
474 // Called when the socket is currently able to send. | 479 // Called when the socket is currently able to send. |
475 void OnReadyToSend(); | 480 void OnReadyToSend(); |
476 | 481 |
477 // Called when a connection is determined to be no longer useful to us. We | 482 // Called when a connection is determined to be no longer useful to us. We |
478 // still keep it around in case the other side wants to use it. But we can | 483 // still keep it around in case the other side wants to use it. But we can |
479 // safely stop pinging on it and we can allow it to time out if the other | 484 // safely stop pinging on it and we can allow it to time out if the other |
480 // side stops using it as well. | 485 // side stops using it as well. |
481 bool pruned() const { return pruned_; } | 486 bool pruned() const { return pruned_; } |
482 void Prune(); | 487 void Prune(); |
488 void Unprune(); | |
483 | 489 |
484 bool use_candidate_attr() const { return use_candidate_attr_; } | 490 bool use_candidate_attr() const { return use_candidate_attr_; } |
485 void set_use_candidate_attr(bool enable); | 491 void set_use_candidate_attr(bool enable); |
486 | 492 |
487 bool nominated() const { return nominated_; } | 493 bool nominated() const { return nominated_; } |
488 void set_nominated(bool nominated) { nominated_ = nominated; } | 494 void set_nominated(bool nominated) { nominated_ = nominated; } |
489 | 495 |
490 void set_remote_ice_mode(IceMode mode) { | 496 void set_remote_ice_mode(IceMode mode) { |
491 remote_ice_mode_ = mode; | 497 remote_ice_mode_ = mode; |
492 } | 498 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 StunMessage* response); | 569 StunMessage* response); |
564 void OnConnectionRequestTimeout(ConnectionRequest* req); | 570 void OnConnectionRequestTimeout(ConnectionRequest* req); |
565 void OnConnectionRequestSent(ConnectionRequest* req); | 571 void OnConnectionRequestSent(ConnectionRequest* req); |
566 | 572 |
567 // Changes the state and signals if necessary. | 573 // Changes the state and signals if necessary. |
568 void set_write_state(WriteState value); | 574 void set_write_state(WriteState value); |
569 void set_receiving(bool value); | 575 void set_receiving(bool value); |
570 void set_state(State state); | 576 void set_state(State state); |
571 void set_connected(bool value); | 577 void set_connected(bool value); |
572 | 578 |
573 // Checks if this connection is useless, and hence, should be destroyed. | |
574 void CheckTimeout(); | |
575 | |
576 void OnMessage(rtc::Message *pmsg); | 579 void OnMessage(rtc::Message *pmsg); |
577 | 580 |
578 Port* port_; | 581 Port* port_; |
579 size_t local_candidate_index_; | 582 size_t local_candidate_index_; |
580 Candidate remote_candidate_; | 583 Candidate remote_candidate_; |
581 WriteState write_state_; | 584 WriteState write_state_; |
582 bool receiving_; | 585 bool receiving_; |
583 bool connected_; | 586 bool connected_; |
584 bool pruned_; | 587 bool pruned_; |
585 // By default |use_candidate_attr_| flag will be true, | 588 // By default |use_candidate_attr_| flag will be true, |
586 // as we will be using aggressive nomination. | 589 // as we will be using aggressive nomination. |
587 // But when peer is ice-lite, this flag "must" be initialized to false and | 590 // But when peer is ice-lite, this flag "must" be initialized to false and |
588 // turn on when connection becomes "best connection". | 591 // turn on when connection becomes "best connection". |
589 bool use_candidate_attr_; | 592 bool use_candidate_attr_; |
590 // Whether this connection has been nominated by the controlling side via | 593 // Whether this connection has been nominated by the controlling side via |
591 // the use_candidate attribute. | 594 // the use_candidate attribute. |
592 bool nominated_; | 595 bool nominated_; |
593 IceMode remote_ice_mode_; | 596 IceMode remote_ice_mode_; |
594 StunRequestManager requests_; | 597 StunRequestManager requests_; |
595 uint32 rtt_; | 598 uint32 rtt_; |
599 uint32 time_created_; | |
596 uint32 last_ping_sent_; // last time we sent a ping to the other side | 600 uint32 last_ping_sent_; // last time we sent a ping to the other side |
597 uint32 last_ping_received_; // last time we received a ping from the other | 601 uint32 last_ping_received_; // last time we received a ping from the other |
598 // side | 602 // side |
599 uint32 last_data_received_; | 603 uint32 last_data_received_; |
600 uint32 last_ping_response_received_; | 604 uint32 last_ping_response_received_; |
601 std::vector<SentPing> pings_since_last_response_; | 605 std::vector<SentPing> pings_since_last_response_; |
602 | 606 |
603 rtc::RateTracker recv_rate_tracker_; | 607 rtc::RateTracker recv_rate_tracker_; |
604 rtc::RateTracker send_rate_tracker_; | 608 rtc::RateTracker send_rate_tracker_; |
605 uint32 sent_packets_discarded_; | 609 uint32 sent_packets_discarded_; |
(...skipping 21 matching lines...) Expand all Loading... | |
627 const rtc::PacketOptions& options); | 631 const rtc::PacketOptions& options); |
628 virtual int GetError() { return error_; } | 632 virtual int GetError() { return error_; } |
629 | 633 |
630 private: | 634 private: |
631 int error_; | 635 int error_; |
632 }; | 636 }; |
633 | 637 |
634 } // namespace cricket | 638 } // namespace cricket |
635 | 639 |
636 #endif // WEBRTC_P2P_BASE_PORT_H_ | 640 #endif // WEBRTC_P2P_BASE_PORT_H_ |
OLD | NEW |