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

Side by Side Diff: net/quic/quic_connection_test.cc

Issue 342983004: Fix a bug where QUIC ack frames were not bundled with crypto stream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_stream.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 // 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/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 EXPECT_TRUE(CanWriteStreamData()); 513 EXPECT_TRUE(CanWriteStreamData());
514 return SendStreamData5(); 514 return SendStreamData5();
515 } 515 }
516 516
517 // The crypto stream has special semantics so that it is not blocked by a 517 // The crypto stream has special semantics so that it is not blocked by a
518 // congestion window limitation, and also so that it gets put into a separate 518 // congestion window limitation, and also so that it gets put into a separate
519 // packet (so that it is easier to reason about a crypto frame not being 519 // packet (so that it is easier to reason about a crypto frame not being
520 // split needlessly across packet boundaries). As a result, we have separate 520 // split needlessly across packet boundaries). As a result, we have separate
521 // tests for some cases for this stream. 521 // tests for some cases for this stream.
522 QuicConsumedData SendCryptoStreamData() { 522 QuicConsumedData SendCryptoStreamData() {
523 this->Flush(); 523 return SendStreamDataWithString(kCryptoStreamId, "chlo", 0, !kFin, NULL);
524 QuicConsumedData consumed =
525 SendStreamDataWithString(kCryptoStreamId, "chlo", 0, !kFin, NULL);
526 this->Flush();
527 return consumed;
528 } 524 }
529 525
530 bool is_server() { 526 bool is_server() {
531 return QuicConnectionPeer::IsServer(this); 527 return QuicConnectionPeer::IsServer(this);
532 } 528 }
533 529
534 void set_version(QuicVersion version) { 530 void set_version(QuicVersion version) {
535 QuicConnectionPeer::GetFramer(this)->set_version(version); 531 QuicConnectionPeer::GetFramer(this)->set_version(version);
536 } 532 }
537 533
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 1658
1663 // Parse the last packet and ensure it's the crypto stream frame. 1659 // Parse the last packet and ensure it's the crypto stream frame.
1664 EXPECT_EQ(1u, writer_->frame_count()); 1660 EXPECT_EQ(1u, writer_->frame_count());
1665 ASSERT_EQ(1u, writer_->stream_frames().size()); 1661 ASSERT_EQ(1u, writer_->stream_frames().size());
1666 EXPECT_EQ(kCryptoStreamId, writer_->stream_frames()[0].stream_id); 1662 EXPECT_EQ(kCryptoStreamId, writer_->stream_frames()[0].stream_id);
1667 } 1663 }
1668 1664
1669 TEST_P(QuicConnectionTest, FramePackingCryptoThenNonCrypto) { 1665 TEST_P(QuicConnectionTest, FramePackingCryptoThenNonCrypto) {
1670 CongestionBlockWrites(); 1666 CongestionBlockWrites();
1671 1667
1672 // Send an ack and two stream frames (one crypto, then one non-crypto) in 3 1668 // Send an ack and two stream frames (one crypto, then one non-crypto) in 2
1673 // packets by queueing them. 1669 // packets by queueing them.
1674 connection_.SendAck(); 1670 connection_.SendAck();
1675 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( 1671 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
1676 IgnoreResult(InvokeWithoutArgs(&connection_, 1672 IgnoreResult(InvokeWithoutArgs(&connection_,
1677 &TestConnection::SendCryptoStreamData)), 1673 &TestConnection::SendCryptoStreamData)),
1678 IgnoreResult(InvokeWithoutArgs(&connection_, 1674 IgnoreResult(InvokeWithoutArgs(&connection_,
1679 &TestConnection::SendStreamData3)))); 1675 &TestConnection::SendStreamData3))));
1680 1676
1681 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); 1677 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
1682 CongestionUnblockWrites(); 1678 CongestionUnblockWrites();
1683 connection_.GetSendAlarm()->Fire(); 1679 connection_.GetSendAlarm()->Fire();
1684 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 1680 EXPECT_EQ(0u, connection_.NumQueuedPackets());
1685 EXPECT_FALSE(connection_.HasQueuedData()); 1681 EXPECT_FALSE(connection_.HasQueuedData());
1686 1682
1687 // Parse the last packet and ensure it's the stream frame from stream 3. 1683 // Parse the last packet and ensure it's the stream frame from stream 3.
1688 EXPECT_EQ(1u, writer_->frame_count()); 1684 EXPECT_EQ(1u, writer_->frame_count());
1689 ASSERT_EQ(1u, writer_->stream_frames().size()); 1685 ASSERT_EQ(1u, writer_->stream_frames().size());
1690 EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0].stream_id); 1686 EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0].stream_id);
1691 } 1687 }
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
3055 TEST_P(QuicConnectionTest, SendDelayedAckOnOutgoingCryptoPacket) { 3051 TEST_P(QuicConnectionTest, SendDelayedAckOnOutgoingCryptoPacket) {
3056 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3052 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3057 ProcessPacket(1); 3053 ProcessPacket(1);
3058 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, NULL); 3054 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, NULL);
3059 // Check that ack is bundled with outgoing crypto data. 3055 // Check that ack is bundled with outgoing crypto data.
3060 EXPECT_EQ(version() <= QUIC_VERSION_15 ? 2u : 3u, writer_->frame_count()); 3056 EXPECT_EQ(version() <= QUIC_VERSION_15 ? 2u : 3u, writer_->frame_count());
3061 EXPECT_FALSE(writer_->ack_frames().empty()); 3057 EXPECT_FALSE(writer_->ack_frames().empty());
3062 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 3058 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
3063 } 3059 }
3064 3060
3061 TEST_P(QuicConnectionTest, BundleAckForSecondCHLO) {
3062 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3063 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
3064 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(
3065 IgnoreResult(InvokeWithoutArgs(&connection_,
3066 &TestConnection::SendCryptoStreamData)));
3067 // Process a packet from the crypto stream, which is frame1_'s default.
3068 // Receiving the CHLO as packet 2 first will cause the connection to
3069 // immediately send an ack, due to the packet gap.
3070 ProcessPacket(2);
3071 // Check that ack is sent and that delayed ack alarm is reset.
3072 if (version() > QUIC_VERSION_15) {
3073 EXPECT_EQ(3u, writer_->frame_count());
3074 EXPECT_FALSE(writer_->stop_waiting_frames().empty());
3075 } else {
3076 EXPECT_EQ(2u, writer_->frame_count());
3077 }
3078 EXPECT_EQ(1u, writer_->stream_frames().size());
3079 EXPECT_FALSE(writer_->ack_frames().empty());
3080 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
3081 }
3082
3065 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { 3083 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) {
3066 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3084 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3067 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, 3085 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0,
3068 !kFin, NULL); 3086 !kFin, NULL);
3069 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 3, 3087 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 3,
3070 !kFin, NULL); 3088 !kFin, NULL);
3071 // Ack the second packet, which will retransmit the first packet. 3089 // Ack the second packet, which will retransmit the first packet.
3072 QuicAckFrame ack = InitAckFrame(2, 0); 3090 QuicAckFrame ack = InitAckFrame(2, 0);
3073 NackPacket(1, &ack); 3091 NackPacket(1, &ack);
3074 SequenceNumberSet lost_packets; 3092 SequenceNumberSet lost_packets;
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
4016 QuicBlockedFrame blocked; 4034 QuicBlockedFrame blocked;
4017 blocked.stream_id = 3; 4035 blocked.stream_id = 3;
4018 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 4036 EXPECT_CALL(visitor_, OnBlockedFrames(_));
4019 ProcessFramePacket(QuicFrame(&blocked)); 4037 ProcessFramePacket(QuicFrame(&blocked));
4020 EXPECT_TRUE(ack_alarm->IsSet()); 4038 EXPECT_TRUE(ack_alarm->IsSet());
4021 } 4039 }
4022 4040
4023 } // namespace 4041 } // namespace
4024 } // namespace test 4042 } // namespace test
4025 } // namespace net 4043 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698