Commit 7ad98f40 authored by rtenneti@chromium.org's avatar rtenneti@chromium.org

Land Recent QUIC Changes.

Add the override annotation to all necessary methods in .../quic/.

Merge internal change: 59008686
https://codereview.chromium.org/126243002/


Enabled StopPacketProcessing unit test.
Added EXPECT_CALL for OnUnauthenticatedPublicHeader.

R=rch@chromium.org
BUG=331630
https://codereview.chromium.org/113073003/


Add an end-to-end test which verifies that QUIC 13 does not generate
QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED errors.

Merge internal change: 58990354
https://codereview.chromium.org/121883003/


Fix a bug in QuicSentPacketManager::ClearPreviousRetransmissions where
the high water mark is not raised past the current transmission of a
packet whose previous packet has been ACKed. This bug was first
observer in jri's lab experiments.

Fix QUIC bug related to ACKs of previous transmission of packets.

Merge internal change: 58760014
https://codereview.chromium.org/125183004/


Correctly handle NACK-based "retransmission" of packets which no longer
have retransmittable data associated with this. These can be the result
of TLP retransmission or a current transmission of a packet whose
previous transmission have been acked.

Fix QUIC bug related to ACKs of previous transmission of packets.

Merge internal change: 58758718
https://codereview.chromium.org/125183003/


Simplify RTO interaction between the QUIC sent packet manager and the
send algorithm. The manager no longer needs to abandon each packet
individually.

Merge internal change: 58755766
https://codereview.chromium.org/125253004/


Remove a QUIC test only flag(limit_rto_increase_for_tests) to limit the
RTO increase in EndToEndTests.

This is no longer necessary now that two TLP's and early retransmit have
been added.

Merge internal change: 58591658
https://codereview.chromium.org/112953003/

Review URL: https://codereview.chromium.org/126513003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243507 0039d316-1c4b-4281-b951-d872f2087c98
parent 20288144
...@@ -89,7 +89,7 @@ bool FixRateSender::OnPacketSent( ...@@ -89,7 +89,7 @@ bool FixRateSender::OnPacketSent(
return true; return true;
} }
void FixRateSender::OnRetransmissionTimeout() { } void FixRateSender::OnRetransmissionTimeout(bool packets_retransmitted) { }
void FixRateSender::OnPacketAbandoned( void FixRateSender::OnPacketAbandoned(
QuicPacketSequenceNumber /*sequence_number*/, QuicPacketSequenceNumber /*sequence_number*/,
......
...@@ -41,7 +41,7 @@ class NET_EXPORT_PRIVATE FixRateSender : public SendAlgorithmInterface { ...@@ -41,7 +41,7 @@ class NET_EXPORT_PRIVATE FixRateSender : public SendAlgorithmInterface {
QuicByteCount bytes, QuicByteCount bytes,
TransmissionType transmission_type, TransmissionType transmission_type,
HasRetransmittableData has_retransmittable_data) OVERRIDE; HasRetransmittableData has_retransmittable_data) OVERRIDE;
virtual void OnRetransmissionTimeout() OVERRIDE; virtual void OnRetransmissionTimeout(bool packets_retransmitted) OVERRIDE;
virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number, virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number,
QuicByteCount abandoned_bytes) OVERRIDE; QuicByteCount abandoned_bytes) OVERRIDE;
virtual QuicTime::Delta TimeUntilSend( virtual QuicTime::Delta TimeUntilSend(
......
...@@ -55,6 +55,12 @@ void InterArrivalProbe::OnAcknowledgedPacket(QuicByteCount bytes) { ...@@ -55,6 +55,12 @@ void InterArrivalProbe::OnAcknowledgedPacket(QuicByteCount bytes) {
} }
} }
void InterArrivalProbe::OnRetransmissionTimeout() {
if (!estimate_available_) {
unacked_data_ = 0;
}
}
QuicByteCount InterArrivalProbe::GetAvailableCongestionWindow() { QuicByteCount InterArrivalProbe::GetAvailableCongestionWindow() {
if (estimate_available_) { if (estimate_available_) {
return 0; return 0;
......
...@@ -29,6 +29,9 @@ class NET_EXPORT_PRIVATE InterArrivalProbe { ...@@ -29,6 +29,9 @@ class NET_EXPORT_PRIVATE InterArrivalProbe {
// the peer for. // the peer for.
void OnAcknowledgedPacket(QuicByteCount bytes); void OnAcknowledgedPacket(QuicByteCount bytes);
// Called when the RTO fires, and all packets have been lost.
void OnRetransmissionTimeout();
// Call to get the number of bytes that can be sent as part of this probe. // Call to get the number of bytes that can be sent as part of this probe.
QuicByteCount GetAvailableCongestionWindow(); QuicByteCount GetAvailableCongestionWindow();
......
...@@ -266,8 +266,12 @@ bool InterArrivalSender::OnPacketSent( ...@@ -266,8 +266,12 @@ bool InterArrivalSender::OnPacketSent(
return true; return true;
} }
void InterArrivalSender::OnRetransmissionTimeout() { void InterArrivalSender::OnRetransmissionTimeout(
bool /*packets_retransmitted*/) {
// TODO(ianswett): Decrease the available bandwidth. // TODO(ianswett): Decrease the available bandwidth.
if (probing_) {
probe_->OnRetransmissionTimeout();
}
} }
void InterArrivalSender::OnPacketAbandoned( void InterArrivalSender::OnPacketAbandoned(
......
...@@ -49,7 +49,7 @@ class NET_EXPORT_PRIVATE InterArrivalSender : public SendAlgorithmInterface { ...@@ -49,7 +49,7 @@ class NET_EXPORT_PRIVATE InterArrivalSender : public SendAlgorithmInterface {
QuicByteCount bytes, QuicByteCount bytes,
TransmissionType transmission_type, TransmissionType transmission_type,
HasRetransmittableData has_retransmittable_data) OVERRIDE; HasRetransmittableData has_retransmittable_data) OVERRIDE;
virtual void OnRetransmissionTimeout() OVERRIDE; virtual void OnRetransmissionTimeout(bool packets_retransmitted) OVERRIDE;
virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number, virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number,
QuicByteCount abandoned_bytes) OVERRIDE; QuicByteCount abandoned_bytes) OVERRIDE;
virtual QuicTime::Delta TimeUntilSend( virtual QuicTime::Delta TimeUntilSend(
......
...@@ -67,8 +67,8 @@ bool PacingSender::OnPacketSent( ...@@ -67,8 +67,8 @@ bool PacingSender::OnPacketSent(
transmission_type, has_retransmittable_data); transmission_type, has_retransmittable_data);
} }
void PacingSender::OnRetransmissionTimeout() { void PacingSender::OnRetransmissionTimeout(bool packets_retransmitted) {
sender_->OnRetransmissionTimeout(); sender_->OnRetransmissionTimeout(packets_retransmitted);
} }
void PacingSender::OnPacketAbandoned(QuicPacketSequenceNumber sequence_number, void PacingSender::OnPacketAbandoned(QuicPacketSequenceNumber sequence_number,
......
...@@ -46,7 +46,7 @@ class NET_EXPORT_PRIVATE PacingSender : public SendAlgorithmInterface { ...@@ -46,7 +46,7 @@ class NET_EXPORT_PRIVATE PacingSender : public SendAlgorithmInterface {
QuicByteCount bytes, QuicByteCount bytes,
TransmissionType transmission_type, TransmissionType transmission_type,
HasRetransmittableData is_retransmittable) OVERRIDE; HasRetransmittableData is_retransmittable) OVERRIDE;
virtual void OnRetransmissionTimeout() OVERRIDE; virtual void OnRetransmissionTimeout(bool packets_retransmitted) OVERRIDE;
virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number, virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number,
QuicByteCount abandoned_bytes) OVERRIDE; QuicByteCount abandoned_bytes) OVERRIDE;
virtual QuicTime::Delta TimeUntilSend( virtual QuicTime::Delta TimeUntilSend(
......
...@@ -82,8 +82,9 @@ class NET_EXPORT_PRIVATE SendAlgorithmInterface { ...@@ -82,8 +82,9 @@ class NET_EXPORT_PRIVATE SendAlgorithmInterface {
TransmissionType transmission_type, TransmissionType transmission_type,
HasRetransmittableData is_retransmittable) = 0; HasRetransmittableData is_retransmittable) = 0;
// Called when the retransmission timeout fires. // Called when the retransmission timeout fires. Neither OnPacketAbandoned
virtual void OnRetransmissionTimeout() = 0; // nor OnPacketLost will be called for these packets.
virtual void OnRetransmissionTimeout(bool packets_retransmitted) = 0;
// Called when a packet is timed out. // Called when a packet is timed out.
virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number, virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number,
......
...@@ -278,9 +278,12 @@ void TcpCubicSender::CongestionAvoidance(QuicPacketSequenceNumber ack) { ...@@ -278,9 +278,12 @@ void TcpCubicSender::CongestionAvoidance(QuicPacketSequenceNumber ack) {
} }
} }
void TcpCubicSender::OnRetransmissionTimeout() { void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) {
cubic_.Reset(); bytes_in_flight_ = 0;
congestion_window_ = kMinimumCongestionWindow; if (packets_retransmitted) {
cubic_.Reset();
congestion_window_ = kMinimumCongestionWindow;
}
} }
void TcpCubicSender::AckAccounting(QuicTime::Delta rtt) { void TcpCubicSender::AckAccounting(QuicTime::Delta rtt) {
......
...@@ -52,7 +52,7 @@ class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface { ...@@ -52,7 +52,7 @@ class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface {
QuicByteCount bytes, QuicByteCount bytes,
TransmissionType transmission_type, TransmissionType transmission_type,
HasRetransmittableData is_retransmittable) OVERRIDE; HasRetransmittableData is_retransmittable) OVERRIDE;
virtual void OnRetransmissionTimeout() OVERRIDE; virtual void OnRetransmissionTimeout(bool packets_retransmitted) OVERRIDE;
virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number, virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number,
QuicByteCount abandoned_bytes) OVERRIDE; QuicByteCount abandoned_bytes) OVERRIDE;
virtual QuicTime::Delta TimeUntilSend( virtual QuicTime::Delta TimeUntilSend(
......
...@@ -243,10 +243,19 @@ TEST_F(TcpCubicSenderTest, RTOCongestionWindow) { ...@@ -243,10 +243,19 @@ TEST_F(TcpCubicSenderTest, RTOCongestionWindow) {
EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow()); EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow());
// Expect the window to decrease to the minimum once the RTO fires. // Expect the window to decrease to the minimum once the RTO fires.
sender_->OnRetransmissionTimeout(); sender_->OnRetransmissionTimeout(true);
EXPECT_EQ(2 * kDefaultTCPMSS, sender_->SendWindow()); EXPECT_EQ(2 * kDefaultTCPMSS, sender_->SendWindow());
} }
TEST_F(TcpCubicSenderTest, RTOCongestionWindowNoRetransmission) {
EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow());
// Expect the window to remain unchanged if the RTO fires but no
// packets are retransmitted.
sender_->OnRetransmissionTimeout(false);
EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow());
}
TEST_F(TcpCubicSenderTest, RetransmissionDelay) { TEST_F(TcpCubicSenderTest, RetransmissionDelay) {
const int64 kRttMs = 10; const int64 kRttMs = 10;
const int64 kDeviationMs = 3; const int64 kDeviationMs = 3;
......
...@@ -26,7 +26,8 @@ class RecordResultCallback : public StrikeRegisterClient::ResultCallback { ...@@ -26,7 +26,8 @@ class RecordResultCallback : public StrikeRegisterClient::ResultCallback {
// |*saved_value| and sets |*called| to true. The callback is self // |*saved_value| and sets |*called| to true. The callback is self
// deleting. // deleting.
RecordResultCallback(bool* called, bool* saved_value) RecordResultCallback(bool* called, bool* saved_value)
: called_(called), saved_value_(saved_value) { : called_(called),
saved_value_(saved_value) {
*called_ = false; *called_ = false;
} }
......
...@@ -152,7 +152,9 @@ class QuicCryptoServerConfigPeer { ...@@ -152,7 +152,9 @@ class QuicCryptoServerConfigPeer {
class TestStrikeRegisterClient : public StrikeRegisterClient { class TestStrikeRegisterClient : public StrikeRegisterClient {
public: public:
explicit TestStrikeRegisterClient(QuicCryptoServerConfig* config) explicit TestStrikeRegisterClient(QuicCryptoServerConfig* config)
: config_(config), is_known_orbit_called_(false) {} : config_(config),
is_known_orbit_called_(false) {
}
virtual bool IsKnownOrbit(StringPiece orbit) const OVERRIDE { virtual bool IsKnownOrbit(StringPiece orbit) const OVERRIDE {
// Ensure that the strike register client lock is not held. // Ensure that the strike register client lock is not held.
......
...@@ -33,7 +33,6 @@ class NET_EXPORT_PRIVATE QuicConnectionHelper ...@@ -33,7 +33,6 @@ class NET_EXPORT_PRIVATE QuicConnectionHelper
QuicConnectionHelper(base::TaskRunner* task_runner, QuicConnectionHelper(base::TaskRunner* task_runner,
const QuicClock* clock, const QuicClock* clock,
QuicRandom* random_generator); QuicRandom* random_generator);
virtual ~QuicConnectionHelper(); virtual ~QuicConnectionHelper();
// QuicConnectionHelperInterface // QuicConnectionHelperInterface
......
...@@ -1324,8 +1324,7 @@ TEST_F(QuicConnectionTest, AbandonFECFromCongestionWindow) { ...@@ -1324,8 +1324,7 @@ TEST_F(QuicConnectionTest, AbandonFECFromCongestionWindow) {
clock_.AdvanceTime(retransmission_time); clock_.AdvanceTime(retransmission_time);
// Abandon FEC packet and data packet. // Abandon FEC packet and data packet.
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(2); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
EXPECT_CALL(visitor_, OnCanWrite()); EXPECT_CALL(visitor_, OnCanWrite());
connection_.OnRetransmissionTimeout(); connection_.OnRetransmissionTimeout();
...@@ -1354,13 +1353,12 @@ TEST_F(QuicConnectionTest, DontAbandonAckedFEC) { ...@@ -1354,13 +1353,12 @@ TEST_F(QuicConnectionTest, DontAbandonAckedFEC) {
// Don't abandon the acked FEC packet, but it will abandon 2 the subsequent // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent
// FEC packets. // FEC packets.
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(5); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3);
connection_.GetRetransmissionAlarm()->Fire(); connection_.GetRetransmissionAlarm()->Fire();
} }
TEST_F(QuicConnectionTest, DontAbandonAllFEC) { TEST_F(QuicConnectionTest, AbandonAllFEC) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
connection_.options()->max_packets_per_fec_group = 1; connection_.options()->max_packets_per_fec_group = 1;
...@@ -1387,14 +1385,12 @@ TEST_F(QuicConnectionTest, DontAbandonAllFEC) { ...@@ -1387,14 +1385,12 @@ TEST_F(QuicConnectionTest, DontAbandonAllFEC) {
clock_.AdvanceTime(DefaultRetransmissionTime().Subtract( clock_.AdvanceTime(DefaultRetransmissionTime().Subtract(
QuicTime::Delta::FromMilliseconds(1))); QuicTime::Delta::FromMilliseconds(1)));
// Don't abandon the acked FEC packet, but it will abandon 1 of the subsequent // Abandon all packets
// FEC packets. EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(false));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(4, _));
connection_.GetRetransmissionAlarm()->Fire(); connection_.GetRetransmissionAlarm()->Fire();
// Ensure the connection's alarm is still set, in order to abandon the third // Ensure the alarm is not set since all packets have been abandoned.
// FEC packet. EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
} }
TEST_F(QuicConnectionTest, FramePacking) { TEST_F(QuicConnectionTest, FramePacking) {
...@@ -1747,8 +1743,7 @@ TEST_F(QuicConnectionTest, QueueAfterTwoRTOs) { ...@@ -1747,8 +1743,7 @@ TEST_F(QuicConnectionTest, QueueAfterTwoRTOs) {
writer_->set_blocked(true); writer_->set_blocked(true);
clock_.AdvanceTime(DefaultRetransmissionTime()); clock_.AdvanceTime(DefaultRetransmissionTime());
// Only one packet should be retransmitted. // Only one packet should be retransmitted.
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout()); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(10);
connection_.GetRetransmissionAlarm()->Fire(); connection_.GetRetransmissionAlarm()->Fire();
EXPECT_TRUE(connection_.HasQueuedData()); EXPECT_TRUE(connection_.HasQueuedData());
...@@ -1941,8 +1936,7 @@ TEST_F(QuicConnectionTest, RTO) { ...@@ -1941,8 +1936,7 @@ TEST_F(QuicConnectionTest, RTO) {
connection_.GetRetransmissionAlarm()->deadline()); connection_.GetRetransmissionAlarm()->deadline());
// Simulate the retransmission alarm firing. // Simulate the retransmission alarm firing.
clock_.AdvanceTime(DefaultRetransmissionTime()); clock_.AdvanceTime(DefaultRetransmissionTime());
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout()); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1u, _));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 2u, _, _, _)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 2u, _, _, _));
connection_.GetRetransmissionAlarm()->Fire(); connection_.GetRetransmissionAlarm()->Fire();
EXPECT_EQ(2u, last_header()->packet_sequence_number); EXPECT_EQ(2u, last_header()->packet_sequence_number);
...@@ -1970,9 +1964,7 @@ TEST_F(QuicConnectionTest, RTOWithSameEncryptionLevel) { ...@@ -1970,9 +1964,7 @@ TEST_F(QuicConnectionTest, RTOWithSameEncryptionLevel) {
connection_.GetRetransmissionAlarm()->deadline()); connection_.GetRetransmissionAlarm()->deadline());
{ {
InSequence s; InSequence s;
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 3, _, RTO_RETRANSMISSION, _)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 3, _, RTO_RETRANSMISSION, _));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 4, _, RTO_RETRANSMISSION, _)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 4, _, RTO_RETRANSMISSION, _));
} }
...@@ -2030,9 +2022,8 @@ TEST_F(QuicConnectionTest, ...@@ -2030,9 +2022,8 @@ TEST_F(QuicConnectionTest,
new TaggingEncrypter(0x02)); new TaggingEncrypter(0x02));
connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout()); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(sequence_number, _)).Times(1);
QuicTime default_retransmission_time = clock_.ApproximateNow().Add( QuicTime default_retransmission_time = clock_.ApproximateNow().Add(
DefaultRetransmissionTime()); DefaultRetransmissionTime());
...@@ -2102,8 +2093,7 @@ TEST_F(QuicConnectionTest, TestRetransmitOrder) { ...@@ -2102,8 +2093,7 @@ TEST_F(QuicConnectionTest, TestRetransmitOrder) {
EXPECT_NE(first_packet_size, second_packet_size); EXPECT_NE(first_packet_size, second_packet_size);
// Advance the clock by huge time to make sure packets will be retransmitted. // Advance the clock by huge time to make sure packets will be retransmitted.
clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout()); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(2);
{ {
InSequence s; InSequence s;
EXPECT_CALL(*send_algorithm_, EXPECT_CALL(*send_algorithm_,
...@@ -2115,8 +2105,7 @@ TEST_F(QuicConnectionTest, TestRetransmitOrder) { ...@@ -2115,8 +2105,7 @@ TEST_F(QuicConnectionTest, TestRetransmitOrder) {
// Advance again and expect the packets to be sent again in the same order. // Advance again and expect the packets to be sent again in the same order.
clock_.AdvanceTime(QuicTime::Delta::FromSeconds(20)); clock_.AdvanceTime(QuicTime::Delta::FromSeconds(20));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout()); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(2);
{ {
InSequence s; InSequence s;
EXPECT_CALL(*send_algorithm_, EXPECT_CALL(*send_algorithm_,
...@@ -2140,9 +2129,7 @@ TEST_F(QuicConnectionTest, RetransmissionCountCalculation) { ...@@ -2140,9 +2129,7 @@ TEST_F(QuicConnectionTest, RetransmissionCountCalculation) {
&connection_, original_sequence_number)); &connection_, original_sequence_number));
// Force retransmission due to RTO. // Force retransmission due to RTO.
clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout()); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_,
OnPacketAbandoned(original_sequence_number, _)).Times(1);
QuicPacketSequenceNumber rto_sequence_number; QuicPacketSequenceNumber rto_sequence_number;
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, RTO_RETRANSMISSION, _)) EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, RTO_RETRANSMISSION, _))
.WillOnce(DoAll(SaveArg<1>(&rto_sequence_number), Return(true))); .WillOnce(DoAll(SaveArg<1>(&rto_sequence_number), Return(true)));
...@@ -2215,9 +2202,8 @@ TEST_F(QuicConnectionTest, DelayRTOWithAckReceipt) { ...@@ -2215,9 +2202,8 @@ TEST_F(QuicConnectionTest, DelayRTOWithAckReceipt) {
// Ensure the second packet gets retransmitted when it finally fires. // Ensure the second packet gets retransmitted when it finally fires.
EXPECT_TRUE(retransmission_alarm->IsSet()); EXPECT_TRUE(retransmission_alarm->IsSet());
EXPECT_LT(retransmission_alarm->deadline(), clock_.ApproximateNow()); EXPECT_LT(retransmission_alarm->deadline(), clock_.ApproximateNow());
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout()); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, RTO_RETRANSMISSION, _)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, RTO_RETRANSMISSION, _));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _));
// Manually cancel the alarm to simulate a real test. // Manually cancel the alarm to simulate a real test.
connection_.GetRetransmissionAlarm()->Fire(); connection_.GetRetransmissionAlarm()->Fire();
...@@ -2426,7 +2412,6 @@ TEST_F(QuicConnectionTest, SendSchedulerDelayThenSend) { ...@@ -2426,7 +2412,6 @@ TEST_F(QuicConnectionTest, SendSchedulerDelayThenSend) {
TEST_F(QuicConnectionTest, SendSchedulerDelayThenRetransmit) { TEST_F(QuicConnectionTest, SendSchedulerDelayThenRetransmit) {
EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, NOT_RETRANSMISSION, _, _)) EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, NOT_RETRANSMISSION, _, _))
.WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
EXPECT_CALL(*send_algorithm_, EXPECT_CALL(*send_algorithm_,
OnPacketSent(_, 1, _, NOT_RETRANSMISSION, _)); OnPacketSent(_, 1, _, NOT_RETRANSMISSION, _));
connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
...@@ -2435,7 +2420,7 @@ TEST_F(QuicConnectionTest, SendSchedulerDelayThenRetransmit) { ...@@ -2435,7 +2420,7 @@ TEST_F(QuicConnectionTest, SendSchedulerDelayThenRetransmit) {
clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(501)); clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(501));
// Test that if we send a retransmit with a delay, it ends up queued in the // Test that if we send a retransmit with a delay, it ends up queued in the
// sent packet manager, but not yet serialized. // sent packet manager, but not yet serialized.
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout()); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, EXPECT_CALL(*send_algorithm_,
TimeUntilSend(_, RTO_RETRANSMISSION, _, _)).WillOnce( TimeUntilSend(_, RTO_RETRANSMISSION, _, _)).WillOnce(
testing::Return(QuicTime::Delta::FromMicroseconds(1))); testing::Return(QuicTime::Delta::FromMicroseconds(1)));
...@@ -3001,12 +2986,12 @@ TEST_F(QuicConnectionTest, CheckSendStats) { ...@@ -3001,12 +2986,12 @@ TEST_F(QuicConnectionTest, CheckSendStats) {
size_t second_packet_size = last_sent_packet_size(); size_t second_packet_size = last_sent_packet_size();
// 2 retransmissions due to rto, 1 due to explicit nack. // 2 retransmissions due to rto, 1 due to explicit nack.
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout()); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, EXPECT_CALL(*send_algorithm_,
OnPacketSent(_, _, _, RTO_RETRANSMISSION, _)).Times(2); OnPacketSent(_, _, _, RTO_RETRANSMISSION, _)).Times(2);
EXPECT_CALL(*send_algorithm_, EXPECT_CALL(*send_algorithm_,
OnPacketSent(_, _, _, NACK_RETRANSMISSION, _)); OnPacketSent(_, _, _, NACK_RETRANSMISSION, _));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(3); EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(1);
EXPECT_CALL(visitor_, OnCanWrite()).WillRepeatedly(Return(true)); EXPECT_CALL(visitor_, OnCanWrite()).WillRepeatedly(Return(true));
// Retransmit due to RTO. // Retransmit due to RTO.
......
...@@ -31,7 +31,6 @@ class NET_EXPORT_PRIVATE QuicDefaultPacketWriter : public QuicPacketWriter { ...@@ -31,7 +31,6 @@ class NET_EXPORT_PRIVATE QuicDefaultPacketWriter : public QuicPacketWriter {
const net::IPAddressNumber& self_address, const net::IPAddressNumber& self_address,
const net::IPEndPoint& peer_address, const net::IPEndPoint& peer_address,
QuicBlockedWriterInterface* blocked_writer) OVERRIDE; QuicBlockedWriterInterface* blocked_writer) OVERRIDE;
virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; virtual bool IsWriteBlockedDataBuffered() const OVERRIDE;
void OnWriteComplete(int rv); void OnWriteComplete(int rv);
......
...@@ -3457,8 +3457,7 @@ TEST_P(QuicFramerTest, FecEntropyTest) { ...@@ -3457,8 +3457,7 @@ TEST_P(QuicFramerTest, FecEntropyTest) {
EXPECT_EQ(1 << 4, visitor_.header_->entropy_hash); EXPECT_EQ(1 << 4, visitor_.header_->entropy_hash);
}; };
// http://crbug.com/331630. TODO(rtenneti): fix the uninitialized memory issue. TEST_P(QuicFramerTest, StopPacketProcessing) {
TEST_P(QuicFramerTest, DISABLED_StopPacketProcessing) {
unsigned char packet[] = { unsigned char packet[] = {
// public flags (8 byte guid) // public flags (8 byte guid)
0x3C, 0x3C,
...@@ -3511,6 +3510,7 @@ TEST_P(QuicFramerTest, DISABLED_StopPacketProcessing) { ...@@ -3511,6 +3510,7 @@ TEST_P(QuicFramerTest, DISABLED_StopPacketProcessing) {
EXPECT_CALL(visitor, OnStreamFrame(_)).WillOnce(Return(false)); EXPECT_CALL(visitor, OnStreamFrame(_)).WillOnce(Return(false));
EXPECT_CALL(visitor, OnAckFrame(_)).Times(0); EXPECT_CALL(visitor, OnAckFrame(_)).Times(0);
EXPECT_CALL(visitor, OnPacketComplete()); EXPECT_CALL(visitor, OnPacketComplete());
EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true));
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); EXPECT_TRUE(framer_.ProcessPacket(encrypted));
......
...@@ -21,10 +21,6 @@ using std::min; ...@@ -21,10 +21,6 @@ using std::min;
// other transmissions. // other transmissions.
bool FLAGS_track_retransmission_history = false; bool FLAGS_track_retransmission_history = false;
// A test-only flag to prevent the RTO from backing off when multiple sequential
// tail drops occur.
bool FLAGS_limit_rto_increase_for_tests = false;
// Do not remove this flag until the Finch-trials described in b/11706275 // Do not remove this flag until the Finch-trials described in b/11706275
// are complete. // are complete.
// If true, QUIC connections will support the use of a pacing algorithm when // If true, QUIC connections will support the use of a pacing algorithm when
...@@ -259,6 +255,13 @@ void QuicSentPacketManager::ClearPreviousRetransmissions(size_t num_to_clear) { ...@@ -259,6 +255,13 @@ void QuicSentPacketManager::ClearPreviousRetransmissions(size_t num_to_clear) {
SequenceNumberSet* previous_transmissions = SequenceNumberSet* previous_transmissions =
it->second.previous_transmissions; it->second.previous_transmissions;
if (previous_transmissions == NULL) { if (previous_transmissions == NULL) {
if (it->second.retransmittable_frames == NULL) {
// This is a current transmission, but a previous transmission has
// been acked, so it's safe to remove.
it = MarkPacketHandled(sequence_number, NOT_RECEIVED_BY_PEER);
--num_to_clear;
continue;
}
break; break;
} }
QuicPacketSequenceNumber newest_transmission = QuicPacketSequenceNumber newest_transmission =
...@@ -422,7 +425,6 @@ QuicSentPacketManager::MarkPacketHandled( ...@@ -422,7 +425,6 @@ QuicSentPacketManager::MarkPacketHandled(
delete newest_it->second.retransmittable_frames; delete newest_it->second.retransmittable_frames;
newest_it->second.retransmittable_frames = NULL; newest_it->second.retransmittable_frames = NULL;
newest_it->second.previous_transmissions = NULL; newest_it->second.previous_transmissions = NULL;
pending_retransmissions_.erase(newest_transmission);
} }
// Clear out information all previous transmissions. // Clear out information all previous transmissions.
...@@ -441,6 +443,18 @@ QuicSentPacketManager::MarkPacketHandled( ...@@ -441,6 +443,18 @@ QuicSentPacketManager::MarkPacketHandled(
delete previous_transmissions; delete previous_transmissions;
if (ContainsKey(pending_retransmissions_, newest_transmission)) {
pending_retransmissions_.erase(newest_transmission);
if (!ContainsKey(pending_packets_, newest_transmission)) {
// If the newest transmission has already been marked for retransmission
// and has already been abandoned, then we should remove it from
// unacked_packets_, as well as cancel the retransmission.
DCHECK(ContainsKey(unacked_packets_, newest_transmission));
DCHECK(!unacked_packets_[newest_transmission].previous_transmissions);
unacked_packets_.erase(newest_transmission);
}
}
UnackedPacketMap::iterator next_unacked = unacked_packets_.begin(); UnackedPacketMap::iterator next_unacked = unacked_packets_.begin();
while (next_unacked != unacked_packets_.end() && while (next_unacked != unacked_packets_.end() &&
next_unacked->first < sequence_number) { next_unacked->first < sequence_number) {
...@@ -626,9 +640,6 @@ void QuicSentPacketManager::RetransmitOldestPacket() { ...@@ -626,9 +640,6 @@ void QuicSentPacketManager::RetransmitOldestPacket() {
void QuicSentPacketManager::RetransmitAllPackets() { void QuicSentPacketManager::RetransmitAllPackets() {
// Abandon all retransmittable packets and packets older than the // Abandon all retransmittable packets and packets older than the
// retransmission delay. // retransmission delay.
QuicTime::Delta retransmission_delay = GetRetransmissionDelay();
QuicTime max_send_time =
clock_->ApproximateNow().Subtract(retransmission_delay);
DVLOG(1) << "OnRetransmissionTimeout() fired with " DVLOG(1) << "OnRetransmissionTimeout() fired with "
<< unacked_packets_.size() << " unacked packets."; << unacked_packets_.size() << " unacked packets.";
...@@ -641,18 +652,15 @@ void QuicSentPacketManager::RetransmitAllPackets() { ...@@ -641,18 +652,15 @@ void QuicSentPacketManager::RetransmitAllPackets() {
for (UnackedPacketMap::const_iterator it = unacked_packets_.begin(); for (UnackedPacketMap::const_iterator it = unacked_packets_.begin();
it != unacked_packets_.end(); ++it) { it != unacked_packets_.end(); ++it) {
if (it->second.retransmittable_frames != NULL) { if (it->second.retransmittable_frames != NULL) {
OnPacketAbandoned(it->first);
packets_retransmitted = true; packets_retransmitted = true;
MarkForRetransmission(it->first, RTO_RETRANSMISSION); MarkForRetransmission(it->first, RTO_RETRANSMISSION);
} else if (it->second.sent_time <= max_send_time) {
OnPacketAbandoned(it->first);
} }
} }
// Only inform the send algorithm of an RTO if data was retransmitted. pending_packets_.clear();
send_algorithm_->OnRetransmissionTimeout(packets_retransmitted);
if (packets_retransmitted) { if (packets_retransmitted) {
++consecutive_rto_count_; ++consecutive_rto_count_;
send_algorithm_->OnRetransmissionTimeout();
} }
} }
...@@ -750,7 +758,14 @@ void QuicSentPacketManager::MaybeRetransmitOnAckFrame( ...@@ -750,7 +758,14 @@ void QuicSentPacketManager::MaybeRetransmitOnAckFrame(
lost_packets.insert(sequence_number); lost_packets.insert(sequence_number);
if (transmission_info.retransmittable_frames) { if (transmission_info.retransmittable_frames) {
++num_retransmitted; ++num_retransmitted;
MarkForRetransmission(*it, NACK_RETRANSMISSION); MarkForRetransmission(sequence_number, NACK_RETRANSMISSION);
} else {
// Since we will not retransmit this, we need to remove it from
// unacked_packets_. This is either the current transmission of
// a packet whose previous transmission has been acked, or it
// is a packet that has been TLP retransmitted.
RemovePreviousTransmission(sequence_number);
unacked_packets_.erase(sequence_number);
} }
++it; ++it;
...@@ -765,8 +780,9 @@ void QuicSentPacketManager::MaybeRetransmitOnAckFrame( ...@@ -765,8 +780,9 @@ void QuicSentPacketManager::MaybeRetransmitOnAckFrame(
// repair the loss, it should be recorded as a loss to the congestion // repair the loss, it should be recorded as a loss to the congestion
// manager, but not retransmitted until it's known whether the FEC packet // manager, but not retransmitted until it's known whether the FEC packet
// arrived. // arrived.
send_algorithm_->OnPacketLost(*it, ack_receive_time); QuicPacketSequenceNumber lost_packet = *it;
OnPacketAbandoned(*it); send_algorithm_->OnPacketLost(lost_packet, ack_receive_time);
OnPacketAbandoned(lost_packet);
} }
} }
...@@ -857,8 +873,8 @@ const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { ...@@ -857,8 +873,8 @@ const QuicTime QuicSentPacketManager::GetRetransmissionTime() const {
return QuicTime::Zero(); return QuicTime::Zero();
} }
const QuicTime::Delta const QuicTime::Delta QuicSentPacketManager::GetCryptoRetransmissionDelay()
QuicSentPacketManager::GetCryptoRetransmissionDelay() const { const {
// This is equivalent to the TailLossProbeDelay, but slightly more aggressive // This is equivalent to the TailLossProbeDelay, but slightly more aggressive
// because crypto handshake messages don't incur a delayed ack time. // because crypto handshake messages don't incur a delayed ack time.
int64 delay_ms = max<int64>(kMinHandshakeTimeoutMs, int64 delay_ms = max<int64>(kMinHandshakeTimeoutMs,
...@@ -879,24 +895,6 @@ const QuicTime::Delta QuicSentPacketManager::GetTailLossProbeDelay() const { ...@@ -879,24 +895,6 @@ const QuicTime::Delta QuicSentPacketManager::GetTailLossProbeDelay() const {
} }
const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const { const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const {
size_t number_retransmissions = consecutive_rto_count_;
// TODO(ianswett): Remove this flag now that EndToEndTest is no longer flaky.
if (FLAGS_limit_rto_increase_for_tests) {
const size_t kTailDropWindowSize = 5;
const size_t kTailDropMaxRetransmissions = 4;
if (pending_packets_.size() <= kTailDropWindowSize) {
// Avoid exponential backoff of RTO when there are only a few packets
// outstanding. This helps avoid the situation where fake packet loss
// causes a packet and it's retransmission to be dropped causing
// test timouts.
if (number_retransmissions <= kTailDropMaxRetransmissions) {
number_retransmissions = 0;
} else {
number_retransmissions -= kTailDropMaxRetransmissions;
}
}
}
QuicTime::Delta retransmission_delay = send_algorithm_->RetransmissionDelay(); QuicTime::Delta retransmission_delay = send_algorithm_->RetransmissionDelay();
if (retransmission_delay.IsZero()) { if (retransmission_delay.IsZero()) {
// We are in the initial state, use default timeout values. // We are in the initial state, use default timeout values.
...@@ -905,7 +903,7 @@ const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const { ...@@ -905,7 +903,7 @@ const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const {
} }
// Calculate exponential back off. // Calculate exponential back off.
retransmission_delay = retransmission_delay.Multiply( retransmission_delay = retransmission_delay.Multiply(
1 << min<size_t>(number_retransmissions, kMaxRetransmissions)); 1 << min<size_t>(consecutive_rto_count_, kMaxRetransmissions));
// TODO(rch): This code should move to |send_algorithm_|. // TODO(rch): This code should move to |send_algorithm_|.
if (retransmission_delay.ToMilliseconds() < kMinRetransmissionTimeMs) { if (retransmission_delay.ToMilliseconds() < kMinRetransmissionTimeMs) {
...@@ -965,4 +963,19 @@ void QuicSentPacketManager::MaybeEnablePacing() { ...@@ -965,4 +963,19 @@ void QuicSentPacketManager::MaybeEnablePacing() {
QuicTime::Delta::FromMicroseconds(1))); QuicTime::Delta::FromMicroseconds(1)));
} }
void QuicSentPacketManager::RemovePreviousTransmission(
QuicPacketSequenceNumber sequence_number) {
SequenceNumberSet* previous_transmissions =
unacked_packets_[sequence_number].previous_transmissions;
if (!previous_transmissions) {
return;
}
previous_transmissions->erase(sequence_number);
if (previous_transmissions->size() == 1) {
QuicPacketSequenceNumber current = *previous_transmissions->begin();
unacked_packets_[current].previous_transmissions = NULL;
delete previous_transmissions;
}
}
} // namespace net } // namespace net
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "net/quic/quic_protocol.h" #include "net/quic/quic_protocol.h"
NET_EXPORT_PRIVATE extern bool FLAGS_track_retransmission_history; NET_EXPORT_PRIVATE extern bool FLAGS_track_retransmission_history;
NET_EXPORT_PRIVATE extern bool FLAGS_limit_rto_increase_for_tests;
NET_EXPORT_PRIVATE extern bool FLAGS_enable_quic_pacing; NET_EXPORT_PRIVATE extern bool FLAGS_enable_quic_pacing;
namespace net { namespace net {
...@@ -296,6 +295,9 @@ class NET_EXPORT_PRIVATE QuicSentPacketManager { ...@@ -296,6 +295,9 @@ class NET_EXPORT_PRIVATE QuicSentPacketManager {
void CleanupPacketHistory(); void CleanupPacketHistory();
// Removes |sequence_number| as a previous transmission of any other packets.
void RemovePreviousTransmission(QuicPacketSequenceNumber sequence_number);
// Newly serialized retransmittable and fec packets are added to this map, // Newly serialized retransmittable and fec packets are added to this map,
// which contains owning pointers to any contained frames. If a packet is // which contains owning pointers to any contained frames. If a packet is
// retransmitted, this map will contain entries for both the old and the new // retransmitted, this map will contain entries for both the old and the new
......
...@@ -113,6 +113,15 @@ class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> { ...@@ -113,6 +113,15 @@ class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> {
&manager_, new_sequence_number)); &manager_, new_sequence_number));
} }
void RetransmitAndSendPacket(QuicPacketSequenceNumber old_sequence_number,
QuicPacketSequenceNumber new_sequence_number) {
RetransmitPacket(old_sequence_number, new_sequence_number);
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, new_sequence_number, _, _, _))
.WillOnce(Return(true));
manager_.OnPacketSent(new_sequence_number, clock_.Now(),
1000, NACK_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
}
SerializedPacket CreateDataPacket(QuicPacketSequenceNumber sequence_number) { SerializedPacket CreateDataPacket(QuicPacketSequenceNumber sequence_number) {
return CreatePacket(sequence_number, true); return CreatePacket(sequence_number, true);
} }
...@@ -266,6 +275,75 @@ TEST_F(QuicSentPacketManagerTest, RetransmitThenAckPrevious) { ...@@ -266,6 +275,75 @@ TEST_F(QuicSentPacketManagerTest, RetransmitThenAckPrevious) {
EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime());
} }
TEST_F(QuicSentPacketManagerTest, RetransmitThenAckPreviousThenNackRetransmit) {
SendDataPacket(1);
RetransmitPacket(1, 2);
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 2, _, _, _))
.WillOnce(Return(true));
manager_.OnPacketSent(2, clock_.ApproximateNow(), 1000,
NACK_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
// First, ACK packet 1 which makes packet 2 non-retransmittable.
EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _, _));
ReceivedPacketInfo received_info;
received_info.largest_observed = 1;
EXPECT_TRUE(manager_.OnIncomingAck(received_info, QuicTime::Zero()));
SendDataPacket(3);
SendDataPacket(4);
SendDataPacket(5);
// Next, NACK packet 2 three times.
received_info.largest_observed = 3;
received_info.missing_packets.insert(2);
EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _, _));
EXPECT_TRUE(manager_.OnIncomingAck(received_info, QuicTime::Zero()));
received_info.largest_observed = 4;
EXPECT_CALL(*send_algorithm_, OnPacketAcked(4, _, _));
EXPECT_TRUE(manager_.OnIncomingAck(received_info, QuicTime::Zero()));
received_info.largest_observed = 5;
EXPECT_CALL(*send_algorithm_, OnPacketAcked(5, _, _));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _));
EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _));
EXPECT_TRUE(manager_.OnIncomingAck(received_info, QuicTime::Zero()));
// No packets remain unacked.
VerifyUnackedPackets(NULL, 0);
VerifyPendingPackets(NULL, 0);
VerifyRetransmittablePackets(NULL, 0);
// Verify that the retransmission alarm would not fire,
// since there is no retransmittable data outstanding.
EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime());
}
TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckPreviousBeforeSend) {
SendDataPacket(1);
RetransmitAndSendPacket(1, 2);
// Fire the RTO, which will mark 2 for retransmission (but will not send it).
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
manager_.OnRetransmissionTimeout();
EXPECT_TRUE(manager_.HasPendingRetransmissions());
// Ack 1 but not 2, before 2 is able to be sent.
// Since 1 has been retransmitted, it has already been lost, and so the
// send algorithm is not informed that it has been ACK'd.
ReceivedPacketInfo received_info;
received_info.largest_observed = 1;
EXPECT_TRUE(manager_.OnIncomingAck(received_info, QuicTime::Zero()));
// Since 2 was marked for retransmit, when 1 is acked, 2 is discarded.
VerifyUnackedPackets(NULL, 0);
VerifyPendingPackets(NULL, 0);
VerifyRetransmittablePackets(NULL, 0);
// Verify that the retransmission alarm would not fire,
// since there is no retransmittable data outstanding.
EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime());
}
TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckFirst) { TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckFirst) {
SendDataPacket(1); SendDataPacket(1);
RetransmitPacket(1, 2); RetransmitPacket(1, 2);
...@@ -310,6 +388,47 @@ TEST_F(QuicSentPacketManagerTest, TruncatedAck) { ...@@ -310,6 +388,47 @@ TEST_F(QuicSentPacketManagerTest, TruncatedAck) {
VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable));
} }
TEST_F(QuicSentPacketManagerTest, AckPreviousTransmissionThenTruncatedAck) {
SerializedPacket serialized_packet(CreateDataPacket(1));
manager_.OnSerializedPacket(serialized_packet);
RetransmitPacket(1, 2);
RetransmitPacket(2, 3);
RetransmitPacket(3, 4);
manager_.OnSerializedPacket(CreateDataPacket(5));
manager_.OnSerializedPacket(CreateDataPacket(6));
manager_.OnSerializedPacket(CreateDataPacket(7));
manager_.OnSerializedPacket(CreateDataPacket(8));
manager_.OnSerializedPacket(CreateDataPacket(9));
// Ack previous transmission
{
ReceivedPacketInfo received_info;
received_info.largest_observed = 2;
received_info.missing_packets.insert(1);
manager_.OnIncomingAck(received_info, QuicTime::Zero());
EXPECT_TRUE(manager_.IsUnacked(4));
}
// Truncated ack with 4 NACKs
{
ReceivedPacketInfo received_info;
received_info.largest_observed = 6;
received_info.missing_packets.insert(3);
received_info.missing_packets.insert(4);
received_info.missing_packets.insert(5);
received_info.missing_packets.insert(6);
received_info.is_truncated = true;
manager_.OnIncomingAck(received_info, QuicTime::Zero());
}
// High water mark will be raised.
QuicPacketSequenceNumber unacked[] = { 5, 6, 7, 8, 9 };
VerifyUnackedPackets(unacked, arraysize(unacked));
QuicPacketSequenceNumber retransmittable[] = { 5, 6, 7, 8, 9 };
VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable));
}
TEST_F(QuicSentPacketManagerTest, SendDropAckRetransmitManyPackets) { TEST_F(QuicSentPacketManagerTest, SendDropAckRetransmitManyPackets) {
manager_.OnSerializedPacket(CreateDataPacket(1)); manager_.OnSerializedPacket(CreateDataPacket(1));
manager_.OnSerializedPacket(CreateDataPacket(2)); manager_.OnSerializedPacket(CreateDataPacket(2));
...@@ -868,11 +987,7 @@ TEST_F(QuicSentPacketManagerTest, TailLossProbeThenRTO) { ...@@ -868,11 +987,7 @@ TEST_F(QuicSentPacketManagerTest, TailLossProbeThenRTO) {
clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000)); clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000));
// The final RTO abandons all of them. // The final RTO abandons all of them.
EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
.WillOnce(Return(QuicTime::Delta::FromMilliseconds(100)));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _))
.Times(kNumSentPackets + 2);
manager_.OnRetransmissionTimeout(); manager_.OnRetransmissionTimeout();
EXPECT_TRUE(manager_.HasPendingRetransmissions()); EXPECT_TRUE(manager_.HasPendingRetransmissions());
} }
...@@ -926,11 +1041,7 @@ TEST_F(QuicSentPacketManagerTest, RetransmissionTimeout) { ...@@ -926,11 +1041,7 @@ TEST_F(QuicSentPacketManagerTest, RetransmissionTimeout) {
SendDataPacket(i); SendDataPacket(i);
} }
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(kNumSentPackets); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
.WillOnce(Return(QuicTime::Delta::FromMilliseconds(1)));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
manager_.OnRetransmissionTimeout(); manager_.OnRetransmissionTimeout();
} }
...@@ -1013,8 +1124,7 @@ TEST_F(QuicSentPacketManagerTest, GetTransmissionTimeRTO) { ...@@ -1013,8 +1124,7 @@ TEST_F(QuicSentPacketManagerTest, GetTransmissionTimeRTO) {
EXPECT_EQ(expected_time, manager_.GetRetransmissionTime()); EXPECT_EQ(expected_time, manager_.GetRetransmissionTime());
// Retransmit the packet by invoking the retransmission timeout. // Retransmit the packet by invoking the retransmission timeout.
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(2); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
clock_.AdvanceTime(expected_rto_delay); clock_.AdvanceTime(expected_rto_delay);
manager_.OnRetransmissionTimeout(); manager_.OnRetransmissionTimeout();
RetransmitNextPacket(3); RetransmitNextPacket(3);
...@@ -1053,34 +1163,10 @@ TEST_F(QuicSentPacketManagerTest, GetTransmissionDelay) { ...@@ -1053,34 +1163,10 @@ TEST_F(QuicSentPacketManagerTest, GetTransmissionDelay) {
EXPECT_EQ(delay, EXPECT_EQ(delay,
QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
delay = delay.Add(delay); delay = delay.Add(delay);
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(i + 1, _)); EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
manager_.OnRetransmissionTimeout();
RetransmitNextPacket(i + 2);
}
}
TEST_F(QuicSentPacketManagerTest, GetTestTransmissionDelayTailDrop) {
FLAGS_limit_rto_increase_for_tests = true;
SendDataPacket(1);
QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500);
EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
.WillRepeatedly(Return(delay));
// No backoff for the first 5 retransmissions.
for (int i = 0; i < 5; ++i) {
EXPECT_EQ(delay,
QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(i + 1, _));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
manager_.OnRetransmissionTimeout(); manager_.OnRetransmissionTimeout();
RetransmitNextPacket(i + 2); RetransmitNextPacket(i + 2);
} }
// Then backoff starts
EXPECT_EQ(delay.Add(delay),
QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
} }
} // namespace } // namespace
......
...@@ -33,7 +33,7 @@ class NET_EXPORT_PRIVATE QuicStreamSequencer { ...@@ -33,7 +33,7 @@ class NET_EXPORT_PRIVATE QuicStreamSequencer {
QuicStreamSequencer(size_t max_frame_memory, QuicStreamSequencer(size_t max_frame_memory,
ReliableQuicStream* quic_stream); ReliableQuicStream* quic_stream);
virtual ~QuicStreamSequencer(); virtual ~QuicStreamSequencer() ;
// Returns the expected value of OnStreamFrame for this frame. // Returns the expected value of OnStreamFrame for this frame.
bool WillAcceptStreamFrame(const QuicStreamFrame& frame) const; bool WillAcceptStreamFrame(const QuicStreamFrame& frame) const;
......
...@@ -43,7 +43,9 @@ class DelayedVerifyStrikeRegisterClient : public LocalStrikeRegisterClient { ...@@ -43,7 +43,9 @@ class DelayedVerifyStrikeRegisterClient : public LocalStrikeRegisterClient {
VerifyArgs(base::StringPiece in_nonce, VerifyArgs(base::StringPiece in_nonce,
QuicWallTime in_now, QuicWallTime in_now,
ResultCallback* in_cb) ResultCallback* in_cb)
: nonce(in_nonce.as_string()), now(in_now), cb(in_cb) { : nonce(in_nonce.as_string()),
now(in_now),
cb(in_cb) {
} }
std::string nonce; std::string nonce;
......
...@@ -16,7 +16,6 @@ namespace net { ...@@ -16,7 +16,6 @@ namespace net {
class MockClock : public QuicClock { class MockClock : public QuicClock {
public: public:
MockClock(); MockClock();
virtual ~MockClock(); virtual ~MockClock();
void AdvanceTime(QuicTime::Delta delta); void AdvanceTime(QuicTime::Delta delta);
......
...@@ -16,7 +16,6 @@ namespace net { ...@@ -16,7 +16,6 @@ namespace net {
class MockCryptoClientStreamFactory : public QuicCryptoClientStreamFactory { class MockCryptoClientStreamFactory : public QuicCryptoClientStreamFactory {
public: public:
MockCryptoClientStreamFactory(); MockCryptoClientStreamFactory();
virtual ~MockCryptoClientStreamFactory() {} virtual ~MockCryptoClientStreamFactory() {}
virtual QuicCryptoClientStream* CreateQuicCryptoClientStream( virtual QuicCryptoClientStream* CreateQuicCryptoClientStream(
......
...@@ -84,7 +84,7 @@ class ValueRestore { ...@@ -84,7 +84,7 @@ class ValueRestore {
class MockFramerVisitor : public QuicFramerVisitorInterface { class MockFramerVisitor : public QuicFramerVisitorInterface {
public: public:
MockFramerVisitor(); MockFramerVisitor();
~MockFramerVisitor(); virtual ~MockFramerVisitor();
MOCK_METHOD1(OnError, void(QuicFramer* framer)); MOCK_METHOD1(OnError, void(QuicFramer* framer));
// The constructor sets this up to return false by default. // The constructor sets this up to return false by default.
...@@ -405,7 +405,7 @@ class MockSendAlgorithm : public SendAlgorithmInterface { ...@@ -405,7 +405,7 @@ class MockSendAlgorithm : public SendAlgorithmInterface {
MOCK_METHOD5(OnPacketSent, MOCK_METHOD5(OnPacketSent,
bool(QuicTime sent_time, QuicPacketSequenceNumber, QuicByteCount, bool(QuicTime sent_time, QuicPacketSequenceNumber, QuicByteCount,
TransmissionType, HasRetransmittableData)); TransmissionType, HasRetransmittableData));
MOCK_METHOD0(OnRetransmissionTimeout, void()); MOCK_METHOD1(OnRetransmissionTimeout, void(bool));
MOCK_METHOD2(OnPacketAbandoned, void(QuicPacketSequenceNumber sequence_number, MOCK_METHOD2(OnPacketAbandoned, void(QuicPacketSequenceNumber sequence_number,
QuicByteCount abandoned_bytes)); QuicByteCount abandoned_bytes));
MOCK_METHOD4(TimeUntilSend, QuicTime::Delta(QuicTime now, TransmissionType, MOCK_METHOD4(TimeUntilSend, QuicTime::Delta(QuicTime now, TransmissionType,
......
...@@ -158,7 +158,6 @@ class EndToEndTest : public ::testing::TestWithParam<TestParams> { ...@@ -158,7 +158,6 @@ class EndToEndTest : public ::testing::TestWithParam<TestParams> {
client_supported_versions_ = GetParam().client_supported_versions; client_supported_versions_ = GetParam().client_supported_versions;
server_supported_versions_ = GetParam().server_supported_versions; server_supported_versions_ = GetParam().server_supported_versions;
negotiated_version_ = GetParam().negotiated_version; negotiated_version_ = GetParam().negotiated_version;
FLAGS_limit_rto_increase_for_tests = true;
FLAGS_enable_quic_pacing = GetParam().use_pacing; FLAGS_enable_quic_pacing = GetParam().use_pacing;
LOG(INFO) << "Using Configuration: " << GetParam(); LOG(INFO) << "Using Configuration: " << GetParam();
...@@ -253,8 +252,10 @@ class EndToEndTest : public ::testing::TestWithParam<TestParams> { ...@@ -253,8 +252,10 @@ class EndToEndTest : public ::testing::TestWithParam<TestParams> {
void SetPacketLossPercentage(int32 loss) { void SetPacketLossPercentage(int32 loss) {
// TODO(rtenneti): enable when we can do random packet loss tests in // TODO(rtenneti): enable when we can do random packet loss tests in
// chrome's tree. // chrome's tree.
// client_writer_->set_fake_packet_loss_percentage(loss); if (loss != 0 && loss != 100)
// server_writer_->set_fake_packet_loss_percentage(loss); return;
client_writer_->set_fake_packet_loss_percentage(loss);
server_writer_->set_fake_packet_loss_percentage(loss);
} }
void SetPacketSendDelay(QuicTime::Delta delay) { void SetPacketSendDelay(QuicTime::Delta delay) {
...@@ -780,6 +781,41 @@ TEST_P(EndToEndTest, MaxStreamsUberTest) { ...@@ -780,6 +781,41 @@ TEST_P(EndToEndTest, MaxStreamsUberTest) {
} }
} }
TEST_P(EndToEndTest, StreamCancelErrorTest) {
ASSERT_TRUE(Initialize());
string small_body;
GenerateBody(&small_body, 256);
AddToCache("GET", "/small_response", "HTTP/1.1", "200", "OK", small_body);
client_->client()->WaitForCryptoHandshakeConfirmed();
QuicSession* session = client_->client()->session();
// Lose the request.
SetPacketLossPercentage(100);
EXPECT_LT(0, client_->SendRequest("/small_response"));
client_->client()->WaitForEvents();
// Transmit the cancel, and ensure the connection is torn down properly.
SetPacketLossPercentage(0);
QuicStreamId stream_id = negotiated_version_ > QUIC_VERSION_12 ? 5 : 3;
session->SendRstStream(stream_id, QUIC_STREAM_CANCELLED);
// WaitForEvents waits 50ms and returns true if there are outstanding
// requests.
while (client_->client()->WaitForEvents() == true) {
}
if (negotiated_version_ > QUIC_VERSION_12) {
// It should be completely fine to RST a stream before any data has bee
// received for that stream.
EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error());
} else {
// Check that the connection is always properly closed
// from a stream being RST before headers are decompressed.
EXPECT_EQ(QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED,
client_->connection_error());
}
}
class WrongAddressWriter : public QuicTestWriter { class WrongAddressWriter : public QuicTestWriter {
public: public:
WrongAddressWriter() { WrongAddressWriter() {
......
...@@ -88,8 +88,9 @@ class QuicClient : public EpollCallbackInterface, ...@@ -88,8 +88,9 @@ class QuicClient : public EpollCallbackInterface,
bool WaitForEvents(); bool WaitForEvents();
// From EpollCallbackInterface // From EpollCallbackInterface
virtual void OnRegistration( virtual void OnRegistration(EpollServer* eps,
EpollServer* eps, int fd, int event_mask) OVERRIDE {} int fd,
int event_mask) OVERRIDE {}
virtual void OnModification(int fd, int event_mask) OVERRIDE {} virtual void OnModification(int fd, int event_mask) OVERRIDE {}
virtual void OnEvent(int fd, EpollEvent* event) OVERRIDE; virtual void OnEvent(int fd, EpollEvent* event) OVERRIDE;
// |fd_| can be unregistered without the client being disconnected. This // |fd_| can be unregistered without the client being disconnected. This
......
...@@ -44,8 +44,9 @@ class QuicServer : public EpollCallbackInterface { ...@@ -44,8 +44,9 @@ class QuicServer : public EpollCallbackInterface {
void Shutdown(); void Shutdown();
// From EpollCallbackInterface // From EpollCallbackInterface
virtual void OnRegistration( virtual void OnRegistration(EpollServer* eps,
EpollServer* eps, int fd, int event_mask) OVERRIDE {} int fd,
int event_mask) OVERRIDE {}
virtual void OnModification(int fd, int event_mask) OVERRIDE {} virtual void OnModification(int fd, int event_mask) OVERRIDE {}
virtual void OnEvent(int fd, EpollEvent* event) OVERRIDE; virtual void OnEvent(int fd, EpollEvent* event) OVERRIDE;
virtual void OnUnregistration(int fd, bool replaced) OVERRIDE {} virtual void OnUnregistration(int fd, bool replaced) OVERRIDE {}
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Common utilities for Quic tests
#ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
#define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
...@@ -127,7 +129,7 @@ class MockPacketWriter : public QuicPacketWriter { ...@@ -127,7 +129,7 @@ class MockPacketWriter : public QuicPacketWriter {
class MockQuicSessionOwner : public QuicSessionOwner { class MockQuicSessionOwner : public QuicSessionOwner {
public: public:
MockQuicSessionOwner(); MockQuicSessionOwner();
~MockQuicSessionOwner(); virtual ~MockQuicSessionOwner();
MOCK_METHOD2(OnConnectionClosed, void(QuicGuid guid, QuicErrorCode error)); MOCK_METHOD2(OnConnectionClosed, void(QuicGuid guid, QuicErrorCode error));
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment