1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-06 22:22:38 +03:00

Track body bytes sent and acked

Summary:
Previously, we maintained state and counters to count both, header and body
bytes together. This commit introduces additional counters and state to keep
track of just the body bytes that were sent and acked etc. Body bytes received
will be implemented later.

Reviewed By: bschlinker

Differential Revision: D27312049

fbshipit-source-id: 33f169c9168dfda625e86de45df7c00d1897ba7e
This commit is contained in:
Sridhar Srinivasan
2021-03-29 16:56:42 -07:00
committed by Facebook GitHub Bot
parent 694f7ed181
commit f7a08066ce
19 changed files with 384 additions and 40 deletions

View File

@@ -142,11 +142,20 @@ class QuicSocket {
uint32_t totalPacketsSpuriouslyMarkedLost{0}; uint32_t totalPacketsSpuriouslyMarkedLost{0};
uint32_t timeoutBasedLoss{0}; uint32_t timeoutBasedLoss{0};
std::chrono::microseconds pto{0us}; std::chrono::microseconds pto{0us};
// // Number of Bytes (packet header + body) that were sent
uint64_t bytesSent{0}; uint64_t bytesSent{0};
// // Number of Bytes (packet header + body) that were acked
uint64_t bytesAcked{0}; uint64_t bytesAcked{0};
// // Number of Bytes (packet header + body) that were received
uint64_t bytesRecvd{0}; uint64_t bytesRecvd{0};
// // Number of Bytes (packet header + body) that are in-flight
uint64_t bytesInFlight{0}; uint64_t bytesInFlight{0};
// // Number of Bytes (packet header + body) that were retxed
uint64_t totalBytesRetransmitted{0}; uint64_t totalBytesRetransmitted{0};
// Number of Bytes (only the encoded packet's body) that were sent
uint64_t bodyBytesSent{0};
// Number of Bytes (only the encoded packet's body) that were acked
uint64_t bodyBytesAcked{0};
uint32_t ptoCount{0}; uint32_t ptoCount{0};
uint32_t totalPTOCount{0}; uint32_t totalPTOCount{0};
folly::Optional<PacketNum> largestPacketAckedByPeer; folly::Optional<PacketNum> largestPacketAckedByPeer;

View File

@@ -603,6 +603,9 @@ QuicSocket::TransportInfo QuicTransportBase::getTransportInfo() const {
transportInfo.bytesAcked = conn_->lossState.totalBytesAcked; transportInfo.bytesAcked = conn_->lossState.totalBytesAcked;
transportInfo.bytesRecvd = conn_->lossState.totalBytesRecvd; transportInfo.bytesRecvd = conn_->lossState.totalBytesRecvd;
transportInfo.bytesInFlight = conn_->lossState.inflightBytes; transportInfo.bytesInFlight = conn_->lossState.inflightBytes;
transportInfo.bodyBytesSent = conn_->lossState.totalBodyBytesSent;
transportInfo.bodyBytesAcked = conn_->lossState.totalBodyBytesAcked;
transportInfo.ptoCount = conn_->lossState.ptoCount; transportInfo.ptoCount = conn_->lossState.ptoCount;
transportInfo.totalPTOCount = conn_->lossState.totalPTOCount; transportInfo.totalPTOCount = conn_->lossState.totalPTOCount;
transportInfo.largestPacketAckedByPeer = transportInfo.largestPacketAckedByPeer =

View File

@@ -261,6 +261,7 @@ DataPathResult continuousMemoryBuildScheduleEncrypt(
headerCipher); headerCipher);
CHECK(!packetBuf->isChained()); CHECK(!packetBuf->isChained());
auto encodedSize = packetBuf->length(); auto encodedSize = packetBuf->length();
auto encodedBodySize = encodedSize - headerLen;
// Include previous packets back. // Include previous packets back.
packetBuf->prepend(prevSize); packetBuf->prepend(prevSize);
connection.bufAccessor->release(std::move(packetBuf)); connection.bufAccessor->release(std::move(packetBuf));
@@ -280,7 +281,8 @@ DataPathResult continuousMemoryBuildScheduleEncrypt(
QUIC_STATS(connection.statsCallback, onWrite, encodedSize); QUIC_STATS(connection.statsCallback, onWrite, encodedSize);
QUIC_STATS(connection.statsCallback, onPacketSent); QUIC_STATS(connection.statsCallback, onPacketSent);
} }
return DataPathResult::makeWriteResult(ret, std::move(result), encodedSize); return DataPathResult::makeWriteResult(
ret, std::move(result), encodedSize, encodedBodySize);
} }
DataPathResult iobufChainBasedBuildScheduleEncrypt( DataPathResult iobufChainBasedBuildScheduleEncrypt(
@@ -344,10 +346,12 @@ DataPathResult iobufChainBasedBuildScheduleEncrypt(
packetBuf->length() - headerLen, packetBuf->length() - headerLen,
headerCipher); headerCipher);
auto encodedSize = packetBuf->computeChainDataLength(); auto encodedSize = packetBuf->computeChainDataLength();
auto encodedBodySize = encodedSize - headerLen;
#if !FOLLY_MOBILE #if !FOLLY_MOBILE
if (encodedSize > connection.udpSendPacketLen) { if (encodedSize > connection.udpSendPacketLen) {
LOG_EVERY_N(ERROR, 5000) LOG_EVERY_N(ERROR, 5000)
<< "Quic sending pkt larger than limit, encodedSize=" << encodedSize; << "Quic sending pkt larger than limit, encodedSize=" << encodedSize
<< " encodedBodySize=" << encodedBodySize;
} }
#endif #endif
bool ret = ioBufBatch.write(std::move(packetBuf), encodedSize); bool ret = ioBufBatch.write(std::move(packetBuf), encodedSize);
@@ -356,7 +360,8 @@ DataPathResult iobufChainBasedBuildScheduleEncrypt(
QUIC_STATS(connection.statsCallback, onWrite, encodedSize); QUIC_STATS(connection.statsCallback, onWrite, encodedSize);
QUIC_STATS(connection.statsCallback, onPacketSent); QUIC_STATS(connection.statsCallback, onPacketSent);
} }
return DataPathResult::makeWriteResult(ret, std::move(result), encodedSize); return DataPathResult::makeWriteResult(
ret, std::move(result), encodedSize, encodedBodySize);
} }
} // namespace } // namespace
@@ -561,6 +566,7 @@ void updateConnection(
RegularQuicWritePacket packet, RegularQuicWritePacket packet,
TimePoint sentTime, TimePoint sentTime,
uint32_t encodedSize, uint32_t encodedSize,
uint32_t encodedBodySize,
bool isDSRPacket) { bool isDSRPacket) {
auto packetNum = packet.header.getPacketSequenceNum(); auto packetNum = packet.header.getPacketSequenceNum();
bool retransmittable = false; // AckFrame and PaddingFrame are not retx-able. bool retransmittable = false; // AckFrame and PaddingFrame are not retx-able.
@@ -574,7 +580,7 @@ void updateConnection(
conn.d6d.lastProbe->packetNum == packetNum; conn.d6d.lastProbe->packetNum == packetNum;
VLOG(10) << nodeToString(conn.nodeType) << " sent packetNum=" << packetNum VLOG(10) << nodeToString(conn.nodeType) << " sent packetNum=" << packetNum
<< " in space=" << packetNumberSpace << " size=" << encodedSize << " in space=" << packetNumberSpace << " size=" << encodedSize
<< " " << conn; << " bodySize: " << encodedBodySize << " " << conn;
if (conn.qLogger) { if (conn.qLogger) {
conn.qLogger->addPacket(packet, encodedSize); conn.qLogger->addPacket(packet, encodedSize);
} }
@@ -749,6 +755,7 @@ void updateConnection(
conn.pendingEvents.setLossDetectionAlarm = retransmittable; conn.pendingEvents.setLossDetectionAlarm = retransmittable;
} }
conn.lossState.totalBytesSent += encodedSize; conn.lossState.totalBytesSent += encodedSize;
conn.lossState.totalBodyBytesSent += encodedBodySize;
conn.lossState.totalPacketsSent++; conn.lossState.totalPacketsSent++;
if (!retransmittable && !isPing) { if (!retransmittable && !isPing) {
@@ -771,12 +778,14 @@ void updateConnection(
std::move(packet), std::move(packet),
sentTime, sentTime,
encodedSize, encodedSize,
encodedBodySize,
isHandshake, isHandshake,
isD6DProbe, isD6DProbe,
// these numbers should all _include_ the current packet // these numbers should all _include_ the current packet
// conn.lossState.inflightBytes isn't updated until below // conn.lossState.inflightBytes isn't updated until below
// conn.outstandings.numOutstanding() + 1 since we're emplacing here // conn.outstandings.numOutstanding() + 1 since we're emplacing here
conn.lossState.totalBytesSent, conn.lossState.totalBytesSent,
conn.lossState.totalBodyBytesSent,
conn.lossState.inflightBytes + encodedSize, conn.lossState.inflightBytes + encodedSize,
conn.outstandings.numOutstanding() + 1, conn.outstandings.numOutstanding() + 1,
conn.lossState, conn.lossState,
@@ -1349,6 +1358,7 @@ uint64_t writeConnectionDataToSocket(
std::move(result->packet->packet), std::move(result->packet->packet),
Clock::now(), Clock::now(),
folly::to<uint32_t>(ret.encodedSize), folly::to<uint32_t>(ret.encodedSize),
folly::to<uint32_t>(ret.encodedBodySize),
false /* isDSRPacket */); false /* isDSRPacket */);
// if ioBufBatch.write returns false // if ioBufBatch.write returns false

View File

@@ -26,6 +26,7 @@ struct DataPathResult {
bool writeSuccess{false}; bool writeSuccess{false};
folly::Optional<SchedulingResult> result; folly::Optional<SchedulingResult> result;
uint64_t encodedSize{0}; uint64_t encodedSize{0};
uint64_t encodedBodySize{0};
static DataPathResult makeBuildFailure() { static DataPathResult makeBuildFailure() {
return DataPathResult(); return DataPathResult();
@@ -34,8 +35,10 @@ struct DataPathResult {
static DataPathResult makeWriteResult( static DataPathResult makeWriteResult(
bool writeSuc, bool writeSuc,
SchedulingResult&& res, SchedulingResult&& res,
uint64_t encodedSizeIn) { uint64_t encodedSizeIn,
return DataPathResult(writeSuc, std::move(res), encodedSizeIn); uint64_t encodedBodySizeIn) {
return DataPathResult(
writeSuc, std::move(res), encodedSizeIn, encodedBodySizeIn);
} }
private: private:
@@ -44,11 +47,13 @@ struct DataPathResult {
explicit DataPathResult( explicit DataPathResult(
bool writeSuc, bool writeSuc,
SchedulingResult&& res, SchedulingResult&& res,
uint64_t encodedSizeIn) uint64_t encodedSizeIn,
uint64_t encodedBodySizeIn)
: buildSuccess(true), : buildSuccess(true),
writeSuccess(writeSuc), writeSuccess(writeSuc),
result(std::move(res)), result(std::move(res)),
encodedSize(encodedSizeIn) {} encodedSize(encodedSizeIn),
encodedBodySize(encodedBodySizeIn) {}
}; };
using DataPathFunc = std::function<DataPathResult( using DataPathFunc = std::function<DataPathResult(
@@ -184,6 +189,7 @@ void updateConnection(
RegularQuicWritePacket packet, RegularQuicWritePacket packet,
TimePoint time, TimePoint time,
uint32_t encodedSize, uint32_t encodedSize,
uint32_t encodedBodySize,
bool isDSRPacket); bool isDSRPacket);
/** /**

View File

@@ -41,7 +41,7 @@ PacketNum addInitialOutstandingPacket(QuicConnectionStateBase& conn) {
QuicVersion::QUIC_DRAFT); QuicVersion::QUIC_DRAFT);
RegularQuicWritePacket packet(std::move(header)); RegularQuicWritePacket packet(std::move(header));
conn.outstandings.packets.emplace_back( conn.outstandings.packets.emplace_back(
packet, Clock::now(), 0, true, 0, 0, 0, LossState(), 0); packet, Clock::now(), 0, 0, true, 0, 0, 0, 0, LossState(), 0);
conn.outstandings.handshakePacketsCount++; conn.outstandings.handshakePacketsCount++;
increaseNextPacketNum(conn, PacketNumberSpace::Handshake); increaseNextPacketNum(conn, PacketNumberSpace::Handshake);
return nextPacketNum; return nextPacketNum;
@@ -60,7 +60,7 @@ PacketNum addHandshakeOutstandingPacket(QuicConnectionStateBase& conn) {
QuicVersion::QUIC_DRAFT); QuicVersion::QUIC_DRAFT);
RegularQuicWritePacket packet(std::move(header)); RegularQuicWritePacket packet(std::move(header));
conn.outstandings.packets.emplace_back( conn.outstandings.packets.emplace_back(
packet, Clock::now(), 0, true, 0, 0, 0, LossState(), 0); packet, Clock::now(), 0, 0, true, 0, 0, 0, 0, LossState(), 0);
conn.outstandings.handshakePacketsCount++; conn.outstandings.handshakePacketsCount++;
increaseNextPacketNum(conn, PacketNumberSpace::Handshake); increaseNextPacketNum(conn, PacketNumberSpace::Handshake);
return nextPacketNum; return nextPacketNum;
@@ -74,7 +74,7 @@ PacketNum addOutstandingPacket(QuicConnectionStateBase& conn) {
nextPacketNum); nextPacketNum);
RegularQuicWritePacket packet(std::move(header)); RegularQuicWritePacket packet(std::move(header));
conn.outstandings.packets.emplace_back( conn.outstandings.packets.emplace_back(
packet, Clock::now(), 0, false, 0, 0, 0, LossState(), 0); packet, Clock::now(), 0, 0, false, 0, 0, 0, 0, LossState());
increaseNextPacketNum(conn, PacketNumberSpace::AppData); increaseNextPacketNum(conn, PacketNumberSpace::AppData);
return nextPacketNum; return nextPacketNum;
} }
@@ -889,6 +889,7 @@ TEST_F(QuicPacketSchedulerTest, CloningSchedulerWithInplaceBuilderFullPacket) {
result.packet->packet, result.packet->packet,
Clock::now(), Clock::now(),
bufferLength, bufferLength,
0,
false /* isDSRPacket */); false /* isDSRPacket */);
buf = bufAccessor.obtain(); buf = bufAccessor.obtain();
ASSERT_EQ(conn.udpSendPacketLen, buf->length()); ASSERT_EQ(conn.udpSendPacketLen, buf->length());
@@ -960,6 +961,7 @@ TEST_F(QuicPacketSchedulerTest, CloneLargerThanOriginalPacket) {
packetResult.packet->packet, packetResult.packet->packet,
Clock::now(), Clock::now(),
encodedSize, encodedSize,
0,
false /* isDSRPacket */); false /* isDSRPacket */);
// make packetNum too larger to be encoded into the same size: // make packetNum too larger to be encoded into the same size:
@@ -1581,7 +1583,7 @@ TEST_F(QuicPacketSchedulerTest, WriteLossWithoutFlowControl) {
scheduler.writeStreams(builder1); scheduler.writeStreams(builder1);
auto packet1 = std::move(builder1).buildPacket().packet; auto packet1 = std::move(builder1).buildPacket().packet;
updateConnection( updateConnection(
conn, folly::none, packet1, Clock::now(), 1000, false /* isDSR */); conn, folly::none, packet1, Clock::now(), 1000, 0, false /* isDSR */);
EXPECT_EQ(1, packet1.frames.size()); EXPECT_EQ(1, packet1.frames.size());
auto& writeStreamFrame1 = *packet1.frames[0].asWriteStreamFrame(); auto& writeStreamFrame1 = *packet1.frames[0].asWriteStreamFrame();
EXPECT_EQ(streamId, writeStreamFrame1.streamId); EXPECT_EQ(streamId, writeStreamFrame1.streamId);
@@ -1608,7 +1610,7 @@ TEST_F(QuicPacketSchedulerTest, WriteLossWithoutFlowControl) {
scheduler.writeStreams(builder2); scheduler.writeStreams(builder2);
auto packet2 = std::move(builder2).buildPacket().packet; auto packet2 = std::move(builder2).buildPacket().packet;
updateConnection( updateConnection(
conn, folly::none, packet2, Clock::now(), 1000, false /* isDSR */); conn, folly::none, packet2, Clock::now(), 1000, 0, false /* isDSR */);
EXPECT_EQ(1, packet2.frames.size()); EXPECT_EQ(1, packet2.frames.size());
auto& writeStreamFrame2 = *packet2.frames[0].asWriteStreamFrame(); auto& writeStreamFrame2 = *packet2.frames[0].asWriteStreamFrame();
EXPECT_EQ(streamId, writeStreamFrame2.streamId); EXPECT_EQ(streamId, writeStreamFrame2.streamId);
@@ -1653,7 +1655,7 @@ TEST_F(QuicPacketSchedulerTest, RunOutFlowControlDuringStreamWrite) {
scheduler.writeStreams(builder1); scheduler.writeStreams(builder1);
auto packet1 = std::move(builder1).buildPacket().packet; auto packet1 = std::move(builder1).buildPacket().packet;
updateConnection( updateConnection(
conn, folly::none, packet1, Clock::now(), 1200, false /* isDSR */); conn, folly::none, packet1, Clock::now(), 1200, 0, false /* isDSR */);
EXPECT_EQ(2, packet1.frames.size()); EXPECT_EQ(2, packet1.frames.size());
auto& writeStreamFrame1 = *packet1.frames[0].asWriteStreamFrame(); auto& writeStreamFrame1 = *packet1.frames[0].asWriteStreamFrame();
EXPECT_EQ(streamId1, writeStreamFrame1.streamId); EXPECT_EQ(streamId1, writeStreamFrame1.streamId);

View File

@@ -141,6 +141,15 @@ uint64_t getEncodedSize(const RegularQuicPacketBuilder::Packet& packet) {
return encodedSize; return encodedSize;
} }
uint64_t getEncodedBodySize(const RegularQuicPacketBuilder::Packet& packet) {
// calculate size as the plaintext size
uint32_t encodedBodySize = 0;
if (packet.body) {
encodedBodySize += packet.body->computeChainDataLength();
}
return encodedBodySize;
}
class QuicTransportFunctionsTest : public Test { class QuicTransportFunctionsTest : public Test {
public: public:
void SetUp() override { void SetUp() override {
@@ -193,6 +202,7 @@ TEST_F(QuicTransportFunctionsTest, PingPacketGoesToOPList) {
packet.packet, packet.packet,
Clock::now(), Clock::now(),
50, 50,
0,
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(1, conn->outstandings.packets.size()); EXPECT_EQ(1, conn->outstandings.packets.size());
// But it won't set loss detection alarm // But it won't set loss detection alarm
@@ -242,6 +252,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) {
packet.packet, packet.packet,
TimePoint{}, TimePoint{},
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ( EXPECT_EQ(
@@ -305,6 +316,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) {
packet2.packet, packet2.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ( EXPECT_EQ(
conn->ackStates.initialAckState.nextPacketNum, conn->ackStates.initialAckState.nextPacketNum,
@@ -387,6 +399,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionD6DNotConsumeSendPing) {
packet.packet, packet.packet,
Clock::now(), Clock::now(),
50, 50,
0,
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(1, conn->outstandings.packets.size()); EXPECT_EQ(1, conn->outstandings.packets.size());
EXPECT_TRUE(conn->outstandings.packets.front().metadata.isD6DProbe); EXPECT_TRUE(conn->outstandings.packets.front().metadata.isD6DProbe);
@@ -408,6 +421,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionD6DNeedsAppDataPNSpace) {
packet.packet, packet.packet,
Clock::now(), Clock::now(),
50, 50,
0,
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(1, conn->outstandings.packets.size()); EXPECT_EQ(1, conn->outstandings.packets.size());
EXPECT_FALSE(conn->outstandings.packets.front().metadata.isD6DProbe); EXPECT_FALSE(conn->outstandings.packets.front().metadata.isD6DProbe);
@@ -440,6 +454,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketSorting) {
handshakePacket.packet, handshakePacket.packet,
TimePoint{}, TimePoint{},
getEncodedSize(handshakePacket), getEncodedSize(handshakePacket),
getEncodedBodySize(handshakePacket),
false /* isDSRPacket */); false /* isDSRPacket */);
updateConnection( updateConnection(
*conn, *conn,
@@ -447,6 +462,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketSorting) {
initialPacket.packet, initialPacket.packet,
TimePoint{}, TimePoint{},
getEncodedSize(initialPacket), getEncodedSize(initialPacket),
getEncodedBodySize(initialPacket),
false /* isDSRPacket */); false /* isDSRPacket */);
updateConnection( updateConnection(
*conn, *conn,
@@ -454,6 +470,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketSorting) {
appDataPacket.packet, appDataPacket.packet,
TimePoint{}, TimePoint{},
getEncodedSize(appDataPacket), getEncodedSize(appDataPacket),
getEncodedBodySize(appDataPacket),
false /* isDSRPacket */); false /* isDSRPacket */);
// verify qLogger added correct logs // verify qLogger added correct logs
std::shared_ptr<quic::FileQLogger> qLogger = std::shared_ptr<quic::FileQLogger> qLogger =
@@ -505,6 +522,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionFinOnly) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
// verify QLogger contains correct packet information // verify QLogger contains correct packet information
@@ -555,6 +573,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionAllBytesExceptFin) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
// verify QLogger contains correct packet information // verify QLogger contains correct packet information
@@ -604,6 +623,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionEmptyAckWriteResult) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
// verify QLogger contains correct packet information // verify QLogger contains correct packet information
@@ -644,6 +664,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPureAckCounter) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
auto nonHandshake = buildEmptyPacket(*conn, PacketNumberSpace::Handshake); auto nonHandshake = buildEmptyPacket(*conn, PacketNumberSpace::Handshake);
@@ -666,6 +687,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPureAckCounter) {
packet2.packet, packet2.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
// verify QLogger contains correct packet and frame information // verify QLogger contains correct packet and frame information
@@ -701,6 +723,7 @@ TEST_F(QuicTransportFunctionsTest, TestPaddingPureAckPacketIsStillPureAck) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
// verify QLogger contains correct packet and frames information // verify QLogger contains correct packet and frames information
@@ -737,6 +760,7 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(1, conn->outstandings.initialPacketsCount); EXPECT_EQ(1, conn->outstandings.initialPacketsCount);
EXPECT_EQ(0, conn->outstandings.handshakePacketsCount); EXPECT_EQ(0, conn->outstandings.handshakePacketsCount);
@@ -756,6 +780,7 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(2, conn->outstandings.initialPacketsCount); EXPECT_EQ(2, conn->outstandings.initialPacketsCount);
EXPECT_EQ(0, conn->outstandings.handshakePacketsCount); EXPECT_EQ(0, conn->outstandings.handshakePacketsCount);
@@ -786,6 +811,7 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(1, conn->outstandings.initialPacketsCount); EXPECT_EQ(1, conn->outstandings.initialPacketsCount);
EXPECT_EQ(1, conn->outstandings.handshakePacketsCount); EXPECT_EQ(1, conn->outstandings.handshakePacketsCount);
@@ -802,6 +828,7 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(1, conn->outstandings.initialPacketsCount); EXPECT_EQ(1, conn->outstandings.initialPacketsCount);
EXPECT_EQ(2, conn->outstandings.handshakePacketsCount); EXPECT_EQ(2, conn->outstandings.handshakePacketsCount);
@@ -858,6 +885,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionHandshakeCounter) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(1, conn->outstandings.handshakePacketsCount); EXPECT_EQ(1, conn->outstandings.handshakePacketsCount);
@@ -877,6 +905,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionHandshakeCounter) {
nonHandshake.packet, nonHandshake.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
// verify QLogger contains correct packet information // verify QLogger contains correct packet information
@@ -932,6 +961,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionForOneRttCryptoData) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(0, conn->outstandings.handshakePacketsCount); EXPECT_EQ(0, conn->outstandings.handshakePacketsCount);
@@ -953,6 +983,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionForOneRttCryptoData) {
nonHandshake.packet, nonHandshake.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
// verify QLogger contains correct packet information // verify QLogger contains correct packet information
@@ -1016,6 +1047,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithPureAck) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(1, conn->lossState.totalPacketsSent); EXPECT_EQ(1, conn->lossState.totalPacketsSent);
EXPECT_EQ(0, conn->lossState.totalAckElicitingPacketsSent); EXPECT_EQ(0, conn->lossState.totalAckElicitingPacketsSent);
@@ -1049,7 +1081,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithBytesStats) {
WriteStreamFrame writeStreamFrame(stream->id, 0, 5, false); WriteStreamFrame writeStreamFrame(stream->id, 0, 5, false);
packet.packet.frames.push_back(std::move(writeStreamFrame)); packet.packet.frames.push_back(std::move(writeStreamFrame));
conn->lossState.totalBytesSent = 13579; conn->lossState.totalBytesSent = 13579;
conn->lossState.totalBytesAcked = 8642; conn->lossState.totalBodyBytesSent = 13000;
conn->lossState.inflightBytes = 16000; conn->lossState.inflightBytes = 16000;
auto currentTime = Clock::now(); auto currentTime = Clock::now();
conn->lossState.lastAckedTime = currentTime - 123s; conn->lossState.lastAckedTime = currentTime - 123s;
@@ -1065,6 +1097,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithBytesStats) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
555, 555,
500,
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(21, conn->lossState.totalPacketsSent); EXPECT_EQ(21, conn->lossState.totalPacketsSent);
EXPECT_EQ(16, conn->lossState.totalAckElicitingPacketsSent); EXPECT_EQ(16, conn->lossState.totalAckElicitingPacketsSent);
@@ -1086,6 +1119,10 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithBytesStats) {
13579 + 555, 13579 + 555,
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake) getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake)
->metadata.totalBytesSent); ->metadata.totalBytesSent);
EXPECT_EQ(
13000 + 500,
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake)
->metadata.totalBodyBytesSent);
EXPECT_EQ( EXPECT_EQ(
16000 + 555, 16000 + 555,
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake) getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake)
@@ -1098,6 +1135,10 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithBytesStats) {
555, 555,
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake) getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake)
->metadata.encodedSize); ->metadata.encodedSize);
EXPECT_EQ(
500,
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake)
->metadata.encodedBodySize);
EXPECT_EQ( EXPECT_EQ(
20 + 1, 20 + 1,
getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake) getFirstOutstandingPacket(*conn, PacketNumberSpace::Handshake)
@@ -1157,6 +1198,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithCloneResult) {
std::move(writePacket), std::move(writePacket),
MockClock::now(), MockClock::now(),
1500, 1500,
1400,
false /* isDSRPacket */); false /* isDSRPacket */);
// verify QLogger contains correct packet information // verify QLogger contains correct packet information
std::shared_ptr<quic::FileQLogger> qLogger = std::shared_ptr<quic::FileQLogger> qLogger =
@@ -1183,6 +1225,10 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithCloneResult) {
1500, 1500,
getLastOutstandingPacket(*conn, PacketNumberSpace::AppData) getLastOutstandingPacket(*conn, PacketNumberSpace::AppData)
->metadata.encodedSize); ->metadata.encodedSize);
EXPECT_EQ(
1400,
getLastOutstandingPacket(*conn, PacketNumberSpace::AppData)
->metadata.encodedBodySize);
EXPECT_EQ( EXPECT_EQ(
event, event,
*getLastOutstandingPacket(*conn, PacketNumberSpace::AppData) *getLastOutstandingPacket(*conn, PacketNumberSpace::AppData)
@@ -1204,6 +1250,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionStreamWindowUpdate) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
// verify QLogger contains correct packet information // verify QLogger contains correct packet information
@@ -1239,6 +1286,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionConnWindowUpdate) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
// verify QLogger contains correct packet information // verify QLogger contains correct packet information
@@ -2191,6 +2239,7 @@ TEST_F(QuicTransportFunctionsTest, UpdateConnectionCloneCounter) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
123, 123,
100,
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(1, conn->outstandings.clonedPacketsCount); EXPECT_EQ(1, conn->outstandings.clonedPacketsCount);
} }
@@ -2208,6 +2257,7 @@ TEST_F(QuicTransportFunctionsTest, ClearBlockedFromPendingEvents) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_FALSE(conn->streamManager->hasBlocked()); EXPECT_FALSE(conn->streamManager->hasBlocked());
EXPECT_FALSE(conn->outstandings.packets.empty()); EXPECT_FALSE(conn->outstandings.packets.empty());
@@ -2231,6 +2281,7 @@ TEST_F(QuicTransportFunctionsTest, ClonedBlocked) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_FALSE(conn->outstandings.packets.empty()); EXPECT_FALSE(conn->outstandings.packets.empty());
EXPECT_EQ(1, conn->outstandings.clonedPacketsCount); EXPECT_EQ(1, conn->outstandings.clonedPacketsCount);
@@ -2251,6 +2302,7 @@ TEST_F(QuicTransportFunctionsTest, TwoConnWindowUpdateWillCrash) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */), false /* isDSRPacket */),
".*Send more than one connection window update.*"); ".*Send more than one connection window update.*");
} }
@@ -2269,6 +2321,7 @@ TEST_F(QuicTransportFunctionsTest, WriteStreamFrameIsNotPureAck) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_FALSE(conn->outstandings.packets.empty()); EXPECT_FALSE(conn->outstandings.packets.empty());
} }
@@ -2287,6 +2340,7 @@ TEST_F(QuicTransportFunctionsTest, ClearRstFromPendingEvents) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_TRUE(conn->pendingEvents.resets.empty()); EXPECT_TRUE(conn->pendingEvents.resets.empty());
EXPECT_FALSE(conn->outstandings.packets.empty()); EXPECT_FALSE(conn->outstandings.packets.empty());
@@ -2311,6 +2365,7 @@ TEST_F(QuicTransportFunctionsTest, ClonedRst) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_FALSE(conn->outstandings.packets.empty()); EXPECT_FALSE(conn->outstandings.packets.empty());
EXPECT_EQ(1, conn->outstandings.clonedPacketsCount); EXPECT_EQ(1, conn->outstandings.clonedPacketsCount);
@@ -2319,6 +2374,7 @@ TEST_F(QuicTransportFunctionsTest, ClonedRst) {
TEST_F(QuicTransportFunctionsTest, TotalBytesSentUpdate) { TEST_F(QuicTransportFunctionsTest, TotalBytesSentUpdate) {
auto conn = createConn(); auto conn = createConn();
conn->lossState.totalBytesSent = 1234; conn->lossState.totalBytesSent = 1234;
conn->lossState.totalBodyBytesSent = 1000;
auto packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake); auto packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake);
updateConnection( updateConnection(
*conn, *conn,
@@ -2326,8 +2382,10 @@ TEST_F(QuicTransportFunctionsTest, TotalBytesSentUpdate) {
packet.packet, packet.packet,
TimePoint{}, TimePoint{},
4321, 4321,
4000,
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(5555, conn->lossState.totalBytesSent); EXPECT_EQ(5555, conn->lossState.totalBytesSent);
EXPECT_EQ(5000, conn->lossState.totalBodyBytesSent);
} }
TEST_F(QuicTransportFunctionsTest, TotalPacketsSentUpdate) { TEST_F(QuicTransportFunctionsTest, TotalPacketsSentUpdate) {
@@ -2341,6 +2399,7 @@ TEST_F(QuicTransportFunctionsTest, TotalPacketsSentUpdate) {
packet.packet, packet.packet,
TimePoint{}, TimePoint{},
4321, 4321,
0,
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(startTotalPacketsSent + 1, conn->lossState.totalPacketsSent); EXPECT_EQ(startTotalPacketsSent + 1, conn->lossState.totalPacketsSent);
} }
@@ -2360,7 +2419,8 @@ TEST_F(QuicTransportFunctionsTest, TimeoutBasedRetxCountUpdate) {
packetEvent, packetEvent,
packet.packet, packet.packet,
TimePoint(), TimePoint(),
500, 0,
0,
false /* isDSRPacket */); false /* isDSRPacket */);
EXPECT_EQ(247, conn->lossState.timeoutBasedRtxCount); EXPECT_EQ(247, conn->lossState.timeoutBasedRtxCount);
} }
@@ -2808,6 +2868,7 @@ TEST_F(QuicTransportFunctionsTest, UpdateConnectionWithBufferMeta) {
packet.packet, packet.packet,
TimePoint(), TimePoint(),
getEncodedSize(packet), getEncodedSize(packet),
getEncodedBodySize(packet),
true /* dsr */); true /* dsr */);
EXPECT_EQ(1000 + bufMetaStartingOffset, stream->writeBufMeta.offset); EXPECT_EQ(1000 + bufMetaStartingOffset, stream->writeBufMeta.offset);
EXPECT_EQ(1000, stream->writeBufMeta.length); EXPECT_EQ(1000, stream->writeBufMeta.length);
@@ -2836,6 +2897,7 @@ TEST_F(QuicTransportFunctionsTest, UpdateConnectionWithBufferMeta) {
retxPacket.packet, retxPacket.packet,
TimePoint(), TimePoint(),
getEncodedSize(retxPacket), getEncodedSize(retxPacket),
getEncodedBodySize(packet),
true /* dsr */); true /* dsr */);
EXPECT_TRUE(stream->lossBufMetas.empty()); EXPECT_TRUE(stream->lossBufMetas.empty());
retxBufMetaIter = stream->retransmissionBufMetas.find(bufMetaStartingOffset); retxBufMetaIter = stream->retransmissionBufMetas.find(bufMetaStartingOffset);

View File

@@ -32,10 +32,12 @@ OutstandingPacket makeDummyOutstandingPacket(
writePacket, writePacket,
Clock::now(), Clock::now(),
1000, 1000,
0,
false, false,
totalBytesSentOnConnection, totalBytesSentOnConnection,
0, 0,
0, 0,
0,
LossState()); LossState());
return packet; return packet;
} }

View File

@@ -577,8 +577,10 @@ OutstandingPacket makeTestingWritePacket(
packet, packet,
sentTime, sentTime,
desiredSize, desiredSize,
0,
false, false,
totalBytesSent, totalBytesSent,
0,
inflightBytes, inflightBytes,
0, 0,
LossState(), LossState(),

View File

@@ -34,10 +34,12 @@ class CopaTest : public Test {
std::move(packet), std::move(packet),
Clock::now(), Clock::now(),
10, 10,
0,
false, false,
totalSentBytes, totalSentBytes,
0, 0,
0, 0,
0,
LossState())); LossState()));
loss.lostBytes = packetData.second; loss.lostBytes = packetData.second;
} }
@@ -57,8 +59,10 @@ class CopaTest : public Test {
std::move(packet), std::move(packet),
Clock::now(), Clock::now(),
size, size,
0,
false, false,
totalSent, totalSent,
0,
inflight, inflight,
0, 0,
LossState()); LossState());

View File

@@ -27,7 +27,16 @@ CongestionController::LossEvent createLossEvent(
RegularQuicWritePacket packet( RegularQuicWritePacket packet(
ShortHeader(ProtectionType::KeyPhaseZero, connId, packetData.first)); ShortHeader(ProtectionType::KeyPhaseZero, connId, packetData.first));
loss.addLostPacket(OutstandingPacket( loss.addLostPacket(OutstandingPacket(
std::move(packet), Clock::now(), 10, false, 10, 0, 0, LossState())); std::move(packet),
Clock::now(),
10,
0,
false,
10,
0,
0,
0,
LossState()));
loss.lostBytes = packetData.second; loss.lostBytes = packetData.second;
} }
loss.lostPackets = lostPackets.size(); loss.lostPackets = lostPackets.size();
@@ -49,10 +58,12 @@ CongestionController::AckEvent createAckEvent(
std::move(packet), std::move(packet),
packetSentTime, packetSentTime,
ackedSize, ackedSize,
0,
false, false,
ackedSize, ackedSize,
0, 0,
0, 0,
0,
LossState()))); LossState())));
return ack; return ack;
} }
@@ -66,7 +77,16 @@ OutstandingPacket createPacket(
RegularQuicWritePacket packet( RegularQuicWritePacket packet(
ShortHeader(ProtectionType::KeyPhaseZero, connId, packetNum)); ShortHeader(ProtectionType::KeyPhaseZero, connId, packetNum));
return OutstandingPacket( return OutstandingPacket(
std::move(packet), sendTime, size, false, size, inflight, 0, LossState()); std::move(packet),
sendTime,
size,
0,
false,
size,
0,
inflight,
0,
LossState());
} }
TEST_F(NewRenoTest, TestLoss) { TEST_F(NewRenoTest, TestLoss) {

View File

@@ -206,6 +206,7 @@ TEST_F(QuicD6DStateFunctionsTest, D6DProbeAckedInBase) {
makeTestShortPacket(), makeTestShortPacket(),
Clock::now(), Clock::now(),
d6d.currentProbeSize, d6d.currentProbeSize,
0,
false, false,
true, true,
d6d.currentProbeSize, d6d.currentProbeSize,
@@ -252,6 +253,7 @@ TEST_F(QuicD6DStateFunctionsTest, D6DProbeAckedInSearchingOne) {
makeTestShortPacket(), makeTestShortPacket(),
Clock::now(), Clock::now(),
d6d.currentProbeSize, d6d.currentProbeSize,
0,
false, false,
true, true,
d6d.currentProbeSize, d6d.currentProbeSize,
@@ -299,6 +301,7 @@ TEST_F(QuicD6DStateFunctionsTest, D6DProbeAckedInSearchingMax) {
makeTestShortPacket(), makeTestShortPacket(),
Clock::now(), Clock::now(),
d6d.currentProbeSize, d6d.currentProbeSize,
0,
false, false,
true, true,
d6d.currentProbeSize, d6d.currentProbeSize,
@@ -354,6 +357,7 @@ TEST_F(QuicD6DStateFunctionsTest, D6DProbeAckedInError) {
makeTestShortPacket(), makeTestShortPacket(),
Clock::now(), Clock::now(),
d6d.currentProbeSize, d6d.currentProbeSize,
0,
false, false,
true, true,
d6d.currentProbeSize, d6d.currentProbeSize,
@@ -399,6 +403,7 @@ TEST_F(QuicD6DStateFunctionsTest, BlackholeInSearching) {
makeTestShortPacket(), makeTestShortPacket(),
now + 10s, now + 10s,
d6d.currentProbeSize, d6d.currentProbeSize,
0,
false, false,
true, true,
d6d.currentProbeSize, d6d.currentProbeSize,
@@ -412,8 +417,10 @@ TEST_F(QuicD6DStateFunctionsTest, BlackholeInSearching) {
makeTestShortPacket(), makeTestShortPacket(),
now + 8s, now + 8s,
conn.udpSendPacketLen, conn.udpSendPacketLen,
0,
false, false,
conn.udpSendPacketLen + d6d.currentProbeSize, conn.udpSendPacketLen + d6d.currentProbeSize,
0,
conn.udpSendPacketLen + d6d.currentProbeSize, conn.udpSendPacketLen + d6d.currentProbeSize,
0, 0,
LossState()); LossState());
@@ -468,6 +475,7 @@ TEST_F(QuicD6DStateFunctionsTest, BlackholeInSearchComplete) {
makeTestShortPacket(), makeTestShortPacket(),
now + 10s, now + 10s,
d6d.currentProbeSize, d6d.currentProbeSize,
0,
false, false,
true, true,
d6d.currentProbeSize, d6d.currentProbeSize,
@@ -481,8 +489,10 @@ TEST_F(QuicD6DStateFunctionsTest, BlackholeInSearchComplete) {
makeTestShortPacket(), makeTestShortPacket(),
now + 12s, now + 12s,
conn.udpSendPacketLen, conn.udpSendPacketLen,
0,
false, false,
conn.udpSendPacketLen + d6d.currentProbeSize, conn.udpSendPacketLen + d6d.currentProbeSize,
0,
conn.udpSendPacketLen + d6d.currentProbeSize, conn.udpSendPacketLen + d6d.currentProbeSize,
0, 0,
LossState()); LossState());
@@ -540,6 +550,7 @@ TEST_F(QuicD6DStateFunctionsTest, ReachMaxPMTU) {
makeTestShortPacket(), makeTestShortPacket(),
Clock::now(), Clock::now(),
d6d.currentProbeSize, d6d.currentProbeSize,
0,
false, false,
true, true,
d6d.currentProbeSize, d6d.currentProbeSize,
@@ -579,6 +590,7 @@ TEST_F(
makeTestShortPacket(), makeTestShortPacket(),
Clock::now(), Clock::now(),
d6d.currentProbeSize, d6d.currentProbeSize,
0,
false, false,
true, true,
d6d.currentProbeSize, d6d.currentProbeSize,
@@ -600,6 +612,7 @@ TEST_F(
makeTestShortPacket(), makeTestShortPacket(),
Clock::now(), Clock::now(),
d6d.currentProbeSize, d6d.currentProbeSize,
0,
false, false,
false, false,
d6d.currentProbeSize, d6d.currentProbeSize,
@@ -638,6 +651,7 @@ TEST_F(QuicD6DStateFunctionsTest, UpperboundIsBase) {
makeTestShortPacket(), makeTestShortPacket(),
Clock::now(), Clock::now(),
d6d.currentProbeSize, d6d.currentProbeSize,
0,
false, false,
true, true,
d6d.currentProbeSize, d6d.currentProbeSize,

View File

@@ -73,6 +73,10 @@ uint64_t writePacketizationRequest(
packet.packet, packet.packet,
Clock::now(), Clock::now(),
packet.encodedSize, packet.encodedSize,
// TODO: (yangchi) Figure out how to calculate the
// packet.encodedBodySize for the DSR case. For now, it's not being
// used, so setting it to 0
0,
true /* isDSRPacket */); true /* isDSRPacket */);
if (!instructionAdded) { if (!instructionAdded) {

View File

@@ -236,19 +236,23 @@ PacketNum QuicLossFunctionsTest::sendPacket(
packet = std::move(sizeEnforcedBuilder).buildPacket(); packet = std::move(sizeEnforcedBuilder).buildPacket();
} }
uint32_t encodedSize = 0; uint32_t encodedSize = 0;
uint32_t encodedBodySize = 0;
if (packet.header) { if (packet.header) {
encodedSize += packet.header->computeChainDataLength(); encodedSize += packet.header->computeChainDataLength();
} }
if (packet.body) { if (packet.body) {
encodedSize += packet.body->computeChainDataLength(); encodedSize += packet.body->computeChainDataLength();
encodedBodySize += packet.body->computeChainDataLength();
} }
auto outstandingPacket = OutstandingPacket( auto outstandingPacket = OutstandingPacket(
packet.packet, packet.packet,
time, time,
encodedSize, encodedSize,
encodedBodySize,
isHandshake, isHandshake,
isD6DProbe, isD6DProbe,
encodedSize, encodedSize,
encodedBodySize,
0, 0,
0, 0,
LossState()); LossState());
@@ -1069,7 +1073,7 @@ TEST_F(QuicLossFunctionsTest, TestHandleAckForLoss) {
RegularQuicWritePacket outstandingRegularPacket(std::move(longHeader)); RegularQuicWritePacket outstandingRegularPacket(std::move(longHeader));
auto now = Clock::now(); auto now = Clock::now();
conn->outstandings.packets.emplace_back(OutstandingPacket( conn->outstandings.packets.emplace_back(OutstandingPacket(
outstandingRegularPacket, now, 0, false, 0, 0, 0, LossState())); outstandingRegularPacket, now, 0, 0, false, 0, 0, 0, 0, LossState()));
bool testLossMarkFuncCalled = false; bool testLossMarkFuncCalled = false;
auto testLossMarkFunc = [&](auto& /* conn */, auto&, bool) { auto testLossMarkFunc = [&](auto& /* conn */, auto&, bool) {

View File

@@ -200,6 +200,8 @@ void processAckFrame(
conn.lossState.totalBytesSentAtLastAck = conn.lossState.totalBytesSent; conn.lossState.totalBytesSentAtLastAck = conn.lossState.totalBytesSent;
conn.lossState.totalBytesAckedAtLastAck = conn.lossState.totalBytesAckedAtLastAck =
conn.lossState.totalBytesAcked; conn.lossState.totalBytesAcked;
conn.lossState.totalBodyBytesAcked +=
rPacketIt->metadata.encodedBodySize;
if (!lastAckedPacketSentTime) { if (!lastAckedPacketSentTime) {
lastAckedPacketSentTime = rPacketIt->metadata.time; lastAckedPacketSentTime = rPacketIt->metadata.time;
} }

View File

@@ -58,6 +58,14 @@ struct LossState {
// The total number of bytes acked on this connection when the last time a // The total number of bytes acked on this connection when the last time a
// packet is acked. // packet is acked.
uint64_t totalBytesAckedAtLastAck{0}; uint64_t totalBytesAckedAtLastAck{0};
// Total number of body bytes sent on this connection. This is after encoding.
uint64_t totalBodyBytesSent{0};
// Total number of body bytes acked on this connection. If a packet is acked
// twice, it won't be count twice. Pure acks packets are NOT included (as they
// have no encoded body bytes).
uint64_t totalBodyBytesAcked{0};
// Total number of packets sent on this connection, including retransmissions. // Total number of packets sent on this connection, including retransmissions.
uint32_t totalPacketsSent{0}; uint32_t totalPacketsSent{0};
// Total number of ack-eliciting packets sent on this connection. // Total number of ack-eliciting packets sent on this connection.

View File

@@ -19,6 +19,8 @@ struct OutstandingPacketMetadata {
TimePoint time; TimePoint time;
// Size of the packet sent on the wire. // Size of the packet sent on the wire.
uint32_t encodedSize; uint32_t encodedSize;
// Size of only the body within the packet sent on the wire.
uint32_t encodedBodySize;
// Whether this packet has any data from stream 0 // Whether this packet has any data from stream 0
bool isHandshake; bool isHandshake;
// Whether the packet is a d6d probe // Whether the packet is a d6d probe
@@ -26,6 +28,9 @@ struct OutstandingPacketMetadata {
// Total sent bytes on this connection including this packet itself when this // Total sent bytes on this connection including this packet itself when this
// packet is sent. // packet is sent.
uint64_t totalBytesSent; uint64_t totalBytesSent;
// Total sent body bytes on this connection including this packet itself when
// this packet is sent.
uint64_t totalBodyBytesSent;
// Bytes in flight on this connection including this packet itself when this // Bytes in flight on this connection including this packet itself when this
// packet is sent. // packet is sent.
uint64_t inflightBytes; uint64_t inflightBytes;
@@ -42,18 +47,22 @@ struct OutstandingPacketMetadata {
OutstandingPacketMetadata( OutstandingPacketMetadata(
TimePoint timeIn, TimePoint timeIn,
uint32_t encodedSizeIn, uint32_t encodedSizeIn,
uint32_t encodedBodySizeIn,
bool isHandshakeIn, bool isHandshakeIn,
bool isD6DProbeIn, bool isD6DProbeIn,
uint64_t totalBytesSentIn, uint64_t totalBytesSentIn,
uint64_t totalBodyBytesSentIn,
uint64_t inflightBytesIn, uint64_t inflightBytesIn,
uint64_t packetsInflightIn, uint64_t packetsInflightIn,
const LossState& lossStateIn, const LossState& lossStateIn,
uint64_t writeCount) uint64_t writeCount)
: time(timeIn), : time(timeIn),
encodedSize(encodedSizeIn), encodedSize(encodedSizeIn),
encodedBodySize(encodedBodySizeIn),
isHandshake(isHandshakeIn), isHandshake(isHandshakeIn),
isD6DProbe(isD6DProbeIn), isD6DProbe(isD6DProbeIn),
totalBytesSent(totalBytesSentIn), totalBytesSent(totalBytesSentIn),
totalBodyBytesSent(totalBodyBytesSentIn),
inflightBytes(inflightBytesIn), inflightBytes(inflightBytesIn),
packetsInflight(packetsInflightIn), packetsInflight(packetsInflightIn),
totalPacketsSent(lossStateIn.totalPacketsSent), totalPacketsSent(lossStateIn.totalPacketsSent),
@@ -80,7 +89,6 @@ struct OutstandingPacket {
// Total acked bytes on this connection when last acked packet is acked, // Total acked bytes on this connection when last acked packet is acked,
// including the last acked packet. // including the last acked packet.
uint64_t totalBytesAcked; uint64_t totalBytesAcked;
LastAckedPacketInfo( LastAckedPacketInfo(
TimePoint sentTimeIn, TimePoint sentTimeIn,
TimePoint ackTimeIn, TimePoint ackTimeIn,
@@ -123,8 +131,10 @@ struct OutstandingPacket {
RegularQuicWritePacket packetIn, RegularQuicWritePacket packetIn,
TimePoint timeIn, TimePoint timeIn,
uint32_t encodedSizeIn, uint32_t encodedSizeIn,
uint32_t encodedBodySizeIn,
bool isHandshakeIn, bool isHandshakeIn,
uint64_t totalBytesSentIn, uint64_t totalBytesSentIn,
uint64_t totalBodyBytesSentIn,
uint64_t inflightBytesIn, uint64_t inflightBytesIn,
uint64_t packetsInflightIn, uint64_t packetsInflightIn,
const LossState& lossStateIn, const LossState& lossStateIn,
@@ -133,9 +143,11 @@ struct OutstandingPacket {
metadata(OutstandingPacketMetadata( metadata(OutstandingPacketMetadata(
timeIn, timeIn,
encodedSizeIn, encodedSizeIn,
encodedBodySizeIn,
isHandshakeIn, isHandshakeIn,
false, false,
totalBytesSentIn, totalBytesSentIn,
totalBodyBytesSentIn,
inflightBytesIn, inflightBytesIn,
packetsInflightIn, packetsInflightIn,
lossStateIn, lossStateIn,
@@ -145,9 +157,11 @@ struct OutstandingPacket {
RegularQuicWritePacket packetIn, RegularQuicWritePacket packetIn,
TimePoint timeIn, TimePoint timeIn,
uint32_t encodedSizeIn, uint32_t encodedSizeIn,
uint32_t encodedBodySizeIn,
bool isHandshakeIn, bool isHandshakeIn,
bool isD6DProbeIn, bool isD6DProbeIn,
uint64_t totalBytesSentIn, uint64_t totalBytesSentIn,
uint64_t totalBodyBytesSentIn,
uint64_t inflightBytesIn, uint64_t inflightBytesIn,
uint64_t packetsInflightIn, uint64_t packetsInflightIn,
const LossState& lossStateIn, const LossState& lossStateIn,
@@ -156,9 +170,11 @@ struct OutstandingPacket {
metadata(OutstandingPacketMetadata( metadata(OutstandingPacketMetadata(
timeIn, timeIn,
encodedSizeIn, encodedSizeIn,
encodedBodySizeIn,
isHandshakeIn, isHandshakeIn,
isD6DProbeIn, isD6DProbeIn,
totalBytesSentIn, totalBytesSentIn,
totalBodyBytesSentIn,
inflightBytesIn, inflightBytesIn,
packetsInflightIn, packetsInflightIn,
lossStateIn, lossStateIn,

View File

@@ -55,8 +55,10 @@ auto emplacePackets(
std::move(regularPacket), std::move(regularPacket),
sentTime, sentTime,
1, 1,
0,
false /* handshake */, false /* handshake */,
packetNum, packetNum,
0,
packetNum + 1, packetNum + 1,
packetNum + 1, packetNum + 1,
quic::LossState()); quic::LossState());
@@ -86,10 +88,12 @@ TEST_P(AckHandlersTest, TestAckMultipleSequentialBlocks) {
std::move(regularPacket), std::move(regularPacket),
sentTime, sentTime,
1, 1,
0,
false, false,
packetNum, packetNum,
0, 0,
0, 0,
0,
LossState())); LossState()));
} }
ReadAckFrame ackFrame; ReadAckFrame ackFrame;
@@ -164,10 +168,12 @@ TEST_P(AckHandlersTest, TestAckMultipleSequentialBlocksLoss) {
std::move(regularPacket), std::move(regularPacket),
sentTime, sentTime,
1, 1,
0,
false, false,
packetNum, packetNum,
0, 0,
0, 0,
0,
LossState())); LossState()));
} }
ReadAckFrame ackFrame; ReadAckFrame ackFrame;
@@ -306,10 +312,12 @@ TEST_P(AckHandlersTest, TestAckBlocksWithGaps) {
std::move(regularPacket), std::move(regularPacket),
Clock::now(), Clock::now(),
1, 1,
0,
false, false,
packetNum, packetNum,
0, 0,
0, 0,
0,
LossState())); LossState()));
} }
@@ -411,10 +419,12 @@ TEST_P(AckHandlersTest, TestNonSequentialPacketNumbers) {
std::move(regularPacket), std::move(regularPacket),
Clock::now(), Clock::now(),
1, 1,
0,
false, false,
packetNum, packetNum,
0, 0,
0, 0,
0,
LossState())); LossState()));
} }
@@ -427,10 +437,12 @@ TEST_P(AckHandlersTest, TestNonSequentialPacketNumbers) {
std::move(regularPacket), std::move(regularPacket),
Clock::now(), Clock::now(),
1, 1,
0,
false, false,
packetNum, packetNum,
0, 0,
0, 0,
0,
LossState())); LossState()));
} }
@@ -512,7 +524,16 @@ TEST_P(AckHandlersTest, AckVisitorForAckTest) {
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.outstandings.packets.emplace_back(OutstandingPacket( conn.outstandings.packets.emplace_back(OutstandingPacket(
std::move(firstPacket), Clock::now(), 0, false, 0, 0, 0, LossState())); std::move(firstPacket),
Clock::now(),
0,
0,
false,
0,
0,
0,
0,
LossState()));
auto secondPacket = createNewPacket(101 /* packetNum */, GetParam()); auto secondPacket = createNewPacket(101 /* packetNum */, GetParam());
WriteAckFrame secondAckFrame; WriteAckFrame secondAckFrame;
@@ -522,7 +543,16 @@ TEST_P(AckHandlersTest, AckVisitorForAckTest) {
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.outstandings.packets.emplace_back(OutstandingPacket( conn.outstandings.packets.emplace_back(OutstandingPacket(
std::move(secondPacket), Clock::now(), 0, false, 0, 0, 0, LossState())); std::move(secondPacket),
Clock::now(),
0,
0,
false,
0,
0,
0,
0,
LossState()));
ReadAckFrame firstReceivedAck; ReadAckFrame firstReceivedAck;
firstReceivedAck.largestAcked = 100; firstReceivedAck.largestAcked = 100;
@@ -583,7 +613,16 @@ TEST_P(AckHandlersTest, NoNewAckedPacket) {
PacketNum packetAfterRtoNum = 10; PacketNum packetAfterRtoNum = 10;
auto packetAfterRto = createNewPacket(packetAfterRtoNum, GetParam()); auto packetAfterRto = createNewPacket(packetAfterRtoNum, GetParam());
conn.outstandings.packets.emplace_back(OutstandingPacket( conn.outstandings.packets.emplace_back(OutstandingPacket(
std::move(packetAfterRto), Clock::now(), 0, false, 0, 0, 0, LossState())); std::move(packetAfterRto),
Clock::now(),
0,
0,
false,
0,
0,
0,
0,
LossState()));
ReadAckFrame ackFrame; ReadAckFrame ackFrame;
ackFrame.largestAcked = 5; ackFrame.largestAcked = 5;
@@ -629,12 +668,30 @@ TEST_P(AckHandlersTest, AckPacketNumDoesNotExist) {
PacketNum packetNum1 = 9; PacketNum packetNum1 = 9;
auto regularPacket1 = createNewPacket(packetNum1, GetParam()); auto regularPacket1 = createNewPacket(packetNum1, GetParam());
conn.outstandings.packets.emplace_back( conn.outstandings.packets.emplace_back(
std::move(regularPacket1), Clock::now(), 0, false, 0, 0, 0, LossState()); std::move(regularPacket1),
Clock::now(),
0,
0,
false,
0,
0,
0,
0,
LossState());
PacketNum packetNum2 = 10; PacketNum packetNum2 = 10;
auto regularPacket2 = createNewPacket(packetNum2, GetParam()); auto regularPacket2 = createNewPacket(packetNum2, GetParam());
conn.outstandings.packets.emplace_back( conn.outstandings.packets.emplace_back(
std::move(regularPacket2), Clock::now(), 0, false, 0, 0, 0, LossState()); std::move(regularPacket2),
Clock::now(),
0,
0,
false,
0,
0,
0,
0,
LossState());
// 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
// threshold. // threshold.
@@ -666,10 +723,12 @@ TEST_P(AckHandlersTest, TestHandshakeCounterUpdate) {
std::move(regularPacket), std::move(regularPacket),
Clock::now(), Clock::now(),
0, 0,
0,
packetNum % 2 && GetParam() != PacketNumberSpace::AppData, packetNum % 2 && GetParam() != PacketNumberSpace::AppData,
packetNum / 2, packetNum / 2,
0, 0,
0, 0,
0,
LossState()); LossState());
if (GetParam() == PacketNumberSpace::Initial) { if (GetParam() == PacketNumberSpace::Initial) {
conn.outstandings.initialPacketsCount += packetNum % 2; conn.outstandings.initialPacketsCount += packetNum % 2;
@@ -753,7 +812,16 @@ TEST_P(AckHandlersTest, NoSkipAckVisitor) {
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.outstandings.packets.emplace_back(OutstandingPacket( conn.outstandings.packets.emplace_back(OutstandingPacket(
std::move(regularPacket), Clock::now(), 1, false, 1, 0, 0, LossState())); std::move(regularPacket),
Clock::now(),
1,
0,
false,
1,
0,
0,
0,
LossState()));
ReadAckFrame ackFrame; ReadAckFrame ackFrame;
ackFrame.largestAcked = 0; ackFrame.largestAcked = 0;
ackFrame.ackBlocks.emplace_back(0, 0); ackFrame.ackBlocks.emplace_back(0, 0);
@@ -795,7 +863,16 @@ TEST_P(AckHandlersTest, SkipAckVisitor) {
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));
OutstandingPacket outstandingPacket( OutstandingPacket outstandingPacket(
std::move(regularPacket), Clock::now(), 1, false, 1, 0, 0, LossState()); std::move(regularPacket),
Clock::now(),
1,
0,
false,
1,
0,
0,
0,
LossState());
// Give this outstandingPacket an associatedEvent that's not in // Give this outstandingPacket an associatedEvent that's not in
// outstandings.packetEvents // outstandings.packetEvents
outstandingPacket.associatedEvent.emplace(PacketNumberSpace::AppData, 0); outstandingPacket.associatedEvent.emplace(PacketNumberSpace::AppData, 0);
@@ -836,12 +913,30 @@ TEST_P(AckHandlersTest, NoDoubleProcess) {
regularPacket2.frames.push_back(frame); regularPacket2.frames.push_back(frame);
OutstandingPacket outstandingPacket1( OutstandingPacket outstandingPacket1(
std::move(regularPacket1), Clock::now(), 1, false, 1, 0, 0, LossState()); std::move(regularPacket1),
Clock::now(),
1,
0,
false,
1,
0,
0,
0,
LossState());
outstandingPacket1.associatedEvent.emplace( outstandingPacket1.associatedEvent.emplace(
PacketNumberSpace::AppData, packetNum1); PacketNumberSpace::AppData, packetNum1);
OutstandingPacket outstandingPacket2( OutstandingPacket outstandingPacket2(
std::move(regularPacket2), Clock::now(), 1, false, 1, 0, 0, LossState()); std::move(regularPacket2),
Clock::now(),
1,
0,
false,
1,
0,
0,
0,
LossState());
// The seconds packet has the same PacketEvent // The seconds packet has the same PacketEvent
outstandingPacket2.associatedEvent.emplace( outstandingPacket2.associatedEvent.emplace(
PacketNumberSpace::AppData, packetNum1); PacketNumberSpace::AppData, packetNum1);
@@ -898,7 +993,16 @@ TEST_P(AckHandlersTest, ClonedPacketsCounter) {
auto regularPacket1 = createNewPacket(packetNum1, GetParam()); auto regularPacket1 = createNewPacket(packetNum1, GetParam());
regularPacket1.frames.push_back(frame); regularPacket1.frames.push_back(frame);
OutstandingPacket outstandingPacket1( OutstandingPacket outstandingPacket1(
std::move(regularPacket1), Clock::now(), 1, false, 1, 0, 0, LossState()); std::move(regularPacket1),
Clock::now(),
1,
0,
false,
1,
0,
0,
0,
LossState());
outstandingPacket1.associatedEvent.emplace( outstandingPacket1.associatedEvent.emplace(
PacketNumberSpace::AppData, packetNum1); PacketNumberSpace::AppData, packetNum1);
@@ -907,7 +1011,16 @@ TEST_P(AckHandlersTest, ClonedPacketsCounter) {
auto regularPacket2 = createNewPacket(packetNum2, GetParam()); auto regularPacket2 = createNewPacket(packetNum2, GetParam());
regularPacket2.frames.push_back(frame); regularPacket2.frames.push_back(frame);
OutstandingPacket outstandingPacket2( OutstandingPacket outstandingPacket2(
std::move(regularPacket2), Clock::now(), 1, false, 1, 0, 0, LossState()); std::move(regularPacket2),
Clock::now(),
1,
0,
false,
1,
0,
0,
0,
LossState());
conn.outstandings.packets.push_back(std::move(outstandingPacket1)); conn.outstandings.packets.push_back(std::move(outstandingPacket1));
conn.outstandings.packets.push_back(std::move(outstandingPacket2)); conn.outstandings.packets.push_back(std::move(outstandingPacket2));
@@ -946,7 +1059,16 @@ TEST_P(AckHandlersTest, UpdateMaxAckDelay) {
auto regularPacket = createNewPacket(packetNum, GetParam()); auto regularPacket = createNewPacket(packetNum, GetParam());
auto sentTime = Clock::now(); auto sentTime = Clock::now();
conn.outstandings.packets.emplace_back(OutstandingPacket( conn.outstandings.packets.emplace_back(OutstandingPacket(
std::move(regularPacket), sentTime, 1, false, 1, 0, 0, LossState())); std::move(regularPacket),
sentTime,
1,
0,
false,
1,
0,
0,
0,
LossState()));
ReadAckFrame ackFrame; ReadAckFrame ackFrame;
// ackDelay has no effect on mrtt // ackDelay has no effect on mrtt
@@ -1001,10 +1123,12 @@ TEST_P(AckHandlersTest, AckNotOutstandingButLoss) {
std::move(regularPacket), std::move(regularPacket),
Clock::now() - delayUntilLost - 20ms, Clock::now() - delayUntilLost - 20ms,
1, 1,
0,
false, false,
1, 1,
0, 0,
0, 0,
0,
LossState()); LossState());
conn.outstandings.packets.push_back(std::move(outstandingPacket)); conn.outstandings.packets.push_back(std::move(outstandingPacket));
conn.outstandings.clonedPacketsCount++; conn.outstandings.clonedPacketsCount++;
@@ -1039,7 +1163,9 @@ TEST_P(AckHandlersTest, UpdatePendingAckStates) {
FizzServerQuicHandshakeContext::Builder().build()); FizzServerQuicHandshakeContext::Builder().build());
conn.congestionController = nullptr; conn.congestionController = nullptr;
conn.lossState.totalBytesSent = 2468; conn.lossState.totalBytesSent = 2468;
conn.lossState.totalBodyBytesSent = 2000;
conn.lossState.totalBytesAcked = 1357; conn.lossState.totalBytesAcked = 1357;
conn.lossState.totalBodyBytesAcked = 1000;
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;
@@ -1047,12 +1173,15 @@ TEST_P(AckHandlersTest, UpdatePendingAckStates) {
std::move(regularPacket), std::move(regularPacket),
sentTime, sentTime,
111, 111,
100,
false, false,
conn.lossState.totalBytesSent + 111, conn.lossState.totalBytesSent + 111,
conn.lossState.totalBodyBytesSent + 100,
0, 0,
0, 0,
LossState())); LossState()));
conn.lossState.totalBytesSent += 111; conn.lossState.totalBytesSent += 111;
conn.lossState.totalBodyBytesSent += 100;
ReadAckFrame ackFrame; ReadAckFrame ackFrame;
ackFrame.largestAcked = 0; ackFrame.largestAcked = 0;
@@ -1071,6 +1200,7 @@ TEST_P(AckHandlersTest, UpdatePendingAckStates) {
EXPECT_EQ(sentTime, *conn.lossState.lastAckedPacketSentTime); EXPECT_EQ(sentTime, *conn.lossState.lastAckedPacketSentTime);
EXPECT_EQ(receiveTime, *conn.lossState.lastAckedTime); EXPECT_EQ(receiveTime, *conn.lossState.lastAckedTime);
EXPECT_EQ(111 + 1357, conn.lossState.totalBytesAcked); EXPECT_EQ(111 + 1357, conn.lossState.totalBytesAcked);
EXPECT_EQ(100 + 1000, conn.lossState.totalBodyBytesAcked);
} }
TEST_P(AckHandlersTest, AckEventCreation) { TEST_P(AckHandlersTest, AckEventCreation) {
@@ -1093,10 +1223,12 @@ TEST_P(AckHandlersTest, AckEventCreation) {
std::move(regularPacket), std::move(regularPacket),
largestSentTime, largestSentTime,
1, 1,
0,
false /* handshake */, false /* handshake */,
packetNum, packetNum,
0, 0,
0, 0,
0,
LossState()); LossState());
sentPacket.isAppLimited = (packetNum % 2); sentPacket.isAppLimited = (packetNum % 2);
conn.outstandings.packets.emplace_back(sentPacket); conn.outstandings.packets.emplace_back(sentPacket);
@@ -1150,8 +1282,10 @@ TEST_P(AckHandlersTest, ImplictAckEventCreation) {
std::move(regularPacket), std::move(regularPacket),
largestSentTime, largestSentTime,
1, 1,
0,
false /* handshake */, false /* handshake */,
packetNum, packetNum,
0,
packetNum + 1, packetNum + 1,
0, 0,
LossState()); LossState());
@@ -1217,8 +1351,10 @@ TEST_P(AckHandlersTest, TestRTTPacketObserverCallback) {
std::move(regularPacket), std::move(regularPacket),
sentTime, sentTime,
1, 1,
0,
false /* handshake */, false /* handshake */,
packetNum, packetNum,
0,
packetNum + 1, packetNum + 1,
0, 0,
LossState()); LossState());

View File

@@ -594,57 +594,97 @@ TEST_F(QuicStateFunctionsTest, GetOutstandingPackets) {
makeTestLongPacket(LongHeader::Types::Initial), makeTestLongPacket(LongHeader::Types::Initial),
Clock::now(), Clock::now(),
135, 135,
0,
false, false,
0, 0,
0, 0,
0, 0,
0,
LossState()); LossState());
conn.outstandings.packets.emplace_back( conn.outstandings.packets.emplace_back(
makeTestLongPacket(LongHeader::Types::Handshake), makeTestLongPacket(LongHeader::Types::Handshake),
Clock::now(), Clock::now(),
1217, 1217,
0,
false, false,
0, 0,
0, 0,
0, 0,
0,
LossState()); LossState());
conn.outstandings.packets.emplace_back( conn.outstandings.packets.emplace_back(
makeTestShortPacket(), Clock::now(), 5556, false, 0, 0, 0, LossState()); makeTestShortPacket(),
Clock::now(),
5556,
5000,
false,
0,
0,
0,
0,
LossState());
conn.outstandings.packets.emplace_back( conn.outstandings.packets.emplace_back(
makeTestLongPacket(LongHeader::Types::Initial), makeTestLongPacket(LongHeader::Types::Initial),
Clock::now(), Clock::now(),
56, 56,
0,
false, false,
0, 0,
0, 0,
0, 0,
0,
LossState()); LossState());
conn.outstandings.packets.emplace_back( conn.outstandings.packets.emplace_back(
makeTestShortPacket(), Clock::now(), 6665, false, 0, 0, 0, LossState()); makeTestShortPacket(),
Clock::now(),
6665,
6000,
false,
0,
0,
0,
0,
LossState());
EXPECT_EQ( EXPECT_EQ(
135, 135,
getFirstOutstandingPacket(conn, PacketNumberSpace::Initial) getFirstOutstandingPacket(conn, PacketNumberSpace::Initial)
->metadata.encodedSize); ->metadata.encodedSize);
EXPECT_EQ(
0,
getFirstOutstandingPacket(conn, PacketNumberSpace::Initial)
->metadata.encodedBodySize);
EXPECT_EQ( EXPECT_EQ(
56, 56,
getLastOutstandingPacket(conn, PacketNumberSpace::Initial) getLastOutstandingPacket(conn, PacketNumberSpace::Initial)
->metadata.encodedSize); ->metadata.encodedSize);
EXPECT_EQ( EXPECT_EQ(
1217, 0,
getFirstOutstandingPacket(conn, PacketNumberSpace::Handshake) getLastOutstandingPacket(conn, PacketNumberSpace::Initial)
->metadata.encodedSize); ->metadata.encodedBodySize);
EXPECT_EQ( EXPECT_EQ(
1217, 1217,
getFirstOutstandingPacket(conn, PacketNumberSpace::Handshake) getFirstOutstandingPacket(conn, PacketNumberSpace::Handshake)
->metadata.encodedSize); ->metadata.encodedSize);
EXPECT_EQ(
0,
getFirstOutstandingPacket(conn, PacketNumberSpace::Handshake)
->metadata.encodedBodySize);
EXPECT_EQ( EXPECT_EQ(
5556, 5556,
getFirstOutstandingPacket(conn, PacketNumberSpace::AppData) getFirstOutstandingPacket(conn, PacketNumberSpace::AppData)
->metadata.encodedSize); ->metadata.encodedSize);
EXPECT_EQ(
5000,
getFirstOutstandingPacket(conn, PacketNumberSpace::AppData)
->metadata.encodedBodySize);
EXPECT_EQ( EXPECT_EQ(
6665, 6665,
getLastOutstandingPacket(conn, PacketNumberSpace::AppData) getLastOutstandingPacket(conn, PacketNumberSpace::AppData)
->metadata.encodedSize); ->metadata.encodedSize);
EXPECT_EQ(
6000,
getLastOutstandingPacket(conn, PacketNumberSpace::AppData)
->metadata.encodedBodySize);
} }
TEST_F(QuicStateFunctionsTest, UpdateLargestReceivePacketsAtLatCloseSent) { TEST_F(QuicStateFunctionsTest, UpdateLargestReceivePacketsAtLatCloseSent) {

View File

@@ -37,7 +37,7 @@ TEST_F(StateDataTest, SingleLostPacketEvent) {
100, 100,
kVersion)); kVersion));
OutstandingPacket outstandingPacket( OutstandingPacket outstandingPacket(
packet, Clock::now(), 1234, false, 1234, 0, 0, LossState()); packet, Clock::now(), 1234, 0, false, 1234, 0, 0, 0, LossState());
CongestionController::LossEvent loss; CongestionController::LossEvent loss;
loss.addLostPacket(outstandingPacket); loss.addLostPacket(outstandingPacket);
EXPECT_EQ(1234, loss.lostBytes); EXPECT_EQ(1234, loss.lostBytes);
@@ -52,7 +52,7 @@ TEST_F(StateDataTest, MultipleLostPacketsEvent) {
100, 100,
kVersion)); kVersion));
OutstandingPacket outstandingPacket1( OutstandingPacket outstandingPacket1(
packet1, Clock::now(), 1234, false, 1234, 0, 0, LossState()); packet1, Clock::now(), 1234, 0, false, 1234, 0, 0, 0, LossState());
RegularQuicWritePacket packet2(LongHeader( RegularQuicWritePacket packet2(LongHeader(
LongHeader::Types::Initial, LongHeader::Types::Initial,
@@ -61,7 +61,7 @@ TEST_F(StateDataTest, MultipleLostPacketsEvent) {
110, 110,
kVersion)); kVersion));
OutstandingPacket outstandingPacket2( OutstandingPacket outstandingPacket2(
packet2, Clock::now(), 1357, false, 1357, 0, 0, LossState()); packet2, Clock::now(), 1357, 0, false, 1357, 0, 0, 0, LossState());
CongestionController::LossEvent loss; CongestionController::LossEvent loss;
loss.addLostPacket(outstandingPacket1); loss.addLostPacket(outstandingPacket1);