OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/core/quic_session.h" | 5 #include "net/quic/core/quic_session.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "net/quic/core/quic_connection.h" | 10 #include "net/quic/core/quic_connection.h" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 return GetCryptoStream()->encryption_established(); | 429 return GetCryptoStream()->encryption_established(); |
430 } | 430 } |
431 | 431 |
432 bool QuicSession::IsCryptoHandshakeConfirmed() { | 432 bool QuicSession::IsCryptoHandshakeConfirmed() { |
433 return GetCryptoStream()->handshake_confirmed(); | 433 return GetCryptoStream()->handshake_confirmed(); |
434 } | 434 } |
435 | 435 |
436 void QuicSession::OnConfigNegotiated() { | 436 void QuicSession::OnConfigNegotiated() { |
437 connection_->SetFromConfig(config_); | 437 connection_->SetFromConfig(config_); |
438 | 438 |
439 const QuicVersion version = connection()->version(); | |
440 uint32_t max_streams = 0; | 439 uint32_t max_streams = 0; |
441 if (version > QUIC_VERSION_34 && | 440 if (config_.HasReceivedMaxIncomingDynamicStreams()) { |
442 config_.HasReceivedMaxIncomingDynamicStreams()) { | |
443 max_streams = config_.ReceivedMaxIncomingDynamicStreams(); | 441 max_streams = config_.ReceivedMaxIncomingDynamicStreams(); |
444 } else { | 442 } else { |
445 max_streams = config_.MaxStreamsPerConnection(); | 443 max_streams = config_.MaxStreamsPerConnection(); |
446 } | 444 } |
447 set_max_open_outgoing_streams(max_streams); | 445 set_max_open_outgoing_streams(max_streams); |
448 if (perspective() == Perspective::IS_SERVER) { | 446 if (perspective() == Perspective::IS_SERVER) { |
449 if (config_.HasReceivedConnectionOptions()) { | 447 if (config_.HasReceivedConnectionOptions()) { |
450 // The following variations change the initial receive flow control | 448 // The following variations change the initial receive flow control |
451 // window sizes. | 449 // window sizes. |
452 if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFW6)) { | 450 if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFW6)) { |
453 AdjustInitialFlowControlWindows(64 * 1024); | 451 AdjustInitialFlowControlWindows(64 * 1024); |
454 } | 452 } |
455 if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFW7)) { | 453 if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFW7)) { |
456 AdjustInitialFlowControlWindows(128 * 1024); | 454 AdjustInitialFlowControlWindows(128 * 1024); |
457 } | 455 } |
458 if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFW8)) { | 456 if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFW8)) { |
459 AdjustInitialFlowControlWindows(256 * 1024); | 457 AdjustInitialFlowControlWindows(256 * 1024); |
460 } | 458 } |
461 if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFW9)) { | 459 if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFW9)) { |
462 AdjustInitialFlowControlWindows(512 * 1024); | 460 AdjustInitialFlowControlWindows(512 * 1024); |
463 } | 461 } |
464 if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFWA)) { | 462 if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFWA)) { |
465 AdjustInitialFlowControlWindows(1024 * 1024); | 463 AdjustInitialFlowControlWindows(1024 * 1024); |
466 } | 464 } |
467 } | 465 } |
468 } | 466 } |
469 | 467 |
470 if (version <= QUIC_VERSION_34) { | 468 // A small number of additional incoming streams beyond the limit should be |
471 // A small number of additional incoming streams beyond the limit should be | 469 // allowed. This helps avoid early connection termination when FIN/RSTs for |
472 // allowed. This helps avoid early connection termination when FIN/RSTs for | 470 // old streams are lost or arrive out of order. |
473 // old streams are lost or arrive out of order. | 471 // Use a minimum number of additional streams, or a percentage increase, |
474 // Use a minimum number of additional streams, or a percentage increase, | 472 // whichever is larger. |
475 // whichever is larger. | 473 uint32_t max_incoming_streams_to_send = |
476 uint32_t max_incoming_streams = | 474 config_.GetMaxIncomingDynamicStreamsToSend(); |
477 std::max(max_streams + kMaxStreamsMinimumIncrement, | 475 uint32_t max_incoming_streams = |
478 static_cast<uint32_t>(max_streams * kMaxStreamsMultiplier)); | 476 std::max(max_incoming_streams_to_send + kMaxStreamsMinimumIncrement, |
479 set_max_open_incoming_streams(max_incoming_streams); | 477 static_cast<uint32_t>(max_incoming_streams_to_send * |
480 } else { | 478 kMaxStreamsMultiplier)); |
481 uint32_t max_incoming_streams_to_send = | 479 set_max_open_incoming_streams(max_incoming_streams); |
482 config_.GetMaxIncomingDynamicStreamsToSend(); | |
483 uint32_t max_incoming_streams = | |
484 std::max(max_incoming_streams_to_send + kMaxStreamsMinimumIncrement, | |
485 static_cast<uint32_t>(max_incoming_streams_to_send * | |
486 kMaxStreamsMultiplier)); | |
487 set_max_open_incoming_streams(max_incoming_streams); | |
488 } | |
489 | 480 |
490 if (config_.HasReceivedInitialStreamFlowControlWindowBytes()) { | 481 if (config_.HasReceivedInitialStreamFlowControlWindowBytes()) { |
491 // Streams which were created before the SHLO was received (0-RTT | 482 // Streams which were created before the SHLO was received (0-RTT |
492 // requests) are now informed of the peer's initial flow control window. | 483 // requests) are now informed of the peer's initial flow control window. |
493 OnNewStreamFlowControlWindow( | 484 OnNewStreamFlowControlWindow( |
494 config_.ReceivedInitialStreamFlowControlWindowBytes()); | 485 config_.ReceivedInitialStreamFlowControlWindowBytes()); |
495 } | 486 } |
496 if (config_.HasReceivedInitialSessionFlowControlWindowBytes()) { | 487 if (config_.HasReceivedInitialSessionFlowControlWindowBytes()) { |
497 OnNewSessionFlowControlWindow( | 488 OnNewSessionFlowControlWindow( |
498 config_.ReceivedInitialSessionFlowControlWindowBytes()); | 489 config_.ReceivedInitialSessionFlowControlWindowBytes()); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 | 857 |
867 size_t QuicSession::MaxAvailableStreams() const { | 858 size_t QuicSession::MaxAvailableStreams() const { |
868 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; | 859 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; |
869 } | 860 } |
870 | 861 |
871 bool QuicSession::IsIncomingStream(QuicStreamId id) const { | 862 bool QuicSession::IsIncomingStream(QuicStreamId id) const { |
872 return id % 2 != next_outgoing_stream_id_ % 2; | 863 return id % 2 != next_outgoing_stream_id_ % 2; |
873 } | 864 } |
874 | 865 |
875 } // namespace net | 866 } // namespace net |
OLD | NEW |