OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_config.h" | 5 #include "net/quic/quic_config.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/quic/crypto/crypto_handshake_message.h" | 10 #include "net/quic/crypto/crypto_handshake_message.h" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 congestion_options_(kCOPT, PRESENCE_OPTIONAL), | 429 congestion_options_(kCOPT, PRESENCE_OPTIONAL), |
430 loss_detection_(kLOSS, PRESENCE_OPTIONAL), | 430 loss_detection_(kLOSS, PRESENCE_OPTIONAL), |
431 idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), | 431 idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), |
432 keepalive_timeout_seconds_(kKATO, PRESENCE_OPTIONAL), | 432 keepalive_timeout_seconds_(kKATO, PRESENCE_OPTIONAL), |
433 max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED), | 433 max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED), |
434 max_time_before_crypto_handshake_(QuicTime::Delta::Zero()), | 434 max_time_before_crypto_handshake_(QuicTime::Delta::Zero()), |
435 initial_congestion_window_(kSWND, PRESENCE_OPTIONAL), | 435 initial_congestion_window_(kSWND, PRESENCE_OPTIONAL), |
436 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), | 436 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), |
437 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring | 437 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring |
438 // QUIC_VERSION_17. | 438 // QUIC_VERSION_17. |
439 initial_flow_control_window_bytes_(kIFCW, PRESENCE_OPTIONAL) { | 439 initial_flow_control_window_bytes_(kIFCW, PRESENCE_OPTIONAL), |
| 440 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring |
| 441 // QUIC_VERSION_19. |
| 442 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), |
| 443 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring |
| 444 // QUIC_VERSION_19. |
| 445 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL) { |
440 } | 446 } |
441 | 447 |
442 QuicConfig::~QuicConfig() {} | 448 QuicConfig::~QuicConfig() {} |
443 | 449 |
444 void QuicConfig::set_congestion_feedback( | 450 void QuicConfig::set_congestion_feedback( |
445 const QuicTagVector& congestion_feedback, | 451 const QuicTagVector& congestion_feedback, |
446 QuicTag default_congestion_feedback) { | 452 QuicTag default_congestion_feedback) { |
447 congestion_feedback_.set(congestion_feedback, default_congestion_feedback); | 453 congestion_feedback_.set(congestion_feedback, default_congestion_feedback); |
448 } | 454 } |
449 | 455 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 } | 557 } |
552 | 558 |
553 bool QuicConfig::HasReceivedInitialFlowControlWindowBytes() const { | 559 bool QuicConfig::HasReceivedInitialFlowControlWindowBytes() const { |
554 return initial_flow_control_window_bytes_.HasReceivedValue(); | 560 return initial_flow_control_window_bytes_.HasReceivedValue(); |
555 } | 561 } |
556 | 562 |
557 uint32 QuicConfig::ReceivedInitialFlowControlWindowBytes() const { | 563 uint32 QuicConfig::ReceivedInitialFlowControlWindowBytes() const { |
558 return initial_flow_control_window_bytes_.GetReceivedValue(); | 564 return initial_flow_control_window_bytes_.GetReceivedValue(); |
559 } | 565 } |
560 | 566 |
| 567 void QuicConfig::SetInitialStreamFlowControlWindowToSend(uint32 window_bytes) { |
| 568 if (window_bytes < kDefaultFlowControlSendWindow) { |
| 569 LOG(DFATAL) << "Initial stream flow control receive window (" |
| 570 << window_bytes << ") cannot be set lower than default (" |
| 571 << kDefaultFlowControlSendWindow << ")."; |
| 572 window_bytes = kDefaultFlowControlSendWindow; |
| 573 } |
| 574 initial_stream_flow_control_window_bytes_.SetSendValue(window_bytes); |
| 575 } |
| 576 |
| 577 uint32 QuicConfig::GetInitialStreamFlowControlWindowToSend() const { |
| 578 return initial_stream_flow_control_window_bytes_.GetSendValue(); |
| 579 } |
| 580 |
| 581 bool QuicConfig::HasReceivedInitialStreamFlowControlWindowBytes() const { |
| 582 return initial_stream_flow_control_window_bytes_.HasReceivedValue(); |
| 583 } |
| 584 |
| 585 uint32 QuicConfig::ReceivedInitialStreamFlowControlWindowBytes() const { |
| 586 return initial_stream_flow_control_window_bytes_.GetReceivedValue(); |
| 587 } |
| 588 |
| 589 void QuicConfig::SetInitialSessionFlowControlWindowToSend(uint32 window_bytes) { |
| 590 if (window_bytes < kDefaultFlowControlSendWindow) { |
| 591 LOG(DFATAL) << "Initial session flow control receive window (" |
| 592 << window_bytes << ") cannot be set lower than default (" |
| 593 << kDefaultFlowControlSendWindow << ")."; |
| 594 window_bytes = kDefaultFlowControlSendWindow; |
| 595 } |
| 596 initial_session_flow_control_window_bytes_.SetSendValue(window_bytes); |
| 597 } |
| 598 |
| 599 uint32 QuicConfig::GetInitialSessionFlowControlWindowToSend() const { |
| 600 return initial_session_flow_control_window_bytes_.GetSendValue(); |
| 601 } |
| 602 |
| 603 bool QuicConfig::HasReceivedInitialSessionFlowControlWindowBytes() const { |
| 604 return initial_session_flow_control_window_bytes_.HasReceivedValue(); |
| 605 } |
| 606 |
| 607 uint32 QuicConfig::ReceivedInitialSessionFlowControlWindowBytes() const { |
| 608 return initial_session_flow_control_window_bytes_.GetReceivedValue(); |
| 609 } |
| 610 |
561 bool QuicConfig::negotiated() { | 611 bool QuicConfig::negotiated() { |
562 // TODO(ianswett): Add the negotiated parameters once and iterate over all | 612 // TODO(ianswett): Add the negotiated parameters once and iterate over all |
563 // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and | 613 // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and |
564 // ProcessServerHello. | 614 // ProcessServerHello. |
565 return congestion_feedback_.negotiated() && | 615 return congestion_feedback_.negotiated() && |
566 idle_connection_state_lifetime_seconds_.negotiated() && | 616 idle_connection_state_lifetime_seconds_.negotiated() && |
567 keepalive_timeout_seconds_.negotiated() && | 617 keepalive_timeout_seconds_.negotiated() && |
568 max_streams_per_connection_.negotiated(); | 618 max_streams_per_connection_.negotiated(); |
569 } | 619 } |
570 | 620 |
571 void QuicConfig::SetDefaults() { | 621 void QuicConfig::SetDefaults() { |
572 QuicTagVector congestion_feedback; | 622 QuicTagVector congestion_feedback; |
573 if (FLAGS_enable_quic_pacing) { | 623 if (FLAGS_enable_quic_pacing) { |
574 congestion_feedback.push_back(kPACE); | 624 congestion_feedback.push_back(kPACE); |
575 } | 625 } |
576 congestion_feedback.push_back(kQBIC); | 626 congestion_feedback.push_back(kQBIC); |
577 congestion_feedback_.set(congestion_feedback, kQBIC); | 627 congestion_feedback_.set(congestion_feedback, kQBIC); |
578 idle_connection_state_lifetime_seconds_.set(kDefaultTimeoutSecs, | 628 idle_connection_state_lifetime_seconds_.set(kDefaultTimeoutSecs, |
579 kDefaultInitialTimeoutSecs); | 629 kDefaultInitialTimeoutSecs); |
580 // kKATO is optional. Return 0 if not negotiated. | 630 // kKATO is optional. Return 0 if not negotiated. |
581 keepalive_timeout_seconds_.set(0, 0); | 631 keepalive_timeout_seconds_.set(0, 0); |
582 max_streams_per_connection_.set(kDefaultMaxStreamsPerConnection, | 632 max_streams_per_connection_.set(kDefaultMaxStreamsPerConnection, |
583 kDefaultMaxStreamsPerConnection); | 633 kDefaultMaxStreamsPerConnection); |
584 max_time_before_crypto_handshake_ = QuicTime::Delta::FromSeconds( | 634 max_time_before_crypto_handshake_ = QuicTime::Delta::FromSeconds( |
585 kDefaultMaxTimeForCryptoHandshakeSecs); | 635 kDefaultMaxTimeForCryptoHandshakeSecs); |
586 | 636 |
587 SetInitialFlowControlWindowToSend(kDefaultFlowControlSendWindow); | 637 SetInitialFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
| 638 SetInitialStreamFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
| 639 SetInitialSessionFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
588 } | 640 } |
589 | 641 |
590 void QuicConfig::EnablePacing(bool enable_pacing) { | 642 void QuicConfig::EnablePacing(bool enable_pacing) { |
591 QuicTagVector congestion_feedback; | 643 QuicTagVector congestion_feedback; |
592 if (enable_pacing) { | 644 if (enable_pacing) { |
593 congestion_feedback.push_back(kPACE); | 645 congestion_feedback.push_back(kPACE); |
594 } | 646 } |
595 congestion_feedback.push_back(kQBIC); | 647 congestion_feedback.push_back(kQBIC); |
596 congestion_feedback_.set(congestion_feedback, kQBIC); | 648 congestion_feedback_.set(congestion_feedback, kQBIC); |
597 } | 649 } |
598 | 650 |
599 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { | 651 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
600 congestion_feedback_.ToHandshakeMessage(out); | 652 congestion_feedback_.ToHandshakeMessage(out); |
601 idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); | 653 idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); |
602 keepalive_timeout_seconds_.ToHandshakeMessage(out); | 654 keepalive_timeout_seconds_.ToHandshakeMessage(out); |
603 max_streams_per_connection_.ToHandshakeMessage(out); | 655 max_streams_per_connection_.ToHandshakeMessage(out); |
604 initial_congestion_window_.ToHandshakeMessage(out); | 656 initial_congestion_window_.ToHandshakeMessage(out); |
605 initial_round_trip_time_us_.ToHandshakeMessage(out); | 657 initial_round_trip_time_us_.ToHandshakeMessage(out); |
606 loss_detection_.ToHandshakeMessage(out); | 658 loss_detection_.ToHandshakeMessage(out); |
607 initial_flow_control_window_bytes_.ToHandshakeMessage(out); | 659 initial_flow_control_window_bytes_.ToHandshakeMessage(out); |
| 660 initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out); |
| 661 initial_session_flow_control_window_bytes_.ToHandshakeMessage(out); |
608 congestion_options_.ToHandshakeMessage(out); | 662 congestion_options_.ToHandshakeMessage(out); |
609 } | 663 } |
610 | 664 |
611 QuicErrorCode QuicConfig::ProcessPeerHello( | 665 QuicErrorCode QuicConfig::ProcessPeerHello( |
612 const CryptoHandshakeMessage& peer_hello, | 666 const CryptoHandshakeMessage& peer_hello, |
613 HelloType hello_type, | 667 HelloType hello_type, |
614 string* error_details) { | 668 string* error_details) { |
615 DCHECK(error_details != NULL); | 669 DCHECK(error_details != NULL); |
616 | 670 |
617 QuicErrorCode error = QUIC_NO_ERROR; | 671 QuicErrorCode error = QUIC_NO_ERROR; |
(...skipping 19 matching lines...) Expand all Loading... |
637 } | 691 } |
638 if (error == QUIC_NO_ERROR) { | 692 if (error == QUIC_NO_ERROR) { |
639 error = initial_round_trip_time_us_.ProcessPeerHello( | 693 error = initial_round_trip_time_us_.ProcessPeerHello( |
640 peer_hello, hello_type, error_details); | 694 peer_hello, hello_type, error_details); |
641 } | 695 } |
642 if (error == QUIC_NO_ERROR) { | 696 if (error == QUIC_NO_ERROR) { |
643 error = initial_flow_control_window_bytes_.ProcessPeerHello( | 697 error = initial_flow_control_window_bytes_.ProcessPeerHello( |
644 peer_hello, hello_type, error_details); | 698 peer_hello, hello_type, error_details); |
645 } | 699 } |
646 if (error == QUIC_NO_ERROR) { | 700 if (error == QUIC_NO_ERROR) { |
| 701 error = initial_stream_flow_control_window_bytes_.ProcessPeerHello( |
| 702 peer_hello, hello_type, error_details); |
| 703 } |
| 704 if (error == QUIC_NO_ERROR) { |
| 705 error = initial_session_flow_control_window_bytes_.ProcessPeerHello( |
| 706 peer_hello, hello_type, error_details); |
| 707 } |
| 708 if (error == QUIC_NO_ERROR) { |
647 error = loss_detection_.ProcessPeerHello( | 709 error = loss_detection_.ProcessPeerHello( |
648 peer_hello, hello_type, error_details); | 710 peer_hello, hello_type, error_details); |
649 } | 711 } |
650 if (error == QUIC_NO_ERROR) { | 712 if (error == QUIC_NO_ERROR) { |
651 error = congestion_options_.ProcessPeerHello( | 713 error = congestion_options_.ProcessPeerHello( |
652 peer_hello, hello_type, error_details); | 714 peer_hello, hello_type, error_details); |
653 } | 715 } |
654 return error; | 716 return error; |
655 } | 717 } |
656 | 718 |
657 } // namespace net | 719 } // namespace net |
OLD | NEW |