| OLD | NEW |
| 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 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 // GetPacketLengthForOneStream() assumes a stream offset of 0 in determining | 1477 // GetPacketLengthForOneStream() assumes a stream offset of 0 in determining |
| 1478 // packet length. The size of the offset field in a stream frame is 0 for | 1478 // packet length. The size of the offset field in a stream frame is 0 for |
| 1479 // offset 0, and 2 for non-zero offsets up through 64K. Increase | 1479 // offset 0, and 2 for non-zero offsets up through 64K. Increase |
| 1480 // max_packet_length by 2 so that subsequent packets containing subsequent | 1480 // max_packet_length by 2 so that subsequent packets containing subsequent |
| 1481 // stream frames with non-zero offets will fit within the packet length. | 1481 // stream frames with non-zero offets will fit within the packet length. |
| 1482 size_t length = 2 + GetPacketLengthForOneStream( | 1482 size_t length = 2 + GetPacketLengthForOneStream( |
| 1483 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, | 1483 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, |
| 1484 IN_FEC_GROUP, &payload_length); | 1484 IN_FEC_GROUP, &payload_length); |
| 1485 creator->set_max_packet_length(length); | 1485 creator->set_max_packet_length(length); |
| 1486 | 1486 |
| 1487 // Enable FEC. | 1487 // Send 4 protected data packets, which should also trigger 1 FEC packet. |
| 1488 creator->set_max_packets_per_fec_group(2); | 1488 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(5); |
| 1489 | |
| 1490 // Send 4 protected data packets, which will also trigger 2 FEC packets. | |
| 1491 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); | |
| 1492 // The first stream frame will have 2 fewer overhead bytes than the other 3. | 1489 // The first stream frame will have 2 fewer overhead bytes than the other 3. |
| 1493 const string payload(payload_length * 4 + 2, 'a'); | 1490 const string payload(payload_length * 4 + 2, 'a'); |
| 1494 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, NULL); | 1491 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, NULL); |
| 1495 // Expect the FEC group to be closed after SendStreamDataWithString. | 1492 // Expect the FEC group to be closed after SendStreamDataWithString. |
| 1496 EXPECT_FALSE(creator->IsFecGroupOpen()); | 1493 EXPECT_FALSE(creator->IsFecGroupOpen()); |
| 1497 EXPECT_FALSE(creator->IsFecProtected()); | 1494 EXPECT_FALSE(creator->IsFecProtected()); |
| 1498 } | 1495 } |
| 1499 | 1496 |
| 1500 TEST_P(QuicConnectionTest, FECQueueing) { | 1497 TEST_P(QuicConnectionTest, FECQueueing) { |
| 1501 // All packets carry version info till version is negotiated. | 1498 // All packets carry version info till version is negotiated. |
| 1502 size_t payload_length; | 1499 size_t payload_length; |
| 1503 QuicPacketCreator* creator = | 1500 QuicPacketCreator* creator = |
| 1504 QuicConnectionPeer::GetPacketCreator(&connection_); | 1501 QuicConnectionPeer::GetPacketCreator(&connection_); |
| 1505 size_t length = GetPacketLengthForOneStream( | 1502 size_t length = GetPacketLengthForOneStream( |
| 1506 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, | 1503 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, |
| 1507 IN_FEC_GROUP, &payload_length); | 1504 IN_FEC_GROUP, &payload_length); |
| 1508 creator->set_max_packet_length(length); | 1505 creator->set_max_packet_length(length); |
| 1509 // Enable FEC. | 1506 EXPECT_TRUE(creator->IsFecEnabled()); |
| 1510 creator->set_max_packets_per_fec_group(1); | |
| 1511 | 1507 |
| 1512 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1508 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 1513 BlockOnNextWrite(); | 1509 BlockOnNextWrite(); |
| 1514 const string payload(payload_length, 'a'); | 1510 const string payload(payload_length, 'a'); |
| 1515 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, NULL); | 1511 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, NULL); |
| 1516 EXPECT_FALSE(creator->IsFecGroupOpen()); | 1512 EXPECT_FALSE(creator->IsFecGroupOpen()); |
| 1517 EXPECT_FALSE(creator->IsFecProtected()); | 1513 EXPECT_FALSE(creator->IsFecProtected()); |
| 1518 // Expect the first data packet and the fec packet to be queued. | 1514 // Expect the first data packet and the fec packet to be queued. |
| 1519 EXPECT_EQ(2u, connection_.NumQueuedPackets()); | 1515 EXPECT_EQ(2u, connection_.NumQueuedPackets()); |
| 1520 } | 1516 } |
| 1521 | 1517 |
| 1522 TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) { | 1518 TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) { |
| 1523 // Enable FEC. | 1519 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( |
| 1524 QuicConnectionPeer::GetPacketCreator( | 1520 &connection_)->IsFecEnabled()); |
| 1525 &connection_)->set_max_packets_per_fec_group(1); | |
| 1526 | 1521 |
| 1527 // 1 Data and 1 FEC packet. | 1522 // 1 Data and 1 FEC packet. |
| 1528 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); | 1523 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); |
| 1529 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL); | 1524 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL); |
| 1530 | 1525 |
| 1531 const QuicTime::Delta retransmission_time = | 1526 const QuicTime::Delta retransmission_time = |
| 1532 QuicTime::Delta::FromMilliseconds(5000); | 1527 QuicTime::Delta::FromMilliseconds(5000); |
| 1533 clock_.AdvanceTime(retransmission_time); | 1528 clock_.AdvanceTime(retransmission_time); |
| 1534 | 1529 |
| 1535 // Abandon FEC packet and data packet. | 1530 // Abandon FEC packet and data packet. |
| 1536 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 1531 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 1537 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 1532 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
| 1538 EXPECT_CALL(visitor_, OnCanWrite()); | 1533 EXPECT_CALL(visitor_, OnCanWrite()); |
| 1539 connection_.OnRetransmissionTimeout(); | 1534 connection_.OnRetransmissionTimeout(); |
| 1540 } | 1535 } |
| 1541 | 1536 |
| 1542 TEST_P(QuicConnectionTest, DontAbandonAckedFEC) { | 1537 TEST_P(QuicConnectionTest, DontAbandonAckedFEC) { |
| 1543 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1538 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1544 // Enable FEC. | 1539 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( |
| 1545 QuicConnectionPeer::GetPacketCreator( | 1540 &connection_)->IsFecEnabled()); |
| 1546 &connection_)->set_max_packets_per_fec_group(1); | |
| 1547 | 1541 |
| 1548 // 1 Data and 1 FEC packet. | 1542 // 1 Data and 1 FEC packet. |
| 1549 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); | 1543 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); |
| 1550 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL); | 1544 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL); |
| 1551 // Send some more data afterwards to ensure early retransmit doesn't trigger. | 1545 // Send some more data afterwards to ensure early retransmit doesn't trigger. |
| 1552 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, NULL); | 1546 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, NULL); |
| 1553 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, NULL); | 1547 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, NULL); |
| 1554 | 1548 |
| 1555 QuicAckFrame ack_fec = InitAckFrame(2, 1); | 1549 QuicAckFrame ack_fec = InitAckFrame(2, 1); |
| 1556 // Data packet missing. | 1550 // Data packet missing. |
| 1557 // TODO(ianswett): Note that this is not a sensible ack, since if the FEC was | 1551 // TODO(ianswett): Note that this is not a sensible ack, since if the FEC was |
| 1558 // received, it would cause the covered packet to be acked as well. | 1552 // received, it would cause the covered packet to be acked as well. |
| 1559 NackPacket(1, &ack_fec); | 1553 NackPacket(1, &ack_fec); |
| 1560 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1554 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1561 ProcessAckPacket(&ack_fec); | 1555 ProcessAckPacket(&ack_fec); |
| 1562 clock_.AdvanceTime(DefaultRetransmissionTime()); | 1556 clock_.AdvanceTime(DefaultRetransmissionTime()); |
| 1563 | 1557 |
| 1564 // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent | 1558 // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent |
| 1565 // FEC packets. | 1559 // FEC packets. |
| 1566 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 1560 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 1567 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); | 1561 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); |
| 1568 connection_.GetRetransmissionAlarm()->Fire(); | 1562 connection_.GetRetransmissionAlarm()->Fire(); |
| 1569 } | 1563 } |
| 1570 | 1564 |
| 1571 TEST_P(QuicConnectionTest, AbandonAllFEC) { | 1565 TEST_P(QuicConnectionTest, AbandonAllFEC) { |
| 1572 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1566 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1573 // Enable FEC. | 1567 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( |
| 1574 QuicConnectionPeer::GetPacketCreator( | 1568 &connection_)->IsFecEnabled()); |
| 1575 &connection_)->set_max_packets_per_fec_group(1); | |
| 1576 | 1569 |
| 1577 // 1 Data and 1 FEC packet. | 1570 // 1 Data and 1 FEC packet. |
| 1578 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); | 1571 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); |
| 1579 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL); | 1572 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL); |
| 1580 // Send some more data afterwards to ensure early retransmit doesn't trigger. | 1573 // Send some more data afterwards to ensure early retransmit doesn't trigger. |
| 1581 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, NULL); | 1574 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, NULL); |
| 1582 // Advance the time so not all the FEC packets are abandoned. | 1575 // Advance the time so not all the FEC packets are abandoned. |
| 1583 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); | 1576 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); |
| 1584 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, NULL); | 1577 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, NULL); |
| 1585 | 1578 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1673 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 1681 EXPECT_FALSE(connection_.HasQueuedData()); | 1674 EXPECT_FALSE(connection_.HasQueuedData()); |
| 1682 | 1675 |
| 1683 // Parse the last packet and ensure it's the stream frame from stream 3. | 1676 // Parse the last packet and ensure it's the stream frame from stream 3. |
| 1684 EXPECT_EQ(1u, writer_->frame_count()); | 1677 EXPECT_EQ(1u, writer_->frame_count()); |
| 1685 ASSERT_EQ(1u, writer_->stream_frames().size()); | 1678 ASSERT_EQ(1u, writer_->stream_frames().size()); |
| 1686 EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0].stream_id); | 1679 EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0].stream_id); |
| 1687 } | 1680 } |
| 1688 | 1681 |
| 1689 TEST_P(QuicConnectionTest, FramePackingFEC) { | 1682 TEST_P(QuicConnectionTest, FramePackingFEC) { |
| 1690 // Enable FEC. | 1683 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( |
| 1691 QuicConnectionPeer::GetPacketCreator( | 1684 &connection_)->IsFecEnabled()); |
| 1692 &connection_)->set_max_packets_per_fec_group(6); | |
| 1693 | 1685 |
| 1694 CongestionBlockWrites(); | 1686 CongestionBlockWrites(); |
| 1695 | 1687 |
| 1696 // Queue an ack and two stream frames. Ack gets flushed when FEC is turned on | 1688 // Queue an ack and two stream frames. Ack gets flushed when FEC is turned on |
| 1697 // for sending protected data; two stream frames are packing in 1 packet. | 1689 // for sending protected data; two stream frames are packing in 1 packet. |
| 1698 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( | 1690 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( |
| 1699 IgnoreResult(InvokeWithoutArgs( | 1691 IgnoreResult(InvokeWithoutArgs( |
| 1700 &connection_, &TestConnection::SendStreamData3WithFec)), | 1692 &connection_, &TestConnection::SendStreamData3WithFec)), |
| 1701 IgnoreResult(InvokeWithoutArgs( | 1693 IgnoreResult(InvokeWithoutArgs( |
| 1702 &connection_, &TestConnection::SendStreamData5WithFec)))); | 1694 &connection_, &TestConnection::SendStreamData5WithFec)))); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1990 writer_->set_is_write_blocked_data_buffered(true); | 1982 writer_->set_is_write_blocked_data_buffered(true); |
| 1991 // Simulate the retransmission alarm firing. | 1983 // Simulate the retransmission alarm firing. |
| 1992 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_)); | 1984 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_)); |
| 1993 clock_.AdvanceTime(DefaultRetransmissionTime()); | 1985 clock_.AdvanceTime(DefaultRetransmissionTime()); |
| 1994 connection_.GetRetransmissionAlarm()->Fire(); | 1986 connection_.GetRetransmissionAlarm()->Fire(); |
| 1995 | 1987 |
| 1996 // Ack the sent packet before the callback returns, which happens in | 1988 // Ack the sent packet before the callback returns, which happens in |
| 1997 // rare circumstances with write blocked sockets. | 1989 // rare circumstances with write blocked sockets. |
| 1998 QuicAckFrame ack = InitAckFrame(1, 0); | 1990 QuicAckFrame ack = InitAckFrame(1, 0); |
| 1999 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1991 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1992 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); |
| 2000 ProcessAckPacket(&ack); | 1993 ProcessAckPacket(&ack); |
| 2001 | 1994 |
| 2002 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0)); | 1995 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0)); |
| 2003 // There is now a pending packet, but with no retransmittable frames. | 1996 // There is now a pending packet, but with no retransmittable frames. |
| 2004 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); | 1997 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 2005 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames(2)); | 1998 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames(2)); |
| 2006 } | 1999 } |
| 2007 | 2000 |
| 2008 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) { | 2001 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) { |
| 2009 // Block the connection. | 2002 // Block the connection. |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2675 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2668 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2676 ProcessAckPacket(&frame); | 2669 ProcessAckPacket(&frame); |
| 2677 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); | 2670 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); |
| 2678 EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)), | 2671 EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)), |
| 2679 connection_.GetPingAlarm()->deadline()); | 2672 connection_.GetPingAlarm()->deadline()); |
| 2680 | 2673 |
| 2681 writer_->Reset(); | 2674 writer_->Reset(); |
| 2682 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(15)); | 2675 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(15)); |
| 2683 connection_.GetPingAlarm()->Fire(); | 2676 connection_.GetPingAlarm()->Fire(); |
| 2684 EXPECT_EQ(1u, writer_->frame_count()); | 2677 EXPECT_EQ(1u, writer_->frame_count()); |
| 2685 if (version() > QUIC_VERSION_17) { | 2678 if (version() >= QUIC_VERSION_18) { |
| 2686 ASSERT_EQ(1u, writer_->ping_frames().size()); | 2679 ASSERT_EQ(1u, writer_->ping_frames().size()); |
| 2687 } else { | 2680 } else { |
| 2688 ASSERT_EQ(1u, writer_->stream_frames().size()); | 2681 ASSERT_EQ(1u, writer_->stream_frames().size()); |
| 2689 EXPECT_EQ(kCryptoStreamId, writer_->stream_frames()[0].stream_id); | 2682 EXPECT_EQ(kCryptoStreamId, writer_->stream_frames()[0].stream_id); |
| 2690 EXPECT_EQ(0u, writer_->stream_frames()[0].offset); | 2683 EXPECT_EQ(0u, writer_->stream_frames()[0].offset); |
| 2691 } | 2684 } |
| 2692 writer_->Reset(); | 2685 writer_->Reset(); |
| 2693 | 2686 |
| 2694 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(false)); | 2687 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(false)); |
| 2695 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 2688 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3557 NackPacket(3, &nack_three); | 3550 NackPacket(3, &nack_three); |
| 3558 NackPacket(1, &nack_three); | 3551 NackPacket(1, &nack_three); |
| 3559 SequenceNumberSet lost_packets; | 3552 SequenceNumberSet lost_packets; |
| 3560 lost_packets.insert(1); | 3553 lost_packets.insert(1); |
| 3561 lost_packets.insert(3); | 3554 lost_packets.insert(3); |
| 3562 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 3555 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 3563 .WillOnce(Return(lost_packets)); | 3556 .WillOnce(Return(lost_packets)); |
| 3564 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3557 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3565 EXPECT_CALL(visitor_, OnCanWrite()).Times(2); | 3558 EXPECT_CALL(visitor_, OnCanWrite()).Times(2); |
| 3566 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3559 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3560 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); |
| 3567 ProcessAckPacket(&nack_three); | 3561 ProcessAckPacket(&nack_three); |
| 3568 | 3562 |
| 3569 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( | 3563 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( |
| 3570 Return(QuicBandwidth::Zero())); | 3564 Return(QuicBandwidth::Zero())); |
| 3571 | 3565 |
| 3572 const QuicConnectionStats& stats = connection_.GetStats(); | 3566 const QuicConnectionStats& stats = connection_.GetStats(); |
| 3573 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, | 3567 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, |
| 3574 stats.bytes_sent); | 3568 stats.bytes_sent); |
| 3575 EXPECT_EQ(5u, stats.packets_sent); | 3569 EXPECT_EQ(5u, stats.packets_sent); |
| 3576 EXPECT_EQ(2 * first_packet_size + second_packet_size - kQuicVersionSize, | 3570 EXPECT_EQ(2 * first_packet_size + second_packet_size - kQuicVersionSize, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3808 connection_.GetRetransmissionAlarm()->deadline()); | 3802 connection_.GetRetransmissionAlarm()->deadline()); |
| 3809 // Simulate the retransmission alarm firing. | 3803 // Simulate the retransmission alarm firing. |
| 3810 clock_.AdvanceTime(DefaultRetransmissionTime()); | 3804 clock_.AdvanceTime(DefaultRetransmissionTime()); |
| 3811 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 3805 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 3812 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); | 3806 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); |
| 3813 connection_.GetRetransmissionAlarm()->Fire(); | 3807 connection_.GetRetransmissionAlarm()->Fire(); |
| 3814 EXPECT_EQ(2u, writer_->header().packet_sequence_number); | 3808 EXPECT_EQ(2u, writer_->header().packet_sequence_number); |
| 3815 // We do not raise the high water mark yet. | 3809 // We do not raise the high water mark yet. |
| 3816 EXPECT_EQ(1u, outgoing_ack()->sent_info.least_unacked); | 3810 EXPECT_EQ(1u, outgoing_ack()->sent_info.least_unacked); |
| 3817 | 3811 |
| 3818 // Ack the original packet. | 3812 // Ack the original packet, which will revert the RTO. |
| 3819 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3813 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3820 EXPECT_CALL(*delegate, OnAckNotification(1, _, 1, _, _)); | 3814 EXPECT_CALL(*delegate, OnAckNotification(1, _, 1, _, _)); |
| 3815 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); |
| 3821 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3816 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3822 QuicAckFrame ack_frame = InitAckFrame(1, 0); | 3817 QuicAckFrame ack_frame = InitAckFrame(1, 0); |
| 3823 ProcessAckPacket(&ack_frame); | 3818 ProcessAckPacket(&ack_frame); |
| 3824 | 3819 |
| 3825 // Delegate is not notified again when the retransmit is acked. | 3820 // Delegate is not notified again when the retransmit is acked. |
| 3826 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3821 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3827 QuicAckFrame second_ack_frame = InitAckFrame(2, 0); | 3822 QuicAckFrame second_ack_frame = InitAckFrame(2, 0); |
| 3828 ProcessAckPacket(&second_ack_frame); | 3823 ProcessAckPacket(&second_ack_frame); |
| 3829 } | 3824 } |
| 3830 | 3825 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4034 QuicBlockedFrame blocked; | 4029 QuicBlockedFrame blocked; |
| 4035 blocked.stream_id = 3; | 4030 blocked.stream_id = 3; |
| 4036 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 4031 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
| 4037 ProcessFramePacket(QuicFrame(&blocked)); | 4032 ProcessFramePacket(QuicFrame(&blocked)); |
| 4038 EXPECT_TRUE(ack_alarm->IsSet()); | 4033 EXPECT_TRUE(ack_alarm->IsSet()); |
| 4039 } | 4034 } |
| 4040 | 4035 |
| 4041 } // namespace | 4036 } // namespace |
| 4042 } // namespace test | 4037 } // namespace test |
| 4043 } // namespace net | 4038 } // namespace net |
| OLD | NEW |