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

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

Issue 114683002: Merge the QUIC unacked packet map with the unacked fec packet map and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more try Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_sent_packet_manager.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/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 TestConnectionHelper::TestAlarm* GetAckAlarm() { 465 TestConnectionHelper::TestAlarm* GetAckAlarm() {
466 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( 466 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
467 QuicConnectionPeer::GetAckAlarm(this)); 467 QuicConnectionPeer::GetAckAlarm(this));
468 } 468 }
469 469
470 TestConnectionHelper::TestAlarm* GetRetransmissionAlarm() { 470 TestConnectionHelper::TestAlarm* GetRetransmissionAlarm() {
471 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( 471 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
472 QuicConnectionPeer::GetRetransmissionAlarm(this)); 472 QuicConnectionPeer::GetRetransmissionAlarm(this));
473 } 473 }
474 474
475 TestConnectionHelper::TestAlarm* GetAbandonFecAlarm() {
476 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
477 QuicConnectionPeer::GetAbandonFecAlarm(this));
478 }
479
480 TestConnectionHelper::TestAlarm* GetSendAlarm() { 475 TestConnectionHelper::TestAlarm* GetSendAlarm() {
481 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( 476 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
482 QuicConnectionPeer::GetSendAlarm(this)); 477 QuicConnectionPeer::GetSendAlarm(this));
483 } 478 }
484 479
485 TestConnectionHelper::TestAlarm* GetResumeWritesAlarm() { 480 TestConnectionHelper::TestAlarm* GetResumeWritesAlarm() {
486 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( 481 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
487 QuicConnectionPeer::GetResumeWritesAlarm(this)); 482 QuicConnectionPeer::GetResumeWritesAlarm(this));
488 } 483 }
489 484
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 TEST_F(QuicConnectionTest, AbandonFECFromCongestionWindow) { 1287 TEST_F(QuicConnectionTest, AbandonFECFromCongestionWindow) {
1293 connection_.options()->max_packets_per_fec_group = 1; 1288 connection_.options()->max_packets_per_fec_group = 1;
1294 // 1 Data and 1 FEC packet. 1289 // 1 Data and 1 FEC packet.
1295 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); 1290 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
1296 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); 1291 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
1297 1292
1298 const QuicTime::Delta retransmission_time = 1293 const QuicTime::Delta retransmission_time =
1299 QuicTime::Delta::FromMilliseconds(5000); 1294 QuicTime::Delta::FromMilliseconds(5000);
1300 clock_.AdvanceTime(retransmission_time); 1295 clock_.AdvanceTime(retransmission_time);
1301 1296
1302 // Abandon FEC packet. 1297 // Abandon FEC packet and data packet.
1303 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(1); 1298 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(2);
1299 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
1300 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
1304 EXPECT_CALL(visitor_, OnCanWrite()); 1301 EXPECT_CALL(visitor_, OnCanWrite());
1305 connection_.OnAbandonFecTimeout(); 1302 connection_.OnRetransmissionTimeout();
1306 } 1303 }
1307 1304
1308 TEST_F(QuicConnectionTest, DontAbandonAckedFEC) { 1305 TEST_F(QuicConnectionTest, DontAbandonAckedFEC) {
1309 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1306 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1310 connection_.options()->max_packets_per_fec_group = 1; 1307 connection_.options()->max_packets_per_fec_group = 1;
1311 1308
1312 // 1 Data and 1 FEC packet. 1309 // 1 Data and 1 FEC packet.
1313 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); 1310 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6);
1314 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); 1311 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
1315 // Send some more data afterwards to ensure early retransmit doesn't trigger. 1312 // Send some more data afterwards to ensure early retransmit doesn't trigger.
(...skipping 10 matching lines...) Expand all
1326 QuicConnectionPeer::GetSentEntropyHash(&connection_, 1); 1323 QuicConnectionPeer::GetSentEntropyHash(&connection_, 1);
1327 1324
1328 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _, _)).Times(1); 1325 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _, _)).Times(1);
1329 1326
1330 ProcessAckPacket(&ack_fec); 1327 ProcessAckPacket(&ack_fec);
1331 1328
1332 clock_.AdvanceTime(DefaultRetransmissionTime()); 1329 clock_.AdvanceTime(DefaultRetransmissionTime());
1333 1330
1334 // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent 1331 // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent
1335 // FEC packets. 1332 // FEC packets.
1336 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(2); 1333 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(5);
1337 connection_.GetAbandonFecAlarm()->Fire(); 1334 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
1335 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3);
1336 connection_.GetRetransmissionAlarm()->Fire();
1337 }
1338
1339 TEST_F(QuicConnectionTest, DontAbandonAllFEC) {
1340 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1341 connection_.options()->max_packets_per_fec_group = 1;
1342
1343 // 1 Data and 1 FEC packet.
1344 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6);
1345 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
1346 // Send some more data afterwards to ensure early retransmit doesn't trigger.
1347 connection_.SendStreamDataWithString(1, "foo", 3, !kFin, NULL);
1348 // Advance the time so not all the FEC packets are abandoned.
1349 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1));
1350 connection_.SendStreamDataWithString(1, "foo", 6, !kFin, NULL);
1351
1352 QuicAckFrame ack_fec(5, QuicTime::Zero(), 1);
1353 // Ack all data packets, but no fec packets.
1354 ack_fec.received_info.missing_packets.insert(2);
1355 ack_fec.received_info.missing_packets.insert(4);
1356 ack_fec.received_info.entropy_hash =
1357 QuicConnectionPeer::GetSentEntropyHash(&connection_, 5) ^
1358 QuicConnectionPeer::GetSentEntropyHash(&connection_, 4) ^
1359 QuicConnectionPeer::GetSentEntropyHash(&connection_, 3) ^
1360 QuicConnectionPeer::GetSentEntropyHash(&connection_, 2) ^
1361 QuicConnectionPeer::GetSentEntropyHash(&connection_, 1);
1362
1363 // Lose the first FEC packet and ack the three data packets.
1364 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _, _)).Times(3);
1365 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _));
1366 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _));
1367 ProcessAckPacket(&ack_fec);
1368
1369 clock_.AdvanceTime(DefaultRetransmissionTime().Subtract(
1370 QuicTime::Delta::FromMilliseconds(1)));
1371
1372 // Don't abandon the acked FEC packet, but it will abandon 1 of the subsequent
1373 // FEC packets.
1374 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(4, _));
1375 connection_.GetRetransmissionAlarm()->Fire();
1376
1377 // Ensure the connection's alarm is still set, in order to abandon the third
1378 // FEC packet.
1379 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1338 } 1380 }
1339 1381
1340 TEST_F(QuicConnectionTest, FramePacking) { 1382 TEST_F(QuicConnectionTest, FramePacking) {
1341 // Block the connection. 1383 // Block the connection.
1342 connection_.GetSendAlarm()->Set( 1384 connection_.GetSendAlarm()->Set(
1343 clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(1))); 1385 clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(1)));
1344 1386
1345 // Send an ack and two stream frames in 1 packet by queueing them. 1387 // Send an ack and two stream frames in 1 packet by queueing them.
1346 connection_.SendAck(); 1388 connection_.SendAck();
1347 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( 1389 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
(...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 true); 3379 true);
3338 TestConnection client(guid_, IPEndPoint(), helper_.get(), writer_.get(), 3380 TestConnection client(guid_, IPEndPoint(), helper_.get(), writer_.get(),
3339 false); 3381 false);
3340 EXPECT_TRUE(client.sent_packet_manager().using_pacing()); 3382 EXPECT_TRUE(client.sent_packet_manager().using_pacing());
3341 EXPECT_FALSE(server.sent_packet_manager().using_pacing()); 3383 EXPECT_FALSE(server.sent_packet_manager().using_pacing());
3342 } 3384 }
3343 3385
3344 } // namespace 3386 } // namespace
3345 } // namespace test 3387 } // namespace test
3346 } // namespace net 3388 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_sent_packet_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698