OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/congestion_control/general_loss_algorithm.h" | 5 #include "net/quic/congestion_control/general_loss_algorithm.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 protected: | 26 protected: |
27 GeneralLossAlgorithmTest() { | 27 GeneralLossAlgorithmTest() { |
28 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100), | 28 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100), |
29 QuicTime::Delta::Zero(), clock_.Now()); | 29 QuicTime::Delta::Zero(), clock_.Now()); |
30 } | 30 } |
31 | 31 |
32 ~GeneralLossAlgorithmTest() override { STLDeleteElements(&packets_); } | 32 ~GeneralLossAlgorithmTest() override { STLDeleteElements(&packets_); } |
33 | 33 |
34 void SendDataPacket(QuicPacketNumber packet_number) { | 34 void SendDataPacket(QuicPacketNumber packet_number) { |
35 packets_.push_back(new QuicEncryptedPacket(nullptr, kDefaultLength)); | 35 packets_.push_back(new QuicEncryptedPacket(nullptr, kDefaultLength)); |
36 QuicFrames* frames = new QuicFrames(); | |
37 QuicStreamFrame* frame = new QuicStreamFrame(); | 36 QuicStreamFrame* frame = new QuicStreamFrame(); |
38 frame->stream_id = kHeadersStreamId; | 37 frame->stream_id = kHeadersStreamId; |
39 frames->push_back(QuicFrame(frame)); | |
40 SerializedPacket packet(kDefaultPathId, packet_number, | 38 SerializedPacket packet(kDefaultPathId, packet_number, |
41 PACKET_1BYTE_PACKET_NUMBER, packets_.back(), 0, | 39 PACKET_1BYTE_PACKET_NUMBER, packets_.back(), 0, |
42 frames, false, false); | 40 false, false); |
| 41 packet.retransmittable_frames.push_back(QuicFrame(frame)); |
43 unacked_packets_.AddSentPacket(&packet, 0, NOT_RETRANSMISSION, clock_.Now(), | 42 unacked_packets_.AddSentPacket(&packet, 0, NOT_RETRANSMISSION, clock_.Now(), |
44 1000, true); | 43 1000, true); |
45 } | 44 } |
46 | 45 |
47 void VerifyLosses(QuicPacketNumber largest_observed, | 46 void VerifyLosses(QuicPacketNumber largest_observed, |
48 QuicPacketNumber* losses_expected, | 47 QuicPacketNumber* losses_expected, |
49 size_t num_losses) { | 48 size_t num_losses) { |
50 unacked_packets_.IncreaseLargestObserved(largest_observed); | 49 unacked_packets_.IncreaseLargestObserved(largest_observed); |
51 PacketNumberSet lost_packets = loss_algorithm_.DetectLostPackets( | 50 PacketNumberSet lost_packets = loss_algorithm_.DetectLostPackets( |
52 unacked_packets_, clock_.Now(), largest_observed, rtt_stats_); | 51 unacked_packets_, clock_.Now(), largest_observed, rtt_stats_); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); | 297 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); |
299 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); | 298 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); |
300 QuicPacketNumber lost[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; | 299 QuicPacketNumber lost[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; |
301 VerifyLosses(10, lost, arraysize(lost)); | 300 VerifyLosses(10, lost, arraysize(lost)); |
302 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); | 301 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); |
303 } | 302 } |
304 | 303 |
305 } // namespace | 304 } // namespace |
306 } // namespace test | 305 } // namespace test |
307 } // namespace net | 306 } // namespace net |
OLD | NEW |