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

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

Issue 2065463002: Always send queued retransmission packets, because of write blocked socket, once the socket gets un… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 6 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 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 EXPECT_EQ(1u, writer_->frame_count()); 2234 EXPECT_EQ(1u, writer_->frame_count());
2235 if (version() > QUIC_VERSION_28) { 2235 if (version() > QUIC_VERSION_28) {
2236 EXPECT_EQ(0u, writer_->rst_stream_frames().size()); 2236 EXPECT_EQ(0u, writer_->rst_stream_frames().size());
2237 } else { 2237 } else {
2238 EXPECT_EQ(1u, writer_->rst_stream_frames().size()); 2238 EXPECT_EQ(1u, writer_->rst_stream_frames().size());
2239 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id); 2239 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
2240 } 2240 }
2241 } 2241 }
2242 2242
2243 TEST_P(QuicConnectionTest, DiscardRetransmit) { 2243 TEST_P(QuicConnectionTest, DiscardRetransmit) {
2244 ValueRestore<bool> old_flag(&FLAGS_quic_always_write_queued_retransmissions,
2245 true);
2244 QuicPacketNumber last_packet; 2246 QuicPacketNumber last_packet;
2245 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 2247 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
2246 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2 2248 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
2247 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3 2249 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3
2248 2250
2249 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2251 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2250 2252
2251 // Instigate a loss with an ack. 2253 // Instigate a loss with an ack.
2252 QuicAckFrame nack_two = InitAckFrame(3); 2254 QuicAckFrame nack_two = InitAckFrame(3);
2253 NackPacket(2, &nack_two); 2255 NackPacket(2, &nack_two);
(...skipping 18 matching lines...) Expand all
2272 // since the previous transmission has been acked, we will not 2274 // since the previous transmission has been acked, we will not
2273 // send the retransmission. 2275 // send the retransmission.
2274 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); 2276 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
2275 2277
2276 writer_->SetWritable(); 2278 writer_->SetWritable();
2277 connection_.OnCanWrite(); 2279 connection_.OnCanWrite();
2278 2280
2279 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 2281 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2280 } 2282 }
2281 2283
2284 TEST_P(QuicConnectionTest, RetransmitAckedPacket) {
2285 FLAGS_quic_always_write_queued_retransmissions = true;
2286 QuicPacketNumber last_packet;
2287 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
2288 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
2289 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3
2290
2291 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2292
2293 // Instigate a loss with an ack.
2294 QuicAckFrame nack_two = InitAckFrame(3);
2295 NackPacket(2, &nack_two);
2296 // The first nack should trigger a fast retransmission, but we'll be
2297 // write blocked, so the packet will be queued.
2298 BlockOnNextWrite();
2299
2300 SendAlgorithmInterface::CongestionVector lost_packets;
2301 lost_packets.push_back(std::make_pair(2, kMaxPacketSize));
2302 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _))
2303 .WillOnce(SetArgPointee<4>(lost_packets));
2304 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2305 ProcessAckPacket(&nack_two);
2306 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2307
2308 // Now, ack the previous transmission.
2309 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _));
2310 QuicAckFrame ack_all = InitAckFrame(3);
2311 ProcessAckPacket(&ack_all);
2312
2313 // Unblock the socket and attempt to send the queued packets. We will always
2314 // send the retransmission.
2315 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 4, _, _)).Times(1);
2316
2317 writer_->SetWritable();
2318 connection_.OnCanWrite();
2319
2320 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2321 // We do not store retransmittable frames of this retransmission.
2322 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames(
2323 kDefaultPathId, 4));
2324 }
2325
2282 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { 2326 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) {
2283 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2327 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2284 QuicPacketNumber largest_observed; 2328 QuicPacketNumber largest_observed;
2285 QuicByteCount packet_size; 2329 QuicByteCount packet_size;
2286 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 2330 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2287 .WillOnce(DoAll(SaveArg<2>(&largest_observed), SaveArg<3>(&packet_size), 2331 .WillOnce(DoAll(SaveArg<2>(&largest_observed), SaveArg<3>(&packet_size),
2288 Return(true))); 2332 Return(true)));
2289 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 2333 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
2290 2334
2291 QuicAckFrame frame = InitAckFrame(1); 2335 QuicAckFrame frame = InitAckFrame(1);
(...skipping 2739 matching lines...) Expand 10 before | Expand all | Expand 10 after
5031 frame1_.data_length = data->length(); 5075 frame1_.data_length = data->length();
5032 5076
5033 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, 5077 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _,
5034 ConnectionCloseSource::FROM_SELF)); 5078 ConnectionCloseSource::FROM_SELF));
5035 ProcessFramePacket(QuicFrame(&frame1_)); 5079 ProcessFramePacket(QuicFrame(&frame1_));
5036 } 5080 }
5037 5081
5038 } // namespace 5082 } // namespace
5039 } // namespace test 5083 } // namespace test
5040 } // namespace net 5084 } // 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