Index: net/quic/quic_connection_test.cc |
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc |
index 42ecdbba9da95c2f7abfe1b863969e15fef99dbe..83331ee10ddd14079e5509ff25c4d5ef242b5183 100644 |
--- a/net/quic/quic_connection_test.cc |
+++ b/net/quic/quic_connection_test.cc |
@@ -482,31 +482,9 @@ class TestConnection : public QuicConnection { |
QuicStreamOffset offset, |
bool fin, |
QuicAckListenerInterface* listener) { |
- return SendStreamDataWithStringHelper(id, data, offset, fin, |
- MAY_FEC_PROTECT, listener); |
- } |
- |
- QuicConsumedData SendStreamDataWithStringWithFec( |
- QuicStreamId id, |
- StringPiece data, |
- QuicStreamOffset offset, |
- bool fin, |
- QuicAckListenerInterface* listener) { |
- return SendStreamDataWithStringHelper(id, data, offset, fin, |
- MUST_FEC_PROTECT, listener); |
- } |
- |
- QuicConsumedData SendStreamDataWithStringHelper( |
- QuicStreamId id, |
- StringPiece data, |
- QuicStreamOffset offset, |
- bool fin, |
- FecProtection fec_protection, |
- QuicAckListenerInterface* listener) { |
struct iovec iov; |
QuicIOVector data_iov(MakeIOVector(data, &iov)); |
- return QuicConnection::SendStreamData(id, data_iov, offset, fin, |
- fec_protection, listener); |
+ return QuicConnection::SendStreamData(id, data_iov, offset, fin, listener); |
} |
QuicConsumedData SendStreamData3() { |
@@ -514,20 +492,11 @@ class TestConnection : public QuicConnection { |
nullptr); |
} |
- QuicConsumedData SendStreamData3WithFec() { |
- return SendStreamDataWithStringWithFec(kClientDataStreamId1, "food", 0, |
- !kFin, nullptr); |
- } |
- |
QuicConsumedData SendStreamData5() { |
return SendStreamDataWithString(kClientDataStreamId2, "food2", 0, !kFin, |
nullptr); |
} |
- QuicConsumedData SendStreamData5WithFec() { |
- return SendStreamDataWithStringWithFec(kClientDataStreamId2, "food2", 0, |
- !kFin, nullptr); |
- } |
// Ensures the connection can write stream data before writing. |
QuicConsumedData EnsureWritableAndSendStreamData5() { |
EXPECT_TRUE(CanWriteStreamData()); |
@@ -586,11 +555,6 @@ class TestConnection : public QuicConnection { |
QuicConnectionPeer::GetPingAlarm(this)); |
} |
- TestConnectionHelper::TestAlarm* GetFecAlarm() { |
- return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
- QuicConnectionPeer::GetFecAlarm(this)); |
- } |
- |
TestConnectionHelper::TestAlarm* GetResumeWritesAlarm() { |
return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
QuicConnectionPeer::GetResumeWritesAlarm(this)); |
@@ -644,26 +608,22 @@ class FecQuicConnectionDebugVisitor : public QuicConnectionDebugVisitor { |
enum class AckResponse { kDefer, kImmediate }; |
-// Run tests with combinations of {QuicVersion, fec_send_policy, |
-// AckResponse}. |
+// Run tests with combinations of {QuicVersion, AckResponse}. |
struct TestParams { |
TestParams(QuicVersion version, |
- FecSendPolicy fec_send_policy, |
AckResponse ack_response) |
: version(version), |
- fec_send_policy(fec_send_policy), |
ack_response(ack_response) {} |
friend ostream& operator<<(ostream& os, const TestParams& p) { |
os << "{ client_version: " << QuicVersionToString(p.version) |
- << " fec_send_policy: " << p.fec_send_policy << " ack_response: " |
+ << " ack_response: " |
<< (p.ack_response == AckResponse::kDefer ? "defer" : "immediate") |
<< " }"; |
return os; |
} |
QuicVersion version; |
- FecSendPolicy fec_send_policy; |
AckResponse ack_response; |
}; |
@@ -672,12 +632,9 @@ vector<TestParams> GetTestParams() { |
vector<TestParams> params; |
QuicVersionVector all_supported_versions = QuicSupportedVersions(); |
for (size_t i = 0; i < all_supported_versions.size(); ++i) { |
- for (FecSendPolicy fec_send_policy : {FEC_ANY_TRIGGER, FEC_ALARM_TRIGGER}) { |
- for (AckResponse ack_response : |
- {AckResponse::kDefer, AckResponse::kImmediate}) { |
- params.push_back(TestParams(all_supported_versions[i], fec_send_policy, |
- ack_response)); |
- } |
+ for (AckResponse ack_response : |
+ {AckResponse::kDefer, AckResponse::kImmediate}) { |
+ params.push_back(TestParams(all_supported_versions[i], ack_response)); |
} |
} |
return params; |
@@ -719,7 +676,6 @@ class QuicConnectionTest : public ::testing::TestWithParam<TestParams> { |
connection_.SetSendAlgorithm(send_algorithm_); |
connection_.SetLossAlgorithm(loss_algorithm_); |
framer_.set_received_entropy_calculator(&entropy_calculator_); |
- generator_->set_fec_send_policy(GetParam().fec_send_policy); |
EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) |
.WillRepeatedly(Return(QuicTime::Delta::Zero())); |
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
@@ -1897,412 +1853,6 @@ TEST_P(QuicConnectionTest, RecordSentTimeBeforePacketSent) { |
<< ". Actual time = " << actual_recorded_send_time.ToDebuggingValue(); |
} |
-TEST_P(QuicConnectionTest, FECSending) { |
- // All packets carry version info till version is negotiated. |
- size_t payload_length; |
- // GetPacketLengthForOneStream() assumes a stream offset of 0 in determining |
- // packet length. The size of the offset field in a stream frame is 0 for |
- // offset 0, and 2 for non-zero offsets up through 64K. Increase |
- // max_packet_length by 2 so that subsequent packets containing subsequent |
- // stream frames with non-zero offets will fit within the packet length. |
- size_t length = |
- 2 + GetPacketLengthForOneStream( |
- connection_.version(), kIncludeVersion, !kIncludePathId, |
- PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_PACKET_NUMBER, |
- IN_FEC_GROUP, &payload_length); |
- connection_.SetMaxPacketLength(length); |
- |
- if (generator_->fec_send_policy() == FEC_ALARM_TRIGGER) { |
- // Send 4 protected data packets. FEC packet is not sent. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(4); |
- } else { |
- // Send 4 protected data packets, which should also trigger 1 FEC packet. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(5); |
- } |
- // The first stream frame will have 2 fewer overhead bytes than the other 3. |
- const string payload(payload_length * 4 + 2, 'a'); |
- connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, nullptr); |
- // Expect the FEC group to be closed after SendStreamDataWithString. |
- EXPECT_FALSE(creator_->IsFecGroupOpen()); |
- EXPECT_FALSE(QuicPacketCreatorPeer::IsFecProtected(creator_)); |
-} |
- |
-TEST_P(QuicConnectionTest, FECQueueing) { |
- // All packets carry version info till version is negotiated. |
- size_t payload_length; |
- size_t length = GetPacketLengthForOneStream( |
- connection_.version(), kIncludeVersion, !kIncludePathId, |
- PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_PACKET_NUMBER, IN_FEC_GROUP, |
- &payload_length); |
- connection_.SetMaxPacketLength(length); |
- EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); |
- |
- EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
- BlockOnNextWrite(); |
- const string payload(payload_length, 'a'); |
- connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, nullptr); |
- EXPECT_FALSE(creator_->IsFecGroupOpen()); |
- EXPECT_FALSE(QuicPacketCreatorPeer::IsFecProtected(creator_)); |
- if (generator_->fec_send_policy() == FEC_ALARM_TRIGGER) { |
- // Expect the first data packet to be queued and not the FEC packet. |
- EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
- } else { |
- // Expect the first data packet and the fec packet to be queued. |
- EXPECT_EQ(2u, connection_.NumQueuedPackets()); |
- } |
-} |
- |
-TEST_P(QuicConnectionTest, FECAlarmStoppedWhenFECPacketSent) { |
- EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); |
- EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
- |
- creator_->set_max_packets_per_fec_group(2); |
- |
- // 1 Data packet. FEC alarm should be set. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 1u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.SendStreamDataWithStringWithFec(3, "foo", 0, true, nullptr); |
- EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
- |
- if (generator_->fec_send_policy() == FEC_ALARM_TRIGGER) { |
- // If FEC send policy is FEC_ALARM_TRIGGER, FEC packet is not sent. |
- // FEC alarm should not be set. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- } else { |
- // Second data packet triggers FEC packet out. FEC alarm should not be set. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(2); |
- } |
- connection_.SendStreamDataWithStringWithFec(5, "foo", 0, true, nullptr); |
- if (generator_->fec_send_policy() == FEC_ANY_TRIGGER) { |
- EXPECT_TRUE(writer_->header().fec_flag); |
- } |
- EXPECT_FALSE(creator_->IsFecGroupOpen()); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
-} |
- |
-TEST_P(QuicConnectionTest, FECAlarmStoppedOnConnectionClose) { |
- EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
- creator_->set_max_packets_per_fec_group(100); |
- |
- // 1 Data packet. FEC alarm should be set. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 1u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.SendStreamDataWithStringWithFec(3, "foo", 0, kFin, nullptr); |
- EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
- |
- EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NO_ERROR, |
- ConnectionCloseSource::FROM_SELF)); |
- // Closing connection should stop the FEC alarm. |
- connection_.CloseConnection(QUIC_NO_ERROR, ConnectionCloseSource::FROM_SELF); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
-} |
- |
-TEST_P(QuicConnectionTest, RemoveFECFromInflightOnRetransmissionTimeout) { |
- EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
- EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); |
- EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
- |
- // 1 Data packet. FEC alarm should be set. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 1u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); |
- EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
- size_t protected_packet = |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_); |
- |
- // Force FEC timeout to send FEC packet out. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 2u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.GetFecAlarm()->Fire(); |
- EXPECT_TRUE(writer_->header().fec_flag); |
- |
- size_t fec_packet = protected_packet; |
- EXPECT_EQ(protected_packet + fec_packet, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- clock_.AdvanceTime(DefaultRetransmissionTime()); |
- |
- // On RTO, both data and FEC packets are removed from inflight, only the data |
- // packet is retransmitted, and this retransmission (but not FEC) gets added |
- // back into the inflight. |
- EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
- connection_.GetRetransmissionAlarm()->Fire(); |
- |
- // The retransmission of packet 1 will be 3 bytes smaller than packet 1, since |
- // the first transmission will have 1 byte for FEC group number and 2 bytes of |
- // stream frame size, which are absent in the retransmission. |
- size_t retransmitted_packet = protected_packet - 3; |
- EXPECT_EQ(protected_packet + retransmitted_packet, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
- |
- // Receive ack for the retransmission. No data should be outstanding. |
- QuicAckFrame ack = InitAckFrame(3); |
- NackPacket(1, &ack); |
- NackPacket(2, &ack); |
- SendAlgorithmInterface::CongestionVector lost_packets; |
- lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); |
- EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
- .WillOnce(SetArgPointee<3>(lost_packets)); |
- EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
- ProcessAckPacket(&ack); |
- |
- // Ensure the alarm is not set since all packets have been acked or abandoned. |
- EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
- EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
-} |
- |
-TEST_P(QuicConnectionTest, RemoveFECFromInflightOnLossRetransmission) { |
- EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
- |
- // 1 FEC-protected data packet. FEC alarm should be set. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.SendStreamDataWithStringWithFec(3, "foo", 0, kFin, nullptr); |
- EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
- size_t protected_packet = |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_); |
- |
- // Force FEC timeout to send FEC packet out. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.GetFecAlarm()->Fire(); |
- EXPECT_TRUE(writer_->header().fec_flag); |
- size_t fec_packet = protected_packet; |
- EXPECT_EQ(protected_packet + fec_packet, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- |
- // Send more data to trigger NACKs. Note that all data starts at stream offset |
- // 0 to ensure the same packet size, for ease of testing. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(4); |
- connection_.SendStreamDataWithString(5, "foo", 0, kFin, nullptr); |
- connection_.SendStreamDataWithString(7, "foo", 0, kFin, nullptr); |
- connection_.SendStreamDataWithString(9, "foo", 0, kFin, nullptr); |
- connection_.SendStreamDataWithString(11, "foo", 0, kFin, nullptr); |
- |
- // An unprotected packet will be 3 bytes smaller than an FEC-protected packet, |
- // since the protected packet will have 1 byte for FEC group number and |
- // 2 bytes of stream frame size, which are absent in the unprotected packet. |
- size_t unprotected_packet = protected_packet - 3; |
- EXPECT_EQ(protected_packet + fec_packet + 4 * unprotected_packet, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
- |
- // Ack data packets, and NACK FEC packet and one data packet. Triggers |
- // NACK-based loss detection of both packets, but only data packet is |
- // retransmitted and considered outstanding. |
- QuicAckFrame ack = InitAckFrame(6); |
- NackPacket(2, &ack); |
- NackPacket(3, &ack); |
- SendAlgorithmInterface::CongestionVector lost_packets; |
- lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); |
- lost_packets.push_back(std::make_pair(3, kMaxPacketSize)); |
- EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
- .WillOnce(SetArgPointee<3>(lost_packets)); |
- EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
- ProcessAckPacket(&ack); |
- // On receiving this ack from the server, the client will no longer send |
- // version number in subsequent packets, including in this retransmission. |
- size_t unprotected_packet_no_version = unprotected_packet - 4; |
- EXPECT_EQ(unprotected_packet_no_version, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- |
- // Receive ack for the retransmission. No data should be outstanding. |
- QuicAckFrame ack2 = InitAckFrame(7); |
- NackPacket(2, &ack2); |
- NackPacket(3, &ack2); |
- EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
- EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
- ProcessAckPacket(&ack2); |
- EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
-} |
- |
-TEST_P(QuicConnectionTest, FECRemainsInflightOnTLPOfEarlierData) { |
- // This test checks if TLP is sent correctly when a data and an FEC packet |
- // are outstanding. TLP should be sent for the data packet when the |
- // retransmission alarm fires. |
- // Turn on TLP for this test. |
- QuicSentPacketManagerPeer::SetMaxTailLossProbes(manager_, 1); |
- EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); |
- EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
- |
- // 1 Data packet. FEC alarm should be set. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 1u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.SendStreamDataWithStringWithFec(3, "foo", 0, kFin, nullptr); |
- EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
- size_t protected_packet = |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_); |
- EXPECT_LT(0u, protected_packet); |
- |
- // Force FEC timeout to send FEC packet out. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 2u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.GetFecAlarm()->Fire(); |
- EXPECT_TRUE(writer_->header().fec_flag); |
- size_t fec_packet = protected_packet; |
- EXPECT_EQ(protected_packet + fec_packet, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- |
- // TLP alarm should be set. |
- QuicTime retransmission_time = |
- connection_.GetRetransmissionAlarm()->deadline(); |
- EXPECT_NE(QuicTime::Zero(), retransmission_time); |
- // Simulate the retransmission alarm firing and sending a TLP, so send |
- // algorithm's OnRetransmissionTimeout is not called. |
- clock_.AdvanceTime(retransmission_time.Subtract(clock_.Now())); |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 3u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.GetRetransmissionAlarm()->Fire(); |
- // The TLP retransmission of packet 1 will be 3 bytes smaller than packet 1, |
- // since packet 1 will have 1 byte for FEC group number and 2 bytes of stream |
- // frame size, which are absent in the the TLP retransmission. |
- size_t tlp_packet = protected_packet - 3; |
- EXPECT_EQ(protected_packet + fec_packet + tlp_packet, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
-} |
- |
-TEST_P(QuicConnectionTest, FECRemainsInflightOnTLPOfLaterData) { |
- // Tests if TLP is sent correctly when data packet 1 and an FEC packet are |
- // sent followed by data packet 2, and data packet 1 is acked. TLP should be |
- // sent for data packet 2 when the retransmission alarm fires. Turn on TLP for |
- // this test. |
- QuicSentPacketManagerPeer::SetMaxTailLossProbes(manager_, 1); |
- EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); |
- EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
- |
- // 1 Data packet. FEC alarm should be set. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 1u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.SendStreamDataWithStringWithFec(3, "foo", 0, kFin, nullptr); |
- EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
- size_t protected_packet = |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_); |
- EXPECT_LT(0u, protected_packet); |
- |
- // Force FEC timeout to send FEC packet out. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 2u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.GetFecAlarm()->Fire(); |
- EXPECT_TRUE(writer_->header().fec_flag); |
- // Protected data packet and FEC packet oustanding. |
- size_t fec_packet = protected_packet; |
- EXPECT_EQ(protected_packet + fec_packet, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- |
- // Send 1 unprotected data packet. No FEC alarm should be set. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 3u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.SendStreamDataWithString(5, "foo", 0, kFin, nullptr); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
- // Protected data packet, FEC packet, and unprotected data packet oustanding. |
- // An unprotected packet will be 3 bytes smaller than an FEC-protected packet, |
- // since the protected packet will have 1 byte for FEC group number and |
- // 2 bytes of stream frame size, which are absent in the unprotected packet. |
- size_t unprotected_packet = protected_packet - 3; |
- EXPECT_EQ(protected_packet + fec_packet + unprotected_packet, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- |
- // Receive ack for first data packet. FEC and second data packet are still |
- // outstanding. |
- QuicAckFrame ack = InitAckFrame(1); |
- EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
- EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
- ProcessAckPacket(&ack); |
- // FEC packet and unprotected data packet oustanding. |
- EXPECT_EQ(fec_packet + unprotected_packet, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- |
- // TLP alarm should be set. |
- QuicTime retransmission_time = |
- connection_.GetRetransmissionAlarm()->deadline(); |
- EXPECT_NE(QuicTime::Zero(), retransmission_time); |
- // Simulate the retransmission alarm firing and sending a TLP, so send |
- // algorithm's OnRetransmissionTimeout is not called. |
- clock_.AdvanceTime(retransmission_time.Subtract(clock_.Now())); |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, 4u, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.GetRetransmissionAlarm()->Fire(); |
- |
- // Having received an ack from the server, the client will no longer send |
- // version number in subsequent packets, including in this retransmission. |
- size_t tlp_packet_no_version = unprotected_packet - 4; |
- EXPECT_EQ(fec_packet + unprotected_packet + tlp_packet_no_version, |
- QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
-} |
- |
-TEST_P(QuicConnectionTest, NoTLPForFECPacket) { |
- // Turn on TLP for this test. |
- QuicSentPacketManagerPeer::SetMaxTailLossProbes(manager_, 1); |
- EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); |
- EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
- |
- // Send 1 FEC-protected data packet. FEC alarm should be set. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); |
- EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
- // Force FEC timeout to send FEC packet out. |
- EXPECT_CALL(*send_algorithm_, |
- OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
- .Times(1); |
- connection_.GetFecAlarm()->Fire(); |
- EXPECT_TRUE(writer_->header().fec_flag); |
- |
- // Ack data packet, but not FEC packet. |
- QuicAckFrame ack = InitAckFrame(1); |
- EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
- ProcessAckPacket(&ack); |
- |
- // No TLP alarm for FEC, but retransmission alarm should be set for an RTO. |
- EXPECT_LT(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
- EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
- QuicTime rto_time = connection_.GetRetransmissionAlarm()->deadline(); |
- EXPECT_NE(QuicTime::Zero(), rto_time); |
- |
- // Simulate the retransmission alarm firing. FEC packet is no longer |
- // outstanding. |
- clock_.AdvanceTime(rto_time.Subtract(clock_.Now())); |
- connection_.GetRetransmissionAlarm()->Fire(); |
- |
- EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
- EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
-} |
- |
TEST_P(QuicConnectionTest, FramePacking) { |
// Send an ack and two stream frames in 1 packet by queueing them. |
{ |
@@ -2363,29 +1913,6 @@ TEST_P(QuicConnectionTest, FramePackingCryptoThenNonCrypto) { |
EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0]->stream_id); |
} |
-TEST_P(QuicConnectionTest, FramePackingFEC) { |
- EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); |
- |
- // Queue an ack and two stream frames. Ack gets flushed when FEC is turned on |
- // for sending protected data; two stream frames are packed in 1 packet. |
- { |
- QuicConnection::ScopedPacketBundler bundler(&connection_, |
- QuicConnection::SEND_ACK); |
- connection_.SendStreamData3WithFec(); |
- connection_.SendStreamData5WithFec(); |
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
- } |
- EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
- EXPECT_FALSE(connection_.HasQueuedData()); |
- |
- // Parse the last packet and ensure it's in an fec group. |
- EXPECT_EQ(2u, writer_->header().fec_group); |
- EXPECT_EQ(2u, writer_->frame_count()); |
- |
- // FEC alarm should be set. |
- EXPECT_TRUE(connection_.GetFecAlarm()->IsSet()); |
-} |
- |
TEST_P(QuicConnectionTest, FramePackingAckResponse) { |
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
// Process a data packet to queue up a pending ack. |
@@ -2428,8 +1955,7 @@ TEST_P(QuicConnectionTest, FramePackingSendv) { |
iov[0].iov_len = 2; |
iov[1].iov_base = data + 2; |
iov[1].iov_len = 2; |
- connection_.SendStreamData(1, QuicIOVector(iov, 2, 4), 0, !kFin, |
- MAY_FEC_PROTECT, nullptr); |
+ connection_.SendStreamData(1, QuicIOVector(iov, 2, 4), 0, !kFin, nullptr); |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
EXPECT_FALSE(connection_.HasQueuedData()); |
@@ -2454,8 +1980,7 @@ TEST_P(QuicConnectionTest, FramePackingSendvQueued) { |
iov[0].iov_len = 2; |
iov[1].iov_base = data + 2; |
iov[1].iov_len = 2; |
- connection_.SendStreamData(1, QuicIOVector(iov, 2, 4), 0, !kFin, |
- MAY_FEC_PROTECT, nullptr); |
+ connection_.SendStreamData(1, QuicIOVector(iov, 2, 4), 0, !kFin, nullptr); |
EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
EXPECT_TRUE(connection_.HasQueuedData()); |
@@ -2475,7 +2000,7 @@ TEST_P(QuicConnectionTest, SendingZeroBytes) { |
// Send a zero byte write with a fin using writev. |
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
QuicIOVector empty_iov(nullptr, 0, 0); |
- connection_.SendStreamData(1, empty_iov, 0, kFin, MAY_FEC_PROTECT, nullptr); |
+ connection_.SendStreamData(1, empty_iov, 0, kFin, nullptr); |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
EXPECT_FALSE(connection_.HasQueuedData()); |
@@ -3603,7 +3128,6 @@ TEST_P(QuicConnectionTest, InitialTimeout) { |
EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); |
EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); |
@@ -3647,7 +3171,6 @@ TEST_P(QuicConnectionTest, HandshakeTimeout) { |
EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
- EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); |
EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); |
@@ -5375,54 +4898,6 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { |
ProcessFecPacket(kDefaultPathId, 2, 1, true, !kEntropyFlag, packet); |
} |
-TEST_P(QuicConnectionTest, NetworkChangeVisitorCwndCallbackChangesFecState) { |
- size_t max_packets_per_fec_group = creator_->max_packets_per_fec_group(); |
- |
- QuicSentPacketManager::NetworkChangeVisitor* visitor = |
- QuicSentPacketManagerPeer::GetNetworkChangeVisitor(manager_); |
- EXPECT_TRUE(visitor); |
- |
- // Increase FEC group size by increasing congestion window to a large number. |
- EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) |
- .WillRepeatedly(Return(1000 * kDefaultTCPMSS)); |
- visitor->OnCongestionWindowChange(); |
- EXPECT_LT(max_packets_per_fec_group, creator_->max_packets_per_fec_group()); |
-} |
- |
-TEST_P(QuicConnectionTest, NetworkChangeVisitorConfigCallbackChangesFecState) { |
- QuicSentPacketManager::NetworkChangeVisitor* visitor = |
- QuicSentPacketManagerPeer::GetNetworkChangeVisitor(manager_); |
- EXPECT_TRUE(visitor); |
- EXPECT_EQ(QuicTime::Delta::Zero(), |
- QuicPacketCreatorPeer::GetFecTimeout(creator_)); |
- |
- // Verify that sending a config with a new initial rtt changes fec timeout. |
- // Create and process a config with a non-zero initial RTT. |
- EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
- QuicConfig config; |
- config.SetInitialRoundTripTimeUsToSend(300000); |
- connection_.SetFromConfig(config); |
- EXPECT_LT(QuicTime::Delta::Zero(), |
- QuicPacketCreatorPeer::GetFecTimeout(creator_)); |
-} |
- |
-TEST_P(QuicConnectionTest, NetworkChangeVisitorRttCallbackChangesFecState) { |
- // Verify that sending a config with a new initial rtt changes fec timeout. |
- QuicSentPacketManager::NetworkChangeVisitor* visitor = |
- QuicSentPacketManagerPeer::GetNetworkChangeVisitor(manager_); |
- EXPECT_TRUE(visitor); |
- EXPECT_EQ(QuicTime::Delta::Zero(), |
- QuicPacketCreatorPeer::GetFecTimeout(creator_)); |
- |
- // Increase FEC timeout by increasing RTT. |
- RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); |
- rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(300), |
- QuicTime::Delta::Zero(), QuicTime::Zero()); |
- visitor->OnRttChange(); |
- EXPECT_LT(QuicTime::Delta::Zero(), |
- QuicPacketCreatorPeer::GetFecTimeout(creator_)); |
-} |
- |
TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) { |
QuicPacketHeader header; |
@@ -5483,43 +4958,6 @@ TEST_P(QuicConnectionTest, NoDataNoFin) { |
"Attempt to send empty stream frame"); |
} |
-TEST_P(QuicConnectionTest, FecSendPolicyReceivedConnectionOption) { |
- // Test sending SetReceivedConnectionOptions when FEC send policy is |
- // FEC_ANY_TRIGGER. |
- if (GetParam().fec_send_policy == FEC_ALARM_TRIGGER) { |
- return; |
- } |
- connection_.set_perspective(Perspective::IS_SERVER); |
- |
- // Test ReceivedConnectionOptions. |
- EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
- QuicConfig config; |
- QuicTagVector copt; |
- copt.push_back(kFSPA); |
- QuicConfigPeer::SetReceivedConnectionOptions(&config, copt); |
- EXPECT_EQ(FEC_ANY_TRIGGER, generator_->fec_send_policy()); |
- connection_.SetFromConfig(config); |
- EXPECT_EQ(FEC_ALARM_TRIGGER, generator_->fec_send_policy()); |
-} |
- |
-// TODO(rtenneti): Delete this code after the 0.25 RTT FEC experiment. |
-TEST_P(QuicConnectionTest, FecRTTMultiplierReceivedConnectionOption) { |
- connection_.set_perspective(Perspective::IS_SERVER); |
- |
- // Test ReceivedConnectionOptions. |
- EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
- QuicConfig config; |
- QuicTagVector copt; |
- copt.push_back(kFRTT); |
- QuicConfigPeer::SetReceivedConnectionOptions(&config, copt); |
- float rtt_multiplier_for_fec_timeout = |
- QuicPacketCreatorPeer::GetRttMultiplierForFecTimeout(creator_); |
- connection_.SetFromConfig(config); |
- // New RTT multiplier is half of the old RTT multiplier. |
- EXPECT_EQ(rtt_multiplier_for_fec_timeout, |
- QuicPacketCreatorPeer::GetRttMultiplierForFecTimeout(creator_) * 2); |
-} |
- |
TEST_P(QuicConnectionTest, DoNotSendGoAwayTwice) { |
EXPECT_FALSE(connection_.goaway_sent()); |
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |