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

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

Issue 1009243002: Do not retransmit QUIC data for streams that have been reset. Protected (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Move_QUIC_reads_88573234
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
« 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 304 }
305 305
306 const vector<QuicStopWaitingFrame>& stop_waiting_frames() const { 306 const vector<QuicStopWaitingFrame>& stop_waiting_frames() const {
307 return framer_.stop_waiting_frames(); 307 return framer_.stop_waiting_frames();
308 } 308 }
309 309
310 const vector<QuicConnectionCloseFrame>& connection_close_frames() const { 310 const vector<QuicConnectionCloseFrame>& connection_close_frames() const {
311 return framer_.connection_close_frames(); 311 return framer_.connection_close_frames();
312 } 312 }
313 313
314 const vector<QuicRstStreamFrame>& rst_stream_frames() const {
315 return framer_.rst_stream_frames();
316 }
317
314 const vector<QuicStreamFrame>& stream_frames() const { 318 const vector<QuicStreamFrame>& stream_frames() const {
315 return framer_.stream_frames(); 319 return framer_.stream_frames();
316 } 320 }
317 321
318 const vector<QuicPingFrame>& ping_frames() const { 322 const vector<QuicPingFrame>& ping_frames() const {
319 return framer_.ping_frames(); 323 return framer_.ping_frames();
320 } 324 }
321 325
322 size_t last_packet_size() { 326 size_t last_packet_size() {
323 return last_packet_size_; 327 return last_packet_size_;
(...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 lost_packets.insert(2); 2199 lost_packets.insert(2);
2196 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) 2200 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
2197 .WillOnce(Return(lost_packets)); 2201 .WillOnce(Return(lost_packets));
2198 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 2202 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2199 EXPECT_CALL(*send_algorithm_, 2203 EXPECT_CALL(*send_algorithm_,
2200 OnPacketSent(_, _, _, second_packet_size - kQuicVersionSize, _)). 2204 OnPacketSent(_, _, _, second_packet_size - kQuicVersionSize, _)).
2201 Times(1); 2205 Times(1);
2202 ProcessAckPacket(&nack_two); 2206 ProcessAckPacket(&nack_two);
2203 } 2207 }
2204 2208
2209 TEST_P(QuicConnectionTest, DoNotSendQueuedPacketForResetStream) {
2210 ValueRestore<bool> old_flag(&FLAGS_quic_do_not_retransmit_for_reset_streams,
2211 true);
2212
2213 // Block the connection to queue the packet.
2214 BlockOnNextWrite();
2215
2216 QuicStreamId stream_id = 2;
2217 connection_.SendStreamDataWithString(stream_id, "foo", 0, !kFin, nullptr);
2218
2219 // Now that there is a queued packet, reset the stream.
2220 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
2221
2222 // Unblock the connection and verify that only the RST_STREAM is sent.
2223 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2224 writer_->SetWritable();
2225 connection_.OnCanWrite();
2226 EXPECT_EQ(1u, writer_->frame_count());
2227 EXPECT_EQ(1u, writer_->rst_stream_frames().size());
2228 }
2229
2230 TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnNack) {
2231 ValueRestore<bool> old_flag(&FLAGS_quic_do_not_retransmit_for_reset_streams,
2232 true);
2233
2234 QuicStreamId stream_id = 2;
2235 QuicPacketSequenceNumber last_packet;
2236 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
2237 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet);
2238 SendStreamDataToPeer(stream_id, "fooos", 7, !kFin, &last_packet);
2239
2240 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2241 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
2242
2243 // Lose a packet and ensure it does not trigger retransmission.
2244 QuicAckFrame nack_two = InitAckFrame(last_packet);
2245 NackPacket(last_packet - 1, &nack_two);
2246 SequenceNumberSet lost_packets;
2247 lost_packets.insert(last_packet - 1);
2248 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2249 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
2250 .WillOnce(Return(lost_packets));
2251 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2252 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
2253 ProcessAckPacket(&nack_two);
2254 }
2255
2256 TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnRTO) {
2257 ValueRestore<bool> old_flag(&FLAGS_quic_do_not_retransmit_for_reset_streams,
2258 true);
2259
2260 QuicStreamId stream_id = 2;
2261 QuicPacketSequenceNumber last_packet;
2262 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
2263
2264 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2265 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
2266
2267 // Fire the RTO and verify that the RST_STREAM is resent, not stream data.
2268 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2269 clock_.AdvanceTime(DefaultRetransmissionTime());
2270 connection_.GetRetransmissionAlarm()->Fire();
2271 EXPECT_EQ(1u, writer_->frame_count());
2272 EXPECT_EQ(1u, writer_->rst_stream_frames().size());
2273 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
2274 }
2275
2276 TEST_P(QuicConnectionTest, DoNotSendPendingRetransmissionForResetStream) {
2277 ValueRestore<bool> old_flag(&FLAGS_quic_do_not_retransmit_for_reset_streams,
2278 true);
2279
2280 QuicStreamId stream_id = 2;
2281 QuicPacketSequenceNumber last_packet;
2282 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
2283 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet);
2284 BlockOnNextWrite();
2285 connection_.SendStreamDataWithString(stream_id, "fooos", 7, !kFin, nullptr);
2286
2287 // Lose a packet which will trigger a pending retransmission.
2288 QuicAckFrame ack = InitAckFrame(last_packet);
2289 NackPacket(last_packet - 1, &ack);
2290 SequenceNumberSet lost_packets;
2291 lost_packets.insert(last_packet - 1);
2292 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2293 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
2294 .WillOnce(Return(lost_packets));
2295 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2296 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
2297 ProcessAckPacket(&ack);
2298
2299 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
2300
2301 // Unblock the connection and verify that the RST_STREAM is sent but not the
2302 // second data packet nor a retransmit.
2303 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2304 writer_->SetWritable();
2305 connection_.OnCanWrite();
2306 EXPECT_EQ(1u, writer_->frame_count());
2307 EXPECT_EQ(1u, writer_->rst_stream_frames().size());
2308 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
2309 }
2310
2205 TEST_P(QuicConnectionTest, DiscardRetransmit) { 2311 TEST_P(QuicConnectionTest, DiscardRetransmit) {
2206 QuicPacketSequenceNumber last_packet; 2312 QuicPacketSequenceNumber last_packet;
2207 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 2313 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
2208 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2 2314 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
2209 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3 2315 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3
2210 2316
2211 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2317 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2212 2318
2213 // Instigate a loss with an ack. 2319 // Instigate a loss with an ack.
2214 QuicAckFrame nack_two = InitAckFrame(3); 2320 QuicAckFrame nack_two = InitAckFrame(3);
(...skipping 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after
4351 // Regression test for b/18594622 4457 // Regression test for b/18594622
4352 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 4458 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
4353 EXPECT_DFATAL( 4459 EXPECT_DFATAL(
4354 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), 4460 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()),
4355 "Attempt to send empty stream frame"); 4461 "Attempt to send empty stream frame");
4356 } 4462 }
4357 4463
4358 } // namespace 4464 } // namespace
4359 } // namespace test 4465 } // namespace test
4360 } // namespace net 4466 } // 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