| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).Times(AnyNumber()); | 722 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).Times(AnyNumber()); |
| 723 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); | 723 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); |
| 724 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); | 724 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); |
| 725 EXPECT_CALL(visitor_, PostProcessAfterData()).Times(AnyNumber()); | 725 EXPECT_CALL(visitor_, PostProcessAfterData()).Times(AnyNumber()); |
| 726 EXPECT_CALL(visitor_, HasOpenDynamicStreams()) | 726 EXPECT_CALL(visitor_, HasOpenDynamicStreams()) |
| 727 .WillRepeatedly(Return(false)); | 727 .WillRepeatedly(Return(false)); |
| 728 EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber()); | 728 EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber()); |
| 729 | 729 |
| 730 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) | 730 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) |
| 731 .WillRepeatedly(Return(QuicTime::Zero())); | 731 .WillRepeatedly(Return(QuicTime::Zero())); |
| 732 if (FLAGS_quic_general_loss_algorithm) { | 732 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)).Times(AnyNumber()); |
| 733 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | |
| 734 .Times(AnyNumber()); | |
| 735 } else { | |
| 736 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 737 .WillRepeatedly(Return(PacketNumberSet())); | |
| 738 } | |
| 739 // TODO(ianswett): Fix QuicConnectionTests so they don't attempt to write | 733 // TODO(ianswett): Fix QuicConnectionTests so they don't attempt to write |
| 740 // non-crypto stream data at ENCRYPTION_NONE. | 734 // non-crypto stream data at ENCRYPTION_NONE. |
| 741 FLAGS_quic_never_write_unencrypted_data = false; | 735 FLAGS_quic_never_write_unencrypted_data = false; |
| 742 FLAGS_quic_no_unencrypted_fec = false; | 736 FLAGS_quic_no_unencrypted_fec = false; |
| 743 } | 737 } |
| 744 | 738 |
| 745 QuicVersion version() { return GetParam().version; } | 739 QuicVersion version() { return GetParam().version; } |
| 746 | 740 |
| 747 QuicAckFrame* outgoing_ack() { | 741 QuicAckFrame* outgoing_ack() { |
| 748 QuicConnectionPeer::PopulateAckFrame(&connection_, &ack_); | 742 QuicConnectionPeer::PopulateAckFrame(&connection_, &ack_); |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 | 1362 |
| 1369 QuicAckFrame frame = InitAckFrame(num_packets); | 1363 QuicAckFrame frame = InitAckFrame(num_packets); |
| 1370 PacketNumberSet lost_packets; | 1364 PacketNumberSet lost_packets; |
| 1371 // Create an ack with 256 nacks, none adjacent to one another. | 1365 // Create an ack with 256 nacks, none adjacent to one another. |
| 1372 for (QuicPacketNumber i = 1; i <= 256; ++i) { | 1366 for (QuicPacketNumber i = 1; i <= 256; ++i) { |
| 1373 NackPacket(i * 2, &frame); | 1367 NackPacket(i * 2, &frame); |
| 1374 if (i < 256) { // Last packet is nacked, but not lost. | 1368 if (i < 256) { // Last packet is nacked, but not lost. |
| 1375 lost_packets.insert(i * 2); | 1369 lost_packets.insert(i * 2); |
| 1376 } | 1370 } |
| 1377 } | 1371 } |
| 1378 if (FLAGS_quic_general_loss_algorithm) { | 1372 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 1379 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 1380 } else { | |
| 1381 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 1382 .WillOnce(Return(lost_packets)); | |
| 1383 } | |
| 1384 EXPECT_CALL(entropy_calculator_, EntropyHash(511)) | 1373 EXPECT_CALL(entropy_calculator_, EntropyHash(511)) |
| 1385 .WillOnce(Return(static_cast<QuicPacketEntropyHash>(0))); | 1374 .WillOnce(Return(static_cast<QuicPacketEntropyHash>(0))); |
| 1386 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1375 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1387 ProcessAckPacket(&frame); | 1376 ProcessAckPacket(&frame); |
| 1388 | 1377 |
| 1389 // A truncated ack will not have the true largest observed. | 1378 // A truncated ack will not have the true largest observed. |
| 1390 EXPECT_GT(num_packets, manager_->largest_observed()); | 1379 EXPECT_GT(num_packets, manager_->largest_observed()); |
| 1391 | 1380 |
| 1392 AckPacket(192, &frame); | 1381 AckPacket(192, &frame); |
| 1393 | 1382 |
| 1394 // Removing one missing packet allows us to ack 192 and one more range, but | 1383 // Removing one missing packet allows us to ack 192 and one more range, but |
| 1395 // 192 has already been declared lost, so it doesn't register as an ack. | 1384 // 192 has already been declared lost, so it doesn't register as an ack. |
| 1396 if (FLAGS_quic_general_loss_algorithm) { | 1385 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 1397 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 1398 } else { | |
| 1399 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 1400 .WillOnce(Return(PacketNumberSet())); | |
| 1401 } | |
| 1402 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1386 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1403 ProcessAckPacket(&frame); | 1387 ProcessAckPacket(&frame); |
| 1404 EXPECT_EQ(num_packets, manager_->largest_observed()); | 1388 EXPECT_EQ(num_packets, manager_->largest_observed()); |
| 1405 } | 1389 } |
| 1406 | 1390 |
| 1407 TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) { | 1391 TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) { |
| 1408 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1392 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1409 | 1393 |
| 1410 ProcessPacket(kDefaultPathId, 1); | 1394 ProcessPacket(kDefaultPathId, 1); |
| 1411 // Delay sending, then queue up an ack. | 1395 // Delay sending, then queue up an ack. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 | 1452 |
| 1469 QuicPacketNumber original; | 1453 QuicPacketNumber original; |
| 1470 QuicByteCount packet_size; | 1454 QuicByteCount packet_size; |
| 1471 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 1455 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 1472 .WillOnce( | 1456 .WillOnce( |
| 1473 DoAll(SaveArg<2>(&original), SaveArg<3>(&packet_size), Return(true))); | 1457 DoAll(SaveArg<2>(&original), SaveArg<3>(&packet_size), Return(true))); |
| 1474 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 1458 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 1475 QuicAckFrame frame = InitAckFrame(original); | 1459 QuicAckFrame frame = InitAckFrame(original); |
| 1476 NackPacket(original, &frame); | 1460 NackPacket(original, &frame); |
| 1477 // First nack triggers early retransmit. | 1461 // First nack triggers early retransmit. |
| 1478 if (FLAGS_quic_general_loss_algorithm) { | 1462 SendAlgorithmInterface::CongestionVector lost_packets; |
| 1479 SendAlgorithmInterface::CongestionVector lost_packets; | 1463 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); |
| 1480 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); | 1464 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 1481 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 1465 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 1482 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 1483 } else { | |
| 1484 PacketNumberSet lost_packets; | |
| 1485 lost_packets.insert(1); | |
| 1486 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 1487 .WillOnce(Return(lost_packets)); | |
| 1488 } | |
| 1489 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1466 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1490 QuicPacketNumber retransmission; | 1467 QuicPacketNumber retransmission; |
| 1491 EXPECT_CALL(*send_algorithm_, | 1468 EXPECT_CALL(*send_algorithm_, |
| 1492 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _)) | 1469 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _)) |
| 1493 .WillOnce(DoAll(SaveArg<2>(&retransmission), Return(true))); | 1470 .WillOnce(DoAll(SaveArg<2>(&retransmission), Return(true))); |
| 1494 | 1471 |
| 1495 ProcessAckPacket(&frame); | 1472 ProcessAckPacket(&frame); |
| 1496 | 1473 |
| 1497 QuicAckFrame frame2 = InitAckFrame(retransmission); | 1474 QuicAckFrame frame2 = InitAckFrame(retransmission); |
| 1498 NackPacket(original, &frame2); | 1475 NackPacket(original, &frame2); |
| 1499 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1476 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1500 if (FLAGS_quic_general_loss_algorithm) { | 1477 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 1501 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 1502 } else { | |
| 1503 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 1504 .WillOnce(Return(PacketNumberSet())); | |
| 1505 } | |
| 1506 ProcessAckPacket(&frame2); | 1478 ProcessAckPacket(&frame2); |
| 1507 | 1479 |
| 1508 // Now if the peer sends an ack which still reports the retransmitted packet | 1480 // Now if the peer sends an ack which still reports the retransmitted packet |
| 1509 // as missing, that will bundle an ack with data after two acks in a row | 1481 // as missing, that will bundle an ack with data after two acks in a row |
| 1510 // indicate the high water mark needs to be raised. | 1482 // indicate the high water mark needs to be raised. |
| 1511 EXPECT_CALL(*send_algorithm_, | 1483 EXPECT_CALL(*send_algorithm_, |
| 1512 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)); | 1484 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)); |
| 1513 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, nullptr); | 1485 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, nullptr); |
| 1514 // No ack sent. | 1486 // No ack sent. |
| 1515 EXPECT_EQ(1u, writer_->frame_count()); | 1487 EXPECT_EQ(1u, writer_->frame_count()); |
| 1516 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1488 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 1517 | 1489 |
| 1518 // No more packet loss for the rest of the test. | 1490 // No more packet loss for the rest of the test. |
| 1519 if (FLAGS_quic_general_loss_algorithm) { | 1491 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)).Times(AnyNumber()); |
| 1520 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)).Times(AnyNumber()); | |
| 1521 } else { | |
| 1522 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 1523 .WillRepeatedly(Return(PacketNumberSet())); | |
| 1524 } | |
| 1525 ProcessAckPacket(&frame2); | 1492 ProcessAckPacket(&frame2); |
| 1526 EXPECT_CALL(*send_algorithm_, | 1493 EXPECT_CALL(*send_algorithm_, |
| 1527 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)); | 1494 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)); |
| 1528 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, nullptr); | 1495 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, nullptr); |
| 1529 // Ack bundled. | 1496 // Ack bundled. |
| 1530 EXPECT_EQ(3u, writer_->frame_count()); | 1497 EXPECT_EQ(3u, writer_->frame_count()); |
| 1531 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1498 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 1532 EXPECT_FALSE(writer_->ack_frames().empty()); | 1499 EXPECT_FALSE(writer_->ack_frames().empty()); |
| 1533 | 1500 |
| 1534 // But an ack with no missing packets will not send an ack. | 1501 // But an ack with no missing packets will not send an ack. |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1991 // stream frame size, which are absent in the retransmission. | 1958 // stream frame size, which are absent in the retransmission. |
| 1992 size_t retransmitted_packet = protected_packet - 3; | 1959 size_t retransmitted_packet = protected_packet - 3; |
| 1993 EXPECT_EQ(protected_packet + retransmitted_packet, | 1960 EXPECT_EQ(protected_packet + retransmitted_packet, |
| 1994 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); | 1961 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 1995 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); | 1962 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 1996 | 1963 |
| 1997 // Receive ack for the retransmission. No data should be outstanding. | 1964 // Receive ack for the retransmission. No data should be outstanding. |
| 1998 QuicAckFrame ack = InitAckFrame(3); | 1965 QuicAckFrame ack = InitAckFrame(3); |
| 1999 NackPacket(1, &ack); | 1966 NackPacket(1, &ack); |
| 2000 NackPacket(2, &ack); | 1967 NackPacket(2, &ack); |
| 2001 if (FLAGS_quic_general_loss_algorithm) { | 1968 SendAlgorithmInterface::CongestionVector lost_packets; |
| 2002 SendAlgorithmInterface::CongestionVector lost_packets; | 1969 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); |
| 2003 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); | 1970 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 2004 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 1971 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 2005 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 2006 } else { | |
| 2007 PacketNumberSet lost_packets; | |
| 2008 lost_packets.insert(1); | |
| 2009 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2010 .WillOnce(Return(lost_packets)); | |
| 2011 } | |
| 2012 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1972 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2013 ProcessAckPacket(&ack); | 1973 ProcessAckPacket(&ack); |
| 2014 | 1974 |
| 2015 // Ensure the alarm is not set since all packets have been acked or abandoned. | 1975 // Ensure the alarm is not set since all packets have been acked or abandoned. |
| 2016 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 1976 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 2017 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); | 1977 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 2018 } | 1978 } |
| 2019 | 1979 |
| 2020 TEST_P(QuicConnectionTest, RemoveFECFromInflightOnLossRetransmission) { | 1980 TEST_P(QuicConnectionTest, RemoveFECFromInflightOnLossRetransmission) { |
| 2021 EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); | 1981 EXPECT_TRUE(QuicPacketCreatorPeer::IsFecEnabled(creator_)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2057 EXPECT_EQ(protected_packet + fec_packet + 4 * unprotected_packet, | 2017 EXPECT_EQ(protected_packet + fec_packet + 4 * unprotected_packet, |
| 2058 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); | 2018 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 2059 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); | 2019 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 2060 | 2020 |
| 2061 // Ack data packets, and NACK FEC packet and one data packet. Triggers | 2021 // Ack data packets, and NACK FEC packet and one data packet. Triggers |
| 2062 // NACK-based loss detection of both packets, but only data packet is | 2022 // NACK-based loss detection of both packets, but only data packet is |
| 2063 // retransmitted and considered outstanding. | 2023 // retransmitted and considered outstanding. |
| 2064 QuicAckFrame ack = InitAckFrame(6); | 2024 QuicAckFrame ack = InitAckFrame(6); |
| 2065 NackPacket(2, &ack); | 2025 NackPacket(2, &ack); |
| 2066 NackPacket(3, &ack); | 2026 NackPacket(3, &ack); |
| 2067 if (FLAGS_quic_general_loss_algorithm) { | 2027 SendAlgorithmInterface::CongestionVector lost_packets; |
| 2068 SendAlgorithmInterface::CongestionVector lost_packets; | 2028 lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); |
| 2069 lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); | 2029 lost_packets.push_back(std::make_pair(3, kMaxPacketSize)); |
| 2070 lost_packets.push_back(std::make_pair(3, kMaxPacketSize)); | 2030 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 2071 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 2031 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 2072 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 2073 } else { | |
| 2074 PacketNumberSet lost_packets; | |
| 2075 lost_packets.insert(2); | |
| 2076 lost_packets.insert(3); | |
| 2077 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2078 .WillOnce(Return(lost_packets)); | |
| 2079 } | |
| 2080 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2032 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2081 EXPECT_CALL(*send_algorithm_, | 2033 EXPECT_CALL(*send_algorithm_, |
| 2082 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) | 2034 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)) |
| 2083 .Times(1); | 2035 .Times(1); |
| 2084 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2036 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2085 ProcessAckPacket(&ack); | 2037 ProcessAckPacket(&ack); |
| 2086 // On receiving this ack from the server, the client will no longer send | 2038 // On receiving this ack from the server, the client will no longer send |
| 2087 // version number in subsequent packets, including in this retransmission. | 2039 // version number in subsequent packets, including in this retransmission. |
| 2088 size_t unprotected_packet_no_version = unprotected_packet - 4; | 2040 size_t unprotected_packet_no_version = unprotected_packet - 4; |
| 2089 EXPECT_EQ(unprotected_packet_no_version, | 2041 EXPECT_EQ(unprotected_packet_no_version, |
| 2090 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); | 2042 QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 2091 | 2043 |
| 2092 // Receive ack for the retransmission. No data should be outstanding. | 2044 // Receive ack for the retransmission. No data should be outstanding. |
| 2093 QuicAckFrame ack2 = InitAckFrame(7); | 2045 QuicAckFrame ack2 = InitAckFrame(7); |
| 2094 NackPacket(2, &ack2); | 2046 NackPacket(2, &ack2); |
| 2095 NackPacket(3, &ack2); | 2047 NackPacket(3, &ack2); |
| 2096 if (FLAGS_quic_general_loss_algorithm) { | 2048 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 2097 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 2098 } else { | |
| 2099 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2100 .WillOnce(Return(PacketNumberSet())); | |
| 2101 } | |
| 2102 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2049 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2103 ProcessAckPacket(&ack2); | 2050 ProcessAckPacket(&ack2); |
| 2104 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); | 2051 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); |
| 2105 } | 2052 } |
| 2106 | 2053 |
| 2107 TEST_P(QuicConnectionTest, FECRemainsInflightOnTLPOfEarlierData) { | 2054 TEST_P(QuicConnectionTest, FECRemainsInflightOnTLPOfEarlierData) { |
| 2108 // This test checks if TLP is sent correctly when a data and an FEC packet | 2055 // This test checks if TLP is sent correctly when a data and an FEC packet |
| 2109 // are outstanding. TLP should be sent for the data packet when the | 2056 // are outstanding. TLP should be sent for the data packet when the |
| 2110 // retransmission alarm fires. | 2057 // retransmission alarm fires. |
| 2111 // Turn on TLP for this test. | 2058 // Turn on TLP for this test. |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2482 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2429 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2483 | 2430 |
| 2484 // Don't lose a packet on an ack, and nothing is retransmitted. | 2431 // Don't lose a packet on an ack, and nothing is retransmitted. |
| 2485 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2432 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2486 QuicAckFrame ack_one = InitAckFrame(1); | 2433 QuicAckFrame ack_one = InitAckFrame(1); |
| 2487 ProcessAckPacket(&ack_one); | 2434 ProcessAckPacket(&ack_one); |
| 2488 | 2435 |
| 2489 // Lose a packet and ensure it triggers retransmission. | 2436 // Lose a packet and ensure it triggers retransmission. |
| 2490 QuicAckFrame nack_two = InitAckFrame(3); | 2437 QuicAckFrame nack_two = InitAckFrame(3); |
| 2491 NackPacket(2, &nack_two); | 2438 NackPacket(2, &nack_two); |
| 2492 if (FLAGS_quic_general_loss_algorithm) { | 2439 SendAlgorithmInterface::CongestionVector lost_packets; |
| 2493 SendAlgorithmInterface::CongestionVector lost_packets; | 2440 lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); |
| 2494 lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); | 2441 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 2495 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 2442 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 2496 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 2497 } else { | |
| 2498 PacketNumberSet lost_packets; | |
| 2499 lost_packets.insert(2); | |
| 2500 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2501 .WillOnce(Return(lost_packets)); | |
| 2502 } | |
| 2503 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2443 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2504 EXPECT_CALL(*send_algorithm_, | 2444 EXPECT_CALL(*send_algorithm_, |
| 2505 OnPacketSent(_, _, _, second_packet_size - kQuicVersionSize, _)) | 2445 OnPacketSent(_, _, _, second_packet_size - kQuicVersionSize, _)) |
| 2506 .Times(1); | 2446 .Times(1); |
| 2507 ProcessAckPacket(&nack_two); | 2447 ProcessAckPacket(&nack_two); |
| 2508 } | 2448 } |
| 2509 | 2449 |
| 2510 TEST_P(QuicConnectionTest, DoNotSendQueuedPacketForResetStream) { | 2450 TEST_P(QuicConnectionTest, DoNotSendQueuedPacketForResetStream) { |
| 2511 // Block the connection to queue the packet. | 2451 // Block the connection to queue the packet. |
| 2512 BlockOnNextWrite(); | 2452 BlockOnNextWrite(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2556 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet); | 2496 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet); |
| 2557 SendStreamDataToPeer(stream_id, "fooos", 7, !kFin, &last_packet); | 2497 SendStreamDataToPeer(stream_id, "fooos", 7, !kFin, &last_packet); |
| 2558 | 2498 |
| 2559 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 2499 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
| 2560 connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14); | 2500 connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14); |
| 2561 | 2501 |
| 2562 // Lose a packet and ensure it does not trigger retransmission. | 2502 // Lose a packet and ensure it does not trigger retransmission. |
| 2563 QuicAckFrame nack_two = InitAckFrame(last_packet); | 2503 QuicAckFrame nack_two = InitAckFrame(last_packet); |
| 2564 NackPacket(last_packet - 1, &nack_two); | 2504 NackPacket(last_packet - 1, &nack_two); |
| 2565 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2505 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2566 if (FLAGS_quic_general_loss_algorithm) { | 2506 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 2567 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 2568 } else { | |
| 2569 PacketNumberSet lost_packets; | |
| 2570 lost_packets.insert(last_packet - 1); | |
| 2571 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2572 .WillOnce(Return(lost_packets)); | |
| 2573 } | |
| 2574 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2507 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2575 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); | 2508 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); |
| 2576 ProcessAckPacket(&nack_two); | 2509 ProcessAckPacket(&nack_two); |
| 2577 } | 2510 } |
| 2578 | 2511 |
| 2579 TEST_P(QuicConnectionTest, RetransmitForQuicRstStreamNoErrorOnNack) { | 2512 TEST_P(QuicConnectionTest, RetransmitForQuicRstStreamNoErrorOnNack) { |
| 2580 QuicStreamId stream_id = 2; | 2513 QuicStreamId stream_id = 2; |
| 2581 QuicPacketNumber last_packet; | 2514 QuicPacketNumber last_packet; |
| 2582 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); | 2515 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); |
| 2583 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet); | 2516 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet); |
| 2584 SendStreamDataToPeer(stream_id, "fooos", 7, !kFin, &last_packet); | 2517 SendStreamDataToPeer(stream_id, "fooos", 7, !kFin, &last_packet); |
| 2585 | 2518 |
| 2586 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 2519 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
| 2587 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14); | 2520 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14); |
| 2588 | 2521 |
| 2589 // Lose a packet, ensure it triggers retransmission on QUIC_VERSION_29 | 2522 // Lose a packet, ensure it triggers retransmission on QUIC_VERSION_29 |
| 2590 // or later versions. | 2523 // or later versions. |
| 2591 QuicAckFrame nack_two = InitAckFrame(last_packet); | 2524 QuicAckFrame nack_two = InitAckFrame(last_packet); |
| 2592 NackPacket(last_packet - 1, &nack_two); | 2525 NackPacket(last_packet - 1, &nack_two); |
| 2593 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2526 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2594 if (FLAGS_quic_general_loss_algorithm) { | 2527 SendAlgorithmInterface::CongestionVector lost_packets; |
| 2595 SendAlgorithmInterface::CongestionVector lost_packets; | 2528 lost_packets.push_back(std::make_pair(last_packet - 1, kMaxPacketSize)); |
| 2596 lost_packets.push_back(std::make_pair(last_packet - 1, kMaxPacketSize)); | 2529 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 2597 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 2530 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 2598 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 2599 } else { | |
| 2600 PacketNumberSet lost_packets; | |
| 2601 lost_packets.insert(last_packet - 1); | |
| 2602 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2603 .WillOnce(Return(lost_packets)); | |
| 2604 } | |
| 2605 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2531 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2606 if (version() > QUIC_VERSION_28) { | 2532 if (version() > QUIC_VERSION_28) { |
| 2607 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 2533 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 2608 .Times(AtLeast(1)); | 2534 .Times(AtLeast(1)); |
| 2609 } else { | 2535 } else { |
| 2610 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); | 2536 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); |
| 2611 } | 2537 } |
| 2612 ProcessAckPacket(&nack_two); | 2538 ProcessAckPacket(&nack_two); |
| 2613 } | 2539 } |
| 2614 | 2540 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2659 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet); | 2585 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet); |
| 2660 BlockOnNextWrite(); | 2586 BlockOnNextWrite(); |
| 2661 connection_.SendStreamDataWithString(stream_id, "fooos", 7, !kFin, nullptr); | 2587 connection_.SendStreamDataWithString(stream_id, "fooos", 7, !kFin, nullptr); |
| 2662 | 2588 |
| 2663 // Lose a packet which will trigger a pending retransmission. | 2589 // Lose a packet which will trigger a pending retransmission. |
| 2664 QuicAckFrame ack = InitAckFrame(last_packet); | 2590 QuicAckFrame ack = InitAckFrame(last_packet); |
| 2665 NackPacket(last_packet - 1, &ack); | 2591 NackPacket(last_packet - 1, &ack); |
| 2666 PacketNumberSet lost_packets; | 2592 PacketNumberSet lost_packets; |
| 2667 lost_packets.insert(last_packet - 1); | 2593 lost_packets.insert(last_packet - 1); |
| 2668 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2594 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2669 if (FLAGS_quic_general_loss_algorithm) { | 2595 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 2670 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 2671 } else { | |
| 2672 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2673 .WillOnce(Return(lost_packets)); | |
| 2674 } | |
| 2675 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2596 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2676 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); | 2597 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); |
| 2677 ProcessAckPacket(&ack); | 2598 ProcessAckPacket(&ack); |
| 2678 | 2599 |
| 2679 connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14); | 2600 connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14); |
| 2680 | 2601 |
| 2681 // Unblock the connection and verify that the RST_STREAM is sent but not the | 2602 // Unblock the connection and verify that the RST_STREAM is sent but not the |
| 2682 // second data packet nor a retransmit. | 2603 // second data packet nor a retransmit. |
| 2683 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 2604 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
| 2684 writer_->SetWritable(); | 2605 writer_->SetWritable(); |
| 2685 connection_.OnCanWrite(); | 2606 connection_.OnCanWrite(); |
| 2686 EXPECT_EQ(1u, writer_->frame_count()); | 2607 EXPECT_EQ(1u, writer_->frame_count()); |
| 2687 EXPECT_EQ(1u, writer_->rst_stream_frames().size()); | 2608 EXPECT_EQ(1u, writer_->rst_stream_frames().size()); |
| 2688 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id); | 2609 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id); |
| 2689 } | 2610 } |
| 2690 | 2611 |
| 2691 TEST_P(QuicConnectionTest, SendPendingRetransmissionForQuicRstStreamNoError) { | 2612 TEST_P(QuicConnectionTest, SendPendingRetransmissionForQuicRstStreamNoError) { |
| 2692 QuicStreamId stream_id = 2; | 2613 QuicStreamId stream_id = 2; |
| 2693 QuicPacketNumber last_packet; | 2614 QuicPacketNumber last_packet; |
| 2694 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); | 2615 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); |
| 2695 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet); | 2616 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet); |
| 2696 BlockOnNextWrite(); | 2617 BlockOnNextWrite(); |
| 2697 connection_.SendStreamDataWithString(stream_id, "fooos", 7, !kFin, nullptr); | 2618 connection_.SendStreamDataWithString(stream_id, "fooos", 7, !kFin, nullptr); |
| 2698 | 2619 |
| 2699 // Lose a packet which will trigger a pending retransmission. | 2620 // Lose a packet which will trigger a pending retransmission. |
| 2700 QuicAckFrame ack = InitAckFrame(last_packet); | 2621 QuicAckFrame ack = InitAckFrame(last_packet); |
| 2701 NackPacket(last_packet - 1, &ack); | 2622 NackPacket(last_packet - 1, &ack); |
| 2702 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2623 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2703 if (FLAGS_quic_general_loss_algorithm) { | 2624 SendAlgorithmInterface::CongestionVector lost_packets; |
| 2704 SendAlgorithmInterface::CongestionVector lost_packets; | 2625 lost_packets.push_back(std::make_pair(last_packet - 1, kMaxPacketSize)); |
| 2705 lost_packets.push_back(std::make_pair(last_packet - 1, kMaxPacketSize)); | 2626 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 2706 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 2627 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 2707 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 2708 } else { | |
| 2709 PacketNumberSet lost_packets; | |
| 2710 lost_packets.insert(last_packet - 1); | |
| 2711 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2712 .WillOnce(Return(lost_packets)); | |
| 2713 } | |
| 2714 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2628 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2715 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); | 2629 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); |
| 2716 ProcessAckPacket(&ack); | 2630 ProcessAckPacket(&ack); |
| 2717 | 2631 |
| 2718 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14); | 2632 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14); |
| 2719 | 2633 |
| 2720 // Unblock the connection and verify that the RST_STREAM is sent and the | 2634 // Unblock the connection and verify that the RST_STREAM is sent and the |
| 2721 // second data packet or a retransmit is only sent on QUIC_VERSION_29 or | 2635 // second data packet or a retransmit is only sent on QUIC_VERSION_29 or |
| 2722 // later versions. | 2636 // later versions. |
| 2723 if (version() > QUIC_VERSION_28) { | 2637 if (version() > QUIC_VERSION_28) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2745 | 2659 |
| 2746 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2660 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2747 | 2661 |
| 2748 // Instigate a loss with an ack. | 2662 // Instigate a loss with an ack. |
| 2749 QuicAckFrame nack_two = InitAckFrame(3); | 2663 QuicAckFrame nack_two = InitAckFrame(3); |
| 2750 NackPacket(2, &nack_two); | 2664 NackPacket(2, &nack_two); |
| 2751 // The first nack should trigger a fast retransmission, but we'll be | 2665 // The first nack should trigger a fast retransmission, but we'll be |
| 2752 // write blocked, so the packet will be queued. | 2666 // write blocked, so the packet will be queued. |
| 2753 BlockOnNextWrite(); | 2667 BlockOnNextWrite(); |
| 2754 | 2668 |
| 2755 if (FLAGS_quic_general_loss_algorithm) { | 2669 SendAlgorithmInterface::CongestionVector lost_packets; |
| 2756 SendAlgorithmInterface::CongestionVector lost_packets; | 2670 lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); |
| 2757 lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); | 2671 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 2758 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 2672 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 2759 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 2760 } else { | |
| 2761 PacketNumberSet lost_packets; | |
| 2762 lost_packets.insert(2); | |
| 2763 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2764 .WillOnce(Return(lost_packets)); | |
| 2765 } | |
| 2766 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2673 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2767 ProcessAckPacket(&nack_two); | 2674 ProcessAckPacket(&nack_two); |
| 2768 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 2675 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
| 2769 | 2676 |
| 2770 // Now, ack the previous transmission. | 2677 // Now, ack the previous transmission. |
| 2771 if (FLAGS_quic_general_loss_algorithm) { | 2678 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 2772 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 2773 } else { | |
| 2774 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2775 .WillOnce(Return(PacketNumberSet())); | |
| 2776 } | |
| 2777 QuicAckFrame ack_all = InitAckFrame(3); | 2679 QuicAckFrame ack_all = InitAckFrame(3); |
| 2778 ProcessAckPacket(&ack_all); | 2680 ProcessAckPacket(&ack_all); |
| 2779 | 2681 |
| 2780 // Unblock the socket and attempt to send the queued packets. However, | 2682 // Unblock the socket and attempt to send the queued packets. However, |
| 2781 // since the previous transmission has been acked, we will not | 2683 // since the previous transmission has been acked, we will not |
| 2782 // send the retransmission. | 2684 // send the retransmission. |
| 2783 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); | 2685 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); |
| 2784 | 2686 |
| 2785 writer_->SetWritable(); | 2687 writer_->SetWritable(); |
| 2786 connection_.OnCanWrite(); | 2688 connection_.OnCanWrite(); |
| 2787 | 2689 |
| 2788 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 2690 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 2789 } | 2691 } |
| 2790 | 2692 |
| 2791 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { | 2693 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { |
| 2792 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2694 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2793 QuicPacketNumber largest_observed; | 2695 QuicPacketNumber largest_observed; |
| 2794 QuicByteCount packet_size; | 2696 QuicByteCount packet_size; |
| 2795 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 2697 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 2796 .WillOnce(DoAll(SaveArg<2>(&largest_observed), SaveArg<3>(&packet_size), | 2698 .WillOnce(DoAll(SaveArg<2>(&largest_observed), SaveArg<3>(&packet_size), |
| 2797 Return(true))); | 2699 Return(true))); |
| 2798 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 2700 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 2799 | 2701 |
| 2800 QuicAckFrame frame = InitAckFrame(1); | 2702 QuicAckFrame frame = InitAckFrame(1); |
| 2801 NackPacket(largest_observed, &frame); | 2703 NackPacket(largest_observed, &frame); |
| 2802 // The first nack should retransmit the largest observed packet. | 2704 // The first nack should retransmit the largest observed packet. |
| 2803 if (FLAGS_quic_general_loss_algorithm) { | 2705 SendAlgorithmInterface::CongestionVector lost_packets; |
| 2804 SendAlgorithmInterface::CongestionVector lost_packets; | 2706 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); |
| 2805 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); | 2707 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 2806 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 2708 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 2807 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 2808 } else { | |
| 2809 PacketNumberSet lost_packets; | |
| 2810 lost_packets.insert(1); | |
| 2811 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2812 .WillOnce(Return(lost_packets)); | |
| 2813 } | |
| 2814 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2709 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2815 EXPECT_CALL(*send_algorithm_, | 2710 EXPECT_CALL(*send_algorithm_, |
| 2816 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _)); | 2711 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _)); |
| 2817 ProcessAckPacket(&frame); | 2712 ProcessAckPacket(&frame); |
| 2818 } | 2713 } |
| 2819 | 2714 |
| 2820 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) { | 2715 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) { |
| 2821 for (int i = 0; i < 10; ++i) { | 2716 for (int i = 0; i < 10; ++i) { |
| 2822 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 2717 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
| 2823 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, nullptr); | 2718 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, nullptr); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2923 } | 2818 } |
| 2924 | 2819 |
| 2925 // Ack 15, nack 1-14. | 2820 // Ack 15, nack 1-14. |
| 2926 | 2821 |
| 2927 QuicAckFrame nack = InitAckFrame(15); | 2822 QuicAckFrame nack = InitAckFrame(15); |
| 2928 for (int i = 1; i < 15; ++i) { | 2823 for (int i = 1; i < 15; ++i) { |
| 2929 NackPacket(i, &nack); | 2824 NackPacket(i, &nack); |
| 2930 } | 2825 } |
| 2931 | 2826 |
| 2932 // 14 packets have been NACK'd and lost. | 2827 // 14 packets have been NACK'd and lost. |
| 2933 if (FLAGS_quic_general_loss_algorithm) { | 2828 SendAlgorithmInterface::CongestionVector lost_packets; |
| 2934 SendAlgorithmInterface::CongestionVector lost_packets; | 2829 for (int i = 1; i < 15; ++i) { |
| 2935 for (int i = 1; i < 15; ++i) { | 2830 lost_packets.push_back(std::make_pair(i, kMaxPacketSize)); |
| 2936 lost_packets.push_back(std::make_pair(i, kMaxPacketSize)); | |
| 2937 } | |
| 2938 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | |
| 2939 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 2940 } else { | |
| 2941 PacketNumberSet lost_packets; | |
| 2942 for (int i = 1; i < 15; ++i) { | |
| 2943 lost_packets.insert(i); | |
| 2944 } | |
| 2945 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 2946 .WillOnce(Return(lost_packets)); | |
| 2947 } | 2831 } |
| 2832 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 2833 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 2948 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2834 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2949 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(14); | 2835 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(14); |
| 2950 ProcessAckPacket(&nack); | 2836 ProcessAckPacket(&nack); |
| 2951 } | 2837 } |
| 2952 | 2838 |
| 2953 // Test sending multiple acks from the connection to the session. | 2839 // Test sending multiple acks from the connection to the session. |
| 2954 TEST_P(QuicConnectionTest, MultipleAcks) { | 2840 TEST_P(QuicConnectionTest, MultipleAcks) { |
| 2955 QuicPacketNumber last_packet; | 2841 QuicPacketNumber last_packet; |
| 2956 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 | 2842 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 |
| 2957 EXPECT_EQ(1u, last_packet); | 2843 EXPECT_EQ(1u, last_packet); |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4601 | 4487 |
| 4602 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { | 4488 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { |
| 4603 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 4489 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 4604 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, | 4490 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, |
| 4605 nullptr); | 4491 nullptr); |
| 4606 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 3, !kFin, | 4492 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 3, !kFin, |
| 4607 nullptr); | 4493 nullptr); |
| 4608 // Ack the second packet, which will retransmit the first packet. | 4494 // Ack the second packet, which will retransmit the first packet. |
| 4609 QuicAckFrame ack = InitAckFrame(2); | 4495 QuicAckFrame ack = InitAckFrame(2); |
| 4610 NackPacket(1, &ack); | 4496 NackPacket(1, &ack); |
| 4611 if (FLAGS_quic_general_loss_algorithm) { | 4497 SendAlgorithmInterface::CongestionVector lost_packets; |
| 4612 SendAlgorithmInterface::CongestionVector lost_packets; | 4498 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); |
| 4613 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); | 4499 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 4614 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 4500 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 4615 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 4616 } else { | |
| 4617 PacketNumberSet lost_packets; | |
| 4618 lost_packets.insert(1); | |
| 4619 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 4620 .WillOnce(Return(lost_packets)); | |
| 4621 } | |
| 4622 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 4501 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 4623 ProcessAckPacket(&ack); | 4502 ProcessAckPacket(&ack); |
| 4624 EXPECT_EQ(1u, writer_->frame_count()); | 4503 EXPECT_EQ(1u, writer_->frame_count()); |
| 4625 EXPECT_EQ(1u, writer_->stream_frames().size()); | 4504 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 4626 writer_->Reset(); | 4505 writer_->Reset(); |
| 4627 | 4506 |
| 4628 // Now ack the retransmission, which will both raise the high water mark | 4507 // Now ack the retransmission, which will both raise the high water mark |
| 4629 // and see if there is more data to send. | 4508 // and see if there is more data to send. |
| 4630 ack = InitAckFrame(3); | 4509 ack = InitAckFrame(3); |
| 4631 NackPacket(1, &ack); | 4510 NackPacket(1, &ack); |
| 4632 if (FLAGS_quic_general_loss_algorithm) { | 4511 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 4633 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 4634 } else { | |
| 4635 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 4636 .WillOnce(Return(PacketNumberSet())); | |
| 4637 } | |
| 4638 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 4512 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 4639 ProcessAckPacket(&ack); | 4513 ProcessAckPacket(&ack); |
| 4640 | 4514 |
| 4641 // Check that no packet is sent and the ack alarm isn't set. | 4515 // Check that no packet is sent and the ack alarm isn't set. |
| 4642 EXPECT_EQ(0u, writer_->frame_count()); | 4516 EXPECT_EQ(0u, writer_->frame_count()); |
| 4643 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 4517 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
| 4644 writer_->Reset(); | 4518 writer_->Reset(); |
| 4645 | 4519 |
| 4646 // Send the same ack, but send both data and an ack together. | 4520 // Send the same ack, but send both data and an ack together. |
| 4647 ack = InitAckFrame(3); | 4521 ack = InitAckFrame(3); |
| 4648 NackPacket(1, &ack); | 4522 NackPacket(1, &ack); |
| 4649 if (FLAGS_quic_general_loss_algorithm) { | 4523 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 4650 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 4651 } else { | |
| 4652 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 4653 .WillOnce(Return(PacketNumberSet())); | |
| 4654 } | |
| 4655 EXPECT_CALL(visitor_, OnCanWrite()) | 4524 EXPECT_CALL(visitor_, OnCanWrite()) |
| 4656 .WillOnce(IgnoreResult(InvokeWithoutArgs( | 4525 .WillOnce(IgnoreResult(InvokeWithoutArgs( |
| 4657 &connection_, &TestConnection::EnsureWritableAndSendStreamData5))); | 4526 &connection_, &TestConnection::EnsureWritableAndSendStreamData5))); |
| 4658 ProcessAckPacket(&ack); | 4527 ProcessAckPacket(&ack); |
| 4659 | 4528 |
| 4660 // Check that ack is bundled with outgoing data and the delayed ack | 4529 // Check that ack is bundled with outgoing data and the delayed ack |
| 4661 // alarm is reset. | 4530 // alarm is reset. |
| 4662 EXPECT_EQ(3u, writer_->frame_count()); | 4531 EXPECT_EQ(3u, writer_->frame_count()); |
| 4663 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 4532 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); |
| 4664 EXPECT_FALSE(writer_->ack_frames().empty()); | 4533 EXPECT_FALSE(writer_->ack_frames().empty()); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5007 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); | 4876 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); |
| 5008 | 4877 |
| 5009 // Retransmit due to RTO. | 4878 // Retransmit due to RTO. |
| 5010 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); | 4879 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); |
| 5011 connection_.GetRetransmissionAlarm()->Fire(); | 4880 connection_.GetRetransmissionAlarm()->Fire(); |
| 5012 | 4881 |
| 5013 // Retransmit due to explicit nacks. | 4882 // Retransmit due to explicit nacks. |
| 5014 QuicAckFrame nack_three = InitAckFrame(4); | 4883 QuicAckFrame nack_three = InitAckFrame(4); |
| 5015 NackPacket(3, &nack_three); | 4884 NackPacket(3, &nack_three); |
| 5016 NackPacket(1, &nack_three); | 4885 NackPacket(1, &nack_three); |
| 5017 if (FLAGS_quic_general_loss_algorithm) { | 4886 SendAlgorithmInterface::CongestionVector lost_packets; |
| 5018 SendAlgorithmInterface::CongestionVector lost_packets; | 4887 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); |
| 5019 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); | 4888 lost_packets.push_back(std::make_pair(3, kMaxPacketSize)); |
| 5020 lost_packets.push_back(std::make_pair(3, kMaxPacketSize)); | 4889 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 5021 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 4890 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 5022 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 5023 } else { | |
| 5024 PacketNumberSet lost_packets; | |
| 5025 lost_packets.insert(1); | |
| 5026 lost_packets.insert(3); | |
| 5027 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 5028 .WillOnce(Return(lost_packets)); | |
| 5029 } | |
| 5030 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 4891 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 5031 EXPECT_CALL(visitor_, OnCanWrite()); | 4892 EXPECT_CALL(visitor_, OnCanWrite()); |
| 5032 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 4893 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 5033 ProcessAckPacket(&nack_three); | 4894 ProcessAckPacket(&nack_three); |
| 5034 | 4895 |
| 5035 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) | 4896 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) |
| 5036 .WillOnce(Return(QuicBandwidth::Zero())); | 4897 .WillOnce(Return(QuicBandwidth::Zero())); |
| 5037 | 4898 |
| 5038 const QuicConnectionStats& stats = connection_.GetStats(); | 4899 const QuicConnectionStats& stats = connection_.GetStats(); |
| 5039 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, | 4900 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5207 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, listener.get()); | 5068 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, listener.get()); |
| 5208 | 5069 |
| 5209 // Send some other data which we will ACK. | 5070 // Send some other data which we will ACK. |
| 5210 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); | 5071 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
| 5211 connection_.SendStreamDataWithString(1, "bar", 0, !kFin, nullptr); | 5072 connection_.SendStreamDataWithString(1, "bar", 0, !kFin, nullptr); |
| 5212 | 5073 |
| 5213 // Now we receive ACK for packets 2 and 3, but importantly missing packet 1 | 5074 // Now we receive ACK for packets 2 and 3, but importantly missing packet 1 |
| 5214 // which we registered to be notified about. | 5075 // which we registered to be notified about. |
| 5215 QuicAckFrame frame = InitAckFrame(3); | 5076 QuicAckFrame frame = InitAckFrame(3); |
| 5216 NackPacket(1, &frame); | 5077 NackPacket(1, &frame); |
| 5217 if (FLAGS_quic_general_loss_algorithm) { | 5078 SendAlgorithmInterface::CongestionVector lost_packets; |
| 5218 SendAlgorithmInterface::CongestionVector lost_packets; | 5079 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); |
| 5219 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); | 5080 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 5220 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 5081 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 5221 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 5222 } else { | |
| 5223 PacketNumberSet lost_packets; | |
| 5224 lost_packets.insert(1); | |
| 5225 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 5226 .WillOnce(Return(lost_packets)); | |
| 5227 } | |
| 5228 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 5082 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 5229 ProcessAckPacket(&frame); | 5083 ProcessAckPacket(&frame); |
| 5230 } | 5084 } |
| 5231 | 5085 |
| 5232 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { | 5086 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { |
| 5233 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 5087 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 5234 | 5088 |
| 5235 // Create a listener which we expect to be called. | 5089 // Create a listener which we expect to be called. |
| 5236 scoped_refptr<MockAckListener> listener(new MockAckListener); | 5090 scoped_refptr<MockAckListener> listener(new MockAckListener); |
| 5237 EXPECT_CALL(*listener, OnPacketRetransmitted(3)).Times(1); | 5091 EXPECT_CALL(*listener, OnPacketRetransmitted(3)).Times(1); |
| 5238 EXPECT_CALL(*listener, OnPacketAcked(3, _)).Times(1); | 5092 EXPECT_CALL(*listener, OnPacketAcked(3, _)).Times(1); |
| 5239 | 5093 |
| 5240 // Send four packets, and register to be notified on ACK of packet 2. | 5094 // Send four packets, and register to be notified on ACK of packet 2. |
| 5241 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 5095 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 5242 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, listener.get()); | 5096 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, listener.get()); |
| 5243 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, nullptr); | 5097 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, nullptr); |
| 5244 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, nullptr); | 5098 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, nullptr); |
| 5245 | 5099 |
| 5246 // Now we receive ACK for packets 1, 3, and 4 and lose 2. | 5100 // Now we receive ACK for packets 1, 3, and 4 and lose 2. |
| 5247 QuicAckFrame frame = InitAckFrame(4); | 5101 QuicAckFrame frame = InitAckFrame(4); |
| 5248 NackPacket(2, &frame); | 5102 NackPacket(2, &frame); |
| 5249 if (FLAGS_quic_general_loss_algorithm) { | 5103 SendAlgorithmInterface::CongestionVector lost_packets; |
| 5250 SendAlgorithmInterface::CongestionVector lost_packets; | 5104 lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); |
| 5251 lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); | 5105 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 5252 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 5106 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 5253 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 5254 } else { | |
| 5255 PacketNumberSet lost_packets; | |
| 5256 lost_packets.insert(2); | |
| 5257 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 5258 .WillOnce(Return(lost_packets)); | |
| 5259 } | |
| 5260 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 5107 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 5261 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 5108 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 5262 ProcessAckPacket(&frame); | 5109 ProcessAckPacket(&frame); |
| 5263 | 5110 |
| 5264 // Now we get an ACK for packet 5 (retransmitted packet 2), which should | 5111 // Now we get an ACK for packet 5 (retransmitted packet 2), which should |
| 5265 // trigger the callback. | 5112 // trigger the callback. |
| 5266 if (FLAGS_quic_general_loss_algorithm) { | 5113 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 5267 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 5268 } else { | |
| 5269 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 5270 .WillOnce(Return(PacketNumberSet())); | |
| 5271 } | |
| 5272 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 5114 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 5273 QuicAckFrame second_ack_frame = InitAckFrame(5); | 5115 QuicAckFrame second_ack_frame = InitAckFrame(5); |
| 5274 ProcessAckPacket(&second_ack_frame); | 5116 ProcessAckPacket(&second_ack_frame); |
| 5275 } | 5117 } |
| 5276 | 5118 |
| 5277 // AckNotifierCallback is triggered by the ack of a packet that timed | 5119 // AckNotifierCallback is triggered by the ack of a packet that timed |
| 5278 // out and was retransmitted, even though the retransmission has a | 5120 // out and was retransmitted, even though the retransmission has a |
| 5279 // different packet number. | 5121 // different packet number. |
| 5280 TEST_P(QuicConnectionTest, AckNotifierCallbackForAckAfterRTO) { | 5122 TEST_P(QuicConnectionTest, AckNotifierCallbackForAckAfterRTO) { |
| 5281 // Create a listener which we expect to be called. | 5123 // Create a listener which we expect to be called. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5322 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 5164 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 5323 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, listener.get()); | 5165 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, listener.get()); |
| 5324 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, nullptr); | 5166 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, nullptr); |
| 5325 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, nullptr); | 5167 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, nullptr); |
| 5326 | 5168 |
| 5327 // Now we receive ACK for packets 1, 3, and 4 and lose 2. | 5169 // Now we receive ACK for packets 1, 3, and 4 and lose 2. |
| 5328 QuicAckFrame frame = InitAckFrame(4); | 5170 QuicAckFrame frame = InitAckFrame(4); |
| 5329 NackPacket(2, &frame); | 5171 NackPacket(2, &frame); |
| 5330 EXPECT_CALL(*listener, OnPacketRetransmitted(_)); | 5172 EXPECT_CALL(*listener, OnPacketRetransmitted(_)); |
| 5331 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 5173 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 5332 if (FLAGS_quic_general_loss_algorithm) { | 5174 SendAlgorithmInterface::CongestionVector lost_packets; |
| 5333 SendAlgorithmInterface::CongestionVector lost_packets; | 5175 lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); |
| 5334 lost_packets.push_back(std::make_pair(2, kMaxPacketSize)); | 5176 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 5335 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 5177 .WillOnce(SetArgPointee<3>(lost_packets)); |
| 5336 .WillOnce(SetArgPointee<3>(lost_packets)); | |
| 5337 } else { | |
| 5338 PacketNumberSet lost_packets; | |
| 5339 lost_packets.insert(2); | |
| 5340 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 5341 .WillOnce(Return(lost_packets)); | |
| 5342 } | |
| 5343 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 5178 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 5344 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 5179 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 5345 ProcessAckPacket(&frame); | 5180 ProcessAckPacket(&frame); |
| 5346 | 5181 |
| 5347 // Now we get an ACK for packet 2, which was previously nacked. | 5182 // Now we get an ACK for packet 2, which was previously nacked. |
| 5348 EXPECT_CALL(*listener, OnPacketAcked(3, _)); | 5183 EXPECT_CALL(*listener, OnPacketAcked(3, _)); |
| 5349 if (FLAGS_quic_general_loss_algorithm) { | 5184 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 5350 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 5351 } else { | |
| 5352 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 5353 .WillOnce(Return(PacketNumberSet())); | |
| 5354 } | |
| 5355 QuicAckFrame second_ack_frame = InitAckFrame(4); | 5185 QuicAckFrame second_ack_frame = InitAckFrame(4); |
| 5356 ProcessAckPacket(&second_ack_frame); | 5186 ProcessAckPacket(&second_ack_frame); |
| 5357 | 5187 |
| 5358 // Verify that the listener is not notified again when the | 5188 // Verify that the listener is not notified again when the |
| 5359 // retransmit is acked. | 5189 // retransmit is acked. |
| 5360 if (FLAGS_quic_general_loss_algorithm) { | 5190 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 5361 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 5362 } else { | |
| 5363 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 5364 .WillOnce(Return(PacketNumberSet())); | |
| 5365 } | |
| 5366 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 5191 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 5367 QuicAckFrame third_ack_frame = InitAckFrame(5); | 5192 QuicAckFrame third_ack_frame = InitAckFrame(5); |
| 5368 ProcessAckPacket(&third_ack_frame); | 5193 ProcessAckPacket(&third_ack_frame); |
| 5369 } | 5194 } |
| 5370 | 5195 |
| 5371 TEST_P(QuicConnectionTest, AckNotifierFECTriggerCallback) { | 5196 TEST_P(QuicConnectionTest, AckNotifierFECTriggerCallback) { |
| 5372 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 5197 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 5373 | 5198 |
| 5374 // Create a listener which we expect to be called. | 5199 // Create a listener which we expect to be called. |
| 5375 scoped_refptr<MockAckListener> listener(new MockAckListener); | 5200 scoped_refptr<MockAckListener> listener(new MockAckListener); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5595 // Evaluate CanWrite, and have it return a non-Zero value. | 5420 // Evaluate CanWrite, and have it return a non-Zero value. |
| 5596 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) | 5421 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) |
| 5597 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1))); | 5422 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1))); |
| 5598 connection_.OnCanWrite(); | 5423 connection_.OnCanWrite(); |
| 5599 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); | 5424 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); |
| 5600 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(1)), | 5425 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(1)), |
| 5601 connection_.GetSendAlarm()->deadline()); | 5426 connection_.GetSendAlarm()->deadline()); |
| 5602 | 5427 |
| 5603 // Process an ack and the send alarm will be set to the new 2ms delay. | 5428 // Process an ack and the send alarm will be set to the new 2ms delay. |
| 5604 QuicAckFrame ack = InitAckFrame(1); | 5429 QuicAckFrame ack = InitAckFrame(1); |
| 5605 if (FLAGS_quic_general_loss_algorithm) { | 5430 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); |
| 5606 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); | |
| 5607 } else { | |
| 5608 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
| 5609 .WillOnce(Return(PacketNumberSet())); | |
| 5610 } | |
| 5611 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 5431 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 5612 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) | 5432 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) |
| 5613 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(2))); | 5433 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(2))); |
| 5614 ProcessAckPacket(&ack); | 5434 ProcessAckPacket(&ack); |
| 5615 EXPECT_EQ(1u, writer_->frame_count()); | 5435 EXPECT_EQ(1u, writer_->frame_count()); |
| 5616 EXPECT_EQ(1u, writer_->stream_frames().size()); | 5436 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 5617 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); | 5437 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); |
| 5618 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(2)), | 5438 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(2)), |
| 5619 connection_.GetSendAlarm()->deadline()); | 5439 connection_.GetSendAlarm()->deadline()); |
| 5620 writer_->Reset(); | 5440 writer_->Reset(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5685 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); | 5505 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); |
| 5686 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)), | 5506 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)), |
| 5687 "Received a packet with multipath flag on when multipath is " | 5507 "Received a packet with multipath flag on when multipath is " |
| 5688 "not enabled."); | 5508 "not enabled."); |
| 5689 EXPECT_FALSE(connection_.connected()); | 5509 EXPECT_FALSE(connection_.connected()); |
| 5690 } | 5510 } |
| 5691 | 5511 |
| 5692 } // namespace | 5512 } // namespace |
| 5693 } // namespace test | 5513 } // namespace test |
| 5694 } // namespace net | 5514 } // namespace net |
| OLD | NEW |