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

Side by Side Diff: net/quic/congestion_control/prr_sender_test.cc

Issue 972033002: Change QUIC's PrrSender::TimeUntilSend to accept bytes instead of packets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Discard_acks_87419283
Patch Set: Created 5 years, 9 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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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/prr_sender.h" 5 #include "net/quic/congestion_control/prr_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "net/quic/crypto/crypto_protocol.h" 10 #include "net/quic/crypto/crypto_protocol.h"
(...skipping 17 matching lines...) Expand all
28 QuicByteCount bytes_in_flight = num_packets_in_flight * kMaxSegmentSize; 28 QuicByteCount bytes_in_flight = num_packets_in_flight * kMaxSegmentSize;
29 const QuicPacketCount ssthresh_after_loss = num_packets_in_flight / 2; 29 const QuicPacketCount ssthresh_after_loss = num_packets_in_flight / 2;
30 const QuicByteCount congestion_window = ssthresh_after_loss * kMaxSegmentSize; 30 const QuicByteCount congestion_window = ssthresh_after_loss * kMaxSegmentSize;
31 31
32 prr.OnPacketLost(bytes_in_flight); 32 prr.OnPacketLost(bytes_in_flight);
33 // Ack a packet. PRR allows one packet to leave immediately. 33 // Ack a packet. PRR allows one packet to leave immediately.
34 prr.OnPacketAcked(kMaxSegmentSize); 34 prr.OnPacketAcked(kMaxSegmentSize);
35 bytes_in_flight -= kMaxSegmentSize; 35 bytes_in_flight -= kMaxSegmentSize;
36 EXPECT_EQ(QuicTime::Delta::Zero(), 36 EXPECT_EQ(QuicTime::Delta::Zero(),
37 prr.TimeUntilSend(congestion_window, bytes_in_flight, 37 prr.TimeUntilSend(congestion_window, bytes_in_flight,
38 ssthresh_after_loss)); 38 ssthresh_after_loss * kMaxSegmentSize));
39 // Send retransmission. 39 // Send retransmission.
40 prr.OnPacketSent(kMaxSegmentSize); 40 prr.OnPacketSent(kMaxSegmentSize);
41 // PRR shouldn't allow sending any more packets. 41 // PRR shouldn't allow sending any more packets.
42 EXPECT_EQ(QuicTime::Delta::Infinite(), 42 EXPECT_EQ(QuicTime::Delta::Infinite(),
43 prr.TimeUntilSend(congestion_window, bytes_in_flight, 43 prr.TimeUntilSend(congestion_window, bytes_in_flight,
44 ssthresh_after_loss)); 44 ssthresh_after_loss * kMaxSegmentSize));
45 45
46 // One packet is lost, and one ack was consumed above. PRR now paces 46 // One packet is lost, and one ack was consumed above. PRR now paces
47 // transmissions through the remaining 48 acks. PRR will alternatively 47 // transmissions through the remaining 48 acks. PRR will alternatively
48 // disallow and allow a packet to be sent in response to an ack. 48 // disallow and allow a packet to be sent in response to an ack.
49 for (uint64 i = 0; i < ssthresh_after_loss - 1; ++i) { 49 for (uint64 i = 0; i < ssthresh_after_loss - 1; ++i) {
50 // Ack a packet. PRR shouldn't allow sending a packet in response. 50 // Ack a packet. PRR shouldn't allow sending a packet in response.
51 prr.OnPacketAcked(kMaxSegmentSize); 51 prr.OnPacketAcked(kMaxSegmentSize);
52 bytes_in_flight -= kMaxSegmentSize; 52 bytes_in_flight -= kMaxSegmentSize;
53 EXPECT_EQ(QuicTime::Delta::Infinite(), 53 EXPECT_EQ(QuicTime::Delta::Infinite(),
54 prr.TimeUntilSend(congestion_window, bytes_in_flight, 54 prr.TimeUntilSend(congestion_window, bytes_in_flight,
55 ssthresh_after_loss)); 55 ssthresh_after_loss * kMaxSegmentSize));
56 // Ack another packet. PRR should now allow sending a packet in response. 56 // Ack another packet. PRR should now allow sending a packet in response.
57 prr.OnPacketAcked(kMaxSegmentSize); 57 prr.OnPacketAcked(kMaxSegmentSize);
58 bytes_in_flight -= kMaxSegmentSize; 58 bytes_in_flight -= kMaxSegmentSize;
59 EXPECT_EQ(QuicTime::Delta::Zero(), 59 EXPECT_EQ(QuicTime::Delta::Zero(),
60 prr.TimeUntilSend(congestion_window, bytes_in_flight, 60 prr.TimeUntilSend(congestion_window, bytes_in_flight,
61 ssthresh_after_loss)); 61 ssthresh_after_loss * kMaxSegmentSize));
62 // Send a packet in response. 62 // Send a packet in response.
63 prr.OnPacketSent(kMaxSegmentSize); 63 prr.OnPacketSent(kMaxSegmentSize);
64 bytes_in_flight += kMaxSegmentSize; 64 bytes_in_flight += kMaxSegmentSize;
65 } 65 }
66 66
67 // Since bytes_in_flight is now equal to congestion_window, PRR now maintains 67 // Since bytes_in_flight is now equal to congestion_window, PRR now maintains
68 // packet conservation, allowing one packet to be sent in response to an ack. 68 // packet conservation, allowing one packet to be sent in response to an ack.
69 EXPECT_EQ(congestion_window, bytes_in_flight); 69 EXPECT_EQ(congestion_window, bytes_in_flight);
70 for (int i = 0; i < 10; ++i) { 70 for (int i = 0; i < 10; ++i) {
71 // Ack a packet. 71 // Ack a packet.
72 prr.OnPacketAcked(kMaxSegmentSize); 72 prr.OnPacketAcked(kMaxSegmentSize);
73 bytes_in_flight -= kMaxSegmentSize; 73 bytes_in_flight -= kMaxSegmentSize;
74 EXPECT_EQ(QuicTime::Delta::Zero(), 74 EXPECT_EQ(QuicTime::Delta::Zero(),
75 prr.TimeUntilSend(congestion_window, bytes_in_flight, 75 prr.TimeUntilSend(congestion_window, bytes_in_flight,
76 ssthresh_after_loss)); 76 ssthresh_after_loss * kMaxSegmentSize));
77 // Send a packet in response, since PRR allows it. 77 // Send a packet in response, since PRR allows it.
78 prr.OnPacketSent(kMaxSegmentSize); 78 prr.OnPacketSent(kMaxSegmentSize);
79 bytes_in_flight += kMaxSegmentSize; 79 bytes_in_flight += kMaxSegmentSize;
80 80
81 // Since bytes_in_flight is equal to the congestion_window, 81 // Since bytes_in_flight is equal to the congestion_window,
82 // PRR disallows sending. 82 // PRR disallows sending.
83 EXPECT_EQ(congestion_window, bytes_in_flight); 83 EXPECT_EQ(congestion_window, bytes_in_flight);
84 EXPECT_EQ(QuicTime::Delta::Infinite(), 84 EXPECT_EQ(QuicTime::Delta::Infinite(),
85 prr.TimeUntilSend(congestion_window, bytes_in_flight, 85 prr.TimeUntilSend(congestion_window, bytes_in_flight,
86 ssthresh_after_loss)); 86 ssthresh_after_loss * kMaxSegmentSize));
87 } 87 }
88 } 88 }
89 89
90 TEST_F(PrrSenderTest, BurstLossResultsInSlowStart) { 90 TEST_F(PrrSenderTest, BurstLossResultsInSlowStart) {
91 PrrSender prr; 91 PrrSender prr;
92 QuicByteCount bytes_in_flight = 20 * kMaxSegmentSize; 92 QuicByteCount bytes_in_flight = 20 * kMaxSegmentSize;
93 const QuicPacketCount num_packets_lost = 13; 93 const QuicPacketCount num_packets_lost = 13;
94 const QuicPacketCount ssthresh_after_loss = 10; 94 const QuicPacketCount ssthresh_after_loss = 10;
95 const QuicByteCount congestion_window = ssthresh_after_loss * kMaxSegmentSize; 95 const QuicByteCount congestion_window = ssthresh_after_loss * kMaxSegmentSize;
96 96
97 // Lose 13 packets. 97 // Lose 13 packets.
98 bytes_in_flight -= num_packets_lost * kMaxSegmentSize; 98 bytes_in_flight -= num_packets_lost * kMaxSegmentSize;
99 prr.OnPacketLost(bytes_in_flight); 99 prr.OnPacketLost(bytes_in_flight);
100 100
101 // PRR-SSRB will allow the following 3 acks to send up to 2 packets. 101 // PRR-SSRB will allow the following 3 acks to send up to 2 packets.
102 for (int i = 0; i < 3; ++i) { 102 for (int i = 0; i < 3; ++i) {
103 prr.OnPacketAcked(kMaxSegmentSize); 103 prr.OnPacketAcked(kMaxSegmentSize);
104 bytes_in_flight -= kMaxSegmentSize; 104 bytes_in_flight -= kMaxSegmentSize;
105 // PRR-SSRB should allow two packets to be sent. 105 // PRR-SSRB should allow two packets to be sent.
106 for (int j = 0; j < 2; ++j) { 106 for (int j = 0; j < 2; ++j) {
107 EXPECT_EQ(QuicTime::Delta::Zero(), 107 EXPECT_EQ(QuicTime::Delta::Zero(),
108 prr.TimeUntilSend(congestion_window, bytes_in_flight, 108 prr.TimeUntilSend(congestion_window, bytes_in_flight,
109 ssthresh_after_loss)); 109 ssthresh_after_loss * kMaxSegmentSize));
110 // Send a packet in response. 110 // Send a packet in response.
111 prr.OnPacketSent(kMaxSegmentSize); 111 prr.OnPacketSent(kMaxSegmentSize);
112 bytes_in_flight += kMaxSegmentSize; 112 bytes_in_flight += kMaxSegmentSize;
113 } 113 }
114 // PRR should allow no more than 2 packets in response to an ack. 114 // PRR should allow no more than 2 packets in response to an ack.
115 EXPECT_EQ(QuicTime::Delta::Infinite(), 115 EXPECT_EQ(QuicTime::Delta::Infinite(),
116 prr.TimeUntilSend(congestion_window, bytes_in_flight, 116 prr.TimeUntilSend(congestion_window, bytes_in_flight,
117 ssthresh_after_loss)); 117 ssthresh_after_loss * kMaxSegmentSize));
118 } 118 }
119 119
120 // Out of SSRB mode, PRR allows one send in response to each ack. 120 // Out of SSRB mode, PRR allows one send in response to each ack.
121 for (int i = 0; i < 10; ++i) { 121 for (int i = 0; i < 10; ++i) {
122 prr.OnPacketAcked(kMaxSegmentSize); 122 prr.OnPacketAcked(kMaxSegmentSize);
123 bytes_in_flight -= kMaxSegmentSize; 123 bytes_in_flight -= kMaxSegmentSize;
124 EXPECT_EQ(QuicTime::Delta::Zero(), 124 EXPECT_EQ(QuicTime::Delta::Zero(),
125 prr.TimeUntilSend(congestion_window, bytes_in_flight, 125 prr.TimeUntilSend(congestion_window, bytes_in_flight,
126 ssthresh_after_loss)); 126 ssthresh_after_loss * kMaxSegmentSize));
127 // Send a packet in response. 127 // Send a packet in response.
128 prr.OnPacketSent(kMaxSegmentSize); 128 prr.OnPacketSent(kMaxSegmentSize);
129 bytes_in_flight += kMaxSegmentSize; 129 bytes_in_flight += kMaxSegmentSize;
130 } 130 }
131 } 131 }
132 132
133 } // namespace test 133 } // namespace test
134 } // namespace net 134 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/prr_sender.cc ('k') | net/quic/congestion_control/tcp_cubic_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698