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_connection.h" | 5 #include "net/quic/core/quic_connection.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <memory> | 8 #include <memory> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <utility> | 10 #include <utility> |
(...skipping 4829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4840 | 4840 |
4841 MockQuicConnectionDebugVisitor debug_visitor; | 4841 MockQuicConnectionDebugVisitor debug_visitor; |
4842 connection_.set_debug_visitor(&debug_visitor); | 4842 connection_.set_debug_visitor(&debug_visitor); |
4843 EXPECT_CALL(debug_visitor, OnPacketHeader(Ref(header))).Times(1); | 4843 EXPECT_CALL(debug_visitor, OnPacketHeader(Ref(header))).Times(1); |
4844 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)).Times(1); | 4844 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)).Times(1); |
4845 EXPECT_CALL(debug_visitor, OnSuccessfulVersionNegotiation(_)).Times(1); | 4845 EXPECT_CALL(debug_visitor, OnSuccessfulVersionNegotiation(_)).Times(1); |
4846 connection_.OnPacketHeader(header); | 4846 connection_.OnPacketHeader(header); |
4847 } | 4847 } |
4848 | 4848 |
4849 TEST_P(QuicConnectionTest, Pacing) { | 4849 TEST_P(QuicConnectionTest, Pacing) { |
4850 // static_cast here does not work if using multipath_sent_packet_manager. | |
4851 FLAGS_quic_reloadable_flag_quic_enable_multipath = false; | |
4852 TestConnection server(connection_id_, kSelfAddress, helper_.get(), | 4850 TestConnection server(connection_id_, kSelfAddress, helper_.get(), |
4853 alarm_factory_.get(), writer_.get(), | 4851 alarm_factory_.get(), writer_.get(), |
4854 Perspective::IS_SERVER, version()); | 4852 Perspective::IS_SERVER, version()); |
4855 TestConnection client(connection_id_, kPeerAddress, helper_.get(), | 4853 TestConnection client(connection_id_, kPeerAddress, helper_.get(), |
4856 alarm_factory_.get(), writer_.get(), | 4854 alarm_factory_.get(), writer_.get(), |
4857 Perspective::IS_CLIENT, version()); | 4855 Perspective::IS_CLIENT, version()); |
4858 EXPECT_FALSE(QuicSentPacketManagerPeer::UsingPacing( | 4856 EXPECT_FALSE(QuicSentPacketManagerPeer::UsingPacing( |
4859 static_cast<const QuicSentPacketManager*>( | 4857 static_cast<const QuicSentPacketManager*>( |
4860 &client.sent_packet_manager()))); | 4858 &client.sent_packet_manager()))); |
4861 EXPECT_FALSE(QuicSentPacketManagerPeer::UsingPacing( | 4859 EXPECT_FALSE(QuicSentPacketManagerPeer::UsingPacing( |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4972 EXPECT_CALL(visitor_, | 4970 EXPECT_CALL(visitor_, |
4973 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA, | 4971 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA, |
4974 _, ConnectionCloseSource::FROM_SELF)); | 4972 _, ConnectionCloseSource::FROM_SELF)); |
4975 struct iovec iov; | 4973 struct iovec iov; |
4976 QuicIOVector data_iov(MakeIOVector("", &iov)); | 4974 QuicIOVector data_iov(MakeIOVector("", &iov)); |
4977 EXPECT_QUIC_BUG(connection_.SendStreamData(3, data_iov, 0, kFin, nullptr), | 4975 EXPECT_QUIC_BUG(connection_.SendStreamData(3, data_iov, 0, kFin, nullptr), |
4978 "Cannot send stream data without encryption."); | 4976 "Cannot send stream data without encryption."); |
4979 EXPECT_FALSE(connection_.connected()); | 4977 EXPECT_FALSE(connection_.connected()); |
4980 } | 4978 } |
4981 | 4979 |
4982 TEST_P(QuicConnectionTest, EnableMultipathNegotiation) { | |
4983 // Test multipath negotiation during crypto handshake. Multipath is enabled | |
4984 // when both endpoints enable multipath. | |
4985 FLAGS_quic_reloadable_flag_quic_enable_multipath = true; | |
4986 EXPECT_TRUE(connection_.connected()); | |
4987 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); | |
4988 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); | |
4989 QuicConfig config; | |
4990 // Enable multipath on server side. | |
4991 config.SetMultipathEnabled(true); | |
4992 | |
4993 // Create a handshake message enables multipath. | |
4994 CryptoHandshakeMessage msg; | |
4995 string error_details; | |
4996 QuicConfig client_config; | |
4997 // Enable multipath on client side. | |
4998 client_config.SetMultipathEnabled(true); | |
4999 client_config.ToHandshakeMessage(&msg); | |
5000 const QuicErrorCode error = | |
5001 config.ProcessPeerHello(msg, CLIENT, &error_details); | |
5002 EXPECT_EQ(QUIC_NO_ERROR, error); | |
5003 | |
5004 connection_.SetFromConfig(config); | |
5005 EXPECT_TRUE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); | |
5006 } | |
5007 | |
5008 TEST_P(QuicConnectionTest, OnPathDegrading) { | 4980 TEST_P(QuicConnectionTest, OnPathDegrading) { |
5009 QuicByteCount packet_size; | 4981 QuicByteCount packet_size; |
5010 const size_t kMinTimeoutsBeforePathDegrading = 2; | 4982 const size_t kMinTimeoutsBeforePathDegrading = 2; |
5011 | 4983 |
5012 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 4984 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
5013 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); | 4985 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); |
5014 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr); | 4986 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr); |
5015 size_t num_timeouts = | 4987 size_t num_timeouts = |
5016 kMinTimeoutsBeforePathDegrading + | 4988 kMinTimeoutsBeforePathDegrading + |
5017 QuicSentPacketManagerPeer::GetMaxTailLossProbes( | 4989 QuicSentPacketManagerPeer::GetMaxTailLossProbes( |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5162 error_details, ConnectionCloseSource::FROM_PEER)); | 5134 error_details, ConnectionCloseSource::FROM_PEER)); |
5163 connection_.set_perspective(Perspective::IS_CLIENT); | 5135 connection_.set_perspective(Perspective::IS_CLIENT); |
5164 connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, | 5136 connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, |
5165 error_details, | 5137 error_details, |
5166 ConnectionCloseBehavior::SILENT_CLOSE); | 5138 ConnectionCloseBehavior::SILENT_CLOSE); |
5167 } | 5139 } |
5168 | 5140 |
5169 } // namespace | 5141 } // namespace |
5170 } // namespace test | 5142 } // namespace test |
5171 } // namespace net | 5143 } // namespace net |
OLD | NEW |