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

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

Issue 2393933002: Move the logic from SendAlgorithmInterface::RetransmissionDelay() into QuicSentPacketManager, becau… (Closed)
Patch Set: Created 4 years, 2 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
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/core/quic_connection.h" 5 #include "net/quic/core/quic_connection.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <utility> 10 #include <utility>
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 AckResponse::kDefer); 715 AckResponse::kDefer);
716 connection_.set_visitor(&visitor_); 716 connection_.set_visitor(&visitor_);
717 connection_.SetSendAlgorithm(kDefaultPathId, send_algorithm_); 717 connection_.SetSendAlgorithm(kDefaultPathId, send_algorithm_);
718 connection_.SetLossAlgorithm(kDefaultPathId, loss_algorithm_.get()); 718 connection_.SetLossAlgorithm(kDefaultPathId, loss_algorithm_.get());
719 framer_.set_received_entropy_calculator(&entropy_calculator_); 719 framer_.set_received_entropy_calculator(&entropy_calculator_);
720 peer_framer_.set_received_entropy_calculator(&peer_entropy_calculator_); 720 peer_framer_.set_received_entropy_calculator(&peer_entropy_calculator_);
721 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)) 721 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
722 .WillRepeatedly(Return(QuicTime::Delta::Zero())); 722 .WillRepeatedly(Return(QuicTime::Delta::Zero()));
723 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 723 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
724 .Times(AnyNumber()); 724 .Times(AnyNumber());
725 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
726 .WillRepeatedly(Return(QuicTime::Delta::Zero()));
727 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) 725 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
728 .WillRepeatedly(Return(kDefaultTCPMSS)); 726 .WillRepeatedly(Return(kDefaultTCPMSS));
729 EXPECT_CALL(*send_algorithm_, PacingRate(_)) 727 EXPECT_CALL(*send_algorithm_, PacingRate(_))
730 .WillRepeatedly(Return(QuicBandwidth::Zero())); 728 .WillRepeatedly(Return(QuicBandwidth::Zero()));
731 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 729 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
732 .WillByDefault(Return(true)); 730 .WillByDefault(Return(true));
733 EXPECT_CALL(*send_algorithm_, HasReliableBandwidthEstimate()) 731 EXPECT_CALL(*send_algorithm_, HasReliableBandwidthEstimate())
734 .Times(AnyNumber()); 732 .Times(AnyNumber());
735 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) 733 EXPECT_CALL(*send_algorithm_, BandwidthEstimate())
736 .Times(AnyNumber()) 734 .Times(AnyNumber())
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2767 EXPECT_TRUE(retransmission_alarm->IsSet()); 2765 EXPECT_TRUE(retransmission_alarm->IsSet());
2768 EXPECT_EQ(clock_.Now() + DefaultRetransmissionTime(), 2766 EXPECT_EQ(clock_.Now() + DefaultRetransmissionTime(),
2769 retransmission_alarm->deadline()); 2767 retransmission_alarm->deadline());
2770 2768
2771 // Advance the time right before the RTO, then receive an ack for the first 2769 // Advance the time right before the RTO, then receive an ack for the first
2772 // packet to delay the RTO. 2770 // packet to delay the RTO.
2773 clock_.AdvanceTime(DefaultRetransmissionTime()); 2771 clock_.AdvanceTime(DefaultRetransmissionTime());
2774 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 2772 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2775 QuicAckFrame ack = InitAckFrame(1); 2773 QuicAckFrame ack = InitAckFrame(1);
2776 ProcessAckPacket(&ack); 2774 ProcessAckPacket(&ack);
2775 // Now we have an RTT sample of DefaultRetransmissionTime(500ms),
2776 // so the RTO has increased to 2 * SRTT.
2777 EXPECT_TRUE(retransmission_alarm->IsSet()); 2777 EXPECT_TRUE(retransmission_alarm->IsSet());
2778 EXPECT_GT(retransmission_alarm->deadline(), clock_.Now()); 2778 EXPECT_EQ(retransmission_alarm->deadline(),
2779 clock_.Now() + 2 * DefaultRetransmissionTime());
2779 2780
2780 // Move forward past the original RTO and ensure the RTO is still pending. 2781 // Move forward past the original RTO and ensure the RTO is still pending.
2781 clock_.AdvanceTime(2 * DefaultRetransmissionTime()); 2782 clock_.AdvanceTime(2 * DefaultRetransmissionTime());
2782 2783
2783 // Ensure the second packet gets retransmitted when it finally fires. 2784 // Ensure the second packet gets retransmitted when it finally fires.
2784 EXPECT_TRUE(retransmission_alarm->IsSet()); 2785 EXPECT_TRUE(retransmission_alarm->IsSet());
2785 EXPECT_LT(retransmission_alarm->deadline(), clock_.ApproximateNow()); 2786 EXPECT_EQ(retransmission_alarm->deadline(), clock_.ApproximateNow());
2786 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 2787 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
2787 // Manually cancel the alarm to simulate a real test. 2788 // Manually cancel the alarm to simulate a real test.
2788 connection_.GetRetransmissionAlarm()->Fire(); 2789 connection_.GetRetransmissionAlarm()->Fire();
2789 2790
2790 // The new retransmitted packet number should set the RTO to a larger value 2791 // The new retransmitted packet number should set the RTO to a larger value
2791 // than previously. 2792 // than previously.
2792 EXPECT_TRUE(retransmission_alarm->IsSet()); 2793 EXPECT_TRUE(retransmission_alarm->IsSet());
2793 QuicTime next_rto_time = retransmission_alarm->deadline(); 2794 QuicTime next_rto_time = retransmission_alarm->deadline();
2794 QuicTime expected_rto_time = 2795 QuicTime expected_rto_time =
2795 connection_.sent_packet_manager().GetRetransmissionTime(); 2796 connection_.sent_packet_manager().GetRetransmissionTime();
(...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after
5263 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 5264 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
5264 EXPECT_EQ(1u, writer_->frame_count()); 5265 EXPECT_EQ(1u, writer_->frame_count());
5265 EXPECT_FALSE(writer_->connection_close_frames().empty()); 5266 EXPECT_FALSE(writer_->connection_close_frames().empty());
5266 // Ack frame is not bundled in connection close packet. 5267 // Ack frame is not bundled in connection close packet.
5267 EXPECT_TRUE(writer_->ack_frames().empty()); 5268 EXPECT_TRUE(writer_->ack_frames().empty());
5268 } 5269 }
5269 5270
5270 } // namespace 5271 } // namespace
5271 } // namespace test 5272 } // namespace test
5272 } // namespace net 5273 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/congestion_control/tcp_cubic_sender_packets_test.cc ('k') | net/quic/core/quic_sent_packet_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698