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

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

Issue 1982103002: Cancel pending retransmissions which are greater than the largest newly acked packet when using the… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@121845603
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_unacked_packet_map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_sent_packet_manager.h" 5 #include "net/quic/quic_sent_packet_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/quic/quic_flags.h" 10 #include "net/quic/quic_flags.h"
11 #include "net/quic/test_tools/quic_config_peer.h" 11 #include "net/quic/test_tools/quic_config_peer.h"
12 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" 12 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
13 #include "net/quic/test_tools/quic_test_utils.h" 13 #include "net/quic/test_tools/quic_test_utils.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using std::vector; 17 using std::vector;
18 using testing::AnyNumber; 18 using testing::AnyNumber;
19 using testing::ElementsAre; 19 using testing::ElementsAre;
20 using testing::IsEmpty; 20 using testing::IsEmpty;
21 using testing::Not; 21 using testing::Not;
22 using testing::Pair; 22 using testing::Pair;
23 using testing::Pointwise; 23 using testing::Pointwise;
24 using testing::Return; 24 using testing::Return;
25 using testing::SetArgPointee;
25 using testing::StrictMock; 26 using testing::StrictMock;
26 using testing::_; 27 using testing::_;
27 28
28 namespace net { 29 namespace net {
29 namespace test { 30 namespace test {
30 namespace { 31 namespace {
31 32
32 // Default packet length. 33 // Default packet length.
33 const uint32_t kDefaultLength = 1000; 34 const uint32_t kDefaultLength = 1000;
34 35
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 1542
1542 options.push_back(kNRTO); 1543 options.push_back(kNRTO);
1543 QuicSentPacketManagerPeer::SetPerspective(&manager_, Perspective::IS_CLIENT); 1544 QuicSentPacketManagerPeer::SetPerspective(&manager_, Perspective::IS_CLIENT);
1544 client_config.SetConnectionOptionsToSend(options); 1545 client_config.SetConnectionOptionsToSend(options);
1545 EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); 1546 EXPECT_CALL(*network_change_visitor_, OnCongestionChange());
1546 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1547 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1547 manager_.SetFromConfig(client_config); 1548 manager_.SetFromConfig(client_config);
1548 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_)); 1549 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1549 } 1550 }
1550 1551
1552 TEST_P(QuicSentPacketManagerTest, NegotiateUndoFromOptionsAtServer) {
1553 FLAGS_quic_loss_recovery_use_largest_acked = true;
1554 EXPECT_FALSE(QuicSentPacketManagerPeer::GetUndoRetransmits(&manager_));
1555 QuicConfig config;
1556 QuicTagVector options;
1557
1558 options.push_back(kUNDO);
1559 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1560 EXPECT_CALL(*network_change_visitor_, OnCongestionChange());
1561 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1562 manager_.SetFromConfig(config);
1563 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUndoRetransmits(&manager_));
1564
1565 // Ensure undo works as intended.
1566 // Send 5 packets, mark the first 4 for retransmission, and then cancel
1567 // them when 1 is acked.
1568 EXPECT_CALL(*send_algorithm_, PacingRate())
1569 .WillRepeatedly(Return(QuicBandwidth::Zero()));
1570 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1571 .WillOnce(Return(10 * kDefaultTCPMSS));
1572 const size_t kNumSentPackets = 5;
1573 for (size_t i = 1; i <= kNumSentPackets; ++i) {
1574 SendDataPacket(i);
1575 }
1576 MockLossAlgorithm* loss_algorithm = new MockLossAlgorithm();
1577 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm);
1578 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
1579 EXPECT_CALL(*network_change_visitor_, OnCongestionChange());
1580 SendAlgorithmInterface::CongestionVector lost_packets;
1581 for (size_t i = 1; i < kNumSentPackets; ++i) {
1582 lost_packets.push_back(std::make_pair(i, kMaxPacketSize));
1583 }
1584 EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _))
1585 .WillOnce(SetArgPointee<4>(lost_packets));
1586 QuicAckFrame ack_frame = InitAckFrame(kNumSentPackets);
1587 NackPackets(1, kNumSentPackets, &ack_frame);
1588 // Congestion block the sending right before losing the packets.
1589 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
1590 .WillRepeatedly(Return(QuicTime::Delta::Infinite()));
1591 manager_.OnIncomingAck(ack_frame, clock_.Now());
1592 EXPECT_TRUE(manager_.HasPendingRetransmissions());
1593 EXPECT_EQ(0u, BytesInFlight());
1594
1595 // Ack 1 and ensure the retransmissions are cancelled and put back in flight.
1596 EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _));
1597 ack_frame = InitAckFrame(5);
1598 NackPackets(2, kNumSentPackets, &ack_frame);
1599 manager_.OnIncomingAck(ack_frame, clock_.Now());
1600 EXPECT_FALSE(manager_.HasPendingRetransmissions());
1601 EXPECT_EQ(3u * kDefaultLength, BytesInFlight());
1602 }
1603
1604 TEST_P(QuicSentPacketManagerTest, NegotiateUndoFromOptionsAtClient) {
1605 FLAGS_quic_loss_recovery_use_largest_acked = true;
1606 EXPECT_FALSE(QuicSentPacketManagerPeer::GetUndoRetransmits(&manager_));
1607 QuicConfig client_config;
1608 QuicTagVector options;
1609
1610 options.push_back(kUNDO);
1611 QuicSentPacketManagerPeer::SetPerspective(&manager_, Perspective::IS_CLIENT);
1612 client_config.SetConnectionOptionsToSend(options);
1613 EXPECT_CALL(*network_change_visitor_, OnCongestionChange());
1614 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1615 manager_.SetFromConfig(client_config);
1616 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUndoRetransmits(&manager_));
1617 }
1618
1551 TEST_P(QuicSentPacketManagerTest, 1619 TEST_P(QuicSentPacketManagerTest,
1552 NegotiateConservativeReceiveWindowFromOptions) { 1620 NegotiateConservativeReceiveWindowFromOptions) {
1553 EXPECT_EQ(kDefaultSocketReceiveBuffer, 1621 EXPECT_EQ(kDefaultSocketReceiveBuffer,
1554 QuicSentPacketManagerPeer::GetReceiveWindow(&manager_)); 1622 QuicSentPacketManagerPeer::GetReceiveWindow(&manager_));
1555 1623
1556 // Try to set a size below the minimum and ensure it gets set to the min. 1624 // Try to set a size below the minimum and ensure it gets set to the min.
1557 QuicConfig client_config; 1625 QuicConfig client_config;
1558 QuicConfigPeer::SetReceivedSocketReceiveBuffer(&client_config, 1024); 1626 QuicConfigPeer::SetReceivedSocketReceiveBuffer(&client_config, 1024);
1559 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1627 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1560 EXPECT_CALL(*send_algorithm_, 1628 EXPECT_CALL(*send_algorithm_,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 manager_.OnConnectionMigration(PORT_CHANGE); 1760 manager_.OnConnectionMigration(PORT_CHANGE);
1693 1761
1694 EXPECT_EQ(2 * default_init_rtt, rtt_stats->initial_rtt_us()); 1762 EXPECT_EQ(2 * default_init_rtt, rtt_stats->initial_rtt_us());
1695 EXPECT_EQ(1u, manager_.consecutive_rto_count()); 1763 EXPECT_EQ(1u, manager_.consecutive_rto_count());
1696 EXPECT_EQ(2u, manager_.consecutive_tlp_count()); 1764 EXPECT_EQ(2u, manager_.consecutive_tlp_count());
1697 } 1765 }
1698 1766
1699 } // namespace 1767 } // namespace
1700 } // namespace test 1768 } // namespace test
1701 } // namespace net 1769 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_unacked_packet_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698