mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-06 22:22:38 +03:00
Put outstanding packets, events and associated counters in one class
Summary: ^ Reviewed By: yangchi Differential Revision: D21956286 fbshipit-source-id: 305b879ad11df23aae8e0c3aac4645c0136b3012
This commit is contained in:
committed by
Facebook GitHub Bot
parent
621ad3bc0c
commit
2d00d56fbd
@@ -510,9 +510,9 @@ CloningScheduler::CloningScheduler(
|
|||||||
|
|
||||||
bool CloningScheduler::hasData() const {
|
bool CloningScheduler::hasData() const {
|
||||||
return frameScheduler_.hasData() ||
|
return frameScheduler_.hasData() ||
|
||||||
(!conn_.outstandingPackets.empty() &&
|
(!conn_.outstandings.packets.empty() &&
|
||||||
conn_.outstandingPackets.size() !=
|
conn_.outstandings.packets.size() !=
|
||||||
conn_.outstandingHandshakePacketsCount);
|
conn_.outstandings.handshakePacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
SchedulingResult CloningScheduler::scheduleFramesForPacket(
|
SchedulingResult CloningScheduler::scheduleFramesForPacket(
|
||||||
@@ -534,8 +534,8 @@ SchedulingResult CloningScheduler::scheduleFramesForPacket(
|
|||||||
std::move(builder).releaseOutputBuffer();
|
std::move(builder).releaseOutputBuffer();
|
||||||
// Look for an outstanding packet that's no larger than the writableBytes
|
// Look for an outstanding packet that's no larger than the writableBytes
|
||||||
// This is a loop, but it builds at most one packet.
|
// This is a loop, but it builds at most one packet.
|
||||||
for (auto iter = conn_.outstandingPackets.rbegin();
|
for (auto iter = conn_.outstandings.packets.rbegin();
|
||||||
iter != conn_.outstandingPackets.rend();
|
iter != conn_.outstandings.packets.rend();
|
||||||
++iter) {
|
++iter) {
|
||||||
auto opPnSpace = iter->packet.header.getPacketNumberSpace();
|
auto opPnSpace = iter->packet.header.getPacketNumberSpace();
|
||||||
if (opPnSpace != PacketNumberSpace::AppData) {
|
if (opPnSpace != PacketNumberSpace::AppData) {
|
||||||
@@ -573,7 +573,7 @@ SchedulingResult CloningScheduler::scheduleFramesForPacket(
|
|||||||
// If the packet is already a clone that has been processed, we don't clone
|
// If the packet is already a clone that has been processed, we don't clone
|
||||||
// it again.
|
// it again.
|
||||||
if (iter->associatedEvent &&
|
if (iter->associatedEvent &&
|
||||||
conn_.outstandingPacketEvents.count(*iter->associatedEvent) == 0) {
|
conn_.outstandings.packetEvents.count(*iter->associatedEvent) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// I think this only fail if udpSendPacketLen somehow shrinks in the middle
|
// I think this only fail if udpSendPacketLen somehow shrinks in the middle
|
||||||
|
@@ -412,8 +412,8 @@ void QuicTransportBase::closeImpl(
|
|||||||
connCallback_ = nullptr;
|
connCallback_ = nullptr;
|
||||||
|
|
||||||
// Don't need outstanding packets.
|
// Don't need outstanding packets.
|
||||||
conn_->outstandingPackets.clear();
|
conn_->outstandings.packets.clear();
|
||||||
conn_->outstandingHandshakePacketsCount = 0;
|
conn_->outstandings.handshakePacketsCount = 0;
|
||||||
|
|
||||||
// We don't need no congestion control.
|
// We don't need no congestion control.
|
||||||
conn_->congestionController = nullptr;
|
conn_->congestionController = nullptr;
|
||||||
@@ -2333,7 +2333,7 @@ void QuicTransportBase::cancelAllAppCallbacks(
|
|||||||
|
|
||||||
void QuicTransportBase::writeSocketData() {
|
void QuicTransportBase::writeSocketData() {
|
||||||
if (socket_) {
|
if (socket_) {
|
||||||
auto packetsBefore = conn_->outstandingPackets.size();
|
auto packetsBefore = conn_->outstandings.packets.size();
|
||||||
writeData();
|
writeData();
|
||||||
if (closeState_ != CloseState::CLOSED) {
|
if (closeState_ != CloseState::CLOSED) {
|
||||||
if (conn_->pendingEvents.closeTransport == true) {
|
if (conn_->pendingEvents.closeTransport == true) {
|
||||||
@@ -2342,7 +2342,7 @@ void QuicTransportBase::writeSocketData() {
|
|||||||
TransportErrorCode::PROTOCOL_VIOLATION);
|
TransportErrorCode::PROTOCOL_VIOLATION);
|
||||||
}
|
}
|
||||||
setLossDetectionAlarm(*conn_, *this);
|
setLossDetectionAlarm(*conn_, *this);
|
||||||
auto packetsAfter = conn_->outstandingPackets.size();
|
auto packetsAfter = conn_->outstandings.packets.size();
|
||||||
bool packetWritten = (packetsAfter > packetsBefore);
|
bool packetWritten = (packetsAfter > packetsBefore);
|
||||||
if (conn_->loopDetectorCallback && packetWritten) {
|
if (conn_->loopDetectorCallback && packetWritten) {
|
||||||
conn_->writeDebugState.currentEmptyLoopCount = 0;
|
conn_->writeDebugState.currentEmptyLoopCount = 0;
|
||||||
|
@@ -621,14 +621,14 @@ void updateConnection(
|
|||||||
}
|
}
|
||||||
auto packetIt =
|
auto packetIt =
|
||||||
std::find_if(
|
std::find_if(
|
||||||
conn.outstandingPackets.rbegin(),
|
conn.outstandings.packets.rbegin(),
|
||||||
conn.outstandingPackets.rend(),
|
conn.outstandings.packets.rend(),
|
||||||
[packetNum](const auto& packetWithTime) {
|
[packetNum](const auto& packetWithTime) {
|
||||||
return packetWithTime.packet.header.getPacketSequenceNum() <
|
return packetWithTime.packet.header.getPacketSequenceNum() <
|
||||||
packetNum;
|
packetNum;
|
||||||
})
|
})
|
||||||
.base();
|
.base();
|
||||||
auto& pkt = *conn.outstandingPackets.emplace(
|
auto& pkt = *conn.outstandings.packets.emplace(
|
||||||
packetIt,
|
packetIt,
|
||||||
std::move(packet),
|
std::move(packet),
|
||||||
std::move(sentTime),
|
std::move(sentTime),
|
||||||
@@ -647,7 +647,7 @@ void updateConnection(
|
|||||||
conn.lossState.totalBytesAckedAtLastAck);
|
conn.lossState.totalBytesAckedAtLastAck);
|
||||||
}
|
}
|
||||||
if (packetEvent) {
|
if (packetEvent) {
|
||||||
DCHECK(conn.outstandingPacketEvents.count(*packetEvent));
|
DCHECK(conn.outstandings.packetEvents.count(*packetEvent));
|
||||||
DCHECK(!isHandshake);
|
DCHECK(!isHandshake);
|
||||||
pkt.associatedEvent = std::move(packetEvent);
|
pkt.associatedEvent = std::move(packetEvent);
|
||||||
conn.lossState.totalBytesCloned += encodedSize;
|
conn.lossState.totalBytesCloned += encodedSize;
|
||||||
@@ -675,19 +675,19 @@ void updateConnection(
|
|||||||
conn.pathValidationLimiter->onPacketSent(pkt.encodedSize);
|
conn.pathValidationLimiter->onPacketSent(pkt.encodedSize);
|
||||||
}
|
}
|
||||||
if (pkt.isHandshake) {
|
if (pkt.isHandshake) {
|
||||||
++conn.outstandingHandshakePacketsCount;
|
++conn.outstandings.handshakePacketsCount;
|
||||||
conn.lossState.lastHandshakePacketSentTime = pkt.time;
|
conn.lossState.lastHandshakePacketSentTime = pkt.time;
|
||||||
}
|
}
|
||||||
conn.lossState.lastRetransmittablePacketSentTime = pkt.time;
|
conn.lossState.lastRetransmittablePacketSentTime = pkt.time;
|
||||||
if (pkt.associatedEvent) {
|
if (pkt.associatedEvent) {
|
||||||
CHECK_EQ(packetNumberSpace, PacketNumberSpace::AppData);
|
CHECK_EQ(packetNumberSpace, PacketNumberSpace::AppData);
|
||||||
++conn.outstandingClonedPacketsCount;
|
++conn.outstandings.clonedPacketsCount;
|
||||||
++conn.lossState.timeoutBasedRtxCount;
|
++conn.lossState.timeoutBasedRtxCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto opCount = conn.outstandingPackets.size();
|
auto opCount = conn.outstandings.packets.size();
|
||||||
DCHECK_GE(opCount, conn.outstandingHandshakePacketsCount);
|
DCHECK_GE(opCount, conn.outstandings.handshakePacketsCount);
|
||||||
DCHECK_GE(opCount, conn.outstandingClonedPacketsCount);
|
DCHECK_GE(opCount, conn.outstandings.clonedPacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t congestionControlWritableBytes(const QuicConnectionStateBase& conn) {
|
uint64_t congestionControlWritableBytes(const QuicConnectionStateBase& conn) {
|
||||||
@@ -1353,7 +1353,7 @@ void implicitAckCryptoStream(
|
|||||||
AckBlocks ackBlocks;
|
AckBlocks ackBlocks;
|
||||||
ReadAckFrame implicitAck;
|
ReadAckFrame implicitAck;
|
||||||
implicitAck.ackDelay = 0ms;
|
implicitAck.ackDelay = 0ms;
|
||||||
for (const auto& op : conn.outstandingPackets) {
|
for (const auto& op : conn.outstandings.packets) {
|
||||||
if (op.packet.header.getPacketNumberSpace() == packetNumSpace) {
|
if (op.packet.header.getPacketNumberSpace() == packetNumSpace) {
|
||||||
ackBlocks.insert(op.packet.header.getPacketSequenceNum());
|
ackBlocks.insert(op.packet.header.getPacketSequenceNum());
|
||||||
}
|
}
|
||||||
|
@@ -37,8 +37,8 @@ PacketNum addInitialOutstandingPacket(QuicConnectionStateBase& conn) {
|
|||||||
nextPacketNum,
|
nextPacketNum,
|
||||||
QuicVersion::QUIC_DRAFT);
|
QuicVersion::QUIC_DRAFT);
|
||||||
RegularQuicWritePacket packet(std::move(header));
|
RegularQuicWritePacket packet(std::move(header));
|
||||||
conn.outstandingPackets.emplace_back(packet, Clock::now(), 0, true, 0);
|
conn.outstandings.packets.emplace_back(packet, Clock::now(), 0, true, 0);
|
||||||
conn.outstandingHandshakePacketsCount++;
|
conn.outstandings.handshakePacketsCount++;
|
||||||
increaseNextPacketNum(conn, PacketNumberSpace::Handshake);
|
increaseNextPacketNum(conn, PacketNumberSpace::Handshake);
|
||||||
return nextPacketNum;
|
return nextPacketNum;
|
||||||
}
|
}
|
||||||
@@ -55,8 +55,8 @@ PacketNum addHandshakeOutstandingPacket(QuicConnectionStateBase& conn) {
|
|||||||
nextPacketNum,
|
nextPacketNum,
|
||||||
QuicVersion::QUIC_DRAFT);
|
QuicVersion::QUIC_DRAFT);
|
||||||
RegularQuicWritePacket packet(std::move(header));
|
RegularQuicWritePacket packet(std::move(header));
|
||||||
conn.outstandingPackets.emplace_back(packet, Clock::now(), 0, true, 0);
|
conn.outstandings.packets.emplace_back(packet, Clock::now(), 0, true, 0);
|
||||||
conn.outstandingHandshakePacketsCount++;
|
conn.outstandings.handshakePacketsCount++;
|
||||||
increaseNextPacketNum(conn, PacketNumberSpace::Handshake);
|
increaseNextPacketNum(conn, PacketNumberSpace::Handshake);
|
||||||
return nextPacketNum;
|
return nextPacketNum;
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ PacketNum addOutstandingPacket(QuicConnectionStateBase& conn) {
|
|||||||
conn.clientConnectionId.value_or(quic::test::getTestConnectionId()),
|
conn.clientConnectionId.value_or(quic::test::getTestConnectionId()),
|
||||||
nextPacketNum);
|
nextPacketNum);
|
||||||
RegularQuicWritePacket packet(std::move(header));
|
RegularQuicWritePacket packet(std::move(header));
|
||||||
conn.outstandingPackets.emplace_back(packet, Clock::now(), 0, false, 0);
|
conn.outstandings.packets.emplace_back(packet, Clock::now(), 0, false, 0);
|
||||||
increaseNextPacketNum(conn, PacketNumberSpace::AppData);
|
increaseNextPacketNum(conn, PacketNumberSpace::AppData);
|
||||||
return nextPacketNum;
|
return nextPacketNum;
|
||||||
}
|
}
|
||||||
@@ -436,7 +436,7 @@ TEST_F(QuicPacketSchedulerTest, CloningSchedulerTest) {
|
|||||||
EXPECT_FALSE(cloningScheduler.hasData());
|
EXPECT_FALSE(cloningScheduler.hasData());
|
||||||
auto packetNum = addOutstandingPacket(conn);
|
auto packetNum = addOutstandingPacket(conn);
|
||||||
// There needs to have retransmittable frame for the rebuilder to work
|
// There needs to have retransmittable frame for the rebuilder to work
|
||||||
conn.outstandingPackets.back().packet.frames.push_back(
|
conn.outstandings.packets.back().packet.frames.push_back(
|
||||||
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
||||||
EXPECT_TRUE(cloningScheduler.hasData());
|
EXPECT_TRUE(cloningScheduler.hasData());
|
||||||
|
|
||||||
@@ -461,15 +461,15 @@ TEST_F(QuicPacketSchedulerTest, DoNotCloneProcessedClonedPacket) {
|
|||||||
FrameScheduler noopScheduler("frame");
|
FrameScheduler noopScheduler("frame");
|
||||||
CloningScheduler cloningScheduler(noopScheduler, conn, "CopyCat", 0);
|
CloningScheduler cloningScheduler(noopScheduler, conn, "CopyCat", 0);
|
||||||
// Add two outstanding packets, but then mark the second one processed by
|
// Add two outstanding packets, but then mark the second one processed by
|
||||||
// adding a PacketEvent that's missing from the outstandingPacketEvents set
|
// adding a PacketEvent that's missing from the outstandings.packetEvents set
|
||||||
PacketNum expected = addOutstandingPacket(conn);
|
PacketNum expected = addOutstandingPacket(conn);
|
||||||
// There needs to have retransmittable frame for the rebuilder to work
|
// There needs to have retransmittable frame for the rebuilder to work
|
||||||
conn.outstandingPackets.back().packet.frames.push_back(
|
conn.outstandings.packets.back().packet.frames.push_back(
|
||||||
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
||||||
addOutstandingPacket(conn);
|
addOutstandingPacket(conn);
|
||||||
conn.outstandingPackets.back().associatedEvent = 1;
|
conn.outstandings.packets.back().associatedEvent = 1;
|
||||||
// There needs to have retransmittable frame for the rebuilder to work
|
// There needs to have retransmittable frame for the rebuilder to work
|
||||||
conn.outstandingPackets.back().packet.frames.push_back(
|
conn.outstandings.packets.back().packet.frames.push_back(
|
||||||
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
||||||
|
|
||||||
ShortHeader header(
|
ShortHeader header(
|
||||||
@@ -511,10 +511,10 @@ TEST_F(QuicPacketSchedulerTest, DoNotCloneHandshake) {
|
|||||||
// Add two outstanding packets, with second one being handshake
|
// Add two outstanding packets, with second one being handshake
|
||||||
auto expected = addOutstandingPacket(conn);
|
auto expected = addOutstandingPacket(conn);
|
||||||
// There needs to have retransmittable frame for the rebuilder to work
|
// There needs to have retransmittable frame for the rebuilder to work
|
||||||
conn.outstandingPackets.back().packet.frames.push_back(
|
conn.outstandings.packets.back().packet.frames.push_back(
|
||||||
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
||||||
addHandshakeOutstandingPacket(conn);
|
addHandshakeOutstandingPacket(conn);
|
||||||
conn.outstandingPackets.back().packet.frames.push_back(
|
conn.outstandings.packets.back().packet.frames.push_back(
|
||||||
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
||||||
|
|
||||||
ShortHeader header(
|
ShortHeader header(
|
||||||
@@ -587,9 +587,9 @@ TEST_F(QuicPacketSchedulerTest, CloneWillGenerateNewWindowUpdate) {
|
|||||||
FrameScheduler noopScheduler("frame");
|
FrameScheduler noopScheduler("frame");
|
||||||
CloningScheduler cloningScheduler(noopScheduler, conn, "GiantsShoulder", 0);
|
CloningScheduler cloningScheduler(noopScheduler, conn, "GiantsShoulder", 0);
|
||||||
auto expectedPacketEvent = addOutstandingPacket(conn);
|
auto expectedPacketEvent = addOutstandingPacket(conn);
|
||||||
ASSERT_EQ(1, conn.outstandingPackets.size());
|
ASSERT_EQ(1, conn.outstandings.packets.size());
|
||||||
conn.outstandingPackets.back().packet.frames.push_back(MaxDataFrame(1000));
|
conn.outstandings.packets.back().packet.frames.push_back(MaxDataFrame(1000));
|
||||||
conn.outstandingPackets.back().packet.frames.push_back(
|
conn.outstandings.packets.back().packet.frames.push_back(
|
||||||
MaxStreamDataFrame(stream->id, 1000));
|
MaxStreamDataFrame(stream->id, 1000));
|
||||||
conn.flowControlState.advertisedMaxOffset = 1000;
|
conn.flowControlState.advertisedMaxOffset = 1000;
|
||||||
stream->flowControlState.advertisedMaxOffset = 1000;
|
stream->flowControlState.advertisedMaxOffset = 1000;
|
||||||
@@ -674,7 +674,7 @@ TEST_F(QuicPacketSchedulerTest, CloningSchedulerWithInplaceBuilder) {
|
|||||||
CloningScheduler cloningScheduler(noopScheduler, conn, "93MillionMiles", 0);
|
CloningScheduler cloningScheduler(noopScheduler, conn, "93MillionMiles", 0);
|
||||||
auto packetNum = addOutstandingPacket(conn);
|
auto packetNum = addOutstandingPacket(conn);
|
||||||
// There needs to have retransmittable frame for the rebuilder to work
|
// There needs to have retransmittable frame for the rebuilder to work
|
||||||
conn.outstandingPackets.back().packet.frames.push_back(
|
conn.outstandings.packets.back().packet.frames.push_back(
|
||||||
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
||||||
EXPECT_TRUE(cloningScheduler.hasData());
|
EXPECT_TRUE(cloningScheduler.hasData());
|
||||||
|
|
||||||
@@ -1227,10 +1227,10 @@ TEST_F(
|
|||||||
CloningScheduler cloningScheduler(noopScheduler, conn, "Little Hurry", 0);
|
CloningScheduler cloningScheduler(noopScheduler, conn, "Little Hurry", 0);
|
||||||
addOutstandingPacket(conn);
|
addOutstandingPacket(conn);
|
||||||
// There needs to have retransmittable frame for the rebuilder to work
|
// There needs to have retransmittable frame for the rebuilder to work
|
||||||
conn.outstandingPackets.back().packet.frames.push_back(
|
conn.outstandings.packets.back().packet.frames.push_back(
|
||||||
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
MaxDataFrame(conn.flowControlState.advertisedMaxOffset));
|
||||||
// Lie about the encodedSize to let the Cloner skip it:
|
// Lie about the encodedSize to let the Cloner skip it:
|
||||||
conn.outstandingPackets.back().encodedSize = kDefaultUDPSendPacketLen * 2;
|
conn.outstandings.packets.back().encodedSize = kDefaultUDPSendPacketLen * 2;
|
||||||
EXPECT_TRUE(cloningScheduler.hasData());
|
EXPECT_TRUE(cloningScheduler.hasData());
|
||||||
|
|
||||||
ASSERT_FALSE(noopScheduler.hasData());
|
ASSERT_FALSE(noopScheduler.hasData());
|
||||||
@@ -1270,7 +1270,7 @@ TEST_F(
|
|||||||
CloningScheduler cloningScheduler(noopScheduler, conn, "HotPot", 0);
|
CloningScheduler cloningScheduler(noopScheduler, conn, "HotPot", 0);
|
||||||
addOutstandingPacket(conn);
|
addOutstandingPacket(conn);
|
||||||
// Not adding frame to this outstanding packet so that rebuild will fail:
|
// Not adding frame to this outstanding packet so that rebuild will fail:
|
||||||
ASSERT_TRUE(conn.outstandingPackets.back().packet.frames.empty());
|
ASSERT_TRUE(conn.outstandings.packets.back().packet.frames.empty());
|
||||||
EXPECT_TRUE(cloningScheduler.hasData());
|
EXPECT_TRUE(cloningScheduler.hasData());
|
||||||
|
|
||||||
ASSERT_FALSE(noopScheduler.hasData());
|
ASSERT_FALSE(noopScheduler.hasData());
|
||||||
|
@@ -1189,9 +1189,9 @@ TEST_F(QuicTransportImplTest, CancelAllDeliveryCallbacksMap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportImplTest, CloseTransportCleansupOutstandingCounters) {
|
TEST_F(QuicTransportImplTest, CloseTransportCleansupOutstandingCounters) {
|
||||||
transport->transportConn->outstandingHandshakePacketsCount = 200;
|
transport->transportConn->outstandings.handshakePacketsCount = 200;
|
||||||
transport->closeNow(folly::none);
|
transport->closeNow(folly::none);
|
||||||
EXPECT_EQ(0, transport->transportConn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(0, transport->transportConn->outstandings.handshakePacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportImplTest, DeliveryCallbackUnsetAll) {
|
TEST_F(QuicTransportImplTest, DeliveryCallbackUnsetAll) {
|
||||||
|
@@ -227,7 +227,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) {
|
|||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
conn->ackStates.appDataAckState.nextPacketNum,
|
conn->ackStates.appDataAckState.nextPacketNum,
|
||||||
currentNextAppDataPacketNum);
|
currentNextAppDataPacketNum);
|
||||||
EXPECT_TRUE(conn->outstandingPackets.back().isAppLimited);
|
EXPECT_TRUE(conn->outstandings.packets.back().isAppLimited);
|
||||||
|
|
||||||
EXPECT_EQ(stream1->retransmissionBuffer.size(), 1);
|
EXPECT_EQ(stream1->retransmissionBuffer.size(), 1);
|
||||||
auto& rt1 = *stream1->retransmissionBuffer.at(0);
|
auto& rt1 = *stream1->retransmissionBuffer.at(0);
|
||||||
@@ -284,7 +284,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) {
|
|||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
conn->ackStates.appDataAckState.nextPacketNum,
|
conn->ackStates.appDataAckState.nextPacketNum,
|
||||||
currentNextAppDataPacketNum);
|
currentNextAppDataPacketNum);
|
||||||
EXPECT_FALSE(conn->outstandingPackets.back().isAppLimited);
|
EXPECT_FALSE(conn->outstandings.packets.back().isAppLimited);
|
||||||
|
|
||||||
EXPECT_EQ(stream1->currentWriteOffset, 13);
|
EXPECT_EQ(stream1->currentWriteOffset, 13);
|
||||||
EXPECT_EQ(stream1->currentWriteOffset, 13);
|
EXPECT_EQ(stream1->currentWriteOffset, 13);
|
||||||
@@ -399,15 +399,15 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketSorting) {
|
|||||||
EXPECT_EQ(event2->packetType, toString(LongHeader::Types::Initial));
|
EXPECT_EQ(event2->packetType, toString(LongHeader::Types::Initial));
|
||||||
EXPECT_EQ(event3->packetType, toString(LongHeader::Types::ZeroRtt));
|
EXPECT_EQ(event3->packetType, toString(LongHeader::Types::ZeroRtt));
|
||||||
|
|
||||||
EXPECT_EQ(3, conn->outstandingPackets.size());
|
EXPECT_EQ(3, conn->outstandings.packets.size());
|
||||||
auto& firstHeader = conn->outstandingPackets.front().packet.header;
|
auto& firstHeader = conn->outstandings.packets.front().packet.header;
|
||||||
auto firstPacketNum = firstHeader.getPacketSequenceNum();
|
auto firstPacketNum = firstHeader.getPacketSequenceNum();
|
||||||
EXPECT_EQ(0, firstPacketNum);
|
EXPECT_EQ(0, firstPacketNum);
|
||||||
EXPECT_EQ(1, event1->packetNum);
|
EXPECT_EQ(1, event1->packetNum);
|
||||||
|
|
||||||
EXPECT_EQ(PacketNumberSpace::Initial, firstHeader.getPacketNumberSpace());
|
EXPECT_EQ(PacketNumberSpace::Initial, firstHeader.getPacketNumberSpace());
|
||||||
|
|
||||||
auto& lastHeader = conn->outstandingPackets.back().packet.header;
|
auto& lastHeader = conn->outstandings.packets.back().packet.header;
|
||||||
|
|
||||||
auto lastPacketNum = lastHeader.getPacketSequenceNum();
|
auto lastPacketNum = lastHeader.getPacketSequenceNum();
|
||||||
|
|
||||||
@@ -539,7 +539,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPureAckCounter) {
|
|||||||
conn->qLogger = std::make_shared<quic::FileQLogger>(VantagePoint::Client);
|
conn->qLogger = std::make_shared<quic::FileQLogger>(VantagePoint::Client);
|
||||||
auto stream = conn->streamManager->createNextBidirectionalStream().value();
|
auto stream = conn->streamManager->createNextBidirectionalStream().value();
|
||||||
writeDataToQuicStream(*stream, nullptr, true);
|
writeDataToQuicStream(*stream, nullptr, true);
|
||||||
EXPECT_EQ(0, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(0, conn->outstandings.handshakePacketsCount);
|
||||||
|
|
||||||
auto packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake);
|
auto packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake);
|
||||||
auto packetEncodedSize =
|
auto packetEncodedSize =
|
||||||
@@ -629,8 +629,8 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) {
|
|||||||
initialStream->writeBuffer.append(data->clone());
|
initialStream->writeBuffer.append(data->clone());
|
||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_EQ(1, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(1, conn->outstandings.handshakePacketsCount);
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
EXPECT_EQ(1, initialStream->retransmissionBuffer.size());
|
EXPECT_EQ(1, initialStream->retransmissionBuffer.size());
|
||||||
|
|
||||||
packet = buildEmptyPacket(*conn, PacketNumberSpace::Initial);
|
packet = buildEmptyPacket(*conn, PacketNumberSpace::Initial);
|
||||||
@@ -642,8 +642,8 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) {
|
|||||||
initialStream->writeBuffer.append(data->clone());
|
initialStream->writeBuffer.append(data->clone());
|
||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_EQ(2, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(2, conn->outstandings.handshakePacketsCount);
|
||||||
EXPECT_EQ(2, conn->outstandingPackets.size());
|
EXPECT_EQ(2, conn->outstandings.packets.size());
|
||||||
EXPECT_EQ(3, initialStream->retransmissionBuffer.size());
|
EXPECT_EQ(3, initialStream->retransmissionBuffer.size());
|
||||||
EXPECT_TRUE(initialStream->writeBuffer.empty());
|
EXPECT_TRUE(initialStream->writeBuffer.empty());
|
||||||
EXPECT_TRUE(initialStream->lossBuffer.empty());
|
EXPECT_TRUE(initialStream->lossBuffer.empty());
|
||||||
@@ -653,8 +653,8 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) {
|
|||||||
initialStream->retransmissionBuffer.find(0)->second->data.move();
|
initialStream->retransmissionBuffer.find(0)->second->data.move();
|
||||||
initialStream->retransmissionBuffer.erase(0);
|
initialStream->retransmissionBuffer.erase(0);
|
||||||
initialStream->lossBuffer.emplace_back(std::move(firstBuf), 0, false);
|
initialStream->lossBuffer.emplace_back(std::move(firstBuf), 0, false);
|
||||||
conn->outstandingPackets.pop_front();
|
conn->outstandings.packets.pop_front();
|
||||||
conn->outstandingHandshakePacketsCount--;
|
conn->outstandings.handshakePacketsCount--;
|
||||||
|
|
||||||
auto handshakeStream =
|
auto handshakeStream =
|
||||||
getCryptoStream(*conn->cryptoState, EncryptionLevel::Handshake);
|
getCryptoStream(*conn->cryptoState, EncryptionLevel::Handshake);
|
||||||
@@ -666,8 +666,8 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) {
|
|||||||
handshakeStream->writeBuffer.append(data->clone());
|
handshakeStream->writeBuffer.append(data->clone());
|
||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_EQ(2, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(2, conn->outstandings.handshakePacketsCount);
|
||||||
EXPECT_EQ(2, conn->outstandingPackets.size());
|
EXPECT_EQ(2, conn->outstandings.packets.size());
|
||||||
EXPECT_EQ(1, handshakeStream->retransmissionBuffer.size());
|
EXPECT_EQ(1, handshakeStream->retransmissionBuffer.size());
|
||||||
|
|
||||||
packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake);
|
packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake);
|
||||||
@@ -676,8 +676,8 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) {
|
|||||||
handshakeStream->writeBuffer.append(data->clone());
|
handshakeStream->writeBuffer.append(data->clone());
|
||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_EQ(3, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(3, conn->outstandings.handshakePacketsCount);
|
||||||
EXPECT_EQ(3, conn->outstandingPackets.size());
|
EXPECT_EQ(3, conn->outstandings.packets.size());
|
||||||
EXPECT_EQ(2, handshakeStream->retransmissionBuffer.size());
|
EXPECT_EQ(2, handshakeStream->retransmissionBuffer.size());
|
||||||
EXPECT_TRUE(handshakeStream->writeBuffer.empty());
|
EXPECT_TRUE(handshakeStream->writeBuffer.empty());
|
||||||
EXPECT_TRUE(handshakeStream->lossBuffer.empty());
|
EXPECT_TRUE(handshakeStream->lossBuffer.empty());
|
||||||
@@ -686,24 +686,24 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) {
|
|||||||
firstBuf = handshakeStream->retransmissionBuffer.find(0)->second->data.move();
|
firstBuf = handshakeStream->retransmissionBuffer.find(0)->second->data.move();
|
||||||
handshakeStream->retransmissionBuffer.erase(0);
|
handshakeStream->retransmissionBuffer.erase(0);
|
||||||
handshakeStream->lossBuffer.emplace_back(std::move(firstBuf), 0, false);
|
handshakeStream->lossBuffer.emplace_back(std::move(firstBuf), 0, false);
|
||||||
auto& op = conn->outstandingPackets.front();
|
auto& op = conn->outstandings.packets.front();
|
||||||
ASSERT_EQ(
|
ASSERT_EQ(
|
||||||
op.packet.header.getPacketNumberSpace(), PacketNumberSpace::Handshake);
|
op.packet.header.getPacketNumberSpace(), PacketNumberSpace::Handshake);
|
||||||
auto frame = op.packet.frames[0].asWriteCryptoFrame();
|
auto frame = op.packet.frames[0].asWriteCryptoFrame();
|
||||||
EXPECT_EQ(frame->offset, 0);
|
EXPECT_EQ(frame->offset, 0);
|
||||||
conn->outstandingPackets.pop_front();
|
conn->outstandings.packets.pop_front();
|
||||||
conn->outstandingHandshakePacketsCount--;
|
conn->outstandings.handshakePacketsCount--;
|
||||||
|
|
||||||
implicitAckCryptoStream(*conn, EncryptionLevel::Initial);
|
implicitAckCryptoStream(*conn, EncryptionLevel::Initial);
|
||||||
EXPECT_EQ(1, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(1, conn->outstandings.handshakePacketsCount);
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
EXPECT_TRUE(initialStream->retransmissionBuffer.empty());
|
EXPECT_TRUE(initialStream->retransmissionBuffer.empty());
|
||||||
EXPECT_TRUE(initialStream->writeBuffer.empty());
|
EXPECT_TRUE(initialStream->writeBuffer.empty());
|
||||||
EXPECT_TRUE(initialStream->lossBuffer.empty());
|
EXPECT_TRUE(initialStream->lossBuffer.empty());
|
||||||
|
|
||||||
implicitAckCryptoStream(*conn, EncryptionLevel::Handshake);
|
implicitAckCryptoStream(*conn, EncryptionLevel::Handshake);
|
||||||
EXPECT_EQ(0, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(0, conn->outstandings.handshakePacketsCount);
|
||||||
EXPECT_TRUE(conn->outstandingPackets.empty());
|
EXPECT_TRUE(conn->outstandings.packets.empty());
|
||||||
EXPECT_TRUE(handshakeStream->retransmissionBuffer.empty());
|
EXPECT_TRUE(handshakeStream->retransmissionBuffer.empty());
|
||||||
EXPECT_TRUE(handshakeStream->writeBuffer.empty());
|
EXPECT_TRUE(handshakeStream->writeBuffer.empty());
|
||||||
EXPECT_TRUE(handshakeStream->lossBuffer.empty());
|
EXPECT_TRUE(handshakeStream->lossBuffer.empty());
|
||||||
@@ -714,7 +714,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionHandshakeCounter) {
|
|||||||
conn->qLogger = std::make_shared<quic::FileQLogger>(VantagePoint::Client);
|
conn->qLogger = std::make_shared<quic::FileQLogger>(VantagePoint::Client);
|
||||||
auto stream = conn->streamManager->createNextBidirectionalStream().value();
|
auto stream = conn->streamManager->createNextBidirectionalStream().value();
|
||||||
writeDataToQuicStream(*stream, nullptr, true);
|
writeDataToQuicStream(*stream, nullptr, true);
|
||||||
EXPECT_EQ(0, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(0, conn->outstandings.handshakePacketsCount);
|
||||||
|
|
||||||
auto packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake);
|
auto packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake);
|
||||||
auto packetEncodedSize =
|
auto packetEncodedSize =
|
||||||
@@ -724,7 +724,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionHandshakeCounter) {
|
|||||||
packet.packet.frames.push_back(WriteCryptoFrame(0, 0));
|
packet.packet.frames.push_back(WriteCryptoFrame(0, 0));
|
||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_EQ(1, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(1, conn->outstandings.handshakePacketsCount);
|
||||||
|
|
||||||
auto nonHandshake = buildEmptyPacket(*conn, PacketNumberSpace::AppData);
|
auto nonHandshake = buildEmptyPacket(*conn, PacketNumberSpace::AppData);
|
||||||
packetEncodedSize =
|
packetEncodedSize =
|
||||||
@@ -771,7 +771,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionHandshakeCounter) {
|
|||||||
EXPECT_EQ(gotFrame->offset, 0);
|
EXPECT_EQ(gotFrame->offset, 0);
|
||||||
EXPECT_EQ(gotFrame->len, 0);
|
EXPECT_EQ(gotFrame->len, 0);
|
||||||
EXPECT_TRUE(gotFrame->fin);
|
EXPECT_TRUE(gotFrame->fin);
|
||||||
EXPECT_EQ(1, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(1, conn->outstandings.handshakePacketsCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -781,7 +781,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionForOneRttCryptoData) {
|
|||||||
conn->qLogger = std::make_shared<quic::FileQLogger>(VantagePoint::Client);
|
conn->qLogger = std::make_shared<quic::FileQLogger>(VantagePoint::Client);
|
||||||
auto stream = conn->streamManager->createNextBidirectionalStream().value();
|
auto stream = conn->streamManager->createNextBidirectionalStream().value();
|
||||||
writeDataToQuicStream(*stream, nullptr, true);
|
writeDataToQuicStream(*stream, nullptr, true);
|
||||||
EXPECT_EQ(0, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(0, conn->outstandings.handshakePacketsCount);
|
||||||
|
|
||||||
// Packet with CryptoFrame in AppData pn space
|
// Packet with CryptoFrame in AppData pn space
|
||||||
auto packet = buildEmptyPacket(*conn, PacketNumberSpace::AppData, true);
|
auto packet = buildEmptyPacket(*conn, PacketNumberSpace::AppData, true);
|
||||||
@@ -793,8 +793,8 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionForOneRttCryptoData) {
|
|||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
|
|
||||||
EXPECT_EQ(0, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(0, conn->outstandings.handshakePacketsCount);
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto nonHandshake = buildEmptyPacket(*conn, PacketNumberSpace::AppData);
|
auto nonHandshake = buildEmptyPacket(*conn, PacketNumberSpace::AppData);
|
||||||
packetEncodedSize =
|
packetEncodedSize =
|
||||||
@@ -843,8 +843,8 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionForOneRttCryptoData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_EQ(0, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(0, conn->outstandings.handshakePacketsCount);
|
||||||
EXPECT_EQ(2, conn->outstandingPackets.size());
|
EXPECT_EQ(2, conn->outstandings.packets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithPureAck) {
|
TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithPureAck) {
|
||||||
@@ -866,7 +866,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithPureAck) {
|
|||||||
EXPECT_CALL(*rawPacer, onPacketSent()).Times(0);
|
EXPECT_CALL(*rawPacer, onPacketSent()).Times(0);
|
||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_EQ(0, conn->outstandingPackets.size());
|
EXPECT_EQ(0, conn->outstandings.packets.size());
|
||||||
EXPECT_EQ(0, conn->lossState.totalBytesAcked);
|
EXPECT_EQ(0, conn->lossState.totalBytesAcked);
|
||||||
std::shared_ptr<quic::FileQLogger> qLogger =
|
std::shared_ptr<quic::FileQLogger> qLogger =
|
||||||
std::dynamic_pointer_cast<quic::FileQLogger>(conn->qLogger);
|
std::dynamic_pointer_cast<quic::FileQLogger>(conn->qLogger);
|
||||||
@@ -961,7 +961,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithCloneResult) {
|
|||||||
conn->pendingEvents.connWindowUpdate = true;
|
conn->pendingEvents.connWindowUpdate = true;
|
||||||
writePacket.frames.push_back(std::move(maxDataFrame));
|
writePacket.frames.push_back(std::move(maxDataFrame));
|
||||||
PacketEvent event = 1;
|
PacketEvent event = 1;
|
||||||
conn->outstandingPacketEvents.insert(event);
|
conn->outstandings.packetEvents.insert(event);
|
||||||
auto futureMoment = thisMoment + 50ms;
|
auto futureMoment = thisMoment + 50ms;
|
||||||
MockClock::mockNow = [=]() { return futureMoment; };
|
MockClock::mockNow = [=]() { return futureMoment; };
|
||||||
EXPECT_CALL(*rawCongestionController, onPacketSent(_)).Times(1);
|
EXPECT_CALL(*rawCongestionController, onPacketSent(_)).Times(1);
|
||||||
@@ -1308,7 +1308,7 @@ TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketWithNoBytesForHeader) {
|
|||||||
getVersion(*conn),
|
getVersion(*conn),
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
// No header space left. Should send nothing.
|
// No header space left. Should send nothing.
|
||||||
EXPECT_TRUE(conn->outstandingPackets.empty());
|
EXPECT_TRUE(conn->outstandings.packets.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketRetxBufferSorted) {
|
TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketRetxBufferSorted) {
|
||||||
@@ -1428,14 +1428,14 @@ TEST_F(QuicTransportFunctionsTest, WriteBlockedFrameWhenBlocked) {
|
|||||||
|
|
||||||
EXPECT_GT(conn->ackStates.appDataAckState.nextPacketNum, originalNextSeq);
|
EXPECT_GT(conn->ackStates.appDataAckState.nextPacketNum, originalNextSeq);
|
||||||
auto blocked = *getFirstFrameInOutstandingPackets(
|
auto blocked = *getFirstFrameInOutstandingPackets(
|
||||||
conn->outstandingPackets,
|
conn->outstandings.packets,
|
||||||
QuicWriteFrame::Type::StreamDataBlockedFrame_E)
|
QuicWriteFrame::Type::StreamDataBlockedFrame_E)
|
||||||
.asStreamDataBlockedFrame();
|
.asStreamDataBlockedFrame();
|
||||||
EXPECT_EQ(blocked.streamId, stream1->id);
|
EXPECT_EQ(blocked.streamId, stream1->id);
|
||||||
|
|
||||||
// Since everything is blocked, we shouldn't write a blocked again, so we
|
// Since everything is blocked, we shouldn't write a blocked again, so we
|
||||||
// won't have any new packets to write if we trigger a write.
|
// won't have any new packets to write if we trigger a write.
|
||||||
auto previousPackets = conn->outstandingPackets.size();
|
auto previousPackets = conn->outstandings.packets.size();
|
||||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(0);
|
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(0);
|
||||||
writeQuicDataToSocket(
|
writeQuicDataToSocket(
|
||||||
*rawSocket,
|
*rawSocket,
|
||||||
@@ -1446,7 +1446,7 @@ TEST_F(QuicTransportFunctionsTest, WriteBlockedFrameWhenBlocked) {
|
|||||||
*headerCipher,
|
*headerCipher,
|
||||||
getVersion(*conn),
|
getVersion(*conn),
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(previousPackets, conn->outstandingPackets.size());
|
EXPECT_EQ(previousPackets, conn->outstandings.packets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, WriteProbingNewData) {
|
TEST_F(QuicTransportFunctionsTest, WriteProbingNewData) {
|
||||||
@@ -1478,9 +1478,9 @@ TEST_F(QuicTransportFunctionsTest, WriteProbingNewData) {
|
|||||||
writeProbingDataToSocketForTest(
|
writeProbingDataToSocketForTest(
|
||||||
*rawSocket, *conn, 1, *aead, *headerCipher, getVersion(*conn));
|
*rawSocket, *conn, 1, *aead, *headerCipher, getVersion(*conn));
|
||||||
EXPECT_LT(currentPacketSeqNum, conn->ackStates.appDataAckState.nextPacketNum);
|
EXPECT_LT(currentPacketSeqNum, conn->ackStates.appDataAckState.nextPacketNum);
|
||||||
EXPECT_FALSE(conn->outstandingPackets.empty());
|
EXPECT_FALSE(conn->outstandings.packets.empty());
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
conn->outstandingPackets.back().packet.header.getPacketSequenceNum(),
|
conn->outstandings.packets.back().packet.header.getPacketSequenceNum(),
|
||||||
currentPacketSeqNum + 1);
|
currentPacketSeqNum + 1);
|
||||||
EXPECT_TRUE(conn->pendingEvents.setLossDetectionAlarm);
|
EXPECT_TRUE(conn->pendingEvents.setLossDetectionAlarm);
|
||||||
EXPECT_GT(stream1->currentWriteOffset, currentStreamWriteOffset);
|
EXPECT_GT(stream1->currentWriteOffset, currentStreamWriteOffset);
|
||||||
@@ -1566,7 +1566,7 @@ TEST_F(QuicTransportFunctionsTest, WriteProbingCryptoData) {
|
|||||||
writeCryptoDataProbesToSocketForTest(
|
writeCryptoDataProbesToSocketForTest(
|
||||||
*rawSocket, conn, 1, *aead, *headerCipher, getVersion(conn));
|
*rawSocket, conn, 1, *aead, *headerCipher, getVersion(conn));
|
||||||
EXPECT_LT(currentPacketSeqNum, conn.ackStates.initialAckState.nextPacketNum);
|
EXPECT_LT(currentPacketSeqNum, conn.ackStates.initialAckState.nextPacketNum);
|
||||||
EXPECT_FALSE(conn.outstandingPackets.empty());
|
EXPECT_FALSE(conn.outstandings.packets.empty());
|
||||||
EXPECT_TRUE(conn.pendingEvents.setLossDetectionAlarm);
|
EXPECT_TRUE(conn.pendingEvents.setLossDetectionAlarm);
|
||||||
EXPECT_GT(cryptoStream->currentWriteOffset, currentStreamWriteOffset);
|
EXPECT_GT(cryptoStream->currentWriteOffset, currentStreamWriteOffset);
|
||||||
EXPECT_FALSE(cryptoStream->retransmissionBuffer.empty());
|
EXPECT_FALSE(cryptoStream->retransmissionBuffer.empty());
|
||||||
@@ -1599,14 +1599,17 @@ TEST_F(QuicTransportFunctionsTest, ProbingFallbackToPing) {
|
|||||||
*aead,
|
*aead,
|
||||||
*headerCipher,
|
*headerCipher,
|
||||||
getVersion(*conn)));
|
getVersion(*conn)));
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
EXPECT_EQ(1, conn->outstandingPackets[0].packet.frames.size());
|
EXPECT_EQ(1, conn->outstandings.packets[0].packet.frames.size());
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
QuicWriteFrame::Type::QuicSimpleFrame_E,
|
QuicWriteFrame::Type::QuicSimpleFrame_E,
|
||||||
conn->outstandingPackets[0].packet.frames[0].type());
|
conn->outstandings.packets[0].packet.frames[0].type());
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
QuicSimpleFrame::Type::PingFrame_E,
|
QuicSimpleFrame::Type::PingFrame_E,
|
||||||
conn->outstandingPackets[0].packet.frames[0].asQuicSimpleFrame()->type());
|
conn->outstandings.packets[0]
|
||||||
|
.packet.frames[0]
|
||||||
|
.asQuicSimpleFrame()
|
||||||
|
->type());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, TestCryptoWritingIsHandshakeInOutstanding) {
|
TEST_F(QuicTransportFunctionsTest, TestCryptoWritingIsHandshakeInOutstanding) {
|
||||||
@@ -1631,7 +1634,7 @@ TEST_F(QuicTransportFunctionsTest, TestCryptoWritingIsHandshakeInOutstanding) {
|
|||||||
*conn->initialHeaderCipher,
|
*conn->initialHeaderCipher,
|
||||||
getVersion(*conn),
|
getVersion(*conn),
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit));
|
conn->transportSettings.writeConnectionDataPacketsLimit));
|
||||||
ASSERT_EQ(1, conn->outstandingPackets.size());
|
ASSERT_EQ(1, conn->outstandings.packets.size());
|
||||||
EXPECT_TRUE(getFirstOutstandingPacket(*conn, PacketNumberSpace::Initial)
|
EXPECT_TRUE(getFirstOutstandingPacket(*conn, PacketNumberSpace::Initial)
|
||||||
->isHandshake);
|
->isHandshake);
|
||||||
}
|
}
|
||||||
@@ -1677,7 +1680,7 @@ TEST_F(QuicTransportFunctionsTest, WritePureAckWhenNoWritableBytes) {
|
|||||||
getVersion(*conn),
|
getVersion(*conn),
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit),
|
conn->transportSettings.writeConnectionDataPacketsLimit),
|
||||||
0);
|
0);
|
||||||
EXPECT_EQ(0, conn->outstandingPackets.size());
|
EXPECT_EQ(0, conn->outstandings.packets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, ShouldWriteDataTest) {
|
TEST_F(QuicTransportFunctionsTest, ShouldWriteDataTest) {
|
||||||
@@ -1926,16 +1929,16 @@ TEST_F(QuicTransportFunctionsTest, HasAppDataToWrite) {
|
|||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, UpdateConnectionCloneCounter) {
|
TEST_F(QuicTransportFunctionsTest, UpdateConnectionCloneCounter) {
|
||||||
auto conn = createConn();
|
auto conn = createConn();
|
||||||
ASSERT_EQ(0, conn->outstandingClonedPacketsCount);
|
ASSERT_EQ(0, conn->outstandings.clonedPacketsCount);
|
||||||
auto packet = buildEmptyPacket(*conn, PacketNumberSpace::AppData);
|
auto packet = buildEmptyPacket(*conn, PacketNumberSpace::AppData);
|
||||||
auto connWindowUpdate =
|
auto connWindowUpdate =
|
||||||
MaxDataFrame(conn->flowControlState.advertisedMaxOffset);
|
MaxDataFrame(conn->flowControlState.advertisedMaxOffset);
|
||||||
conn->pendingEvents.connWindowUpdate = true;
|
conn->pendingEvents.connWindowUpdate = true;
|
||||||
packet.packet.frames.emplace_back(connWindowUpdate);
|
packet.packet.frames.emplace_back(connWindowUpdate);
|
||||||
PacketEvent packetEvent = 100;
|
PacketEvent packetEvent = 100;
|
||||||
conn->outstandingPacketEvents.insert(packetEvent);
|
conn->outstandings.packetEvents.insert(packetEvent);
|
||||||
updateConnection(*conn, packetEvent, packet.packet, TimePoint(), 123);
|
updateConnection(*conn, packetEvent, packet.packet, TimePoint(), 123);
|
||||||
EXPECT_EQ(1, conn->outstandingClonedPacketsCount);
|
EXPECT_EQ(1, conn->outstandings.clonedPacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, ClearBlockedFromPendingEvents) {
|
TEST_F(QuicTransportFunctionsTest, ClearBlockedFromPendingEvents) {
|
||||||
@@ -1948,8 +1951,8 @@ TEST_F(QuicTransportFunctionsTest, ClearBlockedFromPendingEvents) {
|
|||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_FALSE(conn->streamManager->hasBlocked());
|
EXPECT_FALSE(conn->streamManager->hasBlocked());
|
||||||
EXPECT_FALSE(conn->outstandingPackets.empty());
|
EXPECT_FALSE(conn->outstandings.packets.empty());
|
||||||
EXPECT_EQ(0, conn->outstandingClonedPacketsCount);
|
EXPECT_EQ(0, conn->outstandings.clonedPacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, ClonedBlocked) {
|
TEST_F(QuicTransportFunctionsTest, ClonedBlocked) {
|
||||||
@@ -1959,12 +1962,12 @@ TEST_F(QuicTransportFunctionsTest, ClonedBlocked) {
|
|||||||
auto stream = conn->streamManager->createNextBidirectionalStream().value();
|
auto stream = conn->streamManager->createNextBidirectionalStream().value();
|
||||||
StreamDataBlockedFrame blockedFrame(stream->id, 1000);
|
StreamDataBlockedFrame blockedFrame(stream->id, 1000);
|
||||||
packet.packet.frames.emplace_back(blockedFrame);
|
packet.packet.frames.emplace_back(blockedFrame);
|
||||||
conn->outstandingPacketEvents.insert(packetEvent);
|
conn->outstandings.packetEvents.insert(packetEvent);
|
||||||
// This shall not crash
|
// This shall not crash
|
||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, packetEvent, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, packetEvent, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_FALSE(conn->outstandingPackets.empty());
|
EXPECT_FALSE(conn->outstandings.packets.empty());
|
||||||
EXPECT_EQ(1, conn->outstandingClonedPacketsCount);
|
EXPECT_EQ(1, conn->outstandings.clonedPacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, TwoConnWindowUpdateWillCrash) {
|
TEST_F(QuicTransportFunctionsTest, TwoConnWindowUpdateWillCrash) {
|
||||||
@@ -1995,7 +1998,7 @@ TEST_F(QuicTransportFunctionsTest, WriteStreamFrameIsNotPureAck) {
|
|||||||
packet.packet.frames.push_back(std::move(writeStreamFrame));
|
packet.packet.frames.push_back(std::move(writeStreamFrame));
|
||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_FALSE(conn->outstandingPackets.empty());
|
EXPECT_FALSE(conn->outstandings.packets.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, ClearRstFromPendingEvents) {
|
TEST_F(QuicTransportFunctionsTest, ClearRstFromPendingEvents) {
|
||||||
@@ -2009,8 +2012,8 @@ TEST_F(QuicTransportFunctionsTest, ClearRstFromPendingEvents) {
|
|||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, folly::none, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_TRUE(conn->pendingEvents.resets.empty());
|
EXPECT_TRUE(conn->pendingEvents.resets.empty());
|
||||||
EXPECT_FALSE(conn->outstandingPackets.empty());
|
EXPECT_FALSE(conn->outstandings.packets.empty());
|
||||||
EXPECT_EQ(0, conn->outstandingClonedPacketsCount);
|
EXPECT_EQ(0, conn->outstandings.clonedPacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, ClonedRst) {
|
TEST_F(QuicTransportFunctionsTest, ClonedRst) {
|
||||||
@@ -2021,12 +2024,12 @@ TEST_F(QuicTransportFunctionsTest, ClonedRst) {
|
|||||||
RstStreamFrame rstStreamFrame(
|
RstStreamFrame rstStreamFrame(
|
||||||
stream->id, GenericApplicationErrorCode::UNKNOWN, 0);
|
stream->id, GenericApplicationErrorCode::UNKNOWN, 0);
|
||||||
packet.packet.frames.emplace_back(std::move(rstStreamFrame));
|
packet.packet.frames.emplace_back(std::move(rstStreamFrame));
|
||||||
conn->outstandingPacketEvents.insert(packetEvent);
|
conn->outstandings.packetEvents.insert(packetEvent);
|
||||||
// This shall not crash
|
// This shall not crash
|
||||||
updateConnection(
|
updateConnection(
|
||||||
*conn, packetEvent, packet.packet, TimePoint(), getEncodedSize(packet));
|
*conn, packetEvent, packet.packet, TimePoint(), getEncodedSize(packet));
|
||||||
EXPECT_FALSE(conn->outstandingPackets.empty());
|
EXPECT_FALSE(conn->outstandings.packets.empty());
|
||||||
EXPECT_EQ(1, conn->outstandingClonedPacketsCount);
|
EXPECT_EQ(1, conn->outstandings.clonedPacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, TotalBytesSentUpdate) {
|
TEST_F(QuicTransportFunctionsTest, TotalBytesSentUpdate) {
|
||||||
@@ -2046,7 +2049,7 @@ TEST_F(QuicTransportFunctionsTest, TimeoutBasedRetxCountUpdate) {
|
|||||||
stream->id, GenericApplicationErrorCode::UNKNOWN, 0);
|
stream->id, GenericApplicationErrorCode::UNKNOWN, 0);
|
||||||
packet.packet.frames.push_back(rstStreamFrame);
|
packet.packet.frames.push_back(rstStreamFrame);
|
||||||
PacketEvent packetEvent = 100;
|
PacketEvent packetEvent = 100;
|
||||||
conn->outstandingPacketEvents.insert(packetEvent);
|
conn->outstandings.packetEvents.insert(packetEvent);
|
||||||
updateConnection(*conn, packetEvent, packet.packet, TimePoint(), 500);
|
updateConnection(*conn, packetEvent, packet.packet, TimePoint(), 500);
|
||||||
EXPECT_EQ(247, conn->lossState.timeoutBasedRtxCount);
|
EXPECT_EQ(247, conn->lossState.timeoutBasedRtxCount);
|
||||||
}
|
}
|
||||||
@@ -2214,11 +2217,11 @@ TEST_F(QuicTransportFunctionsTest, ProbeWriteNewFunctionalFrames) {
|
|||||||
*headerCipher,
|
*headerCipher,
|
||||||
getVersion(*conn),
|
getVersion(*conn),
|
||||||
1 /* limit to 1 packet */);
|
1 /* limit to 1 packet */);
|
||||||
EXPECT_EQ(2, conn->outstandingPackets.size());
|
EXPECT_EQ(2, conn->outstandings.packets.size());
|
||||||
EXPECT_EQ(1, conn->outstandingPackets[1].packet.frames.size());
|
EXPECT_EQ(1, conn->outstandings.packets[1].packet.frames.size());
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
QuicWriteFrame::Type::MaxDataFrame_E,
|
QuicWriteFrame::Type::MaxDataFrame_E,
|
||||||
conn->outstandingPackets[1].packet.frames[0].type());
|
conn->outstandings.packets[1].packet.frames[0].type());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportFunctionsTest, WriteWithInplaceBuilder) {
|
TEST_F(QuicTransportFunctionsTest, WriteWithInplaceBuilder) {
|
||||||
@@ -2375,13 +2378,13 @@ TEST_F(QuicTransportFunctionsTest, WriteProbingWithInplaceBuilder) {
|
|||||||
conn->transportSettings.writeConnectionDataPacketsLimit + 1);
|
conn->transportSettings.writeConnectionDataPacketsLimit + 1);
|
||||||
ASSERT_EQ(0, bufPtr->length());
|
ASSERT_EQ(0, bufPtr->length());
|
||||||
ASSERT_EQ(0, bufPtr->headroom());
|
ASSERT_EQ(0, bufPtr->headroom());
|
||||||
EXPECT_GE(conn->outstandingPackets.size(), 5);
|
EXPECT_GE(conn->outstandings.packets.size(), 5);
|
||||||
// Make sure there no more new data to write:
|
// Make sure there no more new data to write:
|
||||||
StreamFrameScheduler streamScheduler(*conn);
|
StreamFrameScheduler streamScheduler(*conn);
|
||||||
ASSERT_FALSE(streamScheduler.hasPendingData());
|
ASSERT_FALSE(streamScheduler.hasPendingData());
|
||||||
|
|
||||||
// The last packet may not be a full packet
|
// The last packet may not be a full packet
|
||||||
auto lastPacketSize = conn->outstandingPackets.back().encodedSize;
|
auto lastPacketSize = conn->outstandings.packets.back().encodedSize;
|
||||||
size_t expectedOutstandingPacketsCount = 5;
|
size_t expectedOutstandingPacketsCount = 5;
|
||||||
if (lastPacketSize < conn->udpSendPacketLen) {
|
if (lastPacketSize < conn->udpSendPacketLen) {
|
||||||
expectedOutstandingPacketsCount++;
|
expectedOutstandingPacketsCount++;
|
||||||
@@ -2404,7 +2407,7 @@ TEST_F(QuicTransportFunctionsTest, WriteProbingWithInplaceBuilder) {
|
|||||||
*headerCipher,
|
*headerCipher,
|
||||||
getVersion(*conn));
|
getVersion(*conn));
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
conn->outstandingPackets.size(), expectedOutstandingPacketsCount + 1);
|
conn->outstandings.packets.size(), expectedOutstandingPacketsCount + 1);
|
||||||
EXPECT_EQ(0, bufPtr->length());
|
EXPECT_EQ(0, bufPtr->length());
|
||||||
EXPECT_EQ(0, bufPtr->headroom());
|
EXPECT_EQ(0, bufPtr->headroom());
|
||||||
|
|
||||||
@@ -2442,14 +2445,15 @@ TEST_F(QuicTransportFunctionsTest, WriteProbingWithInplaceBuilder) {
|
|||||||
EXPECT_EQ(0, bufPtr->length());
|
EXPECT_EQ(0, bufPtr->length());
|
||||||
EXPECT_EQ(0, bufPtr->headroom());
|
EXPECT_EQ(0, bufPtr->headroom());
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
conn->outstandingPackets.size(), expectedOutstandingPacketsCount + 3);
|
conn->outstandings.packets.size(), expectedOutstandingPacketsCount + 3);
|
||||||
|
|
||||||
// Clear out all the small packets:
|
// Clear out all the small packets:
|
||||||
while (conn->outstandingPackets.back().encodedSize < conn->udpSendPacketLen) {
|
while (conn->outstandings.packets.back().encodedSize <
|
||||||
conn->outstandingPackets.pop_back();
|
conn->udpSendPacketLen) {
|
||||||
|
conn->outstandings.packets.pop_back();
|
||||||
}
|
}
|
||||||
ASSERT_FALSE(conn->outstandingPackets.empty());
|
ASSERT_FALSE(conn->outstandings.packets.empty());
|
||||||
auto currentOutstandingPackets = conn->outstandingPackets.size();
|
auto currentOutstandingPackets = conn->outstandings.packets.size();
|
||||||
|
|
||||||
// Clone 2 full size packets
|
// Clone 2 full size packets
|
||||||
EXPECT_CALL(mockSock, writeGSO(_, _, _))
|
EXPECT_CALL(mockSock, writeGSO(_, _, _))
|
||||||
@@ -2469,7 +2473,7 @@ TEST_F(QuicTransportFunctionsTest, WriteProbingWithInplaceBuilder) {
|
|||||||
*aead,
|
*aead,
|
||||||
*headerCipher,
|
*headerCipher,
|
||||||
getVersion(*conn));
|
getVersion(*conn));
|
||||||
EXPECT_EQ(conn->outstandingPackets.size(), currentOutstandingPackets + 2);
|
EXPECT_EQ(conn->outstandings.packets.size(), currentOutstandingPackets + 2);
|
||||||
EXPECT_EQ(0, bufPtr->length());
|
EXPECT_EQ(0, bufPtr->length());
|
||||||
EXPECT_EQ(0, bufPtr->headroom());
|
EXPECT_EQ(0, bufPtr->headroom());
|
||||||
}
|
}
|
||||||
|
@@ -243,7 +243,7 @@ size_t bufLength(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dropPackets(QuicServerConnectionState& conn) {
|
void dropPackets(QuicServerConnectionState& conn) {
|
||||||
for (const auto& packet : conn.outstandingPackets) {
|
for (const auto& packet : conn.outstandings.packets) {
|
||||||
for (const auto& frame : packet.packet.frames) {
|
for (const auto& frame : packet.packet.frames) {
|
||||||
const WriteStreamFrame* streamFrame = frame.asWriteStreamFrame();
|
const WriteStreamFrame* streamFrame = frame.asWriteStreamFrame();
|
||||||
if (!streamFrame) {
|
if (!streamFrame) {
|
||||||
@@ -272,7 +272,7 @@ void dropPackets(QuicServerConnectionState& conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to verify the data of buffer is written to outstanding
|
// Helper function to verify the data of buffer is written to outstanding
|
||||||
@@ -288,7 +288,7 @@ void verifyCorrectness(
|
|||||||
size_t totalLen = 0;
|
size_t totalLen = 0;
|
||||||
bool finSet = false;
|
bool finSet = false;
|
||||||
std::vector<uint64_t> offsets;
|
std::vector<uint64_t> offsets;
|
||||||
for (const auto& packet : conn.outstandingPackets) {
|
for (const auto& packet : conn.outstandings.packets) {
|
||||||
for (const auto& frame : packet.packet.frames) {
|
for (const auto& frame : packet.packet.frames) {
|
||||||
auto streamFrame = frame.asWriteStreamFrame();
|
auto streamFrame = frame.asWriteStreamFrame();
|
||||||
if (!streamFrame) {
|
if (!streamFrame) {
|
||||||
@@ -413,7 +413,7 @@ TEST_F(QuicTransportTest, NotAppLimitedWithNoWritableBytes) {
|
|||||||
conn.congestionController = std::move(mockCongestionController);
|
conn.congestionController = std::move(mockCongestionController);
|
||||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||||
.WillRepeatedly(Invoke([&]() {
|
.WillRepeatedly(Invoke([&]() {
|
||||||
if (conn.outstandingPackets.empty()) {
|
if (conn.outstandings.packets.empty()) {
|
||||||
return 5000;
|
return 5000;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -512,7 +512,7 @@ TEST_F(QuicTransportTest, WriteLarge) {
|
|||||||
transport_->writeChain(stream, buf->clone(), false, false);
|
transport_->writeChain(stream, buf->clone(), false, false);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
auto& conn = transport_->getConnectionState();
|
auto& conn = transport_->getConnectionState();
|
||||||
EXPECT_EQ(NumFullPackets + 1, conn.outstandingPackets.size());
|
EXPECT_EQ(NumFullPackets + 1, conn.outstandings.packets.size());
|
||||||
verifyCorrectness(conn, 0, stream, *buf);
|
verifyCorrectness(conn, 0, stream, *buf);
|
||||||
|
|
||||||
// Test retransmission
|
// Test retransmission
|
||||||
@@ -529,7 +529,7 @@ TEST_F(QuicTransportTest, WriteLarge) {
|
|||||||
*headerCipher_,
|
*headerCipher_,
|
||||||
transport_->getVersion(),
|
transport_->getVersion(),
|
||||||
conn.transportSettings.writeConnectionDataPacketsLimit);
|
conn.transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(NumFullPackets + 1, conn.outstandingPackets.size());
|
EXPECT_EQ(NumFullPackets + 1, conn.outstandings.packets.size());
|
||||||
verifyCorrectness(conn, 0, stream, *buf);
|
verifyCorrectness(conn, 0, stream, *buf);
|
||||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(conn));
|
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(conn));
|
||||||
}
|
}
|
||||||
@@ -545,7 +545,7 @@ TEST_F(QuicTransportTest, WriteMultipleTimes) {
|
|||||||
conn.streamManager->findStream(stream)->currentWriteOffset;
|
conn.streamManager->findStream(stream)->currentWriteOffset;
|
||||||
verifyCorrectness(conn, 0, stream, *buf);
|
verifyCorrectness(conn, 0, stream, *buf);
|
||||||
|
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
conn.streamManager->findStream(stream)->retransmissionBuffer.clear();
|
conn.streamManager->findStream(stream)->retransmissionBuffer.clear();
|
||||||
buf = buildRandomInputData(50);
|
buf = buildRandomInputData(50);
|
||||||
EXPECT_CALL(*socket_, write(_, _)).WillOnce(Invoke(bufLength));
|
EXPECT_CALL(*socket_, write(_, _)).WillOnce(Invoke(bufLength));
|
||||||
@@ -610,7 +610,7 @@ TEST_F(QuicTransportTest, WriteFlowControl) {
|
|||||||
transport_->writeChain(streamId, buf->clone(), false, false);
|
transport_->writeChain(streamId, buf->clone(), false, false);
|
||||||
|
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
EXPECT_EQ(conn.outstandingPackets.size(), 1);
|
EXPECT_EQ(conn.outstandings.packets.size(), 1);
|
||||||
auto& packet =
|
auto& packet =
|
||||||
getFirstOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
getFirstOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
||||||
bool blockedFound = false;
|
bool blockedFound = false;
|
||||||
@@ -623,7 +623,7 @@ TEST_F(QuicTransportTest, WriteFlowControl) {
|
|||||||
blockedFound = true;
|
blockedFound = true;
|
||||||
}
|
}
|
||||||
EXPECT_TRUE(blockedFound);
|
EXPECT_TRUE(blockedFound);
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
|
|
||||||
// Stream flow control
|
// Stream flow control
|
||||||
auto buf1 = buf->clone();
|
auto buf1 = buf->clone();
|
||||||
@@ -793,7 +793,7 @@ TEST_F(QuicTransportTest, WriteImmediateAcks) {
|
|||||||
*headerCipher_,
|
*headerCipher_,
|
||||||
transport_->getVersion(),
|
transport_->getVersion(),
|
||||||
conn.transportSettings.writeConnectionDataPacketsLimit);
|
conn.transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_TRUE(conn.outstandingPackets.empty());
|
EXPECT_TRUE(conn.outstandings.packets.empty());
|
||||||
EXPECT_EQ(conn.ackStates.appDataAckState.largestAckScheduled, end);
|
EXPECT_EQ(conn.ackStates.appDataAckState.largestAckScheduled, end);
|
||||||
EXPECT_FALSE(conn.ackStates.appDataAckState.needsToSendAckImmediately);
|
EXPECT_FALSE(conn.ackStates.appDataAckState.needsToSendAckImmediately);
|
||||||
EXPECT_EQ(0, conn.ackStates.appDataAckState.numNonRxPacketsRecvd);
|
EXPECT_EQ(0, conn.ackStates.appDataAckState.numNonRxPacketsRecvd);
|
||||||
@@ -833,7 +833,7 @@ TEST_F(QuicTransportTest, WritePendingAckIfHavingData) {
|
|||||||
// We should write acks if there is data pending
|
// We should write acks if there is data pending
|
||||||
transport_->writeChain(streamId, buf->clone(), true, false);
|
transport_->writeChain(streamId, buf->clone(), true, false);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
EXPECT_EQ(conn.outstandingPackets.size(), 1);
|
EXPECT_EQ(conn.outstandings.packets.size(), 1);
|
||||||
auto& packet =
|
auto& packet =
|
||||||
getFirstOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
getFirstOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
||||||
EXPECT_GE(packet.frames.size(), 2);
|
EXPECT_GE(packet.frames.size(), 2);
|
||||||
@@ -865,7 +865,7 @@ TEST_F(QuicTransportTest, RstStream) {
|
|||||||
EXPECT_CALL(*socket_, write(_, _)).WillOnce(Invoke(bufLength));
|
EXPECT_CALL(*socket_, write(_, _)).WillOnce(Invoke(bufLength));
|
||||||
transport_->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);
|
transport_->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -901,7 +901,7 @@ TEST_F(QuicTransportTest, StopSending) {
|
|||||||
EXPECT_CALL(*socket_, write(_, _)).WillOnce(Invoke(bufLength));
|
EXPECT_CALL(*socket_, write(_, _)).WillOnce(Invoke(bufLength));
|
||||||
transport_->stopSending(streamId, GenericApplicationErrorCode::UNKNOWN);
|
transport_->stopSending(streamId, GenericApplicationErrorCode::UNKNOWN);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -943,7 +943,7 @@ TEST_F(QuicTransportTest, SendPathChallenge) {
|
|||||||
EXPECT_EQ(conn.outstandingPathValidation, pathChallenge);
|
EXPECT_EQ(conn.outstandingPathValidation, pathChallenge);
|
||||||
EXPECT_TRUE(transport_->getPathValidationTimeout().isScheduled());
|
EXPECT_TRUE(transport_->getPathValidationTimeout().isScheduled());
|
||||||
|
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -984,7 +984,7 @@ TEST_F(QuicTransportTest, PathValidationTimeoutExpired) {
|
|||||||
EXPECT_EQ(conn.outstandingPathValidation, pathChallenge);
|
EXPECT_EQ(conn.outstandingPathValidation, pathChallenge);
|
||||||
EXPECT_TRUE(transport_->getPathValidationTimeout().isScheduled());
|
EXPECT_TRUE(transport_->getPathValidationTimeout().isScheduled());
|
||||||
|
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
|
|
||||||
transport_->getPathValidationTimeout().cancelTimeout();
|
transport_->getPathValidationTimeout().cancelTimeout();
|
||||||
transport_->getPathValidationTimeout().timeoutExpired();
|
transport_->getPathValidationTimeout().timeoutExpired();
|
||||||
@@ -1012,7 +1012,7 @@ TEST_F(QuicTransportTest, SendPathValidationWhileThereIsOutstandingOne) {
|
|||||||
EXPECT_EQ(conn.outstandingPathValidation, pathChallenge);
|
EXPECT_EQ(conn.outstandingPathValidation, pathChallenge);
|
||||||
EXPECT_TRUE(transport_->getPathValidationTimeout().isScheduled());
|
EXPECT_TRUE(transport_->getPathValidationTimeout().isScheduled());
|
||||||
|
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
|
|
||||||
PathChallengeFrame pathChallenge2(456);
|
PathChallengeFrame pathChallenge2(456);
|
||||||
transport_->getPathValidationTimeout().cancelTimeout();
|
transport_->getPathValidationTimeout().cancelTimeout();
|
||||||
@@ -1029,14 +1029,14 @@ TEST_F(QuicTransportTest, SendPathValidationWhileThereIsOutstandingOne) {
|
|||||||
EXPECT_EQ(conn.outstandingPathValidation, pathChallenge2);
|
EXPECT_EQ(conn.outstandingPathValidation, pathChallenge2);
|
||||||
EXPECT_TRUE(transport_->getPathValidationTimeout().isScheduled());
|
EXPECT_TRUE(transport_->getPathValidationTimeout().isScheduled());
|
||||||
|
|
||||||
EXPECT_EQ(2, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(2, transport_->getConnectionState().outstandings.packets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportTest, ClonePathChallenge) {
|
TEST_F(QuicTransportTest, ClonePathChallenge) {
|
||||||
auto& conn = transport_->getConnectionState();
|
auto& conn = transport_->getConnectionState();
|
||||||
// knock every handshake outstanding packets out
|
// knock every handshake outstanding packets out
|
||||||
conn.outstandingHandshakePacketsCount = 0;
|
conn.outstandings.handshakePacketsCount = 0;
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
for (auto& t : conn.lossState.lossTimes) {
|
for (auto& t : conn.lossState.lossTimes) {
|
||||||
t.reset();
|
t.reset();
|
||||||
}
|
}
|
||||||
@@ -1048,20 +1048,20 @@ TEST_F(QuicTransportTest, ClonePathChallenge) {
|
|||||||
transport_->updateWriteLooper(true);
|
transport_->updateWriteLooper(true);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
EXPECT_EQ(conn.outstandingPackets.size(), 1);
|
EXPECT_EQ(conn.outstandings.packets.size(), 1);
|
||||||
auto numPathChallengePackets = std::count_if(
|
auto numPathChallengePackets = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<QuicSimpleFrame::Type::PathChallengeFrame_E>());
|
findFrameInPacketFunc<QuicSimpleFrame::Type::PathChallengeFrame_E>());
|
||||||
EXPECT_EQ(numPathChallengePackets, 1);
|
EXPECT_EQ(numPathChallengePackets, 1);
|
||||||
|
|
||||||
// Force a timeout with no data so that it clones the packet
|
// Force a timeout with no data so that it clones the packet
|
||||||
transport_->lossTimeout().timeoutExpired();
|
transport_->lossTimeout().timeoutExpired();
|
||||||
// On PTO, endpoint sends 2 probing packets, thus 1+2=3
|
// On PTO, endpoint sends 2 probing packets, thus 1+2=3
|
||||||
EXPECT_EQ(conn.outstandingPackets.size(), 3);
|
EXPECT_EQ(conn.outstandings.packets.size(), 3);
|
||||||
numPathChallengePackets = std::count_if(
|
numPathChallengePackets = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<QuicSimpleFrame::Type::PathChallengeFrame_E>());
|
findFrameInPacketFunc<QuicSimpleFrame::Type::PathChallengeFrame_E>());
|
||||||
|
|
||||||
EXPECT_EQ(numPathChallengePackets, 3);
|
EXPECT_EQ(numPathChallengePackets, 3);
|
||||||
@@ -1070,8 +1070,8 @@ TEST_F(QuicTransportTest, ClonePathChallenge) {
|
|||||||
TEST_F(QuicTransportTest, OnlyClonePathValidationIfOutstanding) {
|
TEST_F(QuicTransportTest, OnlyClonePathValidationIfOutstanding) {
|
||||||
auto& conn = transport_->getConnectionState();
|
auto& conn = transport_->getConnectionState();
|
||||||
// knock every handshake outstanding packets out
|
// knock every handshake outstanding packets out
|
||||||
conn.outstandingHandshakePacketsCount = 0;
|
conn.outstandings.handshakePacketsCount = 0;
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
for (auto& t : conn.lossState.lossTimes) {
|
for (auto& t : conn.lossState.lossTimes) {
|
||||||
t.reset();
|
t.reset();
|
||||||
}
|
}
|
||||||
@@ -1084,8 +1084,8 @@ TEST_F(QuicTransportTest, OnlyClonePathValidationIfOutstanding) {
|
|||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
auto numPathChallengePackets = std::count_if(
|
auto numPathChallengePackets = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<QuicSimpleFrame::Type::PathChallengeFrame_E>());
|
findFrameInPacketFunc<QuicSimpleFrame::Type::PathChallengeFrame_E>());
|
||||||
EXPECT_EQ(numPathChallengePackets, 1);
|
EXPECT_EQ(numPathChallengePackets, 1);
|
||||||
|
|
||||||
@@ -1097,8 +1097,8 @@ TEST_F(QuicTransportTest, OnlyClonePathValidationIfOutstanding) {
|
|||||||
// Force a timeout with no data so that it clones the packet
|
// Force a timeout with no data so that it clones the packet
|
||||||
transport_->lossTimeout().timeoutExpired();
|
transport_->lossTimeout().timeoutExpired();
|
||||||
numPathChallengePackets = std::count_if(
|
numPathChallengePackets = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<QuicSimpleFrame::Type::PathChallengeFrame_E>());
|
findFrameInPacketFunc<QuicSimpleFrame::Type::PathChallengeFrame_E>());
|
||||||
EXPECT_EQ(numPathChallengePackets, 1);
|
EXPECT_EQ(numPathChallengePackets, 1);
|
||||||
}
|
}
|
||||||
@@ -1113,7 +1113,7 @@ TEST_F(QuicTransportTest, ResendPathChallengeOnLoss) {
|
|||||||
transport_->updateWriteLooper(true);
|
transport_->updateWriteLooper(true);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -1134,7 +1134,7 @@ TEST_F(QuicTransportTest, DoNotResendLostPathChallengeIfNotOutstanding) {
|
|||||||
transport_->updateWriteLooper(true);
|
transport_->updateWriteLooper(true);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -1160,7 +1160,7 @@ TEST_F(QuicTransportTest, SendPathResponse) {
|
|||||||
loopForWrites();
|
loopForWrites();
|
||||||
EXPECT_EQ(conn.pendingEvents.frames.size(), 0);
|
EXPECT_EQ(conn.pendingEvents.frames.size(), 0);
|
||||||
|
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
||||||
bool foundPathResponse = false;
|
bool foundPathResponse = false;
|
||||||
@@ -1184,7 +1184,7 @@ TEST_F(QuicTransportTest, CloneAfterRecvReset) {
|
|||||||
auto streamId = transport_->createBidirectionalStream().value();
|
auto streamId = transport_->createBidirectionalStream().value();
|
||||||
transport_->writeChain(streamId, IOBuf::create(0), true, false);
|
transport_->writeChain(streamId, IOBuf::create(0), true, false);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
auto stream = conn.streamManager->getStream(streamId);
|
auto stream = conn.streamManager->getStream(streamId);
|
||||||
EXPECT_EQ(1, stream->retransmissionBuffer.size());
|
EXPECT_EQ(1, stream->retransmissionBuffer.size());
|
||||||
EXPECT_EQ(0, stream->retransmissionBuffer.at(0)->data.chainLength());
|
EXPECT_EQ(0, stream->retransmissionBuffer.at(0)->data.chainLength());
|
||||||
@@ -1201,10 +1201,10 @@ TEST_F(QuicTransportTest, CloneAfterRecvReset) {
|
|||||||
// the future, thus the EXPECT were written with LT and LE. But it will clone
|
// the future, thus the EXPECT were written with LT and LE. But it will clone
|
||||||
// for sure and we shouldn't crash.
|
// for sure and we shouldn't crash.
|
||||||
transport_->lossTimeout().timeoutExpired();
|
transport_->lossTimeout().timeoutExpired();
|
||||||
EXPECT_LT(1, conn.outstandingPackets.size());
|
EXPECT_LT(1, conn.outstandings.packets.size());
|
||||||
size_t cloneCounter = std::count_if(
|
size_t cloneCounter = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
[](const auto& packet) { return packet.associatedEvent.hasValue(); });
|
[](const auto& packet) { return packet.associatedEvent.hasValue(); });
|
||||||
EXPECT_LE(1, cloneCounter);
|
EXPECT_LE(1, cloneCounter);
|
||||||
}
|
}
|
||||||
@@ -1212,8 +1212,8 @@ TEST_F(QuicTransportTest, CloneAfterRecvReset) {
|
|||||||
TEST_F(QuicTransportTest, ClonePathResponse) {
|
TEST_F(QuicTransportTest, ClonePathResponse) {
|
||||||
auto& conn = transport_->getConnectionState();
|
auto& conn = transport_->getConnectionState();
|
||||||
// knock every handshake outstanding packets out
|
// knock every handshake outstanding packets out
|
||||||
conn.outstandingHandshakePacketsCount = 0;
|
conn.outstandings.handshakePacketsCount = 0;
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
for (auto& t : conn.lossState.lossTimes) {
|
for (auto& t : conn.lossState.lossTimes) {
|
||||||
t.reset();
|
t.reset();
|
||||||
}
|
}
|
||||||
@@ -1227,16 +1227,16 @@ TEST_F(QuicTransportTest, ClonePathResponse) {
|
|||||||
EXPECT_EQ(conn.pendingEvents.frames.size(), 0);
|
EXPECT_EQ(conn.pendingEvents.frames.size(), 0);
|
||||||
|
|
||||||
auto numPathResponsePackets = std::count_if(
|
auto numPathResponsePackets = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<QuicSimpleFrame::Type::PathResponseFrame_E>());
|
findFrameInPacketFunc<QuicSimpleFrame::Type::PathResponseFrame_E>());
|
||||||
EXPECT_EQ(numPathResponsePackets, 1);
|
EXPECT_EQ(numPathResponsePackets, 1);
|
||||||
|
|
||||||
// Force a timeout with no data so that it clones the packet
|
// Force a timeout with no data so that it clones the packet
|
||||||
transport_->lossTimeout().timeoutExpired();
|
transport_->lossTimeout().timeoutExpired();
|
||||||
numPathResponsePackets = std::count_if(
|
numPathResponsePackets = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<QuicSimpleFrame::Type::PathResponseFrame_E>());
|
findFrameInPacketFunc<QuicSimpleFrame::Type::PathResponseFrame_E>());
|
||||||
EXPECT_EQ(numPathResponsePackets, 1);
|
EXPECT_EQ(numPathResponsePackets, 1);
|
||||||
}
|
}
|
||||||
@@ -1252,7 +1252,7 @@ TEST_F(QuicTransportTest, DoNotResendPathResponseOnLoss) {
|
|||||||
loopForWrites();
|
loopForWrites();
|
||||||
EXPECT_EQ(conn.pendingEvents.frames.size(), 0);
|
EXPECT_EQ(conn.pendingEvents.frames.size(), 0);
|
||||||
|
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
||||||
|
|
||||||
@@ -1270,7 +1270,7 @@ TEST_F(QuicTransportTest, SendNewConnectionIdFrame) {
|
|||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
EXPECT_TRUE(conn.pendingEvents.frames.empty());
|
EXPECT_TRUE(conn.pendingEvents.frames.empty());
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -1295,8 +1295,8 @@ TEST_F(QuicTransportTest, SendNewConnectionIdFrame) {
|
|||||||
TEST_F(QuicTransportTest, CloneNewConnectionIdFrame) {
|
TEST_F(QuicTransportTest, CloneNewConnectionIdFrame) {
|
||||||
auto& conn = transport_->getConnectionState();
|
auto& conn = transport_->getConnectionState();
|
||||||
// knock every handshake outstanding packets out
|
// knock every handshake outstanding packets out
|
||||||
conn.outstandingHandshakePacketsCount = 0;
|
conn.outstandings.handshakePacketsCount = 0;
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
for (auto& t : conn.lossState.lossTimes) {
|
for (auto& t : conn.lossState.lossTimes) {
|
||||||
t.reset();
|
t.reset();
|
||||||
}
|
}
|
||||||
@@ -1307,20 +1307,20 @@ TEST_F(QuicTransportTest, CloneNewConnectionIdFrame) {
|
|||||||
transport_->updateWriteLooper(true);
|
transport_->updateWriteLooper(true);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
EXPECT_EQ(conn.outstandingPackets.size(), 1);
|
EXPECT_EQ(conn.outstandings.packets.size(), 1);
|
||||||
auto numNewConnIdPackets = std::count_if(
|
auto numNewConnIdPackets = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<QuicSimpleFrame::Type::NewConnectionIdFrame_E>());
|
findFrameInPacketFunc<QuicSimpleFrame::Type::NewConnectionIdFrame_E>());
|
||||||
EXPECT_EQ(numNewConnIdPackets, 1);
|
EXPECT_EQ(numNewConnIdPackets, 1);
|
||||||
|
|
||||||
// Force a timeout with no data so that it clones the packet
|
// Force a timeout with no data so that it clones the packet
|
||||||
transport_->lossTimeout().timeoutExpired();
|
transport_->lossTimeout().timeoutExpired();
|
||||||
// On PTO, endpoint sends 2 probing packets, thus 1+2=3
|
// On PTO, endpoint sends 2 probing packets, thus 1+2=3
|
||||||
EXPECT_EQ(conn.outstandingPackets.size(), 3);
|
EXPECT_EQ(conn.outstandings.packets.size(), 3);
|
||||||
numNewConnIdPackets = std::count_if(
|
numNewConnIdPackets = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<QuicSimpleFrame::Type::NewConnectionIdFrame_E>());
|
findFrameInPacketFunc<QuicSimpleFrame::Type::NewConnectionIdFrame_E>());
|
||||||
EXPECT_EQ(numNewConnIdPackets, 3);
|
EXPECT_EQ(numNewConnIdPackets, 3);
|
||||||
}
|
}
|
||||||
@@ -1356,7 +1356,7 @@ TEST_F(QuicTransportTest, BusyWriteLoopDetection) {
|
|||||||
EXPECT_EQ(WriteDataReason::STREAM, conn.writeDebugState.writeDataReason);
|
EXPECT_EQ(WriteDataReason::STREAM, conn.writeDebugState.writeDataReason);
|
||||||
EXPECT_CALL(*socket_, write(_, _)).WillOnce(Return(1000));
|
EXPECT_CALL(*socket_, write(_, _)).WillOnce(Return(1000));
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
EXPECT_EQ(0, conn.writeDebugState.currentEmptyLoopCount);
|
EXPECT_EQ(0, conn.writeDebugState.currentEmptyLoopCount);
|
||||||
|
|
||||||
// Queue a window update for a stream doesn't exist
|
// Queue a window update for a stream doesn't exist
|
||||||
@@ -1371,7 +1371,7 @@ TEST_F(QuicTransportTest, BusyWriteLoopDetection) {
|
|||||||
onSuspiciousWriteLoops(1, WriteDataReason::STREAM_WINDOW_UPDATE, _, _))
|
onSuspiciousWriteLoops(1, WriteDataReason::STREAM_WINDOW_UPDATE, _, _))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
EXPECT_EQ(1, conn.writeDebugState.currentEmptyLoopCount);
|
EXPECT_EQ(1, conn.writeDebugState.currentEmptyLoopCount);
|
||||||
|
|
||||||
transport_->close(folly::none);
|
transport_->close(folly::none);
|
||||||
@@ -1386,7 +1386,7 @@ TEST_F(QuicTransportTest, ResendNewConnectionIdOnLoss) {
|
|||||||
transport_->updateWriteLooper(true);
|
transport_->updateWriteLooper(true);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -1410,7 +1410,7 @@ TEST_F(QuicTransportTest, SendRetireConnectionIdFrame) {
|
|||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
EXPECT_TRUE(conn.pendingEvents.frames.empty());
|
EXPECT_TRUE(conn.pendingEvents.frames.empty());
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -1435,8 +1435,8 @@ TEST_F(QuicTransportTest, SendRetireConnectionIdFrame) {
|
|||||||
TEST_F(QuicTransportTest, CloneRetireConnectionIdFrame) {
|
TEST_F(QuicTransportTest, CloneRetireConnectionIdFrame) {
|
||||||
auto& conn = transport_->getConnectionState();
|
auto& conn = transport_->getConnectionState();
|
||||||
// knock every handshake outstanding packets out
|
// knock every handshake outstanding packets out
|
||||||
conn.outstandingHandshakePacketsCount = 0;
|
conn.outstandings.handshakePacketsCount = 0;
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
for (auto& t : conn.lossState.lossTimes) {
|
for (auto& t : conn.lossState.lossTimes) {
|
||||||
t.reset();
|
t.reset();
|
||||||
}
|
}
|
||||||
@@ -1446,10 +1446,10 @@ TEST_F(QuicTransportTest, CloneRetireConnectionIdFrame) {
|
|||||||
transport_->updateWriteLooper(true);
|
transport_->updateWriteLooper(true);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
EXPECT_EQ(conn.outstandingPackets.size(), 1);
|
EXPECT_EQ(conn.outstandings.packets.size(), 1);
|
||||||
auto numRetireConnIdPackets = std::count_if(
|
auto numRetireConnIdPackets = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<
|
findFrameInPacketFunc<
|
||||||
QuicSimpleFrame::Type::RetireConnectionIdFrame_E>());
|
QuicSimpleFrame::Type::RetireConnectionIdFrame_E>());
|
||||||
EXPECT_EQ(numRetireConnIdPackets, 1);
|
EXPECT_EQ(numRetireConnIdPackets, 1);
|
||||||
@@ -1457,10 +1457,10 @@ TEST_F(QuicTransportTest, CloneRetireConnectionIdFrame) {
|
|||||||
// Force a timeout with no data so that it clones the packet
|
// Force a timeout with no data so that it clones the packet
|
||||||
transport_->lossTimeout().timeoutExpired();
|
transport_->lossTimeout().timeoutExpired();
|
||||||
// On PTO, endpoint sends 2 probing packets, thus 1+2=3
|
// On PTO, endpoint sends 2 probing packets, thus 1+2=3
|
||||||
EXPECT_EQ(conn.outstandingPackets.size(), 3);
|
EXPECT_EQ(conn.outstandings.packets.size(), 3);
|
||||||
numRetireConnIdPackets = std::count_if(
|
numRetireConnIdPackets = std::count_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<
|
findFrameInPacketFunc<
|
||||||
QuicSimpleFrame::Type::RetireConnectionIdFrame_E>());
|
QuicSimpleFrame::Type::RetireConnectionIdFrame_E>());
|
||||||
EXPECT_EQ(numRetireConnIdPackets, 3);
|
EXPECT_EQ(numRetireConnIdPackets, 3);
|
||||||
@@ -1474,7 +1474,7 @@ TEST_F(QuicTransportTest, ResendRetireConnectionIdOnLoss) {
|
|||||||
transport_->updateWriteLooper(true);
|
transport_->updateWriteLooper(true);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -1534,7 +1534,7 @@ TEST_F(QuicTransportTest, RstWrittenStream) {
|
|||||||
transport_->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);
|
transport_->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
// 2 packets are outstanding: one for Stream frame one for RstStream frame:
|
// 2 packets are outstanding: one for Stream frame one for RstStream frame:
|
||||||
EXPECT_EQ(2, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(2, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -1568,7 +1568,7 @@ TEST_F(QuicTransportTest, RstStreamUDPWriteFailNonFatal) {
|
|||||||
transport_->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);
|
transport_->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size());
|
EXPECT_EQ(1, transport_->getConnectionState().outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(
|
getLastOutstandingPacket(
|
||||||
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
transport_->getConnectionState(), PacketNumberSpace::AppData)
|
||||||
@@ -1605,7 +1605,7 @@ TEST_F(QuicTransportTest, RstStreamUDPWriteFailFatal) {
|
|||||||
.WillRepeatedly(SetErrnoAndReturn(EBADF, -1));
|
.WillRepeatedly(SetErrnoAndReturn(EBADF, -1));
|
||||||
transport_->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);
|
transport_->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
EXPECT_TRUE(transport_->getConnectionState().outstandingPackets.empty());
|
EXPECT_TRUE(transport_->getConnectionState().outstandings.packets.empty());
|
||||||
|
|
||||||
// Streams should be empty now since the connection will be closed.
|
// Streams should be empty now since the connection will be closed.
|
||||||
EXPECT_EQ(transport_->getConnectionState().streamManager->streamCount(), 0);
|
EXPECT_EQ(transport_->getConnectionState().streamManager->streamCount(), 0);
|
||||||
@@ -1640,7 +1640,7 @@ TEST_F(QuicTransportTest, WriteAfterSendRst) {
|
|||||||
|
|
||||||
// only 2 packets are outstanding: one for Stream frame one for RstStream
|
// only 2 packets are outstanding: one for Stream frame one for RstStream
|
||||||
// frame. The 2nd writeChain won't write anything.
|
// frame. The 2nd writeChain won't write anything.
|
||||||
EXPECT_EQ(2, conn.outstandingPackets.size());
|
EXPECT_EQ(2, conn.outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
||||||
EXPECT_GE(packet.frames.size(), 1);
|
EXPECT_GE(packet.frames.size(), 1);
|
||||||
@@ -1720,7 +1720,7 @@ TEST_F(QuicTransportTest, WriteWindowUpdate) {
|
|||||||
transport_->getVersion(),
|
transport_->getVersion(),
|
||||||
conn.transportSettings.writeConnectionDataPacketsLimit);
|
conn.transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(1, res); // Write one packet out
|
EXPECT_EQ(1, res); // Write one packet out
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
auto packet =
|
auto packet =
|
||||||
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
||||||
EXPECT_GE(packet.frames.size(), 1);
|
EXPECT_GE(packet.frames.size(), 1);
|
||||||
@@ -1737,7 +1737,7 @@ TEST_F(QuicTransportTest, WriteWindowUpdate) {
|
|||||||
EXPECT_TRUE(connWindowFound);
|
EXPECT_TRUE(connWindowFound);
|
||||||
|
|
||||||
EXPECT_EQ(conn.flowControlState.advertisedMaxOffset, 100);
|
EXPECT_EQ(conn.flowControlState.advertisedMaxOffset, 100);
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
|
|
||||||
auto stream = transport_->createBidirectionalStream().value();
|
auto stream = transport_->createBidirectionalStream().value();
|
||||||
auto streamState = conn.streamManager->getStream(stream);
|
auto streamState = conn.streamManager->getStream(stream);
|
||||||
@@ -1756,7 +1756,7 @@ TEST_F(QuicTransportTest, WriteWindowUpdate) {
|
|||||||
transport_->getVersion(),
|
transport_->getVersion(),
|
||||||
conn.transportSettings.writeConnectionDataPacketsLimit);
|
conn.transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(1, res); // Write one packet out
|
EXPECT_EQ(1, res); // Write one packet out
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
auto packet1 =
|
auto packet1 =
|
||||||
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
||||||
const MaxStreamDataFrame* streamWindowUpdate =
|
const MaxStreamDataFrame* streamWindowUpdate =
|
||||||
@@ -2353,14 +2353,14 @@ TEST_F(QuicTransportTest, WriteStreamFromMiddleOfMap) {
|
|||||||
*headerCipher_,
|
*headerCipher_,
|
||||||
transport_->getVersion(),
|
transport_->getVersion(),
|
||||||
conn.transportSettings.writeConnectionDataPacketsLimit);
|
conn.transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
auto& packet = *getFirstOutstandingPacket(conn, PacketNumberSpace::AppData);
|
auto& packet = *getFirstOutstandingPacket(conn, PacketNumberSpace::AppData);
|
||||||
EXPECT_EQ(1, packet.packet.frames.size());
|
EXPECT_EQ(1, packet.packet.frames.size());
|
||||||
auto& frame = packet.packet.frames.front();
|
auto& frame = packet.packet.frames.front();
|
||||||
const WriteStreamFrame* streamFrame = frame.asWriteStreamFrame();
|
const WriteStreamFrame* streamFrame = frame.asWriteStreamFrame();
|
||||||
EXPECT_TRUE(streamFrame);
|
EXPECT_TRUE(streamFrame);
|
||||||
EXPECT_EQ(streamFrame->streamId, s1);
|
EXPECT_EQ(streamFrame->streamId, s1);
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
|
|
||||||
// Start from stream2 instead of stream1
|
// Start from stream2 instead of stream1
|
||||||
conn.schedulingState.nextScheduledStream = s2;
|
conn.schedulingState.nextScheduledStream = s2;
|
||||||
@@ -2376,14 +2376,14 @@ TEST_F(QuicTransportTest, WriteStreamFromMiddleOfMap) {
|
|||||||
*headerCipher_,
|
*headerCipher_,
|
||||||
transport_->getVersion(),
|
transport_->getVersion(),
|
||||||
conn.transportSettings.writeConnectionDataPacketsLimit);
|
conn.transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
auto& packet2 = *getFirstOutstandingPacket(conn, PacketNumberSpace::AppData);
|
auto& packet2 = *getFirstOutstandingPacket(conn, PacketNumberSpace::AppData);
|
||||||
EXPECT_EQ(1, packet2.packet.frames.size());
|
EXPECT_EQ(1, packet2.packet.frames.size());
|
||||||
auto& frame2 = packet2.packet.frames.front();
|
auto& frame2 = packet2.packet.frames.front();
|
||||||
const WriteStreamFrame* streamFrame2 = frame2.asWriteStreamFrame();
|
const WriteStreamFrame* streamFrame2 = frame2.asWriteStreamFrame();
|
||||||
EXPECT_TRUE(streamFrame2);
|
EXPECT_TRUE(streamFrame2);
|
||||||
EXPECT_EQ(streamFrame2->streamId, s2);
|
EXPECT_EQ(streamFrame2->streamId, s2);
|
||||||
conn.outstandingPackets.clear();
|
conn.outstandings.packets.clear();
|
||||||
|
|
||||||
// Test wrap around
|
// Test wrap around
|
||||||
conn.schedulingState.nextScheduledStream = s2;
|
conn.schedulingState.nextScheduledStream = s2;
|
||||||
@@ -2398,7 +2398,7 @@ TEST_F(QuicTransportTest, WriteStreamFromMiddleOfMap) {
|
|||||||
*headerCipher_,
|
*headerCipher_,
|
||||||
transport_->getVersion(),
|
transport_->getVersion(),
|
||||||
conn.transportSettings.writeConnectionDataPacketsLimit);
|
conn.transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
auto& packet3 = *getFirstOutstandingPacket(conn, PacketNumberSpace::AppData);
|
auto& packet3 = *getFirstOutstandingPacket(conn, PacketNumberSpace::AppData);
|
||||||
EXPECT_EQ(2, packet3.packet.frames.size());
|
EXPECT_EQ(2, packet3.packet.frames.size());
|
||||||
auto& frame3 = packet3.packet.frames.front();
|
auto& frame3 = packet3.packet.frames.front();
|
||||||
@@ -2424,7 +2424,7 @@ TEST_F(QuicTransportTest, NoStream) {
|
|||||||
*headerCipher_,
|
*headerCipher_,
|
||||||
transport_->getVersion(),
|
transport_->getVersion(),
|
||||||
conn.transportSettings.writeConnectionDataPacketsLimit);
|
conn.transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_TRUE(conn.outstandingPackets.empty());
|
EXPECT_TRUE(conn.outstandings.packets.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportTest, CancelAckTimeout) {
|
TEST_F(QuicTransportTest, CancelAckTimeout) {
|
||||||
|
@@ -25,16 +25,16 @@ uint64_t PacketRebuilder::getHeaderBytes() const {
|
|||||||
|
|
||||||
PacketEvent PacketRebuilder::cloneOutstandingPacket(OutstandingPacket& packet) {
|
PacketEvent PacketRebuilder::cloneOutstandingPacket(OutstandingPacket& packet) {
|
||||||
// Either the packet has never been cloned before, or it's associatedEvent is
|
// Either the packet has never been cloned before, or it's associatedEvent is
|
||||||
// still in the outstandingPacketEvents set.
|
// still in the outstandings.packetEvents set.
|
||||||
DCHECK(
|
DCHECK(
|
||||||
!packet.associatedEvent ||
|
!packet.associatedEvent ||
|
||||||
conn_.outstandingPacketEvents.count(*packet.associatedEvent));
|
conn_.outstandings.packetEvents.count(*packet.associatedEvent));
|
||||||
if (!packet.associatedEvent) {
|
if (!packet.associatedEvent) {
|
||||||
auto packetNum = packet.packet.header.getPacketSequenceNum();
|
auto packetNum = packet.packet.header.getPacketSequenceNum();
|
||||||
DCHECK(!conn_.outstandingPacketEvents.count(packetNum));
|
DCHECK(!conn_.outstandings.packetEvents.count(packetNum));
|
||||||
packet.associatedEvent = packetNum;
|
packet.associatedEvent = packetNum;
|
||||||
conn_.outstandingPacketEvents.insert(packetNum);
|
conn_.outstandings.packetEvents.insert(packetNum);
|
||||||
++conn_.outstandingClonedPacketsCount;
|
++conn_.outstandings.clonedPacketsCount;
|
||||||
}
|
}
|
||||||
return *packet.associatedEvent;
|
return *packet.associatedEvent;
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ class PacketRebuilder {
|
|||||||
/**
|
/**
|
||||||
* A helper function that takes a OutstandingPacket that's not processed, and
|
* A helper function that takes a OutstandingPacket that's not processed, and
|
||||||
* return its associatedEvent. If this packet has never been cloned, then
|
* return its associatedEvent. If this packet has never been cloned, then
|
||||||
* create the associatedEvent and add it into outstandingPacketEvents first.
|
* create the associatedEvent and add it into outstandings.packetEvents first.
|
||||||
*/
|
*/
|
||||||
PacketEvent cloneOutstandingPacket(OutstandingPacket& packet);
|
PacketEvent cloneOutstandingPacket(OutstandingPacket& packet);
|
||||||
|
|
||||||
|
@@ -448,7 +448,7 @@ TEST_F(QuicPacketRebuilderTest, CloneCounter) {
|
|||||||
PacketRebuilder rebuilder(regularBuilder2, conn);
|
PacketRebuilder rebuilder(regularBuilder2, conn);
|
||||||
rebuilder.rebuildFromPacket(outstandingPacket);
|
rebuilder.rebuildFromPacket(outstandingPacket);
|
||||||
EXPECT_TRUE(outstandingPacket.associatedEvent.has_value());
|
EXPECT_TRUE(outstandingPacket.associatedEvent.has_value());
|
||||||
EXPECT_EQ(1, conn.outstandingClonedPacketsCount);
|
EXPECT_EQ(1, conn.outstandings.clonedPacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicPacketRebuilderTest, LastStreamFrameSkipLen) {
|
TEST_F(QuicPacketRebuilderTest, LastStreamFrameSkipLen) {
|
||||||
|
@@ -45,7 +45,7 @@ const RegularQuicWritePacket& writeQuicPacket(
|
|||||||
version,
|
version,
|
||||||
conn.transportSettings.writeConnectionDataPacketsLimit);
|
conn.transportSettings.writeConnectionDataPacketsLimit);
|
||||||
CHECK(
|
CHECK(
|
||||||
conn.outstandingPackets.rend() !=
|
conn.outstandings.packets.rend() !=
|
||||||
getLastOutstandingPacket(conn, PacketNumberSpace::AppData));
|
getLastOutstandingPacket(conn, PacketNumberSpace::AppData));
|
||||||
return getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
return getLastOutstandingPacket(conn, PacketNumberSpace::AppData)->packet;
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ PacketNum rstStreamAndSendPacket(
|
|||||||
version,
|
version,
|
||||||
conn.transportSettings.writeConnectionDataPacketsLimit);
|
conn.transportSettings.writeConnectionDataPacketsLimit);
|
||||||
|
|
||||||
for (const auto& packet : conn.outstandingPackets) {
|
for (const auto& packet : conn.outstandings.packets) {
|
||||||
for (const auto& frame : packet.packet.frames) {
|
for (const auto& frame : packet.packet.frames) {
|
||||||
auto rstFrame = frame.asRstStreamFrame();
|
auto rstFrame = frame.asRstStreamFrame();
|
||||||
if (!rstFrame) {
|
if (!rstFrame) {
|
||||||
|
@@ -202,7 +202,7 @@ OutstandingPacket* findOutstandingPacket(
|
|||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
return helper(conn.outstandingPackets);
|
return helper(conn.outstandings.packets);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to generate a buffer containing random data of given length
|
// Helper function to generate a buffer containing random data of given length
|
||||||
|
@@ -27,14 +27,12 @@ struct Bandwidth {
|
|||||||
UnitType unitType{UnitType::BYTES};
|
UnitType unitType{UnitType::BYTES};
|
||||||
|
|
||||||
explicit Bandwidth()
|
explicit Bandwidth()
|
||||||
: units(0),
|
: units(0), interval(std::chrono::microseconds::zero()) {}
|
||||||
interval(std::chrono::microseconds::zero()) {}
|
|
||||||
|
|
||||||
explicit Bandwidth(
|
explicit Bandwidth(
|
||||||
uint64_t unitsDelievered,
|
uint64_t unitsDelievered,
|
||||||
std::chrono::microseconds deliveryInterval)
|
std::chrono::microseconds deliveryInterval)
|
||||||
: units(unitsDelievered),
|
: units(unitsDelievered), interval(deliveryInterval) {}
|
||||||
interval(deliveryInterval) {}
|
|
||||||
|
|
||||||
explicit Bandwidth(
|
explicit Bandwidth(
|
||||||
uint64_t unitsDelievered,
|
uint64_t unitsDelievered,
|
||||||
|
@@ -50,8 +50,8 @@ PacingRate calculatePacingRate(
|
|||||||
conn.transportSettings.pacingTimerTickInterval,
|
conn.transportSettings.pacingTimerTickInterval,
|
||||||
rtt * burstPerInterval / cwndInPackets);
|
rtt * burstPerInterval / cwndInPackets);
|
||||||
return PacingRate::Builder()
|
return PacingRate::Builder()
|
||||||
.setInterval(interval)
|
.setInterval(interval)
|
||||||
.setBurstSize(burstPerInterval)
|
.setBurstSize(burstPerInterval)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
} // namespace quic
|
} // namespace quic
|
||||||
|
@@ -548,7 +548,7 @@ TEST_F(BbrTest, BytesCounting) {
|
|||||||
|
|
||||||
PacketNum packetNum = 0;
|
PacketNum packetNum = 0;
|
||||||
auto packet = makeTestingWritePacket(packetNum, 1200, 1200);
|
auto packet = makeTestingWritePacket(packetNum, 1200, 1200);
|
||||||
conn.outstandingPackets.push_back(packet);
|
conn.outstandings.packets.push_back(packet);
|
||||||
ReadAckFrame ackFrame;
|
ReadAckFrame ackFrame;
|
||||||
ackFrame.largestAcked = packetNum;
|
ackFrame.largestAcked = packetNum;
|
||||||
ackFrame.ackBlocks.emplace_back(packetNum, packetNum);
|
ackFrame.ackBlocks.emplace_back(packetNum, packetNum);
|
||||||
|
@@ -72,6 +72,5 @@ TEST_F(CongestionControlFunctionsTest, RttSmallerThanInterval) {
|
|||||||
conn.transportSettings.writeConnectionDataPacketsLimit, result.burstSize);
|
conn.transportSettings.writeConnectionDataPacketsLimit, result.burstSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace test
|
} // namespace test
|
||||||
} // namespace quic
|
} // namespace quic
|
||||||
|
@@ -3474,7 +3474,7 @@ TEST_F(QuicClientTransportAfterStartTest, CloseConnectionWithStreamPending) {
|
|||||||
client->writeChain(streamId, expected->clone(), true, false);
|
client->writeChain(streamId, expected->clone(), true, false);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
// ack all the packets
|
// ack all the packets
|
||||||
ASSERT_FALSE(client->getConn().outstandingPackets.empty());
|
ASSERT_FALSE(client->getConn().outstandings.packets.empty());
|
||||||
|
|
||||||
AckBlocks acks;
|
AckBlocks acks;
|
||||||
auto start = getFirstOutstandingPacket(
|
auto start = getFirstOutstandingPacket(
|
||||||
@@ -3549,7 +3549,7 @@ TEST_F(QuicClientTransportAfterStartTest, CloseConnectionWithNoStreamPending) {
|
|||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
// ack all the packets
|
// ack all the packets
|
||||||
ASSERT_FALSE(client->getConn().outstandingPackets.empty());
|
ASSERT_FALSE(client->getConn().outstandings.packets.empty());
|
||||||
|
|
||||||
AckBlocks acks;
|
AckBlocks acks;
|
||||||
auto start = getFirstOutstandingPacket(
|
auto start = getFirstOutstandingPacket(
|
||||||
@@ -3961,7 +3961,7 @@ TEST_F(QuicClientTransportAfterStartTest, IdleTimerNotResetOnWritingOldData) {
|
|||||||
TEST_F(QuicClientTransportAfterStartTest, IdleTimerResetNoOutstandingPackets) {
|
TEST_F(QuicClientTransportAfterStartTest, IdleTimerResetNoOutstandingPackets) {
|
||||||
// This will clear out all the outstanding packets
|
// This will clear out all the outstanding packets
|
||||||
AckBlocks sentPackets;
|
AckBlocks sentPackets;
|
||||||
for (auto& packet : client->getNonConstConn().outstandingPackets) {
|
for (auto& packet : client->getNonConstConn().outstandings.packets) {
|
||||||
auto packetNum = packet.packet.header.getPacketSequenceNum();
|
auto packetNum = packet.packet.header.getPacketSequenceNum();
|
||||||
sentPackets.insert(packetNum);
|
sentPackets.insert(packetNum);
|
||||||
}
|
}
|
||||||
@@ -3974,9 +3974,9 @@ TEST_F(QuicClientTransportAfterStartTest, IdleTimerResetNoOutstandingPackets) {
|
|||||||
|
|
||||||
// Clear out all the outstanding packets to simulate quiescent state.
|
// Clear out all the outstanding packets to simulate quiescent state.
|
||||||
client->getNonConstConn().receivedNewPacketBeforeWrite = false;
|
client->getNonConstConn().receivedNewPacketBeforeWrite = false;
|
||||||
client->getNonConstConn().outstandingPackets.clear();
|
client->getNonConstConn().outstandings.packets.clear();
|
||||||
client->getNonConstConn().outstandingHandshakePacketsCount = 0;
|
client->getNonConstConn().outstandings.handshakePacketsCount = 0;
|
||||||
client->getNonConstConn().outstandingClonedPacketsCount = 0;
|
client->getNonConstConn().outstandings.clonedPacketsCount = 0;
|
||||||
client->idleTimeout().cancelTimeout();
|
client->idleTimeout().cancelTimeout();
|
||||||
auto streamId = client->createBidirectionalStream().value();
|
auto streamId = client->createBidirectionalStream().value();
|
||||||
auto expected = folly::IOBuf::copyBuffer("hello");
|
auto expected = folly::IOBuf::copyBuffer("hello");
|
||||||
@@ -4723,7 +4723,7 @@ TEST_F(QuicClientTransportAfterStartTest, ResetClearsPendingLoss) {
|
|||||||
};
|
};
|
||||||
client->writeChain(streamId, IOBuf::copyBuffer("hello"), true, false);
|
client->writeChain(streamId, IOBuf::copyBuffer("hello"), true, false);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
ASSERT_FALSE(client->getConn().outstandingPackets.empty());
|
ASSERT_FALSE(client->getConn().outstandings.packets.empty());
|
||||||
|
|
||||||
RegularQuicWritePacket* forceLossPacket =
|
RegularQuicWritePacket* forceLossPacket =
|
||||||
CHECK_NOTNULL(findPacketWithStream(client->getNonConstConn(), streamId));
|
CHECK_NOTNULL(findPacketWithStream(client->getNonConstConn(), streamId));
|
||||||
@@ -4748,7 +4748,7 @@ TEST_F(QuicClientTransportAfterStartTest, LossAfterResetStream) {
|
|||||||
};
|
};
|
||||||
client->writeChain(streamId, IOBuf::copyBuffer("hello"), true, false);
|
client->writeChain(streamId, IOBuf::copyBuffer("hello"), true, false);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
ASSERT_FALSE(client->getConn().outstandingPackets.empty());
|
ASSERT_FALSE(client->getConn().outstandings.packets.empty());
|
||||||
|
|
||||||
client->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);
|
client->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);
|
||||||
|
|
||||||
@@ -5367,7 +5367,7 @@ class QuicZeroRttClientTest : public QuicClientTransportAfterStartTestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool zeroRttPacketsOutstanding() {
|
bool zeroRttPacketsOutstanding() {
|
||||||
for (auto& packet : client->getNonConstConn().outstandingPackets) {
|
for (auto& packet : client->getNonConstConn().outstandings.packets) {
|
||||||
bool isZeroRtt =
|
bool isZeroRtt =
|
||||||
packet.packet.header.getProtectionType() == ProtectionType::ZeroRtt;
|
packet.packet.header.getProtectionType() == ProtectionType::ZeroRtt;
|
||||||
if (isZeroRtt) {
|
if (isZeroRtt) {
|
||||||
|
@@ -38,7 +38,7 @@ void onPTOAlarm(QuicConnectionStateBase& conn) {
|
|||||||
conn,
|
conn,
|
||||||
conn.lossState.largestSent.value_or(0),
|
conn.lossState.largestSent.value_or(0),
|
||||||
conn.lossState.ptoCount,
|
conn.lossState.ptoCount,
|
||||||
(uint64_t)conn.outstandingPackets.size());
|
(uint64_t)conn.outstandings.packets.size());
|
||||||
QUIC_STATS(conn.statsCallback, onPTO);
|
QUIC_STATS(conn.statsCallback, onPTO);
|
||||||
conn.lossState.ptoCount++;
|
conn.lossState.ptoCount++;
|
||||||
conn.lossState.totalPTOCount++;
|
conn.lossState.totalPTOCount++;
|
||||||
@@ -46,7 +46,7 @@ void onPTOAlarm(QuicConnectionStateBase& conn) {
|
|||||||
conn.qLogger->addLossAlarm(
|
conn.qLogger->addLossAlarm(
|
||||||
conn.lossState.largestSent.value_or(0),
|
conn.lossState.largestSent.value_or(0),
|
||||||
conn.lossState.ptoCount,
|
conn.lossState.ptoCount,
|
||||||
(uint64_t)conn.outstandingPackets.size(),
|
(uint64_t)conn.outstandings.packets.size(),
|
||||||
kPtoAlarm);
|
kPtoAlarm);
|
||||||
}
|
}
|
||||||
if (conn.lossState.ptoCount == conn.transportSettings.maxNumPTOs) {
|
if (conn.lossState.ptoCount == conn.transportSettings.maxNumPTOs) {
|
||||||
|
@@ -77,7 +77,7 @@ calculateAlarmDuration(const QuicConnectionStateBase& conn) {
|
|||||||
alarmDuration = 0us;
|
alarmDuration = 0us;
|
||||||
}
|
}
|
||||||
alarmMethod = LossState::AlarmMethod::EarlyRetransmitOrReordering;
|
alarmMethod = LossState::AlarmMethod::EarlyRetransmitOrReordering;
|
||||||
} else if (conn.outstandingHandshakePacketsCount > 0) {
|
} else if (conn.outstandings.handshakePacketsCount > 0) {
|
||||||
if (conn.lossState.srtt == 0us) {
|
if (conn.lossState.srtt == 0us) {
|
||||||
alarmDuration = conn.transportSettings.initialRtt * 2;
|
alarmDuration = conn.transportSettings.initialRtt * 2;
|
||||||
} else {
|
} else {
|
||||||
@@ -106,7 +106,7 @@ calculateAlarmDuration(const QuicConnectionStateBase& conn) {
|
|||||||
lastSentPacketTime + alarmDuration - now);
|
lastSentPacketTime + alarmDuration - now);
|
||||||
} else {
|
} else {
|
||||||
auto lastSentPacketNum =
|
auto lastSentPacketNum =
|
||||||
conn.outstandingPackets.back().packet.header.getPacketSequenceNum();
|
conn.outstandings.packets.back().packet.header.getPacketSequenceNum();
|
||||||
VLOG(10) << __func__ << " alarm already due method=" << *alarmMethod
|
VLOG(10) << __func__ << " alarm already due method=" << *alarmMethod
|
||||||
<< " lastSentPacketNum=" << lastSentPacketNum
|
<< " lastSentPacketNum=" << lastSentPacketNum
|
||||||
<< " lastSentPacketTime="
|
<< " lastSentPacketTime="
|
||||||
@@ -138,7 +138,7 @@ void setLossDetectionAlarm(QuicConnectionStateBase& conn, Timeout& timeout) {
|
|||||||
*/
|
*/
|
||||||
bool hasDataToWrite = hasAckDataToWrite(conn) ||
|
bool hasDataToWrite = hasAckDataToWrite(conn) ||
|
||||||
(hasNonAckDataToWrite(conn) != WriteDataReason::NO_WRITE);
|
(hasNonAckDataToWrite(conn) != WriteDataReason::NO_WRITE);
|
||||||
auto totalPacketsOutstanding = conn.outstandingPackets.size();
|
auto totalPacketsOutstanding = conn.outstandings.packets.size();
|
||||||
/*
|
/*
|
||||||
* We have this condition to disambiguate the case where we have.
|
* We have this condition to disambiguate the case where we have.
|
||||||
* (1) All outstanding packets that are clones that are processed and there
|
* (1) All outstanding packets that are clones that are processed and there
|
||||||
@@ -151,11 +151,11 @@ void setLossDetectionAlarm(QuicConnectionStateBase& conn, Timeout& timeout) {
|
|||||||
* write them since we could be blocked by cwnd. So we must set the loss timer
|
* write them since we could be blocked by cwnd. So we must set the loss timer
|
||||||
* so that we can write this data with the slack packet space for the clones.
|
* so that we can write this data with the slack packet space for the clones.
|
||||||
*/
|
*/
|
||||||
if (!hasDataToWrite && conn.outstandingPacketEvents.empty() &&
|
if (!hasDataToWrite && conn.outstandings.packetEvents.empty() &&
|
||||||
totalPacketsOutstanding == conn.outstandingClonedPacketsCount) {
|
totalPacketsOutstanding == conn.outstandings.clonedPacketsCount) {
|
||||||
VLOG(10) << __func__ << " unset alarm pure ack or processed packets only"
|
VLOG(10) << __func__ << " unset alarm pure ack or processed packets only"
|
||||||
<< " outstanding=" << totalPacketsOutstanding
|
<< " outstanding=" << totalPacketsOutstanding
|
||||||
<< " handshakePackets=" << conn.outstandingHandshakePacketsCount
|
<< " handshakePackets=" << conn.outstandings.handshakePacketsCount
|
||||||
<< " " << conn;
|
<< " " << conn;
|
||||||
conn.pendingEvents.setLossDetectionAlarm = false;
|
conn.pendingEvents.setLossDetectionAlarm = false;
|
||||||
timeout.cancelLossTimeout();
|
timeout.cancelLossTimeout();
|
||||||
@@ -165,8 +165,8 @@ void setLossDetectionAlarm(QuicConnectionStateBase& conn, Timeout& timeout) {
|
|||||||
VLOG_IF(10, !timeout.isLossTimeoutScheduled())
|
VLOG_IF(10, !timeout.isLossTimeoutScheduled())
|
||||||
<< __func__ << " alarm not scheduled"
|
<< __func__ << " alarm not scheduled"
|
||||||
<< " outstanding=" << totalPacketsOutstanding
|
<< " outstanding=" << totalPacketsOutstanding
|
||||||
<< " handshakePackets=" << conn.outstandingHandshakePacketsCount << " "
|
<< " handshakePackets=" << conn.outstandings.handshakePacketsCount
|
||||||
<< nodeToString(conn.nodeType) << " " << conn;
|
<< " " << nodeToString(conn.nodeType) << " " << conn;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timeout.cancelLossTimeout();
|
timeout.cancelLossTimeout();
|
||||||
@@ -176,7 +176,7 @@ void setLossDetectionAlarm(QuicConnectionStateBase& conn, Timeout& timeout) {
|
|||||||
<< " alarm=" << alarmDuration.first.count() << "ms"
|
<< " alarm=" << alarmDuration.first.count() << "ms"
|
||||||
<< " method=" << conn.lossState.currentAlarmMethod
|
<< " method=" << conn.lossState.currentAlarmMethod
|
||||||
<< " outstanding=" << totalPacketsOutstanding
|
<< " outstanding=" << totalPacketsOutstanding
|
||||||
<< " handshakePackets=" << conn.outstandingHandshakePacketsCount
|
<< " handshakePackets=" << conn.outstandings.handshakePacketsCount
|
||||||
<< " " << nodeToString(conn.nodeType) << " " << conn;
|
<< " " << nodeToString(conn.nodeType) << " " << conn;
|
||||||
timeout.scheduleLossTimeout(alarmDuration.first);
|
timeout.scheduleLossTimeout(alarmDuration.first);
|
||||||
conn.pendingEvents.setLossDetectionAlarm = false;
|
conn.pendingEvents.setLossDetectionAlarm = false;
|
||||||
@@ -198,7 +198,7 @@ folly::Optional<CongestionController::LossEvent> detectLossPackets(
|
|||||||
std::max(conn.lossState.srtt, conn.lossState.lrtt) *
|
std::max(conn.lossState.srtt, conn.lossState.lrtt) *
|
||||||
conn.transportSettings.timeReorderingThreshDividend /
|
conn.transportSettings.timeReorderingThreshDividend /
|
||||||
conn.transportSettings.timeReorderingThreshDivisor;
|
conn.transportSettings.timeReorderingThreshDivisor;
|
||||||
VLOG(10) << __func__ << " outstanding=" << conn.outstandingPackets.size()
|
VLOG(10) << __func__ << " outstanding=" << conn.outstandings.packets.size()
|
||||||
<< " largestAcked=" << largestAcked.value_or(0)
|
<< " largestAcked=" << largestAcked.value_or(0)
|
||||||
<< " delayUntilLost=" << delayUntilLost.count() << "us"
|
<< " delayUntilLost=" << delayUntilLost.count() << "us"
|
||||||
<< " " << conn;
|
<< " " << conn;
|
||||||
@@ -206,7 +206,7 @@ folly::Optional<CongestionController::LossEvent> detectLossPackets(
|
|||||||
// Note that time based loss detection is also within the same PNSpace.
|
// Note that time based loss detection is also within the same PNSpace.
|
||||||
auto iter = getFirstOutstandingPacket(conn, pnSpace);
|
auto iter = getFirstOutstandingPacket(conn, pnSpace);
|
||||||
bool shouldSetTimer = false;
|
bool shouldSetTimer = false;
|
||||||
while (iter != conn.outstandingPackets.end()) {
|
while (iter != conn.outstandings.packets.end()) {
|
||||||
auto& pkt = *iter;
|
auto& pkt = *iter;
|
||||||
auto currentPacketNum = pkt.packet.header.getPacketSequenceNum();
|
auto currentPacketNum = pkt.packet.header.getPacketSequenceNum();
|
||||||
if (!largestAcked.has_value() || currentPacketNum >= *largestAcked) {
|
if (!largestAcked.has_value() || currentPacketNum >= *largestAcked) {
|
||||||
@@ -228,40 +228,40 @@ folly::Optional<CongestionController::LossEvent> detectLossPackets(
|
|||||||
}
|
}
|
||||||
lossEvent.addLostPacket(pkt);
|
lossEvent.addLostPacket(pkt);
|
||||||
if (pkt.associatedEvent) {
|
if (pkt.associatedEvent) {
|
||||||
DCHECK_GT(conn.outstandingClonedPacketsCount, 0);
|
DCHECK_GT(conn.outstandings.clonedPacketsCount, 0);
|
||||||
--conn.outstandingClonedPacketsCount;
|
--conn.outstandings.clonedPacketsCount;
|
||||||
}
|
}
|
||||||
// Invoke LossVisitor if the packet doesn't have a associated PacketEvent;
|
// Invoke LossVisitor if the packet doesn't have a associated PacketEvent;
|
||||||
// or if the PacketEvent is present in conn.outstandingPacketEvents.
|
// or if the PacketEvent is present in conn.outstandings.packetEvents.
|
||||||
bool processed = pkt.associatedEvent &&
|
bool processed = pkt.associatedEvent &&
|
||||||
!conn.outstandingPacketEvents.count(*pkt.associatedEvent);
|
!conn.outstandings.packetEvents.count(*pkt.associatedEvent);
|
||||||
lossVisitor(conn, pkt.packet, processed, currentPacketNum);
|
lossVisitor(conn, pkt.packet, processed, currentPacketNum);
|
||||||
// Remove the PacketEvent from the outstandingPacketEvents set
|
// Remove the PacketEvent from the outstandings.packetEvents set
|
||||||
if (pkt.associatedEvent) {
|
if (pkt.associatedEvent) {
|
||||||
conn.outstandingPacketEvents.erase(*pkt.associatedEvent);
|
conn.outstandings.packetEvents.erase(*pkt.associatedEvent);
|
||||||
}
|
}
|
||||||
if (pkt.isHandshake) {
|
if (pkt.isHandshake) {
|
||||||
DCHECK(conn.outstandingHandshakePacketsCount);
|
DCHECK(conn.outstandings.handshakePacketsCount);
|
||||||
--conn.outstandingHandshakePacketsCount;
|
--conn.outstandings.handshakePacketsCount;
|
||||||
}
|
}
|
||||||
VLOG(10) << __func__ << " lost packetNum=" << currentPacketNum
|
VLOG(10) << __func__ << " lost packetNum=" << currentPacketNum
|
||||||
<< " handshake=" << pkt.isHandshake << " " << conn;
|
<< " handshake=" << pkt.isHandshake << " " << conn;
|
||||||
iter = conn.outstandingPackets.erase(iter);
|
iter = conn.outstandings.packets.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto earliest = getFirstOutstandingPacket(conn, pnSpace);
|
auto earliest = getFirstOutstandingPacket(conn, pnSpace);
|
||||||
for (; earliest != conn.outstandingPackets.end();
|
for (; earliest != conn.outstandings.packets.end();
|
||||||
earliest = getNextOutstandingPacket(conn, pnSpace, earliest + 1)) {
|
earliest = getNextOutstandingPacket(conn, pnSpace, earliest + 1)) {
|
||||||
if (!earliest->associatedEvent ||
|
if (!earliest->associatedEvent ||
|
||||||
conn.outstandingPacketEvents.count(*earliest->associatedEvent)) {
|
conn.outstandings.packetEvents.count(*earliest->associatedEvent)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shouldSetTimer && earliest != conn.outstandingPackets.end()) {
|
if (shouldSetTimer && earliest != conn.outstandings.packets.end()) {
|
||||||
// We are eligible to set a loss timer and there are a few packets which
|
// We are eligible to set a loss timer and there are a few packets which
|
||||||
// are unacked, so we can set the early retransmit timer for them.
|
// are unacked, so we can set the early retransmit timer for them.
|
||||||
VLOG(10) << __func__ << " early retransmit timer outstanding="
|
VLOG(10) << __func__ << " early retransmit timer outstanding="
|
||||||
<< conn.outstandingPackets.empty() << " delayUntilLost"
|
<< conn.outstandings.packets.empty() << " delayUntilLost"
|
||||||
<< delayUntilLost.count() << "us"
|
<< delayUntilLost.count() << "us"
|
||||||
<< " " << conn;
|
<< " " << conn;
|
||||||
getLossTime(conn, pnSpace) = delayUntilLost + earliest->time;
|
getLossTime(conn, pnSpace) = delayUntilLost + earliest->time;
|
||||||
@@ -308,18 +308,18 @@ void onHandshakeAlarm(
|
|||||||
conn,
|
conn,
|
||||||
conn.lossState.largestSent.value_or(0),
|
conn.lossState.largestSent.value_or(0),
|
||||||
conn.lossState.handshakeAlarmCount,
|
conn.lossState.handshakeAlarmCount,
|
||||||
(uint64_t)conn.outstandingHandshakePacketsCount,
|
(uint64_t)conn.outstandings.handshakePacketsCount,
|
||||||
(uint64_t)conn.outstandingPackets.size());
|
(uint64_t)conn.outstandings.packets.size());
|
||||||
if (conn.qLogger) {
|
if (conn.qLogger) {
|
||||||
conn.qLogger->addLossAlarm(
|
conn.qLogger->addLossAlarm(
|
||||||
conn.lossState.largestSent.value_or(0),
|
conn.lossState.largestSent.value_or(0),
|
||||||
conn.lossState.handshakeAlarmCount,
|
conn.lossState.handshakeAlarmCount,
|
||||||
(uint64_t)conn.outstandingPackets.size(),
|
(uint64_t)conn.outstandings.packets.size(),
|
||||||
kHandshakeAlarm);
|
kHandshakeAlarm);
|
||||||
}
|
}
|
||||||
CongestionController::LossEvent lossEvent(ClockType::now());
|
CongestionController::LossEvent lossEvent(ClockType::now());
|
||||||
auto iter = conn.outstandingPackets.begin();
|
auto iter = conn.outstandings.packets.begin();
|
||||||
while (iter != conn.outstandingPackets.end()) {
|
while (iter != conn.outstandings.packets.end()) {
|
||||||
// the word "handshake" in our code base is unfortunately overloaded.
|
// the word "handshake" in our code base is unfortunately overloaded.
|
||||||
if (iter->isHandshake) {
|
if (iter->isHandshake) {
|
||||||
auto& packet = *iter;
|
auto& packet = *iter;
|
||||||
@@ -329,11 +329,11 @@ void onHandshakeAlarm(
|
|||||||
<< " packetNumSpace=" << currentPacketNumSpace << " " << conn;
|
<< " packetNumSpace=" << currentPacketNumSpace << " " << conn;
|
||||||
lossEvent.addLostPacket(std::move(packet));
|
lossEvent.addLostPacket(std::move(packet));
|
||||||
lossVisitor(conn, packet.packet, false, currentPacketNum);
|
lossVisitor(conn, packet.packet, false, currentPacketNum);
|
||||||
DCHECK(conn.outstandingHandshakePacketsCount);
|
DCHECK(conn.outstandings.handshakePacketsCount);
|
||||||
--conn.outstandingHandshakePacketsCount;
|
--conn.outstandings.handshakePacketsCount;
|
||||||
++conn.lossState.timeoutBasedRtxCount;
|
++conn.lossState.timeoutBasedRtxCount;
|
||||||
++conn.lossState.rtxCount;
|
++conn.lossState.rtxCount;
|
||||||
iter = conn.outstandingPackets.erase(iter);
|
iter = conn.outstandings.packets.erase(iter);
|
||||||
} else {
|
} else {
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,7 @@ void onLossDetectionAlarm(
|
|||||||
QuicConnectionStateBase& conn,
|
QuicConnectionStateBase& conn,
|
||||||
const LossVisitor& lossVisitor) {
|
const LossVisitor& lossVisitor) {
|
||||||
auto now = ClockType::now();
|
auto now = ClockType::now();
|
||||||
if (conn.outstandingPackets.empty()) {
|
if (conn.outstandings.packets.empty()) {
|
||||||
VLOG(10) << "Transmission alarm fired with no outstanding packets " << conn;
|
VLOG(10) << "Transmission alarm fired with no outstanding packets " << conn;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -385,11 +385,11 @@ void onLossDetectionAlarm(
|
|||||||
} else {
|
} else {
|
||||||
onPTOAlarm(conn);
|
onPTOAlarm(conn);
|
||||||
}
|
}
|
||||||
conn.pendingEvents.setLossDetectionAlarm = !conn.outstandingPackets.empty();
|
conn.pendingEvents.setLossDetectionAlarm = !conn.outstandings.packets.empty();
|
||||||
VLOG(10) << __func__ << " setLossDetectionAlarm="
|
VLOG(10) << __func__ << " setLossDetectionAlarm="
|
||||||
<< conn.pendingEvents.setLossDetectionAlarm
|
<< conn.pendingEvents.setLossDetectionAlarm
|
||||||
<< " outstanding=" << conn.outstandingPackets.size()
|
<< " outstanding=" << conn.outstandings.packets.size()
|
||||||
<< " handshakePackets=" << conn.outstandingHandshakePacketsCount
|
<< " handshakePackets=" << conn.outstandings.handshakePacketsCount
|
||||||
<< " " << conn;
|
<< " " << conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,13 +426,13 @@ folly::Optional<CongestionController::LossEvent> handleAckForLoss(
|
|||||||
lossVisitor,
|
lossVisitor,
|
||||||
ack.ackTime,
|
ack.ackTime,
|
||||||
pnSpace);
|
pnSpace);
|
||||||
conn.pendingEvents.setLossDetectionAlarm = !conn.outstandingPackets.empty();
|
conn.pendingEvents.setLossDetectionAlarm = !conn.outstandings.packets.empty();
|
||||||
VLOG(10) << __func__
|
VLOG(10) << __func__
|
||||||
<< " largestAckedInPacket=" << ack.largestAckedPacket.value_or(0)
|
<< " largestAckedInPacket=" << ack.largestAckedPacket.value_or(0)
|
||||||
<< " setLossDetectionAlarm="
|
<< " setLossDetectionAlarm="
|
||||||
<< conn.pendingEvents.setLossDetectionAlarm
|
<< conn.pendingEvents.setLossDetectionAlarm
|
||||||
<< " outstanding=" << conn.outstandingPackets.size()
|
<< " outstanding=" << conn.outstandings.packets.size()
|
||||||
<< " handshakePackets=" << conn.outstandingHandshakePacketsCount
|
<< " handshakePackets=" << conn.outstandings.handshakePacketsCount
|
||||||
<< " " << conn;
|
<< " " << conn;
|
||||||
return lossEvent;
|
return lossEvent;
|
||||||
}
|
}
|
||||||
@@ -446,7 +446,7 @@ void markZeroRttPacketsLost(
|
|||||||
const LossVisitor& lossVisitor) {
|
const LossVisitor& lossVisitor) {
|
||||||
CongestionController::LossEvent lossEvent(ClockType::now());
|
CongestionController::LossEvent lossEvent(ClockType::now());
|
||||||
auto iter = getFirstOutstandingPacket(conn, PacketNumberSpace::AppData);
|
auto iter = getFirstOutstandingPacket(conn, PacketNumberSpace::AppData);
|
||||||
while (iter != conn.outstandingPackets.end()) {
|
while (iter != conn.outstandings.packets.end()) {
|
||||||
DCHECK_EQ(
|
DCHECK_EQ(
|
||||||
iter->packet.header.getPacketNumberSpace(), PacketNumberSpace::AppData);
|
iter->packet.header.getPacketNumberSpace(), PacketNumberSpace::AppData);
|
||||||
auto isZeroRttPacket =
|
auto isZeroRttPacket =
|
||||||
@@ -456,16 +456,16 @@ void markZeroRttPacketsLost(
|
|||||||
DCHECK(!pkt.isHandshake);
|
DCHECK(!pkt.isHandshake);
|
||||||
auto currentPacketNum = pkt.packet.header.getPacketSequenceNum();
|
auto currentPacketNum = pkt.packet.header.getPacketSequenceNum();
|
||||||
bool processed = pkt.associatedEvent &&
|
bool processed = pkt.associatedEvent &&
|
||||||
!conn.outstandingPacketEvents.count(*pkt.associatedEvent);
|
!conn.outstandings.packetEvents.count(*pkt.associatedEvent);
|
||||||
lossVisitor(conn, pkt.packet, processed, currentPacketNum);
|
lossVisitor(conn, pkt.packet, processed, currentPacketNum);
|
||||||
// Remove the PacketEvent from the outstandingPacketEvents set
|
// Remove the PacketEvent from the outstandings.packetEvents set
|
||||||
if (pkt.associatedEvent) {
|
if (pkt.associatedEvent) {
|
||||||
conn.outstandingPacketEvents.erase(*pkt.associatedEvent);
|
conn.outstandings.packetEvents.erase(*pkt.associatedEvent);
|
||||||
DCHECK_GT(conn.outstandingClonedPacketsCount, 0);
|
DCHECK_GT(conn.outstandings.clonedPacketsCount, 0);
|
||||||
--conn.outstandingClonedPacketsCount;
|
--conn.outstandings.clonedPacketsCount;
|
||||||
}
|
}
|
||||||
lossEvent.addLostPacket(pkt);
|
lossEvent.addLostPacket(pkt);
|
||||||
iter = conn.outstandingPackets.erase(iter);
|
iter = conn.outstandings.packets.erase(iter);
|
||||||
iter = getNextOutstandingPacket(conn, PacketNumberSpace::AppData, iter);
|
iter = getNextOutstandingPacket(conn, PacketNumberSpace::AppData, iter);
|
||||||
} else {
|
} else {
|
||||||
iter =
|
iter =
|
||||||
|
@@ -187,7 +187,7 @@ PacketNum QuicLossFunctionsTest::sendPacket(
|
|||||||
packet.packet, time, encodedSize, isHandshake, encodedSize);
|
packet.packet, time, encodedSize, isHandshake, encodedSize);
|
||||||
outstandingPacket.associatedEvent = associatedEvent;
|
outstandingPacket.associatedEvent = associatedEvent;
|
||||||
if (isHandshake) {
|
if (isHandshake) {
|
||||||
conn.outstandingHandshakePacketsCount++;
|
conn.outstandings.handshakePacketsCount++;
|
||||||
conn.lossState.lastHandshakePacketSentTime = time;
|
conn.lossState.lastHandshakePacketSentTime = time;
|
||||||
}
|
}
|
||||||
conn.lossState.lastRetransmittablePacketSentTime = time;
|
conn.lossState.lastRetransmittablePacketSentTime = time;
|
||||||
@@ -195,24 +195,24 @@ PacketNum QuicLossFunctionsTest::sendPacket(
|
|||||||
conn.congestionController->onPacketSent(outstandingPacket);
|
conn.congestionController->onPacketSent(outstandingPacket);
|
||||||
}
|
}
|
||||||
if (associatedEvent) {
|
if (associatedEvent) {
|
||||||
conn.outstandingClonedPacketsCount++;
|
conn.outstandings.clonedPacketsCount++;
|
||||||
// Simulates what the real writer does.
|
// Simulates what the real writer does.
|
||||||
auto it = std::find_if(
|
auto it = std::find_if(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
[&associatedEvent](const auto& packet) {
|
[&associatedEvent](const auto& packet) {
|
||||||
auto packetNum = packet.packet.header.getPacketSequenceNum();
|
auto packetNum = packet.packet.header.getPacketSequenceNum();
|
||||||
return packetNum == *associatedEvent;
|
return packetNum == *associatedEvent;
|
||||||
});
|
});
|
||||||
if (it != conn.outstandingPackets.end()) {
|
if (it != conn.outstandings.packets.end()) {
|
||||||
if (!it->associatedEvent) {
|
if (!it->associatedEvent) {
|
||||||
conn.outstandingPacketEvents.emplace(*associatedEvent);
|
conn.outstandings.packetEvents.emplace(*associatedEvent);
|
||||||
conn.outstandingClonedPacketsCount++;
|
conn.outstandings.clonedPacketsCount++;
|
||||||
it->associatedEvent = *associatedEvent;
|
it->associatedEvent = *associatedEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conn.outstandingPackets.emplace_back(std::move(outstandingPacket));
|
conn.outstandings.packets.emplace_back(std::move(outstandingPacket));
|
||||||
conn.lossState.largestSent = getNextPacketNum(conn, packetNumberSpace);
|
conn.lossState.largestSent = getNextPacketNum(conn, packetNumberSpace);
|
||||||
increaseNextPacketNum(conn, packetNumberSpace);
|
increaseNextPacketNum(conn, packetNumberSpace);
|
||||||
conn.pendingEvents.setLossDetectionAlarm = true;
|
conn.pendingEvents.setLossDetectionAlarm = true;
|
||||||
@@ -275,8 +275,8 @@ TEST_F(QuicLossFunctionsTest, TestOnLossDetectionAlarm) {
|
|||||||
onLossDetectionAlarm<decltype(testingLossMarkFunc(lostPacket)), MockClock>(
|
onLossDetectionAlarm<decltype(testingLossMarkFunc(lostPacket)), MockClock>(
|
||||||
*conn, testingLossMarkFunc(lostPacket));
|
*conn, testingLossMarkFunc(lostPacket));
|
||||||
EXPECT_EQ(conn->lossState.ptoCount, 2);
|
EXPECT_EQ(conn->lossState.ptoCount, 2);
|
||||||
// PTO doesn't take anything out of outstandingPackets
|
// PTO doesn't take anything out of outstandings.packets
|
||||||
EXPECT_FALSE(conn->outstandingPackets.empty());
|
EXPECT_FALSE(conn->outstandings.packets.empty());
|
||||||
EXPECT_TRUE(conn->pendingEvents.setLossDetectionAlarm);
|
EXPECT_TRUE(conn->pendingEvents.setLossDetectionAlarm);
|
||||||
// PTO shouldn't mark loss
|
// PTO shouldn't mark loss
|
||||||
EXPECT_TRUE(lostPacket.empty());
|
EXPECT_TRUE(lostPacket.empty());
|
||||||
@@ -290,16 +290,16 @@ TEST_F(QuicLossFunctionsTest, TestOnPTOSkipProcessed) {
|
|||||||
EXPECT_CALL(*rawCongestionController, onPacketSent(_))
|
EXPECT_CALL(*rawCongestionController, onPacketSent(_))
|
||||||
.WillRepeatedly(Return());
|
.WillRepeatedly(Return());
|
||||||
// By adding an associatedEvent that doesn't exist in the
|
// By adding an associatedEvent that doesn't exist in the
|
||||||
// outstandingPacketEvents, they are all processed and will skip lossVisitor
|
// outstandings.packetEvents, they are all processed and will skip lossVisitor
|
||||||
for (auto i = 0; i < 10; i++) {
|
for (auto i = 0; i < 10; i++) {
|
||||||
sendPacket(*conn, TimePoint(), i, PacketType::OneRtt);
|
sendPacket(*conn, TimePoint(), i, PacketType::OneRtt);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(10, conn->outstandingPackets.size());
|
EXPECT_EQ(10, conn->outstandings.packets.size());
|
||||||
std::vector<PacketNum> lostPackets;
|
std::vector<PacketNum> lostPackets;
|
||||||
EXPECT_CALL(*rawCongestionController, onRemoveBytesFromInflight(_)).Times(0);
|
EXPECT_CALL(*rawCongestionController, onRemoveBytesFromInflight(_)).Times(0);
|
||||||
EXPECT_CALL(*transportInfoCb_, onPTO());
|
EXPECT_CALL(*transportInfoCb_, onPTO());
|
||||||
onPTOAlarm(*conn);
|
onPTOAlarm(*conn);
|
||||||
EXPECT_EQ(10, conn->outstandingPackets.size());
|
EXPECT_EQ(10, conn->outstandings.packets.size());
|
||||||
EXPECT_TRUE(lostPackets.empty());
|
EXPECT_TRUE(lostPackets.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +335,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLoss) {
|
|||||||
*conn->version,
|
*conn->version,
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
|
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
auto& packet =
|
auto& packet =
|
||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)->packet;
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)->packet;
|
||||||
auto packetNum = packet.header.getPacketSequenceNum();
|
auto packetNum = packet.header.getPacketSequenceNum();
|
||||||
@@ -371,7 +371,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLossMerge) {
|
|||||||
*headerCipher,
|
*headerCipher,
|
||||||
*conn->version,
|
*conn->version,
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto buf2 = buildRandomInputData(20);
|
auto buf2 = buildRandomInputData(20);
|
||||||
writeDataToQuicStream(*stream1, buf2->clone(), false);
|
writeDataToQuicStream(*stream1, buf2->clone(), false);
|
||||||
@@ -384,7 +384,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLossMerge) {
|
|||||||
*headerCipher,
|
*headerCipher,
|
||||||
*conn->version,
|
*conn->version,
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(2, conn->outstandingPackets.size());
|
EXPECT_EQ(2, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto& packet1 =
|
auto& packet1 =
|
||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)->packet;
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)->packet;
|
||||||
@@ -427,7 +427,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLossNoMerge) {
|
|||||||
*headerCipher,
|
*headerCipher,
|
||||||
*conn->version,
|
*conn->version,
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto buf2 = buildRandomInputData(20);
|
auto buf2 = buildRandomInputData(20);
|
||||||
writeDataToQuicStream(*stream1, buf2->clone(), false);
|
writeDataToQuicStream(*stream1, buf2->clone(), false);
|
||||||
@@ -440,7 +440,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLossNoMerge) {
|
|||||||
*headerCipher,
|
*headerCipher,
|
||||||
*conn->version,
|
*conn->version,
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(2, conn->outstandingPackets.size());
|
EXPECT_EQ(2, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto buf3 = buildRandomInputData(20);
|
auto buf3 = buildRandomInputData(20);
|
||||||
writeDataToQuicStream(*stream1, buf3->clone(), false);
|
writeDataToQuicStream(*stream1, buf3->clone(), false);
|
||||||
@@ -453,7 +453,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLossNoMerge) {
|
|||||||
*headerCipher,
|
*headerCipher,
|
||||||
*conn->version,
|
*conn->version,
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_EQ(3, conn->outstandingPackets.size());
|
EXPECT_EQ(3, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto& packet1 =
|
auto& packet1 =
|
||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)->packet;
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)->packet;
|
||||||
@@ -508,8 +508,8 @@ TEST_F(QuicLossFunctionsTest, RetxBufferSortedAfterLoss) {
|
|||||||
*stream,
|
*stream,
|
||||||
*buf3);
|
*buf3);
|
||||||
EXPECT_EQ(3, stream->retransmissionBuffer.size());
|
EXPECT_EQ(3, stream->retransmissionBuffer.size());
|
||||||
EXPECT_EQ(3, conn->outstandingPackets.size());
|
EXPECT_EQ(3, conn->outstandings.packets.size());
|
||||||
auto packet = conn->outstandingPackets[folly::Random::rand32() % 3];
|
auto packet = conn->outstandings.packets[folly::Random::rand32() % 3];
|
||||||
markPacketLoss(
|
markPacketLoss(
|
||||||
*conn, packet.packet, false, packet.packet.header.getPacketSequenceNum());
|
*conn, packet.packet, false, packet.packet.header.getPacketSequenceNum());
|
||||||
EXPECT_EQ(2, stream->retransmissionBuffer.size());
|
EXPECT_EQ(2, stream->retransmissionBuffer.size());
|
||||||
@@ -539,9 +539,9 @@ TEST_F(QuicLossFunctionsTest, TestMarkCryptoLostAfterCancelRetransmission) {
|
|||||||
*headerCipher,
|
*headerCipher,
|
||||||
*conn->version,
|
*conn->version,
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
ASSERT_EQ(conn->outstandingPackets.size(), 1);
|
ASSERT_EQ(conn->outstandings.packets.size(), 1);
|
||||||
EXPECT_GT(conn->cryptoState->handshakeStream.retransmissionBuffer.size(), 0);
|
EXPECT_GT(conn->cryptoState->handshakeStream.retransmissionBuffer.size(), 0);
|
||||||
auto& packet = conn->outstandingPackets.front().packet;
|
auto& packet = conn->outstandings.packets.front().packet;
|
||||||
auto packetNum = packet.header.getPacketSequenceNum();
|
auto packetNum = packet.header.getPacketSequenceNum();
|
||||||
cancelHandshakeCryptoStreamRetransmissions(*conn->cryptoState);
|
cancelHandshakeCryptoStreamRetransmissions(*conn->cryptoState);
|
||||||
markPacketLoss(*conn, packet, false, packetNum);
|
markPacketLoss(*conn, packet, false, packetNum);
|
||||||
@@ -573,9 +573,9 @@ TEST_F(QuicLossFunctionsTest, TestMarkCryptoLostCancel) {
|
|||||||
*headerCipher,
|
*headerCipher,
|
||||||
*conn->version,
|
*conn->version,
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
ASSERT_EQ(conn->outstandingPackets.size(), 1);
|
ASSERT_EQ(conn->outstandings.packets.size(), 1);
|
||||||
EXPECT_GT(conn->cryptoState->handshakeStream.retransmissionBuffer.size(), 0);
|
EXPECT_GT(conn->cryptoState->handshakeStream.retransmissionBuffer.size(), 0);
|
||||||
auto& packet = conn->outstandingPackets.front().packet;
|
auto& packet = conn->outstandings.packets.front().packet;
|
||||||
auto packetNum = packet.header.getPacketSequenceNum();
|
auto packetNum = packet.header.getPacketSequenceNum();
|
||||||
markPacketLoss(*conn, packet, false, packetNum);
|
markPacketLoss(*conn, packet, false, packetNum);
|
||||||
EXPECT_EQ(conn->cryptoState->handshakeStream.retransmissionBuffer.size(), 0);
|
EXPECT_EQ(conn->cryptoState->handshakeStream.retransmissionBuffer.size(), 0);
|
||||||
@@ -627,7 +627,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThreshold) {
|
|||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
sendPacket(*conn, Clock::now(), folly::none, PacketType::Handshake);
|
sendPacket(*conn, Clock::now(), folly::none, PacketType::Handshake);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(6, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(6, conn->outstandings.handshakePacketsCount);
|
||||||
// Assume some packets are already acked
|
// Assume some packets are already acked
|
||||||
for (auto iter =
|
for (auto iter =
|
||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake) + 2;
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake) + 2;
|
||||||
@@ -635,12 +635,12 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThreshold) {
|
|||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake) + 5;
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake) + 5;
|
||||||
iter++) {
|
iter++) {
|
||||||
if (iter->isHandshake) {
|
if (iter->isHandshake) {
|
||||||
conn->outstandingHandshakePacketsCount--;
|
conn->outstandings.handshakePacketsCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto firstHandshakeOpIter =
|
auto firstHandshakeOpIter =
|
||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake);
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake);
|
||||||
conn->outstandingPackets.erase(
|
conn->outstandings.packets.erase(
|
||||||
firstHandshakeOpIter + 2, firstHandshakeOpIter + 5);
|
firstHandshakeOpIter + 2, firstHandshakeOpIter + 5);
|
||||||
// Ack for packet 9 arrives
|
// Ack for packet 9 arrives
|
||||||
auto lossEvent = detectLossPackets<decltype(testingLossMarkFunc)>(
|
auto lossEvent = detectLossPackets<decltype(testingLossMarkFunc)>(
|
||||||
@@ -657,12 +657,12 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThreshold) {
|
|||||||
EXPECT_EQ(lostPacket.back(), 2);
|
EXPECT_EQ(lostPacket.back(), 2);
|
||||||
|
|
||||||
// Packet 6 is the only thing remaining inflight, it is a handshake pkt
|
// Packet 6 is the only thing remaining inflight, it is a handshake pkt
|
||||||
EXPECT_EQ(1, conn->outstandingHandshakePacketsCount);
|
EXPECT_EQ(1, conn->outstandings.handshakePacketsCount);
|
||||||
|
|
||||||
// Packet 6 should remain in packet as the delta is less than threshold
|
// Packet 6 should remain in packet as the delta is less than threshold
|
||||||
EXPECT_EQ(conn->outstandingPackets.size(), 1);
|
EXPECT_EQ(conn->outstandings.packets.size(), 1);
|
||||||
auto packetNum =
|
auto packetNum =
|
||||||
conn->outstandingPackets.front().packet.header.getPacketSequenceNum();
|
conn->outstandings.packets.front().packet.header.getPacketSequenceNum();
|
||||||
EXPECT_EQ(packetNum, 6);
|
EXPECT_EQ(packetNum, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,7 +681,7 @@ TEST_F(QuicLossFunctionsTest, TestHandleAckForLoss) {
|
|||||||
conn->version.value());
|
conn->version.value());
|
||||||
RegularQuicWritePacket outstandingRegularPacket(std::move(longHeader));
|
RegularQuicWritePacket outstandingRegularPacket(std::move(longHeader));
|
||||||
auto now = Clock::now();
|
auto now = Clock::now();
|
||||||
conn->outstandingPackets.emplace_back(
|
conn->outstandings.packets.emplace_back(
|
||||||
OutstandingPacket(outstandingRegularPacket, now, 0, false, 0));
|
OutstandingPacket(outstandingRegularPacket, now, 0, false, 0));
|
||||||
|
|
||||||
bool testLossMarkFuncCalled = false;
|
bool testLossMarkFuncCalled = false;
|
||||||
@@ -697,7 +697,7 @@ TEST_F(QuicLossFunctionsTest, TestHandleAckForLoss) {
|
|||||||
*conn, testLossMarkFunc, ackEvent, PacketNumberSpace::Handshake);
|
*conn, testLossMarkFunc, ackEvent, PacketNumberSpace::Handshake);
|
||||||
|
|
||||||
EXPECT_EQ(0, conn->lossState.ptoCount);
|
EXPECT_EQ(0, conn->lossState.ptoCount);
|
||||||
EXPECT_TRUE(conn->outstandingPackets.empty());
|
EXPECT_TRUE(conn->outstandings.packets.empty());
|
||||||
EXPECT_FALSE(conn->pendingEvents.setLossDetectionAlarm);
|
EXPECT_FALSE(conn->pendingEvents.setLossDetectionAlarm);
|
||||||
EXPECT_TRUE(testLossMarkFuncCalled);
|
EXPECT_TRUE(testLossMarkFuncCalled);
|
||||||
}
|
}
|
||||||
@@ -736,10 +736,10 @@ TEST_F(QuicLossFunctionsTest, TestHandleAckedPacket) {
|
|||||||
|
|
||||||
EXPECT_EQ(0, conn->lossState.ptoCount);
|
EXPECT_EQ(0, conn->lossState.ptoCount);
|
||||||
EXPECT_EQ(0, conn->lossState.handshakeAlarmCount);
|
EXPECT_EQ(0, conn->lossState.handshakeAlarmCount);
|
||||||
EXPECT_TRUE(conn->outstandingPackets.empty());
|
EXPECT_TRUE(conn->outstandings.packets.empty());
|
||||||
EXPECT_FALSE(conn->pendingEvents.setLossDetectionAlarm);
|
EXPECT_FALSE(conn->pendingEvents.setLossDetectionAlarm);
|
||||||
EXPECT_FALSE(testLossMarkFuncCalled);
|
EXPECT_FALSE(testLossMarkFuncCalled);
|
||||||
ASSERT_TRUE(conn->outstandingPackets.empty());
|
ASSERT_TRUE(conn->outstandings.packets.empty());
|
||||||
|
|
||||||
setLossDetectionAlarm<decltype(timeout), MockClock>(*conn, timeout);
|
setLossDetectionAlarm<decltype(timeout), MockClock>(*conn, timeout);
|
||||||
EXPECT_FALSE(conn->pendingEvents.setLossDetectionAlarm);
|
EXPECT_FALSE(conn->pendingEvents.setLossDetectionAlarm);
|
||||||
@@ -765,7 +765,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkRstLoss) {
|
|||||||
*conn->version,
|
*conn->version,
|
||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
|
|
||||||
EXPECT_EQ(conn->outstandingPackets.size(), 1);
|
EXPECT_EQ(conn->outstandings.packets.size(), 1);
|
||||||
EXPECT_TRUE(conn->pendingEvents.resets.empty());
|
EXPECT_TRUE(conn->pendingEvents.resets.empty());
|
||||||
auto& packet =
|
auto& packet =
|
||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)->packet;
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)->packet;
|
||||||
@@ -857,7 +857,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkWindowUpdateLoss) {
|
|||||||
conn->transportSettings.writeConnectionDataPacketsLimit);
|
conn->transportSettings.writeConnectionDataPacketsLimit);
|
||||||
EXPECT_FALSE(conn->streamManager->hasWindowUpdates());
|
EXPECT_FALSE(conn->streamManager->hasWindowUpdates());
|
||||||
|
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
auto& packet =
|
auto& packet =
|
||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)->packet;
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)->packet;
|
||||||
|
|
||||||
@@ -883,7 +883,7 @@ TEST_F(QuicLossFunctionsTest, TestTimeReordering) {
|
|||||||
// Some packets are already acked
|
// Some packets are already acked
|
||||||
conn->lossState.srtt = 400ms;
|
conn->lossState.srtt = 400ms;
|
||||||
conn->lossState.lrtt = 350ms;
|
conn->lossState.lrtt = 350ms;
|
||||||
conn->outstandingPackets.erase(
|
conn->outstandings.packets.erase(
|
||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData) + 2,
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData) + 2,
|
||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData) + 5);
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData) + 5);
|
||||||
auto lossEvent = detectLossPackets<decltype(testingLossMarkFunc(lostPacket))>(
|
auto lossEvent = detectLossPackets<decltype(testingLossMarkFunc(lostPacket))>(
|
||||||
@@ -900,7 +900,7 @@ TEST_F(QuicLossFunctionsTest, TestTimeReordering) {
|
|||||||
EXPECT_EQ(lostPacket.back(), 2);
|
EXPECT_EQ(lostPacket.back(), 2);
|
||||||
|
|
||||||
// Packet 6, 7 should remain in outstanding packet list
|
// Packet 6, 7 should remain in outstanding packet list
|
||||||
EXPECT_EQ(2, conn->outstandingPackets.size());
|
EXPECT_EQ(2, conn->outstandings.packets.size());
|
||||||
auto packetNum = getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
auto packetNum = getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
||||||
->packet.header.getPacketSequenceNum();
|
->packet.header.getPacketSequenceNum();
|
||||||
EXPECT_EQ(packetNum, 6);
|
EXPECT_EQ(packetNum, 6);
|
||||||
@@ -945,14 +945,14 @@ TEST_F(QuicLossFunctionsTest, LossTimePreemptsCryptoTimer) {
|
|||||||
|
|
||||||
// Second packet gets acked:
|
// Second packet gets acked:
|
||||||
getAckState(*conn, PacketNumberSpace::Handshake).largestAckedByPeer = second;
|
getAckState(*conn, PacketNumberSpace::Handshake).largestAckedByPeer = second;
|
||||||
conn->outstandingPackets.pop_back();
|
conn->outstandings.packets.pop_back();
|
||||||
MockClock::mockNow = [=]() { return sendTime + expectedDelayUntilLost + 5s; };
|
MockClock::mockNow = [=]() { return sendTime + expectedDelayUntilLost + 5s; };
|
||||||
onLossDetectionAlarm<decltype(testingLossMarkFunc(lostPackets)), MockClock>(
|
onLossDetectionAlarm<decltype(testingLossMarkFunc(lostPackets)), MockClock>(
|
||||||
*conn, testingLossMarkFunc(lostPackets));
|
*conn, testingLossMarkFunc(lostPackets));
|
||||||
EXPECT_EQ(1, lostPackets.size());
|
EXPECT_EQ(1, lostPackets.size());
|
||||||
EXPECT_FALSE(
|
EXPECT_FALSE(
|
||||||
conn->lossState.lossTimes[PacketNumberSpace::Handshake].has_value());
|
conn->lossState.lossTimes[PacketNumberSpace::Handshake].has_value());
|
||||||
EXPECT_TRUE(conn->outstandingPackets.empty());
|
EXPECT_TRUE(conn->outstandings.packets.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicLossFunctionsTest, PTONoLongerMarksPacketsToBeRetransmitted) {
|
TEST_F(QuicLossFunctionsTest, PTONoLongerMarksPacketsToBeRetransmitted) {
|
||||||
@@ -1006,8 +1006,8 @@ TEST_F(
|
|||||||
expectedLargestLostNum, i % 2 ? sentPacketNum : expectedLargestLostNum);
|
expectedLargestLostNum, i % 2 ? sentPacketNum : expectedLargestLostNum);
|
||||||
}
|
}
|
||||||
uint64_t expectedLostBytes = std::accumulate(
|
uint64_t expectedLostBytes = std::accumulate(
|
||||||
conn->outstandingPackets.begin(),
|
conn->outstandings.packets.begin(),
|
||||||
conn->outstandingPackets.end(),
|
conn->outstandings.packets.end(),
|
||||||
0,
|
0,
|
||||||
[](uint64_t num, const OutstandingPacket& packet) {
|
[](uint64_t num, const OutstandingPacket& packet) {
|
||||||
return packet.isHandshake ? num + packet.encodedSize : num;
|
return packet.isHandshake ? num + packet.encodedSize : num;
|
||||||
@@ -1214,9 +1214,9 @@ TEST_F(QuicLossFunctionsTest, NoDoubleProcess) {
|
|||||||
for (size_t i = 0; i < 6; i++) {
|
for (size_t i = 0; i < 6; i++) {
|
||||||
lastSent = sendPacket(*conn, Clock::now(), event, PacketType::OneRtt);
|
lastSent = sendPacket(*conn, Clock::now(), event, PacketType::OneRtt);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(6, conn->outstandingPackets.size());
|
EXPECT_EQ(6, conn->outstandings.packets.size());
|
||||||
// Add the PacketEvent to the outstandingPacketEvents set
|
// Add the PacketEvent to the outstandings.packetEvents set
|
||||||
conn->outstandingPacketEvents.insert(event);
|
conn->outstandings.packetEvents.insert(event);
|
||||||
|
|
||||||
// Ack the last sent packet. Despite two losses, lossVisitor only visit one
|
// Ack the last sent packet. Despite two losses, lossVisitor only visit one
|
||||||
// packet
|
// packet
|
||||||
@@ -1227,7 +1227,7 @@ TEST_F(QuicLossFunctionsTest, NoDoubleProcess) {
|
|||||||
TimePoint(100ms),
|
TimePoint(100ms),
|
||||||
PacketNumberSpace::AppData);
|
PacketNumberSpace::AppData);
|
||||||
EXPECT_EQ(1, lossVisitorCount);
|
EXPECT_EQ(1, lossVisitorCount);
|
||||||
EXPECT_EQ(4, conn->outstandingPackets.size());
|
EXPECT_EQ(4, conn->outstandings.packets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicLossFunctionsTest, DetectPacketLossClonedPacketsCounter) {
|
TEST_F(QuicLossFunctionsTest, DetectPacketLossClonedPacketsCounter) {
|
||||||
@@ -1246,14 +1246,14 @@ TEST_F(QuicLossFunctionsTest, DetectPacketLossClonedPacketsCounter) {
|
|||||||
noopLossMarker,
|
noopLossMarker,
|
||||||
Clock::now(),
|
Clock::now(),
|
||||||
PacketNumberSpace::AppData);
|
PacketNumberSpace::AppData);
|
||||||
EXPECT_EQ(0, conn->outstandingClonedPacketsCount);
|
EXPECT_EQ(0, conn->outstandings.clonedPacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicLossFunctionsTest, TestMarkPacketLossProcessedPacket) {
|
TEST_F(QuicLossFunctionsTest, TestMarkPacketLossProcessedPacket) {
|
||||||
MockAsyncUDPSocket socket(&evb);
|
MockAsyncUDPSocket socket(&evb);
|
||||||
auto conn = createConn();
|
auto conn = createConn();
|
||||||
ASSERT_TRUE(conn->outstandingPackets.empty());
|
ASSERT_TRUE(conn->outstandings.packets.empty());
|
||||||
ASSERT_TRUE(conn->outstandingPacketEvents.empty());
|
ASSERT_TRUE(conn->outstandings.packetEvents.empty());
|
||||||
auto stream1Id =
|
auto stream1Id =
|
||||||
conn->streamManager->createNextBidirectionalStream().value()->id;
|
conn->streamManager->createNextBidirectionalStream().value()->id;
|
||||||
auto buf = folly::IOBuf::copyBuffer("I wrestled by the sea.");
|
auto buf = folly::IOBuf::copyBuffer("I wrestled by the sea.");
|
||||||
@@ -1276,8 +1276,8 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLossProcessedPacket) {
|
|||||||
true);
|
true);
|
||||||
EXPECT_FALSE(conn->streamManager->pendingWindowUpdate(stream2->id));
|
EXPECT_FALSE(conn->streamManager->pendingWindowUpdate(stream2->id));
|
||||||
EXPECT_FALSE(conn->pendingEvents.connWindowUpdate);
|
EXPECT_FALSE(conn->pendingEvents.connWindowUpdate);
|
||||||
ASSERT_EQ(1, conn->outstandingPackets.size());
|
ASSERT_EQ(1, conn->outstandings.packets.size());
|
||||||
ASSERT_TRUE(conn->outstandingPacketEvents.empty());
|
ASSERT_TRUE(conn->outstandings.packetEvents.empty());
|
||||||
uint32_t streamDataCounter = 0, streamWindowUpdateCounter = 0,
|
uint32_t streamDataCounter = 0, streamWindowUpdateCounter = 0,
|
||||||
connWindowUpdateCounter = 0;
|
connWindowUpdateCounter = 0;
|
||||||
for (const auto& frame :
|
for (const auto& frame :
|
||||||
@@ -1358,7 +1358,7 @@ TEST_F(QuicLossFunctionsTest, TotalLossCount) {
|
|||||||
largestSent =
|
largestSent =
|
||||||
sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt);
|
sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(10, conn->outstandingPackets.size());
|
EXPECT_EQ(10, conn->outstandings.packets.size());
|
||||||
uint32_t lostPackets = 0;
|
uint32_t lostPackets = 0;
|
||||||
auto countingLossVisitor = [&](auto& /* conn */,
|
auto countingLossVisitor = [&](auto& /* conn */,
|
||||||
auto& /* packet */,
|
auto& /* packet */,
|
||||||
@@ -1387,13 +1387,13 @@ TEST_F(QuicLossFunctionsTest, TestZeroRttRejected) {
|
|||||||
EXPECT_CALL(*rawCongestionController, onPacketSent(_))
|
EXPECT_CALL(*rawCongestionController, onPacketSent(_))
|
||||||
.WillRepeatedly(Return());
|
.WillRepeatedly(Return());
|
||||||
// By adding an associatedEvent that doesn't exist in the
|
// By adding an associatedEvent that doesn't exist in the
|
||||||
// outstandingPacketEvents, they are all processed and will skip lossVisitor
|
// outstandings.packetEvents, they are all processed and will skip lossVisitor
|
||||||
for (auto i = 0; i < 2; i++) {
|
for (auto i = 0; i < 2; i++) {
|
||||||
sendPacket(*conn, TimePoint(), folly::none, PacketType::OneRtt);
|
sendPacket(*conn, TimePoint(), folly::none, PacketType::OneRtt);
|
||||||
sendPacket(*conn, TimePoint(), folly::none, PacketType::ZeroRtt);
|
sendPacket(*conn, TimePoint(), folly::none, PacketType::ZeroRtt);
|
||||||
}
|
}
|
||||||
EXPECT_FALSE(conn->outstandingPackets.empty());
|
EXPECT_FALSE(conn->outstandings.packets.empty());
|
||||||
EXPECT_EQ(4, conn->outstandingPackets.size());
|
EXPECT_EQ(4, conn->outstandings.packets.size());
|
||||||
std::vector<std::pair<PacketNum, bool>> lostPackets;
|
std::vector<std::pair<PacketNum, bool>> lostPackets;
|
||||||
// onRemoveBytesFromInflight should still happen
|
// onRemoveBytesFromInflight should still happen
|
||||||
EXPECT_CALL(*rawCongestionController, onRemoveBytesFromInflight(_)).Times(1);
|
EXPECT_CALL(*rawCongestionController, onRemoveBytesFromInflight(_)).Times(1);
|
||||||
@@ -1401,13 +1401,13 @@ TEST_F(QuicLossFunctionsTest, TestZeroRttRejected) {
|
|||||||
*conn, [&lostPackets](auto&, auto&, bool processed, PacketNum packetNum) {
|
*conn, [&lostPackets](auto&, auto&, bool processed, PacketNum packetNum) {
|
||||||
lostPackets.emplace_back(packetNum, processed);
|
lostPackets.emplace_back(packetNum, processed);
|
||||||
});
|
});
|
||||||
EXPECT_EQ(2, conn->outstandingPackets.size());
|
EXPECT_EQ(2, conn->outstandings.packets.size());
|
||||||
EXPECT_EQ(lostPackets.size(), 2);
|
EXPECT_EQ(lostPackets.size(), 2);
|
||||||
for (auto lostPacket : lostPackets) {
|
for (auto lostPacket : lostPackets) {
|
||||||
EXPECT_FALSE(lostPacket.second);
|
EXPECT_FALSE(lostPacket.second);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < conn->outstandingPackets.size(); ++i) {
|
for (size_t i = 0; i < conn->outstandings.packets.size(); ++i) {
|
||||||
auto longHeader = conn->outstandingPackets[i].packet.header.asLong();
|
auto longHeader = conn->outstandings.packets[i].packet.header.asLong();
|
||||||
EXPECT_FALSE(
|
EXPECT_FALSE(
|
||||||
longHeader &&
|
longHeader &&
|
||||||
longHeader->getProtectionType() == ProtectionType::ZeroRtt);
|
longHeader->getProtectionType() == ProtectionType::ZeroRtt);
|
||||||
@@ -1423,7 +1423,7 @@ TEST_F(QuicLossFunctionsTest, TestZeroRttRejectedWithClones) {
|
|||||||
EXPECT_CALL(*rawCongestionController, onPacketSent(_))
|
EXPECT_CALL(*rawCongestionController, onPacketSent(_))
|
||||||
.WillRepeatedly(Return());
|
.WillRepeatedly(Return());
|
||||||
// By adding an associatedEvent that doesn't exist in the
|
// By adding an associatedEvent that doesn't exist in the
|
||||||
// outstandingPacketEvents, they are all processed and will skip lossVisitor
|
// outstandings.packetEvents, they are all processed and will skip lossVisitor
|
||||||
std::set<PacketNum> zeroRttPackets;
|
std::set<PacketNum> zeroRttPackets;
|
||||||
folly::Optional<PacketNum> lastPacket;
|
folly::Optional<PacketNum> lastPacket;
|
||||||
for (auto i = 0; i < 2; i++) {
|
for (auto i = 0; i < 2; i++) {
|
||||||
@@ -1438,9 +1438,9 @@ TEST_F(QuicLossFunctionsTest, TestZeroRttRejectedWithClones) {
|
|||||||
sendPacket(*conn, TimePoint(), zeroRttPacketNum, PacketType::OneRtt);
|
sendPacket(*conn, TimePoint(), zeroRttPacketNum, PacketType::OneRtt);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_EQ(6, conn->outstandingPackets.size());
|
EXPECT_EQ(6, conn->outstandings.packets.size());
|
||||||
ASSERT_EQ(conn->outstandingClonedPacketsCount, 6);
|
ASSERT_EQ(conn->outstandings.clonedPacketsCount, 6);
|
||||||
ASSERT_EQ(conn->outstandingPacketEvents.size(), 2);
|
ASSERT_EQ(conn->outstandings.packetEvents.size(), 2);
|
||||||
|
|
||||||
std::vector<std::pair<PacketNum, bool>> lostPackets;
|
std::vector<std::pair<PacketNum, bool>> lostPackets;
|
||||||
// onRemoveBytesFromInflight should still happen
|
// onRemoveBytesFromInflight should still happen
|
||||||
@@ -1449,17 +1449,17 @@ TEST_F(QuicLossFunctionsTest, TestZeroRttRejectedWithClones) {
|
|||||||
*conn, [&lostPackets](auto&, auto&, bool processed, PacketNum packetNum) {
|
*conn, [&lostPackets](auto&, auto&, bool processed, PacketNum packetNum) {
|
||||||
lostPackets.emplace_back(packetNum, processed);
|
lostPackets.emplace_back(packetNum, processed);
|
||||||
});
|
});
|
||||||
ASSERT_EQ(conn->outstandingPacketEvents.size(), 0);
|
ASSERT_EQ(conn->outstandings.packetEvents.size(), 0);
|
||||||
EXPECT_EQ(3, conn->outstandingPackets.size());
|
EXPECT_EQ(3, conn->outstandings.packets.size());
|
||||||
EXPECT_EQ(lostPackets.size(), 3);
|
EXPECT_EQ(lostPackets.size(), 3);
|
||||||
ASSERT_EQ(conn->outstandingClonedPacketsCount, 3);
|
ASSERT_EQ(conn->outstandings.clonedPacketsCount, 3);
|
||||||
size_t numProcessed = 0;
|
size_t numProcessed = 0;
|
||||||
for (auto lostPacket : lostPackets) {
|
for (auto lostPacket : lostPackets) {
|
||||||
numProcessed += lostPacket.second;
|
numProcessed += lostPacket.second;
|
||||||
}
|
}
|
||||||
EXPECT_EQ(numProcessed, 1);
|
EXPECT_EQ(numProcessed, 1);
|
||||||
for (size_t i = 0; i < conn->outstandingPackets.size(); ++i) {
|
for (size_t i = 0; i < conn->outstandings.packets.size(); ++i) {
|
||||||
auto longHeader = conn->outstandingPackets[i].packet.header.asLong();
|
auto longHeader = conn->outstandings.packets[i].packet.header.asLong();
|
||||||
EXPECT_FALSE(
|
EXPECT_FALSE(
|
||||||
longHeader &&
|
longHeader &&
|
||||||
longHeader->getProtectionType() == ProtectionType::ZeroRtt);
|
longHeader->getProtectionType() == ProtectionType::ZeroRtt);
|
||||||
@@ -1509,12 +1509,12 @@ TEST_P(QuicLossFunctionsTest, CappedShiftNoCrash) {
|
|||||||
conn->lossState.handshakeAlarmCount =
|
conn->lossState.handshakeAlarmCount =
|
||||||
std::numeric_limits<decltype(conn->lossState.handshakeAlarmCount)>::max();
|
std::numeric_limits<decltype(conn->lossState.handshakeAlarmCount)>::max();
|
||||||
sendPacket(*conn, Clock::now(), folly::none, PacketType::Handshake);
|
sendPacket(*conn, Clock::now(), folly::none, PacketType::Handshake);
|
||||||
ASSERT_GT(conn->outstandingHandshakePacketsCount, 0);
|
ASSERT_GT(conn->outstandings.handshakePacketsCount, 0);
|
||||||
calculateAlarmDuration(*conn);
|
calculateAlarmDuration(*conn);
|
||||||
|
|
||||||
conn->lossState.handshakeAlarmCount = 0;
|
conn->lossState.handshakeAlarmCount = 0;
|
||||||
conn->outstandingHandshakePacketsCount = 0;
|
conn->outstandings.handshakePacketsCount = 0;
|
||||||
conn->outstandingPackets.clear();
|
conn->outstandings.packets.clear();
|
||||||
conn->lossState.ptoCount =
|
conn->lossState.ptoCount =
|
||||||
std::numeric_limits<decltype(conn->lossState.ptoCount)>::max();
|
std::numeric_limits<decltype(conn->lossState.ptoCount)>::max();
|
||||||
sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt);
|
sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt);
|
||||||
|
@@ -506,7 +506,7 @@ class QuicServerTransportTest : public Test {
|
|||||||
// Issue (kMinNumAvailableConnIds - 1) more connection ids on handshake
|
// Issue (kMinNumAvailableConnIds - 1) more connection ids on handshake
|
||||||
// complete
|
// complete
|
||||||
auto numNewConnIdFrames = 0;
|
auto numNewConnIdFrames = 0;
|
||||||
for (const auto& packet : server->getConn().outstandingPackets) {
|
for (const auto& packet : server->getConn().outstandings.packets) {
|
||||||
for (const auto& frame : packet.packet.frames) {
|
for (const auto& frame : packet.packet.frames) {
|
||||||
switch (frame.type()) {
|
switch (frame.type()) {
|
||||||
case QuicWriteFrame::Type::QuicSimpleFrame_E: {
|
case QuicWriteFrame::Type::QuicSimpleFrame_E: {
|
||||||
@@ -813,9 +813,9 @@ TEST_F(QuicServerTransportTest, IdleTimerNotResetOnDuplicatePacket) {
|
|||||||
TEST_F(QuicServerTransportTest, IdleTimerNotResetWhenDataOutstanding) {
|
TEST_F(QuicServerTransportTest, IdleTimerNotResetWhenDataOutstanding) {
|
||||||
// Clear the receivedNewPacketBeforeWrite flag, since we may reveice from
|
// Clear the receivedNewPacketBeforeWrite flag, since we may reveice from
|
||||||
// client during the SetUp of the test case.
|
// client during the SetUp of the test case.
|
||||||
server->getNonConstConn().outstandingPackets.clear();
|
server->getNonConstConn().outstandings.packets.clear();
|
||||||
server->getNonConstConn().receivedNewPacketBeforeWrite = false;
|
server->getNonConstConn().receivedNewPacketBeforeWrite = false;
|
||||||
server->getNonConstConn().outstandingPackets.clear();
|
server->getNonConstConn().outstandings.packets.clear();
|
||||||
StreamId streamId = server->createBidirectionalStream().value();
|
StreamId streamId = server->createBidirectionalStream().value();
|
||||||
|
|
||||||
server->idleTimeout().cancelTimeout();
|
server->idleTimeout().cancelTimeout();
|
||||||
@@ -1175,8 +1175,8 @@ TEST_F(QuicServerTransportTest, TestOpenAckStreamFrame) {
|
|||||||
auto data = IOBuf::copyBuffer("Aloha");
|
auto data = IOBuf::copyBuffer("Aloha");
|
||||||
|
|
||||||
// Remove any packets that might have been queued.
|
// Remove any packets that might have been queued.
|
||||||
server->getNonConstConn().outstandingPackets.clear();
|
server->getNonConstConn().outstandings.packets.clear();
|
||||||
server->getNonConstConn().outstandingHandshakePacketsCount = 0;
|
server->getNonConstConn().outstandings.handshakePacketsCount = 0;
|
||||||
server->writeChain(streamId, data->clone(), false, false);
|
server->writeChain(streamId, data->clone(), false, false);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
server->writeChain(streamId, data->clone(), false, false);
|
server->writeChain(streamId, data->clone(), false, false);
|
||||||
@@ -1184,10 +1184,10 @@ TEST_F(QuicServerTransportTest, TestOpenAckStreamFrame) {
|
|||||||
loopForWrites();
|
loopForWrites();
|
||||||
|
|
||||||
auto stream = server->getNonConstConn().streamManager->getStream(streamId);
|
auto stream = server->getNonConstConn().streamManager->getStream(streamId);
|
||||||
ASSERT_FALSE(server->getConn().outstandingPackets.empty());
|
ASSERT_FALSE(server->getConn().outstandings.packets.empty());
|
||||||
ASSERT_FALSE(stream->retransmissionBuffer.empty());
|
ASSERT_FALSE(stream->retransmissionBuffer.empty());
|
||||||
// We need more than one packet for this test.
|
// We need more than one packet for this test.
|
||||||
ASSERT_FALSE(server->getConn().outstandingPackets.empty());
|
ASSERT_FALSE(server->getConn().outstandings.packets.empty());
|
||||||
|
|
||||||
PacketNum packetNum1 =
|
PacketNum packetNum1 =
|
||||||
getFirstOutstandingPacket(
|
getFirstOutstandingPacket(
|
||||||
@@ -1200,9 +1200,9 @@ TEST_F(QuicServerTransportTest, TestOpenAckStreamFrame) {
|
|||||||
->packet.header.getPacketSequenceNum();
|
->packet.header.getPacketSequenceNum();
|
||||||
|
|
||||||
uint32_t buffersInPacket1 = 0;
|
uint32_t buffersInPacket1 = 0;
|
||||||
for (size_t i = 0; i < server->getNonConstConn().outstandingPackets.size();
|
for (size_t i = 0; i < server->getNonConstConn().outstandings.packets.size();
|
||||||
++i) {
|
++i) {
|
||||||
auto& packet = server->getNonConstConn().outstandingPackets[i];
|
auto& packet = server->getNonConstConn().outstandings.packets[i];
|
||||||
if (packet.packet.header.getPacketNumberSpace() !=
|
if (packet.packet.header.getPacketNumberSpace() !=
|
||||||
PacketNumberSpace::AppData) {
|
PacketNumberSpace::AppData) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1265,7 +1265,7 @@ TEST_F(QuicServerTransportTest, TestOpenAckStreamFrame) {
|
|||||||
auto empty = IOBuf::create(0);
|
auto empty = IOBuf::create(0);
|
||||||
server->writeChain(streamId, std::move(empty), true, false);
|
server->writeChain(streamId, std::move(empty), true, false);
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
ASSERT_FALSE(server->getConn().outstandingPackets.empty());
|
ASSERT_FALSE(server->getConn().outstandings.packets.empty());
|
||||||
|
|
||||||
PacketNum finPacketNum =
|
PacketNum finPacketNum =
|
||||||
getFirstOutstandingPacket(
|
getFirstOutstandingPacket(
|
||||||
@@ -1778,8 +1778,8 @@ TEST_F(QuicServerTransportTest, TestCloneStopSending) {
|
|||||||
server->getNonConstConn().qLogger = qLogger;
|
server->getNonConstConn().qLogger = qLogger;
|
||||||
server->getNonConstConn().streamManager->getStream(streamId);
|
server->getNonConstConn().streamManager->getStream(streamId);
|
||||||
// knock every handshake outstanding packets out
|
// knock every handshake outstanding packets out
|
||||||
server->getNonConstConn().outstandingHandshakePacketsCount = 0;
|
server->getNonConstConn().outstandings.handshakePacketsCount = 0;
|
||||||
server->getNonConstConn().outstandingPackets.clear();
|
server->getNonConstConn().outstandings.packets.clear();
|
||||||
for (auto& t : server->getNonConstConn().lossState.lossTimes) {
|
for (auto& t : server->getNonConstConn().lossState.lossTimes) {
|
||||||
t.reset();
|
t.reset();
|
||||||
}
|
}
|
||||||
@@ -1788,17 +1788,18 @@ TEST_F(QuicServerTransportTest, TestCloneStopSending) {
|
|||||||
loopForWrites();
|
loopForWrites();
|
||||||
// Find the outstanding StopSending.
|
// Find the outstanding StopSending.
|
||||||
auto packetItr = std::find_if(
|
auto packetItr = std::find_if(
|
||||||
server->getNonConstConn().outstandingPackets.begin(),
|
server->getNonConstConn().outstandings.packets.begin(),
|
||||||
server->getNonConstConn().outstandingPackets.end(),
|
server->getNonConstConn().outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<QuicSimpleFrame::Type::StopSendingFrame_E>());
|
findFrameInPacketFunc<QuicSimpleFrame::Type::StopSendingFrame_E>());
|
||||||
|
|
||||||
ASSERT_TRUE(packetItr != server->getNonConstConn().outstandingPackets.end());
|
ASSERT_TRUE(
|
||||||
|
packetItr != server->getNonConstConn().outstandings.packets.end());
|
||||||
// Force a timeout with no data so that it clones the packet
|
// Force a timeout with no data so that it clones the packet
|
||||||
server->lossTimeout().timeoutExpired();
|
server->lossTimeout().timeoutExpired();
|
||||||
loopForWrites();
|
loopForWrites();
|
||||||
auto numStopSendingPackets = std::count_if(
|
auto numStopSendingPackets = std::count_if(
|
||||||
server->getNonConstConn().outstandingPackets.begin(),
|
server->getNonConstConn().outstandings.packets.begin(),
|
||||||
server->getNonConstConn().outstandingPackets.end(),
|
server->getNonConstConn().outstandings.packets.end(),
|
||||||
findFrameInPacketFunc<QuicSimpleFrame::Type::StopSendingFrame_E>());
|
findFrameInPacketFunc<QuicSimpleFrame::Type::StopSendingFrame_E>());
|
||||||
|
|
||||||
EXPECT_GT(numStopSendingPackets, 1);
|
EXPECT_GT(numStopSendingPackets, 1);
|
||||||
@@ -3696,7 +3697,7 @@ TEST_F(QuicUnencryptedServerTransportTest, TestSendHandshakeDone) {
|
|||||||
setupClientReadCodec();
|
setupClientReadCodec();
|
||||||
recvClientHello(true, QuicVersion::QUIC_DRAFT);
|
recvClientHello(true, QuicVersion::QUIC_DRAFT);
|
||||||
recvClientFinished(true, nullptr, QuicVersion::QUIC_DRAFT);
|
recvClientFinished(true, nullptr, QuicVersion::QUIC_DRAFT);
|
||||||
auto& packets = server->getConn().outstandingPackets;
|
auto& packets = server->getConn().outstandings.packets;
|
||||||
ASSERT_FALSE(packets.empty());
|
ASSERT_FALSE(packets.empty());
|
||||||
int numHandshakeDone = 0;
|
int numHandshakeDone = 0;
|
||||||
for (auto& p : packets) {
|
for (auto& p : packets) {
|
||||||
|
@@ -23,7 +23,7 @@ namespace quic {
|
|||||||
* order of packet number. For each ack block, we try to find a continuous range
|
* order of packet number. For each ack block, we try to find a continuous range
|
||||||
* of outstanding packets in the connection's outstanding packets list that is
|
* of outstanding packets in the connection's outstanding packets list that is
|
||||||
* acked by the current ack block. The search is in the reverse order of the
|
* acked by the current ack block. The search is in the reverse order of the
|
||||||
* outstandingPackets given that the list is sorted in the ascending order of
|
* outstandings.packets given that the list is sorted in the ascending order of
|
||||||
* packet number. For each outstanding packet that is acked by current ack
|
* packet number. For each outstanding packet that is acked by current ack
|
||||||
* frame, ack and loss visitors are invoked on the sent frames. The outstanding
|
* frame, ack and loss visitors are invoked on the sent frames. The outstanding
|
||||||
* packets may contain packets from all three packet number spaces. But ack is
|
* packets may contain packets from all three packet number spaces. But ack is
|
||||||
@@ -54,22 +54,22 @@ void processAckFrame(
|
|||||||
lastAckedPacketSentTime;
|
lastAckedPacketSentTime;
|
||||||
auto ackBlockIt = frame.ackBlocks.cbegin();
|
auto ackBlockIt = frame.ackBlocks.cbegin();
|
||||||
while (ackBlockIt != frame.ackBlocks.cend() &&
|
while (ackBlockIt != frame.ackBlocks.cend() &&
|
||||||
currentPacketIt != conn.outstandingPackets.rend()) {
|
currentPacketIt != conn.outstandings.packets.rend()) {
|
||||||
// In reverse order, find the first outstanding packet that has a packet
|
// In reverse order, find the first outstanding packet that has a packet
|
||||||
// number LE the endPacket of the current ack range.
|
// number LE the endPacket of the current ack range.
|
||||||
auto rPacketIt = std::lower_bound(
|
auto rPacketIt = std::lower_bound(
|
||||||
currentPacketIt,
|
currentPacketIt,
|
||||||
conn.outstandingPackets.rend(),
|
conn.outstandings.packets.rend(),
|
||||||
ackBlockIt->endPacket,
|
ackBlockIt->endPacket,
|
||||||
[&](const auto& packetWithTime, const auto& val) {
|
[&](const auto& packetWithTime, const auto& val) {
|
||||||
return packetWithTime.packet.header.getPacketSequenceNum() > val;
|
return packetWithTime.packet.header.getPacketSequenceNum() > val;
|
||||||
});
|
});
|
||||||
if (rPacketIt == conn.outstandingPackets.rend()) {
|
if (rPacketIt == conn.outstandings.packets.rend()) {
|
||||||
// This means that all the packets are greater than the end packet.
|
// This means that all the packets are greater than the end packet.
|
||||||
// Since we iterate the ACK blocks in reverse order of end packets, our
|
// Since we iterate the ACK blocks in reverse order of end packets, our
|
||||||
// work here is done.
|
// work here is done.
|
||||||
VLOG(10) << __func__ << " less than all outstanding packets outstanding="
|
VLOG(10) << __func__ << " less than all outstanding packets outstanding="
|
||||||
<< conn.outstandingPackets.size() << " range=["
|
<< conn.outstandings.packets.size() << " range=["
|
||||||
<< ackBlockIt->startPacket << ", " << ackBlockIt->endPacket
|
<< ackBlockIt->startPacket << ", " << ackBlockIt->endPacket
|
||||||
<< "]"
|
<< "]"
|
||||||
<< " " << conn;
|
<< " " << conn;
|
||||||
@@ -80,7 +80,7 @@ void processAckFrame(
|
|||||||
// TODO: only process ACKs from packets which are sent from a greater than
|
// TODO: only process ACKs from packets which are sent from a greater than
|
||||||
// or equal to crypto protection level.
|
// or equal to crypto protection level.
|
||||||
auto eraseEnd = rPacketIt;
|
auto eraseEnd = rPacketIt;
|
||||||
while (rPacketIt != conn.outstandingPackets.rend()) {
|
while (rPacketIt != conn.outstandings.packets.rend()) {
|
||||||
auto currentPacketNum = rPacketIt->packet.header.getPacketSequenceNum();
|
auto currentPacketNum = rPacketIt->packet.header.getPacketSequenceNum();
|
||||||
auto currentPacketNumberSpace =
|
auto currentPacketNumberSpace =
|
||||||
rPacketIt->packet.header.getPacketNumberSpace();
|
rPacketIt->packet.header.getPacketNumberSpace();
|
||||||
@@ -91,8 +91,8 @@ void processAckFrame(
|
|||||||
// this ack block. So the code erases the current iterator range and
|
// this ack block. So the code erases the current iterator range and
|
||||||
// move the iterator to be the next search point.
|
// move the iterator to be the next search point.
|
||||||
if (rPacketIt != eraseEnd) {
|
if (rPacketIt != eraseEnd) {
|
||||||
auto nextElem =
|
auto nextElem = conn.outstandings.packets.erase(
|
||||||
conn.outstandingPackets.erase(rPacketIt.base(), eraseEnd.base());
|
rPacketIt.base(), eraseEnd.base());
|
||||||
rPacketIt = std::reverse_iterator<decltype(nextElem)>(nextElem) + 1;
|
rPacketIt = std::reverse_iterator<decltype(nextElem)>(nextElem) + 1;
|
||||||
eraseEnd = rPacketIt;
|
eraseEnd = rPacketIt;
|
||||||
} else {
|
} else {
|
||||||
@@ -123,15 +123,15 @@ void processAckFrame(
|
|||||||
updateRtt(conn, rttSample, frame.ackDelay);
|
updateRtt(conn, rttSample, frame.ackDelay);
|
||||||
}
|
}
|
||||||
// Only invoke AckVisitor if the packet doesn't have an associated
|
// Only invoke AckVisitor if the packet doesn't have an associated
|
||||||
// PacketEvent; or the PacketEvent is in conn.outstandingPacketEvents
|
// PacketEvent; or the PacketEvent is in conn.outstandings.packetEvents
|
||||||
if (!rPacketIt->associatedEvent ||
|
if (!rPacketIt->associatedEvent ||
|
||||||
conn.outstandingPacketEvents.count(*rPacketIt->associatedEvent)) {
|
conn.outstandings.packetEvents.count(*rPacketIt->associatedEvent)) {
|
||||||
for (auto& packetFrame : rPacketIt->packet.frames) {
|
for (auto& packetFrame : rPacketIt->packet.frames) {
|
||||||
ackVisitor(*rPacketIt, packetFrame, frame);
|
ackVisitor(*rPacketIt, packetFrame, frame);
|
||||||
}
|
}
|
||||||
// Remove this PacketEvent from the outstandingPacketEvents set
|
// Remove this PacketEvent from the outstandings.packetEvents set
|
||||||
if (rPacketIt->associatedEvent) {
|
if (rPacketIt->associatedEvent) {
|
||||||
conn.outstandingPacketEvents.erase(*rPacketIt->associatedEvent);
|
conn.outstandings.packetEvents.erase(*rPacketIt->associatedEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ack.largestAckedPacket ||
|
if (!ack.largestAckedPacket ||
|
||||||
@@ -167,7 +167,7 @@ void processAckFrame(
|
|||||||
// the next search point.
|
// the next search point.
|
||||||
if (rPacketIt != eraseEnd) {
|
if (rPacketIt != eraseEnd) {
|
||||||
auto nextElem =
|
auto nextElem =
|
||||||
conn.outstandingPackets.erase(rPacketIt.base(), eraseEnd.base());
|
conn.outstandings.packets.erase(rPacketIt.base(), eraseEnd.base());
|
||||||
currentPacketIt = std::reverse_iterator<decltype(nextElem)>(nextElem);
|
currentPacketIt = std::reverse_iterator<decltype(nextElem)>(nextElem);
|
||||||
} else {
|
} else {
|
||||||
currentPacketIt = rPacketIt;
|
currentPacketIt = rPacketIt;
|
||||||
@@ -177,14 +177,15 @@ void processAckFrame(
|
|||||||
if (lastAckedPacketSentTime) {
|
if (lastAckedPacketSentTime) {
|
||||||
conn.lossState.lastAckedPacketSentTime = *lastAckedPacketSentTime;
|
conn.lossState.lastAckedPacketSentTime = *lastAckedPacketSentTime;
|
||||||
}
|
}
|
||||||
DCHECK_GE(conn.outstandingHandshakePacketsCount, handshakePacketAcked);
|
DCHECK_GE(conn.outstandings.handshakePacketsCount, handshakePacketAcked);
|
||||||
conn.outstandingHandshakePacketsCount -= handshakePacketAcked;
|
conn.outstandings.handshakePacketsCount -= handshakePacketAcked;
|
||||||
DCHECK_GE(conn.outstandingClonedPacketsCount, clonedPacketsAcked);
|
DCHECK_GE(conn.outstandings.clonedPacketsCount, clonedPacketsAcked);
|
||||||
conn.outstandingClonedPacketsCount -= clonedPacketsAcked;
|
conn.outstandings.clonedPacketsCount -= clonedPacketsAcked;
|
||||||
auto updatedOustandingPacketsCount = conn.outstandingPackets.size();
|
auto updatedOustandingPacketsCount = conn.outstandings.packets.size();
|
||||||
DCHECK_GE(
|
DCHECK_GE(
|
||||||
updatedOustandingPacketsCount, conn.outstandingHandshakePacketsCount);
|
updatedOustandingPacketsCount, conn.outstandings.handshakePacketsCount);
|
||||||
DCHECK_GE(updatedOustandingPacketsCount, conn.outstandingClonedPacketsCount);
|
DCHECK_GE(
|
||||||
|
updatedOustandingPacketsCount, conn.outstandings.clonedPacketsCount);
|
||||||
auto lossEvent = handleAckForLoss(conn, lossVisitor, ack, pnSpace);
|
auto lossEvent = handleAckForLoss(conn, lossVisitor, ack, pnSpace);
|
||||||
if (conn.congestionController &&
|
if (conn.congestionController &&
|
||||||
(ack.largestAckedPacket.has_value() || lossEvent)) {
|
(ack.largestAckedPacket.has_value() || lossEvent)) {
|
||||||
|
@@ -18,4 +18,4 @@ void updatePacingOnClose(QuicConnectionStateBase& conn) {
|
|||||||
conn.canBePaced = false;
|
conn.canBePaced = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace quic
|
||||||
|
@@ -16,4 +16,4 @@ void updatePacingOnKeyEstablished(QuicConnectionStateBase& conn);
|
|||||||
|
|
||||||
void updatePacingOnClose(QuicConnectionStateBase& conn);
|
void updatePacingOnClose(QuicConnectionStateBase& conn);
|
||||||
|
|
||||||
}
|
} // namespace quic
|
||||||
|
@@ -19,7 +19,7 @@ getPreviousOutstandingPacket(
|
|||||||
quic::PacketNumberSpace packetNumberSpace,
|
quic::PacketNumberSpace packetNumberSpace,
|
||||||
std::deque<quic::OutstandingPacket>::reverse_iterator from) {
|
std::deque<quic::OutstandingPacket>::reverse_iterator from) {
|
||||||
return std::find_if(
|
return std::find_if(
|
||||||
from, conn.outstandingPackets.rend(), [=](const auto& op) {
|
from, conn.outstandings.packets.rend(), [=](const auto& op) {
|
||||||
return packetNumberSpace == op.packet.header.getPacketNumberSpace();
|
return packetNumberSpace == op.packet.header.getPacketNumberSpace();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -212,23 +212,24 @@ std::deque<OutstandingPacket>::iterator getFirstOutstandingPacket(
|
|||||||
QuicConnectionStateBase& conn,
|
QuicConnectionStateBase& conn,
|
||||||
PacketNumberSpace packetNumberSpace) {
|
PacketNumberSpace packetNumberSpace) {
|
||||||
return getNextOutstandingPacket(
|
return getNextOutstandingPacket(
|
||||||
conn, packetNumberSpace, conn.outstandingPackets.begin());
|
conn, packetNumberSpace, conn.outstandings.packets.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::deque<OutstandingPacket>::reverse_iterator getLastOutstandingPacket(
|
std::deque<OutstandingPacket>::reverse_iterator getLastOutstandingPacket(
|
||||||
QuicConnectionStateBase& conn,
|
QuicConnectionStateBase& conn,
|
||||||
PacketNumberSpace packetNumberSpace) {
|
PacketNumberSpace packetNumberSpace) {
|
||||||
return getPreviousOutstandingPacket(
|
return getPreviousOutstandingPacket(
|
||||||
conn, packetNumberSpace, conn.outstandingPackets.rbegin());
|
conn, packetNumberSpace, conn.outstandings.packets.rbegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::deque<OutstandingPacket>::iterator getNextOutstandingPacket(
|
std::deque<OutstandingPacket>::iterator getNextOutstandingPacket(
|
||||||
QuicConnectionStateBase& conn,
|
QuicConnectionStateBase& conn,
|
||||||
PacketNumberSpace packetNumberSpace,
|
PacketNumberSpace packetNumberSpace,
|
||||||
std::deque<OutstandingPacket>::iterator from) {
|
std::deque<OutstandingPacket>::iterator from) {
|
||||||
return std::find_if(from, conn.outstandingPackets.end(), [=](const auto& op) {
|
return std::find_if(
|
||||||
return packetNumberSpace == op.packet.header.getPacketNumberSpace();
|
from, conn.outstandings.packets.end(), [=](const auto& op) {
|
||||||
});
|
return packetNumberSpace == op.packet.header.getPacketNumberSpace();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasReceivedPacketsAtLastCloseSent(
|
bool hasReceivedPacketsAtLastCloseSent(
|
||||||
|
@@ -179,6 +179,23 @@ struct OutstandingPacket {
|
|||||||
totalBytesSent(totalBytesSentIn) {}
|
totalBytesSent(totalBytesSentIn) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct OutstandingsInfo {
|
||||||
|
// Sent packets which have not been acked. These are sorted by PacketNum.
|
||||||
|
std::deque<OutstandingPacket> packets;
|
||||||
|
|
||||||
|
// All PacketEvents of this connection. If a OutstandingPacket doesn't have an
|
||||||
|
// associatedEvent or if it's not in this set, there is no need to process its
|
||||||
|
// frames upon ack or loss.
|
||||||
|
// TODO: Enforce only AppTraffic packets to be clonable
|
||||||
|
folly::F14FastSet<PacketEvent> packetEvents;
|
||||||
|
|
||||||
|
// Number of handshake packets outstanding.
|
||||||
|
uint64_t handshakePacketsCount{0};
|
||||||
|
|
||||||
|
// Number of packets are clones or cloned.
|
||||||
|
uint64_t clonedPacketsCount{0};
|
||||||
|
};
|
||||||
|
|
||||||
struct Pacer {
|
struct Pacer {
|
||||||
virtual ~Pacer() = default;
|
virtual ~Pacer() = default;
|
||||||
|
|
||||||
@@ -352,9 +369,9 @@ struct CongestionController {
|
|||||||
* Take bytes out of flight without mutating other states of the controller
|
* Take bytes out of flight without mutating other states of the controller
|
||||||
* TODO(yangchi): I'm not sure how long I'd like to keep this API. This is a
|
* TODO(yangchi): I'm not sure how long I'd like to keep this API. This is a
|
||||||
* temporary workaround the fact that there are packets we will need to take
|
* temporary workaround the fact that there are packets we will need to take
|
||||||
* out of outstandingPackets but not considered loss for congestion control
|
* out of outstandings.packets but not considered loss for congestion
|
||||||
* perspective. In long term, we shouldn't take them out of
|
* control perspective. In long term, we shouldn't take them out of
|
||||||
* outstandingPackets, then we don't have to do this.
|
* outstandings.packets, then we don't have to do this.
|
||||||
*/
|
*/
|
||||||
virtual void onRemoveBytesFromInflight(uint64_t) = 0;
|
virtual void onRemoveBytesFromInflight(uint64_t) = 0;
|
||||||
virtual void onPacketSent(const OutstandingPacket& packet) = 0;
|
virtual void onPacketSent(const OutstandingPacket& packet) = 0;
|
||||||
@@ -535,22 +552,9 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction {
|
|||||||
|
|
||||||
std::unique_ptr<PendingPathRateLimiter> pathValidationLimiter;
|
std::unique_ptr<PendingPathRateLimiter> pathValidationLimiter;
|
||||||
|
|
||||||
// TODO: We really really should wrap outstandingPackets, all its associated
|
// Outstanding packets, packet events, and associated counters wrapped in one
|
||||||
// counters and the outstandingPacketEvents into one class.
|
// class
|
||||||
// Sent packets which have not been acked. These are sorted by PacketNum.
|
OutstandingsInfo outstandings;
|
||||||
std::deque<OutstandingPacket> outstandingPackets;
|
|
||||||
|
|
||||||
// All PacketEvents of this connection. If a OutstandingPacket doesn't have an
|
|
||||||
// associatedEvent or if it's not in this set, there is no need to process its
|
|
||||||
// frames upon ack or loss.
|
|
||||||
// TODO: Enforce only AppTraffic packets to be clonable
|
|
||||||
folly::F14FastSet<PacketEvent> outstandingPacketEvents;
|
|
||||||
|
|
||||||
// Number of handshake packets outstanding.
|
|
||||||
uint64_t outstandingHandshakePacketsCount{0};
|
|
||||||
|
|
||||||
// Number of packets are clones or cloned.
|
|
||||||
uint64_t outstandingClonedPacketsCount{0};
|
|
||||||
|
|
||||||
// The read codec to decrypt and decode packets.
|
// The read codec to decrypt and decode packets.
|
||||||
std::unique_ptr<QuicReadCodec> readCodec;
|
std::unique_ptr<QuicReadCodec> readCodec;
|
||||||
|
@@ -19,4 +19,4 @@ void resetQuicStream(QuicStreamState& stream, ApplicationErrorCode error);
|
|||||||
void onResetQuicStream(QuicStreamState& stream, RstStreamFrame&& frame);
|
void onResetQuicStream(QuicStreamState& stream, RstStreamFrame&& frame);
|
||||||
|
|
||||||
bool isAllDataReceived(const QuicStreamState& stream);
|
bool isAllDataReceived(const QuicStreamState& stream);
|
||||||
}
|
} // namespace quic
|
||||||
|
@@ -161,7 +161,7 @@ TEST_F(QuicOpenStateTest, AckStream) {
|
|||||||
true);
|
true);
|
||||||
|
|
||||||
EXPECT_EQ(stream->retransmissionBuffer.size(), 1);
|
EXPECT_EQ(stream->retransmissionBuffer.size(), 1);
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto& streamFrame =
|
auto& streamFrame =
|
||||||
*getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
*getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
||||||
@@ -211,10 +211,10 @@ TEST_F(QuicOpenStateTest, AckStreamMulti) {
|
|||||||
false);
|
false);
|
||||||
|
|
||||||
EXPECT_EQ(stream->retransmissionBuffer.size(), 3);
|
EXPECT_EQ(stream->retransmissionBuffer.size(), 3);
|
||||||
EXPECT_EQ(3, conn->outstandingPackets.size());
|
EXPECT_EQ(3, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto& streamFrame3 =
|
auto& streamFrame3 =
|
||||||
*conn->outstandingPackets[2].packet.frames[0].asWriteStreamFrame();
|
*conn->outstandings.packets[2].packet.frames[0].asWriteStreamFrame();
|
||||||
|
|
||||||
sendAckSMHandler(*stream, streamFrame3);
|
sendAckSMHandler(*stream, streamFrame3);
|
||||||
ASSERT_EQ(stream->sendState, StreamSendState::Open_E);
|
ASSERT_EQ(stream->sendState, StreamSendState::Open_E);
|
||||||
@@ -222,7 +222,7 @@ TEST_F(QuicOpenStateTest, AckStreamMulti) {
|
|||||||
ASSERT_EQ(stream->ackedIntervals.front().end, 21);
|
ASSERT_EQ(stream->ackedIntervals.front().end, 21);
|
||||||
|
|
||||||
auto& streamFrame2 =
|
auto& streamFrame2 =
|
||||||
*conn->outstandingPackets[1].packet.frames[0].asWriteStreamFrame();
|
*conn->outstandings.packets[1].packet.frames[0].asWriteStreamFrame();
|
||||||
|
|
||||||
sendAckSMHandler(*stream, streamFrame2);
|
sendAckSMHandler(*stream, streamFrame2);
|
||||||
ASSERT_EQ(stream->sendState, StreamSendState::Open_E);
|
ASSERT_EQ(stream->sendState, StreamSendState::Open_E);
|
||||||
@@ -230,7 +230,7 @@ TEST_F(QuicOpenStateTest, AckStreamMulti) {
|
|||||||
ASSERT_EQ(stream->ackedIntervals.front().end, 21);
|
ASSERT_EQ(stream->ackedIntervals.front().end, 21);
|
||||||
|
|
||||||
auto& streamFrame1 =
|
auto& streamFrame1 =
|
||||||
*conn->outstandingPackets[0].packet.frames[0].asWriteStreamFrame();
|
*conn->outstandings.packets[0].packet.frames[0].asWriteStreamFrame();
|
||||||
|
|
||||||
sendAckSMHandler(*stream, streamFrame1);
|
sendAckSMHandler(*stream, streamFrame1);
|
||||||
ASSERT_EQ(stream->sendState, StreamSendState::Open_E);
|
ASSERT_EQ(stream->sendState, StreamSendState::Open_E);
|
||||||
@@ -275,9 +275,9 @@ TEST_F(QuicOpenStateTest, RetxBufferSortedAfterAck) {
|
|||||||
false);
|
false);
|
||||||
|
|
||||||
EXPECT_EQ(3, stream->retransmissionBuffer.size());
|
EXPECT_EQ(3, stream->retransmissionBuffer.size());
|
||||||
EXPECT_EQ(3, conn->outstandingPackets.size());
|
EXPECT_EQ(3, conn->outstandings.packets.size());
|
||||||
auto packet = conn->outstandingPackets[folly::Random::rand32() % 3];
|
auto packet = conn->outstandings.packets[folly::Random::rand32() % 3];
|
||||||
auto streamFrame = *conn->outstandingPackets[std::rand() % 3]
|
auto streamFrame = *conn->outstandings.packets[std::rand() % 3]
|
||||||
.packet.frames.front()
|
.packet.frames.front()
|
||||||
.asWriteStreamFrame();
|
.asWriteStreamFrame();
|
||||||
sendAckSMHandler(*stream, streamFrame);
|
sendAckSMHandler(*stream, streamFrame);
|
||||||
@@ -305,7 +305,7 @@ TEST_F(QuicOpenStateTest, AckStreamAfterSkip) {
|
|||||||
true);
|
true);
|
||||||
|
|
||||||
EXPECT_EQ(stream->retransmissionBuffer.size(), 1);
|
EXPECT_EQ(stream->retransmissionBuffer.size(), 1);
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto& streamFrame =
|
auto& streamFrame =
|
||||||
*getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
*getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
||||||
@@ -349,7 +349,7 @@ TEST_F(QuicOpenStateTest, AckStreamAfterSkipHalfBuf) {
|
|||||||
true);
|
true);
|
||||||
|
|
||||||
EXPECT_EQ(stream->retransmissionBuffer.size(), 1);
|
EXPECT_EQ(stream->retransmissionBuffer.size(), 1);
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto& streamFrame =
|
auto& streamFrame =
|
||||||
*getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
*getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
||||||
@@ -400,7 +400,7 @@ TEST_F(QuicOpenStateTest, AckStreamAfterSkipOneAndAHalfBuf) {
|
|||||||
true);
|
true);
|
||||||
|
|
||||||
EXPECT_EQ(stream->retransmissionBuffer.size(), 2);
|
EXPECT_EQ(stream->retransmissionBuffer.size(), 2);
|
||||||
EXPECT_EQ(2, conn->outstandingPackets.size());
|
EXPECT_EQ(2, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto streamFrameIt =
|
auto streamFrameIt =
|
||||||
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData);
|
getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData);
|
||||||
@@ -545,7 +545,7 @@ TEST_F(QuicHalfClosedRemoteStateTest, AckStream) {
|
|||||||
true);
|
true);
|
||||||
|
|
||||||
EXPECT_EQ(stream->retransmissionBuffer.size(), 1);
|
EXPECT_EQ(stream->retransmissionBuffer.size(), 1);
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto& streamFrame =
|
auto& streamFrame =
|
||||||
*getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
*getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
||||||
@@ -583,7 +583,7 @@ TEST_F(QuicHalfClosedRemoteStateTest, AckStreamAfterSkip) {
|
|||||||
true);
|
true);
|
||||||
|
|
||||||
EXPECT_EQ(stream->retransmissionBuffer.size(), 1);
|
EXPECT_EQ(stream->retransmissionBuffer.size(), 1);
|
||||||
EXPECT_EQ(1, conn->outstandingPackets.size());
|
EXPECT_EQ(1, conn->outstandings.packets.size());
|
||||||
|
|
||||||
auto& streamFrame =
|
auto& streamFrame =
|
||||||
*getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
*getFirstOutstandingPacket(*conn, PacketNumberSpace::AppData)
|
||||||
|
@@ -50,7 +50,7 @@ TEST_P(AckHandlersTest, TestAckMultipleSequentialBlocks) {
|
|||||||
createNewPacket(packetNum, GetParam());
|
createNewPacket(packetNum, GetParam());
|
||||||
WriteStreamFrame frame(currentStreamId++, 0, 0, true);
|
WriteStreamFrame frame(currentStreamId++, 0, 0, true);
|
||||||
regularPacket.frames.emplace_back(std::move(frame));
|
regularPacket.frames.emplace_back(std::move(frame));
|
||||||
conn.outstandingPackets.emplace_back(OutstandingPacket(
|
conn.outstandings.packets.emplace_back(OutstandingPacket(
|
||||||
std::move(regularPacket), sentTime, 1, false, packetNum));
|
std::move(regularPacket), sentTime, 1, false, packetNum));
|
||||||
}
|
}
|
||||||
ReadAckFrame ackFrame;
|
ReadAckFrame ackFrame;
|
||||||
@@ -94,13 +94,13 @@ TEST_P(AckHandlersTest, TestAckMultipleSequentialBlocks) {
|
|||||||
start--;
|
start--;
|
||||||
}
|
}
|
||||||
// only unacked packets should be remaining
|
// only unacked packets should be remaining
|
||||||
EXPECT_EQ(conn.outstandingPackets.size(), 5);
|
EXPECT_EQ(conn.outstandings.packets.size(), 5);
|
||||||
PacketNum lostPackt = 10;
|
PacketNum lostPackt = 10;
|
||||||
for (auto& pkt : lostPackets) {
|
for (auto& pkt : lostPackets) {
|
||||||
EXPECT_EQ(pkt, lostPackt++);
|
EXPECT_EQ(pkt, lostPackt++);
|
||||||
}
|
}
|
||||||
PacketNum packetNum = 16;
|
PacketNum packetNum = 16;
|
||||||
for (auto& packet : conn.outstandingPackets) {
|
for (auto& packet : conn.outstandings.packets) {
|
||||||
auto currentPacketNum = packet.packet.header.getPacketSequenceNum();
|
auto currentPacketNum = packet.packet.header.getPacketSequenceNum();
|
||||||
EXPECT_EQ(currentPacketNum, packetNum);
|
EXPECT_EQ(currentPacketNum, packetNum);
|
||||||
packetNum++;
|
packetNum++;
|
||||||
@@ -121,7 +121,7 @@ TEST_P(AckHandlersTest, TestAckBlocksWithGaps) {
|
|||||||
auto regularPacket = createNewPacket(packetNum, GetParam());
|
auto regularPacket = createNewPacket(packetNum, GetParam());
|
||||||
WriteStreamFrame frame(currentStreamId++, 0, 0, true);
|
WriteStreamFrame frame(currentStreamId++, 0, 0, true);
|
||||||
regularPacket.frames.emplace_back(std::move(frame));
|
regularPacket.frames.emplace_back(std::move(frame));
|
||||||
conn.outstandingPackets.emplace_back(OutstandingPacket(
|
conn.outstandings.packets.emplace_back(OutstandingPacket(
|
||||||
std::move(regularPacket), Clock::now(), 1, false, packetNum));
|
std::move(regularPacket), Clock::now(), 1, false, packetNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,8 +185,8 @@ TEST_P(AckHandlersTest, TestAckBlocksWithGaps) {
|
|||||||
|
|
||||||
std::vector<PacketNum> actualPacketNumbers;
|
std::vector<PacketNum> actualPacketNumbers;
|
||||||
std::transform(
|
std::transform(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
std::back_insert_iterator<decltype(actualPacketNumbers)>(
|
std::back_insert_iterator<decltype(actualPacketNumbers)>(
|
||||||
actualPacketNumbers),
|
actualPacketNumbers),
|
||||||
[](const auto& packet) {
|
[](const auto& packet) {
|
||||||
@@ -222,7 +222,7 @@ TEST_P(AckHandlersTest, TestNonSequentialPacketNumbers) {
|
|||||||
auto regularPacket = createNewPacket(packetNum, GetParam());
|
auto regularPacket = createNewPacket(packetNum, GetParam());
|
||||||
WriteStreamFrame frame(current++, 0, 0, true);
|
WriteStreamFrame frame(current++, 0, 0, true);
|
||||||
regularPacket.frames.emplace_back(std::move(frame));
|
regularPacket.frames.emplace_back(std::move(frame));
|
||||||
conn.outstandingPackets.emplace_back(OutstandingPacket(
|
conn.outstandings.packets.emplace_back(OutstandingPacket(
|
||||||
std::move(regularPacket), Clock::now(), 1, false, packetNum));
|
std::move(regularPacket), Clock::now(), 1, false, packetNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +231,7 @@ TEST_P(AckHandlersTest, TestNonSequentialPacketNumbers) {
|
|||||||
WriteStreamFrame frame(current, 0, 0, true);
|
WriteStreamFrame frame(current, 0, 0, true);
|
||||||
current += 3;
|
current += 3;
|
||||||
regularPacket.frames.emplace_back(std::move(frame));
|
regularPacket.frames.emplace_back(std::move(frame));
|
||||||
conn.outstandingPackets.emplace_back(OutstandingPacket(
|
conn.outstandings.packets.emplace_back(OutstandingPacket(
|
||||||
std::move(regularPacket), Clock::now(), 1, false, packetNum));
|
std::move(regularPacket), Clock::now(), 1, false, packetNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,8 +286,8 @@ TEST_P(AckHandlersTest, TestNonSequentialPacketNumbers) {
|
|||||||
|
|
||||||
std::vector<PacketNum> actualPacketNumbers;
|
std::vector<PacketNum> actualPacketNumbers;
|
||||||
std::transform(
|
std::transform(
|
||||||
conn.outstandingPackets.begin(),
|
conn.outstandings.packets.begin(),
|
||||||
conn.outstandingPackets.end(),
|
conn.outstandings.packets.end(),
|
||||||
std::back_insert_iterator<decltype(actualPacketNumbers)>(
|
std::back_insert_iterator<decltype(actualPacketNumbers)>(
|
||||||
actualPacketNumbers),
|
actualPacketNumbers),
|
||||||
[](const auto& packet) {
|
[](const auto& packet) {
|
||||||
@@ -311,7 +311,7 @@ TEST_P(AckHandlersTest, AckVisitorForAckTest) {
|
|||||||
conn.ackStates.appDataAckState.acks.insert(900, 1000);
|
conn.ackStates.appDataAckState.acks.insert(900, 1000);
|
||||||
conn.ackStates.appDataAckState.acks.insert(500, 700);
|
conn.ackStates.appDataAckState.acks.insert(500, 700);
|
||||||
firstPacket.frames.emplace_back(std::move(firstAckFrame));
|
firstPacket.frames.emplace_back(std::move(firstAckFrame));
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
OutstandingPacket(std::move(firstPacket), Clock::now(), 0, false, 0));
|
OutstandingPacket(std::move(firstPacket), Clock::now(), 0, false, 0));
|
||||||
|
|
||||||
auto secondPacket = createNewPacket(101 /* packetNum */, GetParam());
|
auto secondPacket = createNewPacket(101 /* packetNum */, GetParam());
|
||||||
@@ -321,7 +321,7 @@ TEST_P(AckHandlersTest, AckVisitorForAckTest) {
|
|||||||
conn.ackStates.appDataAckState.acks.insert(1100, 2000);
|
conn.ackStates.appDataAckState.acks.insert(1100, 2000);
|
||||||
conn.ackStates.appDataAckState.acks.insert(1002, 1090);
|
conn.ackStates.appDataAckState.acks.insert(1002, 1090);
|
||||||
secondPacket.frames.emplace_back(std::move(secondAckFrame));
|
secondPacket.frames.emplace_back(std::move(secondAckFrame));
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
OutstandingPacket(std::move(secondPacket), Clock::now(), 0, false, 0));
|
OutstandingPacket(std::move(secondPacket), Clock::now(), 0, false, 0));
|
||||||
|
|
||||||
ReadAckFrame firstReceivedAck;
|
ReadAckFrame firstReceivedAck;
|
||||||
@@ -385,7 +385,7 @@ TEST_P(AckHandlersTest, NoNewAckedPacket) {
|
|||||||
conn.lossState.ptoCount = 1;
|
conn.lossState.ptoCount = 1;
|
||||||
PacketNum packetAfterRtoNum = 10;
|
PacketNum packetAfterRtoNum = 10;
|
||||||
auto packetAfterRto = createNewPacket(packetAfterRtoNum, GetParam());
|
auto packetAfterRto = createNewPacket(packetAfterRtoNum, GetParam());
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
OutstandingPacket(std::move(packetAfterRto), Clock::now(), 0, false, 0));
|
OutstandingPacket(std::move(packetAfterRto), Clock::now(), 0, false, 0));
|
||||||
|
|
||||||
ReadAckFrame ackFrame;
|
ReadAckFrame ackFrame;
|
||||||
@@ -429,12 +429,12 @@ TEST_P(AckHandlersTest, AckPacketNumDoesNotExist) {
|
|||||||
|
|
||||||
PacketNum packetNum1 = 9;
|
PacketNum packetNum1 = 9;
|
||||||
auto regularPacket1 = createNewPacket(packetNum1, GetParam());
|
auto regularPacket1 = createNewPacket(packetNum1, GetParam());
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
std::move(regularPacket1), Clock::now(), 0, false, 0);
|
std::move(regularPacket1), Clock::now(), 0, false, 0);
|
||||||
|
|
||||||
PacketNum packetNum2 = 10;
|
PacketNum packetNum2 = 10;
|
||||||
auto regularPacket2 = createNewPacket(packetNum2, GetParam());
|
auto regularPacket2 = createNewPacket(packetNum2, GetParam());
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
std::move(regularPacket2), Clock::now(), 0, false, 0);
|
std::move(regularPacket2), Clock::now(), 0, false, 0);
|
||||||
|
|
||||||
// Ack a packet one higher than the packet so that we don't trigger reordering
|
// Ack a packet one higher than the packet so that we don't trigger reordering
|
||||||
@@ -450,7 +450,7 @@ TEST_P(AckHandlersTest, AckPacketNumDoesNotExist) {
|
|||||||
[](const auto&, const auto&, const auto&) {},
|
[](const auto&, const auto&, const auto&) {},
|
||||||
[](auto&, auto&, bool, PacketNum) {},
|
[](auto&, auto&, bool, PacketNum) {},
|
||||||
Clock::now());
|
Clock::now());
|
||||||
EXPECT_EQ(1, conn.outstandingPackets.size());
|
EXPECT_EQ(1, conn.outstandings.packets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(AckHandlersTest, TestHandshakeCounterUpdate) {
|
TEST_P(AckHandlersTest, TestHandshakeCounterUpdate) {
|
||||||
@@ -461,13 +461,13 @@ TEST_P(AckHandlersTest, TestHandshakeCounterUpdate) {
|
|||||||
WriteStreamFrame frame(
|
WriteStreamFrame frame(
|
||||||
stream, 100 * packetNum + 0, 100 * packetNum + 100, false);
|
stream, 100 * packetNum + 0, 100 * packetNum + 100, false);
|
||||||
regularPacket.frames.emplace_back(std::move(frame));
|
regularPacket.frames.emplace_back(std::move(frame));
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
std::move(regularPacket),
|
std::move(regularPacket),
|
||||||
Clock::now(),
|
Clock::now(),
|
||||||
0,
|
0,
|
||||||
packetNum % 2,
|
packetNum % 2,
|
||||||
packetNum / 2);
|
packetNum / 2);
|
||||||
conn.outstandingHandshakePacketsCount += packetNum % 2;
|
conn.outstandings.handshakePacketsCount += packetNum % 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadAckFrame ackFrame;
|
ReadAckFrame ackFrame;
|
||||||
@@ -484,8 +484,8 @@ TEST_P(AckHandlersTest, TestHandshakeCounterUpdate) {
|
|||||||
Clock::now());
|
Clock::now());
|
||||||
// When [3, 7] are acked, [0, 2] will also be marked loss, due to reordering
|
// When [3, 7] are acked, [0, 2] will also be marked loss, due to reordering
|
||||||
// threshold
|
// threshold
|
||||||
EXPECT_EQ(1, conn.outstandingHandshakePacketsCount);
|
EXPECT_EQ(1, conn.outstandings.handshakePacketsCount);
|
||||||
EXPECT_EQ(2, conn.outstandingPackets.size());
|
EXPECT_EQ(2, conn.outstandings.packets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(AckHandlersTest, PurgeAcks) {
|
TEST_P(AckHandlersTest, PurgeAcks) {
|
||||||
@@ -524,7 +524,7 @@ TEST_P(AckHandlersTest, NoSkipAckVisitor) {
|
|||||||
// We need to at least have one frame to trigger ackVisitor
|
// We need to at least have one frame to trigger ackVisitor
|
||||||
WriteStreamFrame frame(0, 0, 0, true);
|
WriteStreamFrame frame(0, 0, 0, true);
|
||||||
regularPacket.frames.emplace_back(std::move(frame));
|
regularPacket.frames.emplace_back(std::move(frame));
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
OutstandingPacket(std::move(regularPacket), Clock::now(), 1, false, 1));
|
OutstandingPacket(std::move(regularPacket), Clock::now(), 1, false, 1));
|
||||||
ReadAckFrame ackFrame;
|
ReadAckFrame ackFrame;
|
||||||
ackFrame.largestAcked = 0;
|
ackFrame.largestAcked = 0;
|
||||||
@@ -570,10 +570,10 @@ TEST_P(AckHandlersTest, SkipAckVisitor) {
|
|||||||
OutstandingPacket outstandingPacket(
|
OutstandingPacket outstandingPacket(
|
||||||
std::move(regularPacket), Clock::now(), 1, false, 1);
|
std::move(regularPacket), Clock::now(), 1, false, 1);
|
||||||
// Give this outstandingPacket an associatedEvent that's not in
|
// Give this outstandingPacket an associatedEvent that's not in
|
||||||
// outstandingPacketEvents
|
// outstandings.packetEvents
|
||||||
outstandingPacket.associatedEvent = 0;
|
outstandingPacket.associatedEvent = 0;
|
||||||
conn.outstandingPackets.push_back(std::move(outstandingPacket));
|
conn.outstandings.packets.push_back(std::move(outstandingPacket));
|
||||||
conn.outstandingClonedPacketsCount++;
|
conn.outstandings.clonedPacketsCount++;
|
||||||
|
|
||||||
ReadAckFrame ackFrame;
|
ReadAckFrame ackFrame;
|
||||||
ackFrame.largestAcked = 0;
|
ackFrame.largestAcked = 0;
|
||||||
@@ -618,10 +618,10 @@ TEST_P(AckHandlersTest, NoDoubleProcess) {
|
|||||||
// The seconds packet has the same PacketEvent
|
// The seconds packet has the same PacketEvent
|
||||||
outstandingPacket2.associatedEvent = packetNum1;
|
outstandingPacket2.associatedEvent = packetNum1;
|
||||||
|
|
||||||
conn.outstandingPackets.push_back(std::move(outstandingPacket1));
|
conn.outstandings.packets.push_back(std::move(outstandingPacket1));
|
||||||
conn.outstandingPackets.push_back(std::move(outstandingPacket2));
|
conn.outstandings.packets.push_back(std::move(outstandingPacket2));
|
||||||
conn.outstandingClonedPacketsCount += 2;
|
conn.outstandings.clonedPacketsCount += 2;
|
||||||
conn.outstandingPacketEvents.insert(packetNum1);
|
conn.outstandings.packetEvents.insert(packetNum1);
|
||||||
|
|
||||||
// A counting ack visitor
|
// A counting ack visitor
|
||||||
uint16_t ackVisitorCounter = 0;
|
uint16_t ackVisitorCounter = 0;
|
||||||
@@ -682,10 +682,10 @@ TEST_P(AckHandlersTest, ClonedPacketsCounter) {
|
|||||||
OutstandingPacket outstandingPacket2(
|
OutstandingPacket outstandingPacket2(
|
||||||
std::move(regularPacket2), Clock::now(), 1, false, 1);
|
std::move(regularPacket2), Clock::now(), 1, false, 1);
|
||||||
|
|
||||||
conn.outstandingPackets.push_back(std::move(outstandingPacket1));
|
conn.outstandings.packets.push_back(std::move(outstandingPacket1));
|
||||||
conn.outstandingPackets.push_back(std::move(outstandingPacket2));
|
conn.outstandings.packets.push_back(std::move(outstandingPacket2));
|
||||||
conn.outstandingClonedPacketsCount = 1;
|
conn.outstandings.clonedPacketsCount = 1;
|
||||||
conn.outstandingPacketEvents.insert(packetNum1);
|
conn.outstandings.packetEvents.insert(packetNum1);
|
||||||
|
|
||||||
ReadAckFrame ackFrame;
|
ReadAckFrame ackFrame;
|
||||||
ackFrame.largestAcked = packetNum2;
|
ackFrame.largestAcked = packetNum2;
|
||||||
@@ -708,7 +708,7 @@ TEST_P(AckHandlersTest, ClonedPacketsCounter) {
|
|||||||
PacketNum) { /* no-op */ },
|
PacketNum) { /* no-op */ },
|
||||||
Clock::now());
|
Clock::now());
|
||||||
EXPECT_EQ(2, ackVisitorCounter);
|
EXPECT_EQ(2, ackVisitorCounter);
|
||||||
EXPECT_EQ(0, conn.outstandingClonedPacketsCount);
|
EXPECT_EQ(0, conn.outstandings.clonedPacketsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(AckHandlersTest, UpdateMaxAckDelay) {
|
TEST_P(AckHandlersTest, UpdateMaxAckDelay) {
|
||||||
@@ -718,7 +718,7 @@ TEST_P(AckHandlersTest, UpdateMaxAckDelay) {
|
|||||||
PacketNum packetNum = 0;
|
PacketNum packetNum = 0;
|
||||||
auto regularPacket = createNewPacket(packetNum, GetParam());
|
auto regularPacket = createNewPacket(packetNum, GetParam());
|
||||||
auto sentTime = Clock::now();
|
auto sentTime = Clock::now();
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
OutstandingPacket(std::move(regularPacket), sentTime, 1, false, 1));
|
OutstandingPacket(std::move(regularPacket), sentTime, 1, false, 1));
|
||||||
|
|
||||||
ReadAckFrame ackFrame;
|
ReadAckFrame ackFrame;
|
||||||
@@ -775,8 +775,8 @@ TEST_P(AckHandlersTest, AckNotOutstandingButLoss) {
|
|||||||
1,
|
1,
|
||||||
false,
|
false,
|
||||||
1);
|
1);
|
||||||
conn.outstandingPackets.push_back(std::move(outstandingPacket));
|
conn.outstandings.packets.push_back(std::move(outstandingPacket));
|
||||||
conn.outstandingClonedPacketsCount++;
|
conn.outstandings.clonedPacketsCount++;
|
||||||
|
|
||||||
EXPECT_CALL(*mockQLogger, addPacketsLost(1, 1, 1));
|
EXPECT_CALL(*mockQLogger, addPacketsLost(1, 1, 1));
|
||||||
|
|
||||||
@@ -813,7 +813,7 @@ TEST_P(AckHandlersTest, UpdatePendingAckStates) {
|
|||||||
PacketNum packetNum = 0;
|
PacketNum packetNum = 0;
|
||||||
auto regularPacket = createNewPacket(packetNum, GetParam());
|
auto regularPacket = createNewPacket(packetNum, GetParam());
|
||||||
auto sentTime = Clock::now() - 1500ms;
|
auto sentTime = Clock::now() - 1500ms;
|
||||||
conn.outstandingPackets.emplace_back(OutstandingPacket(
|
conn.outstandings.packets.emplace_back(OutstandingPacket(
|
||||||
std::move(regularPacket),
|
std::move(regularPacket),
|
||||||
sentTime,
|
sentTime,
|
||||||
111,
|
111,
|
||||||
@@ -862,7 +862,7 @@ TEST_P(AckHandlersTest, AckEventCreation) {
|
|||||||
false /* handshake */,
|
false /* handshake */,
|
||||||
packetNum);
|
packetNum);
|
||||||
sentPacket.isAppLimited = (packetNum % 2);
|
sentPacket.isAppLimited = (packetNum % 2);
|
||||||
conn.outstandingPackets.emplace_back(sentPacket);
|
conn.outstandings.packets.emplace_back(sentPacket);
|
||||||
packetNum++;
|
packetNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,5 +31,5 @@ TEST_F(QuicPacingFunctionsTest, OnClose) {
|
|||||||
EXPECT_FALSE(conn.canBePaced);
|
EXPECT_FALSE(conn.canBePaced);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace test
|
||||||
}
|
} // namespace quic
|
||||||
|
@@ -533,27 +533,27 @@ TEST_F(QuicStateFunctionsTest, IsConnectionPaced) {
|
|||||||
|
|
||||||
TEST_F(QuicStateFunctionsTest, GetOutstandingPackets) {
|
TEST_F(QuicStateFunctionsTest, GetOutstandingPackets) {
|
||||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
makeTestLongPacket(LongHeader::Types::Initial),
|
makeTestLongPacket(LongHeader::Types::Initial),
|
||||||
Clock::now(),
|
Clock::now(),
|
||||||
135,
|
135,
|
||||||
false,
|
false,
|
||||||
0);
|
0);
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
makeTestLongPacket(LongHeader::Types::Handshake),
|
makeTestLongPacket(LongHeader::Types::Handshake),
|
||||||
Clock::now(),
|
Clock::now(),
|
||||||
1217,
|
1217,
|
||||||
false,
|
false,
|
||||||
0);
|
0);
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
makeTestShortPacket(), Clock::now(), 5556, false, 0);
|
makeTestShortPacket(), Clock::now(), 5556, false, 0);
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
makeTestLongPacket(LongHeader::Types::Initial),
|
makeTestLongPacket(LongHeader::Types::Initial),
|
||||||
Clock::now(),
|
Clock::now(),
|
||||||
56,
|
56,
|
||||||
false,
|
false,
|
||||||
0);
|
0);
|
||||||
conn.outstandingPackets.emplace_back(
|
conn.outstandings.packets.emplace_back(
|
||||||
makeTestShortPacket(), Clock::now(), 6665, false, 0);
|
makeTestShortPacket(), Clock::now(), 6665, false, 0);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
135,
|
135,
|
||||||
|
Reference in New Issue
Block a user