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

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

Issue 731863007: Changes QUIC's SentPacketManager to pass in HAS_RETRANSMITTABLE_DATA to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Record_last_packet_send_time_80138676
Patch Set: Created 6 years, 1 month 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/congestion_control/time_loss_algorithm_test.cc ('k') | net/quic/quic_protocol.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 // offset 0, and 2 for non-zero offsets up through 64K. Increase 1647 // offset 0, and 2 for non-zero offsets up through 64K. Increase
1648 // max_packet_length by 2 so that subsequent packets containing subsequent 1648 // max_packet_length by 2 so that subsequent packets containing subsequent
1649 // stream frames with non-zero offets will fit within the packet length. 1649 // stream frames with non-zero offets will fit within the packet length.
1650 size_t length = 2 + GetPacketLengthForOneStream( 1650 size_t length = 2 + GetPacketLengthForOneStream(
1651 connection_.version(), kIncludeVersion, 1651 connection_.version(), kIncludeVersion,
1652 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER, 1652 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER,
1653 IN_FEC_GROUP, &payload_length); 1653 IN_FEC_GROUP, &payload_length);
1654 creator->set_max_packet_length(length); 1654 creator->set_max_packet_length(length);
1655 1655
1656 // Send 4 protected data packets, which should also trigger 1 FEC packet. 1656 // Send 4 protected data packets, which should also trigger 1 FEC packet.
1657 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(5); 1657 EXPECT_CALL(*send_algorithm_,
1658 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(5);
1658 // The first stream frame will have 2 fewer overhead bytes than the other 3. 1659 // The first stream frame will have 2 fewer overhead bytes than the other 3.
1659 const string payload(payload_length * 4 + 2, 'a'); 1660 const string payload(payload_length * 4 + 2, 'a');
1660 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, nullptr); 1661 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, nullptr);
1661 // Expect the FEC group to be closed after SendStreamDataWithString. 1662 // Expect the FEC group to be closed after SendStreamDataWithString.
1662 EXPECT_FALSE(creator->IsFecGroupOpen()); 1663 EXPECT_FALSE(creator->IsFecGroupOpen());
1663 EXPECT_FALSE(creator->IsFecProtected()); 1664 EXPECT_FALSE(creator->IsFecProtected());
1664 } 1665 }
1665 1666
1666 TEST_P(QuicConnectionTest, FECQueueing) { 1667 TEST_P(QuicConnectionTest, FECQueueing) {
1667 // All packets carry version info till version is negotiated. 1668 // All packets carry version info till version is negotiated.
(...skipping 15 matching lines...) Expand all
1683 EXPECT_FALSE(creator->IsFecProtected()); 1684 EXPECT_FALSE(creator->IsFecProtected());
1684 // Expect the first data packet and the fec packet to be queued. 1685 // Expect the first data packet and the fec packet to be queued.
1685 EXPECT_EQ(2u, connection_.NumQueuedPackets()); 1686 EXPECT_EQ(2u, connection_.NumQueuedPackets());
1686 } 1687 }
1687 1688
1688 TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) { 1689 TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) {
1689 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( 1690 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator(
1690 &connection_)->IsFecEnabled()); 1691 &connection_)->IsFecEnabled());
1691 1692
1692 // 1 Data and 1 FEC packet. 1693 // 1 Data and 1 FEC packet.
1693 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); 1694 EXPECT_CALL(*send_algorithm_,
1695 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(2);
1694 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); 1696 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr);
1695 1697
1696 const QuicTime::Delta retransmission_time = 1698 const QuicTime::Delta retransmission_time =
1697 QuicTime::Delta::FromMilliseconds(5000); 1699 QuicTime::Delta::FromMilliseconds(5000);
1698 clock_.AdvanceTime(retransmission_time); 1700 clock_.AdvanceTime(retransmission_time);
1699 1701
1700 // Abandon FEC packet and data packet. 1702 // Abandon FEC packet and data packet.
1701 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1703 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1702 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 1704 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
1703 EXPECT_CALL(visitor_, OnCanWrite()); 1705 EXPECT_CALL(visitor_, OnCanWrite());
1704 connection_.OnRetransmissionTimeout(); 1706 connection_.OnRetransmissionTimeout();
1705 } 1707 }
1706 1708
1707 TEST_P(QuicConnectionTest, DontAbandonAckedFEC) { 1709 TEST_P(QuicConnectionTest, DontAbandonAckedFEC) {
1708 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1710 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1709 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( 1711 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator(
1710 &connection_)->IsFecEnabled()); 1712 &connection_)->IsFecEnabled());
1711 1713
1712 // 1 Data and 1 FEC packet. 1714 // 3 Data and 3 FEC packets.
1713 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); 1715 EXPECT_CALL(*send_algorithm_,
1716 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(6);
1714 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); 1717 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr);
1715 // Send some more data afterwards to ensure early retransmit doesn't trigger. 1718 // Send some more data afterwards to ensure early retransmit doesn't trigger.
1716 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, nullptr); 1719 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, nullptr);
1717 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, nullptr); 1720 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, nullptr);
1718 1721
1719 QuicAckFrame ack_fec = InitAckFrame(2); 1722 QuicAckFrame ack_fec = InitAckFrame(2);
1720 // Data packet missing. 1723 // Data packet missing.
1721 // TODO(ianswett): Note that this is not a sensible ack, since if the FEC was 1724 // TODO(ianswett): Note that this is not a sensible ack, since if the FEC was
1722 // received, it would cause the covered packet to be acked as well. 1725 // received, it would cause the covered packet to be acked as well.
1723 NackPacket(1, &ack_fec); 1726 NackPacket(1, &ack_fec);
1724 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 1727 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
1725 ProcessAckPacket(&ack_fec); 1728 ProcessAckPacket(&ack_fec);
1726 clock_.AdvanceTime(DefaultRetransmissionTime()); 1729 clock_.AdvanceTime(DefaultRetransmissionTime());
1727 1730
1728 // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent 1731 // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent
1729 // FEC packets. 1732 // FEC packets.
1730 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1733 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1731 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); 1734 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3);
1732 connection_.GetRetransmissionAlarm()->Fire(); 1735 connection_.GetRetransmissionAlarm()->Fire();
1733 } 1736 }
1734 1737
1735 TEST_P(QuicConnectionTest, AbandonAllFEC) { 1738 TEST_P(QuicConnectionTest, AbandonAllFEC) {
1736 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1739 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1737 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( 1740 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator(
1738 &connection_)->IsFecEnabled()); 1741 &connection_)->IsFecEnabled());
1739 1742
1740 // 1 Data and 1 FEC packet. 1743 // 3 Data and 3 FEC packet.
1741 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); 1744 EXPECT_CALL(*send_algorithm_,
1745 OnPacketSent(_, _, _, _, HAS_RETRANSMITTABLE_DATA)).Times(6);
1742 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); 1746 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr);
1743 // Send some more data afterwards to ensure early retransmit doesn't trigger. 1747 // Send some more data afterwards to ensure early retransmit doesn't trigger.
1744 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, nullptr); 1748 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, nullptr);
1745 // Advance the time so not all the FEC packets are abandoned. 1749 // Advance the time so not all the FEC packets are abandoned.
1746 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); 1750 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1));
1747 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, nullptr); 1751 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, nullptr);
1748 1752
1749 QuicAckFrame ack_fec = InitAckFrame(5); 1753 QuicAckFrame ack_fec = InitAckFrame(5);
1750 // Ack all data packets, but no fec packets. 1754 // Ack all data packets, but no fec packets.
1751 NackPacket(2, &ack_fec); 1755 NackPacket(2, &ack_fec);
(...skipping 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after
4185 QuicBlockedFrame blocked; 4189 QuicBlockedFrame blocked;
4186 blocked.stream_id = 3; 4190 blocked.stream_id = 3;
4187 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 4191 EXPECT_CALL(visitor_, OnBlockedFrames(_));
4188 ProcessFramePacket(QuicFrame(&blocked)); 4192 ProcessFramePacket(QuicFrame(&blocked));
4189 EXPECT_TRUE(ack_alarm->IsSet()); 4193 EXPECT_TRUE(ack_alarm->IsSet());
4190 } 4194 }
4191 4195
4192 } // namespace 4196 } // namespace
4193 } // namespace test 4197 } // namespace test
4194 } // namespace net 4198 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/time_loss_algorithm_test.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698