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

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

Issue 2179713004: Deprecate FLAGS_quic_always_write_queued_retransmissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@128171703
Patch Set: Created 4 years, 4 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_connection.cc ('k') | net/quic/quic_flags.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 <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 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 2142
2143 // Unblock the connection and verify that the RST_STREAM is sent and the 2143 // Unblock the connection and verify that the RST_STREAM is sent and the
2144 // second data packet or a retransmit is sent. 2144 // second data packet or a retransmit is sent.
2145 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AtLeast(2)); 2145 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AtLeast(2));
2146 writer_->SetWritable(); 2146 writer_->SetWritable();
2147 connection_.OnCanWrite(); 2147 connection_.OnCanWrite();
2148 EXPECT_EQ(1u, writer_->frame_count()); 2148 EXPECT_EQ(1u, writer_->frame_count());
2149 EXPECT_EQ(0u, writer_->rst_stream_frames().size()); 2149 EXPECT_EQ(0u, writer_->rst_stream_frames().size());
2150 } 2150 }
2151 2151
2152 TEST_P(QuicConnectionTest, DiscardRetransmit) { 2152 TEST_P(QuicConnectionTest, RetransmitAckedPacket) {
2153 FLAGS_quic_always_write_queued_retransmissions = false;
2154 QuicPacketNumber last_packet; 2153 QuicPacketNumber last_packet;
2155 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 2154 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
2156 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2 2155 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
2157 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3
2158
2159 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2160
2161 // Instigate a loss with an ack.
2162 QuicAckFrame nack_two = InitAckFrame(3);
2163 NackPacket(2, &nack_two);
2164 // The first nack should trigger a fast retransmission, but we'll be
2165 // write blocked, so the packet will be queued.
2166 BlockOnNextWrite();
2167
2168 SendAlgorithmInterface::CongestionVector lost_packets;
2169 lost_packets.push_back(std::make_pair(2, kMaxPacketSize));
2170 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _))
2171 .WillOnce(SetArgPointee<4>(lost_packets));
2172 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2173 ProcessAckPacket(&nack_two);
2174 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2175
2176 // Now, ack the previous transmission.
2177 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _));
2178 QuicAckFrame ack_all = InitAckFrame(3);
2179 ProcessAckPacket(&ack_all);
2180
2181 // Unblock the socket and attempt to send the queued packets. However,
2182 // since the previous transmission has been acked, we will not
2183 // send the retransmission.
2184 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
2185
2186 writer_->SetWritable();
2187 connection_.OnCanWrite();
2188
2189 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2190 }
2191
2192 TEST_P(QuicConnectionTest, RetransmitAckedPacket) {
2193 FLAGS_quic_always_write_queued_retransmissions = true;
2194 QuicPacketNumber last_packet;
2195 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
2196 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
2197 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3 2156 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3
2198 2157
2199 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2158 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2200 2159
2201 // Instigate a loss with an ack. 2160 // Instigate a loss with an ack.
2202 QuicAckFrame nack_two = InitAckFrame(3); 2161 QuicAckFrame nack_two = InitAckFrame(3);
2203 NackPacket(2, &nack_two); 2162 NackPacket(2, &nack_two);
2204 // The first nack should trigger a fast retransmission, but we'll be 2163 // The first nack should trigger a fast retransmission, but we'll be
2205 // write blocked, so the packet will be queued. 2164 // write blocked, so the packet will be queued.
2206 BlockOnNextWrite(); 2165 BlockOnNextWrite();
(...skipping 13 matching lines...) Expand all
2220 2179
2221 // Unblock the socket and attempt to send the queued packets. We will always 2180 // Unblock the socket and attempt to send the queued packets. We will always
2222 // send the retransmission. 2181 // send the retransmission.
2223 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 4, _, _)).Times(1); 2182 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 4, _, _)).Times(1);
2224 2183
2225 writer_->SetWritable(); 2184 writer_->SetWritable();
2226 connection_.OnCanWrite(); 2185 connection_.OnCanWrite();
2227 2186
2228 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 2187 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2229 // We do not store retransmittable frames of this retransmission. 2188 // We do not store retransmittable frames of this retransmission.
2230 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames( 2189 EXPECT_FALSE(QuicConnectionPeer::HasRetransmittableFrames(&connection_,
2231 kDefaultPathId, 4)); 2190 kDefaultPathId, 4));
2232 } 2191 }
2233 2192
2234 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { 2193 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) {
2235 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2194 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2236 QuicPacketNumber largest_observed; 2195 QuicPacketNumber largest_observed;
2237 QuicByteCount packet_size; 2196 QuicByteCount packet_size;
2238 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 2197 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2239 .WillOnce(DoAll(SaveArg<2>(&largest_observed), SaveArg<3>(&packet_size), 2198 .WillOnce(DoAll(SaveArg<2>(&largest_observed), SaveArg<3>(&packet_size),
2240 Return(true))); 2199 Return(true)));
2241 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 2200 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 // Ack the sent packet before the callback returns, which happens in 2283 // Ack the sent packet before the callback returns, which happens in
2325 // rare circumstances with write blocked sockets. 2284 // rare circumstances with write blocked sockets.
2326 QuicAckFrame ack = InitAckFrame(1); 2285 QuicAckFrame ack = InitAckFrame(1);
2327 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 2286 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2328 ProcessAckPacket(&ack); 2287 ProcessAckPacket(&ack);
2329 2288
2330 writer_->SetWritable(); 2289 writer_->SetWritable();
2331 connection_.OnCanWrite(); 2290 connection_.OnCanWrite();
2332 // There is now a pending packet, but with no retransmittable frames. 2291 // There is now a pending packet, but with no retransmittable frames.
2333 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); 2292 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
2334 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames( 2293 EXPECT_FALSE(QuicConnectionPeer::HasRetransmittableFrames(&connection_,
2335 ack.path_id, 2)); 2294 ack.path_id, 2));
2336 } 2295 }
2337 2296
2338 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) { 2297 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) {
2339 // Block the connection. 2298 // Block the connection.
2340 BlockOnNextWrite(); 2299 BlockOnNextWrite();
2341 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 2300 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
2342 EXPECT_EQ(1u, writer_->packets_write_attempts()); 2301 EXPECT_EQ(1u, writer_->packets_write_attempts());
2343 EXPECT_TRUE(writer_->IsWriteBlocked()); 2302 EXPECT_TRUE(writer_->IsWriteBlocked());
2344 2303
2345 // Set the send and resumption alarms. Fire the alarms and ensure they don't 2304 // Set the send and resumption alarms. Fire the alarms and ensure they don't
(...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after
4981 frame1_.data_length = data->length(); 4940 frame1_.data_length = data->length();
4982 4941
4983 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, 4942 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _,
4984 ConnectionCloseSource::FROM_SELF)); 4943 ConnectionCloseSource::FROM_SELF));
4985 ProcessFramePacket(QuicFrame(&frame1_)); 4944 ProcessFramePacket(QuicFrame(&frame1_));
4986 } 4945 }
4987 4946
4988 } // namespace 4947 } // namespace
4989 } // namespace test 4948 } // namespace test
4990 } // namespace net 4949 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698