mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-08 09:42:06 +03:00
Revert PMTU and size-enforced packet builder
Differential Revision: D23283619 fbshipit-source-id: b7fe31871dad5711016234a2d10ae84edc4fd24c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
918cc5786d
commit
c47c3cf5c6
@@ -38,8 +38,8 @@ constexpr uint16_t kDefaultMaxUDPPayload = 1452;
|
||||
// maximum QUIC packet size.
|
||||
constexpr uint16_t kMinMaxUDPPayload = 1200;
|
||||
|
||||
// How many bytes to reduce from udpSendPacketLen when socket write leads
|
||||
// to EMSGSIZE.
|
||||
// How many bytes to reduce from udpSendPacketLen when socket write leads to
|
||||
// EMSGSIZE.
|
||||
constexpr uint16_t kDefaultMsgSizeBackOffSize = 50;
|
||||
|
||||
// Size of read buffer we provide to AsyncUDPSocket. The packet size cannot be
|
||||
|
@@ -590,7 +590,7 @@ TEST_P(QuicBatchWriterTest, InplaceWriterBufResidueCheck) {
|
||||
auto bufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn_.udpSendPacketLen * batchSize);
|
||||
conn_.bufAccessor = bufAccessor.get();
|
||||
updateUdpSendPacketLen(conn_, 1000);
|
||||
conn_.udpSendPacketLen = 1000;
|
||||
auto batchWriter = quic::BatchWriterFactory::makeBatchWriter(
|
||||
sock,
|
||||
quic::QuicBatchingMode::BATCHING_MODE_GSO,
|
||||
|
@@ -862,7 +862,7 @@ TEST_F(QuicPacketSchedulerTest, CloningSchedulerWithInplaceBuilderFullPacket) {
|
||||
TEST_F(QuicPacketSchedulerTest, CloneLargerThanOriginalPacket) {
|
||||
QuicClientConnectionState conn(
|
||||
FizzClientQuicHandshakeContext::Builder().build());
|
||||
updateUdpSendPacketLen(conn, 1000);
|
||||
conn.udpSendPacketLen = 1000;
|
||||
conn.streamManager->setMaxLocalBidirectionalStreams(10);
|
||||
conn.flowControlState.peerAdvertisedMaxOffset = 100000;
|
||||
conn.flowControlState.peerAdvertisedInitialMaxStreamOffsetBidiRemote = 100000;
|
||||
|
@@ -1087,7 +1087,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionConnWindowUpdate) {
|
||||
|
||||
TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketWithCC) {
|
||||
auto conn = createConn();
|
||||
updateUdpSendPacketLen(*conn, 30);
|
||||
conn->udpSendPacketLen = 30;
|
||||
auto mockCongestionController =
|
||||
std::make_unique<NiceMock<MockCongestionController>>();
|
||||
auto rawCongestionController = mockCongestionController.get();
|
||||
@@ -1162,7 +1162,7 @@ TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketLimitTest) {
|
||||
std::make_unique<NiceMock<MockCongestionController>>();
|
||||
auto rawCongestionController = mockCongestionController.get();
|
||||
conn->congestionController = std::move(mockCongestionController);
|
||||
updateUdpSendPacketLen(*conn, aead->getCipherOverhead() + 50);
|
||||
conn->udpSendPacketLen = aead->getCipherOverhead() + 50;
|
||||
|
||||
EventBase evb;
|
||||
auto socket =
|
||||
@@ -2124,7 +2124,7 @@ TEST_F(QuicTransportFunctionsTest, WriteLimitBytRttFraction) {
|
||||
|
||||
TEST_F(QuicTransportFunctionsTest, CongestionControlWritableBytesRoundUp) {
|
||||
auto conn = createConn();
|
||||
updateUdpSendPacketLen(*conn, 2000);
|
||||
conn->udpSendPacketLen = 2000;
|
||||
auto mockCongestionController =
|
||||
std::make_unique<NiceMock<MockCongestionController>>();
|
||||
auto rawCongestionController = mockCongestionController.get();
|
||||
@@ -2217,7 +2217,7 @@ TEST_F(QuicTransportFunctionsTest, HandshakeConfirmedDropCipher) {
|
||||
|
||||
TEST_F(QuicTransportFunctionsTest, ProbeWriteNewFunctionalFrames) {
|
||||
auto conn = createConn();
|
||||
updateUdpSendPacketLen(*conn, 1200);
|
||||
conn->udpSendPacketLen = 1200;
|
||||
EventBase evb;
|
||||
auto sock = std::make_unique<NiceMock<folly::test::MockAsyncUDPSocket>>(&evb);
|
||||
auto rawSocket = sock.get();
|
||||
|
@@ -3034,7 +3034,7 @@ TEST_F(QuicTransportTest, PacingWillBurstFirst) {
|
||||
TEST_F(QuicTransportTest, AlreadyScheduledPacingNoWrite) {
|
||||
transport_->setPacingTimer(TimerHighRes::newTimer(&evb_, 1ms));
|
||||
auto& conn = transport_->getConnectionState();
|
||||
updateUdpSendPacketLen(conn, 100);
|
||||
conn.udpSendPacketLen = 100;
|
||||
auto mockCongestionController =
|
||||
std::make_unique<NiceMock<MockCongestionController>>();
|
||||
auto rawCongestionController = mockCongestionController.get();
|
||||
|
@@ -1423,21 +1423,17 @@ void QuicClientTransport::addNewPeerAddress(folly::SocketAddress peerAddress) {
|
||||
CHECK(peerAddress.isInitialized());
|
||||
|
||||
if (happyEyeballsEnabled_) {
|
||||
updateUdpSendPacketLen(
|
||||
*conn_,
|
||||
std::min(
|
||||
conn_->udpSendPacketLen = std::min(
|
||||
conn_->udpSendPacketLen,
|
||||
(peerAddress.getFamily() == AF_INET6
|
||||
? kDefaultV6UDPSendPacketLen
|
||||
: kDefaultV4UDPSendPacketLen)));
|
||||
(peerAddress.getFamily() == AF_INET6 ? kDefaultV6UDPSendPacketLen
|
||||
: kDefaultV4UDPSendPacketLen));
|
||||
happyEyeballsAddPeerAddress(*conn_, peerAddress);
|
||||
return;
|
||||
}
|
||||
|
||||
updateUdpSendPacketLen(
|
||||
*conn_,
|
||||
peerAddress.getFamily() == AF_INET6 ? kDefaultV6UDPSendPacketLen
|
||||
: kDefaultV4UDPSendPacketLen);
|
||||
conn_->udpSendPacketLen = peerAddress.getFamily() == AF_INET6
|
||||
? kDefaultV6UDPSendPacketLen
|
||||
: kDefaultV4UDPSendPacketLen;
|
||||
conn_->originalPeerAddress = peerAddress;
|
||||
conn_->peerAddress = std::move(peerAddress);
|
||||
}
|
||||
|
@@ -43,8 +43,6 @@ std::unique_ptr<QuicClientConnectionState> undoAllClientStateForRetry(
|
||||
newConn->originalPeerAddress = conn->originalPeerAddress;
|
||||
newConn->peerAddress = conn->peerAddress;
|
||||
newConn->udpSendPacketLen = conn->udpSendPacketLen;
|
||||
newConn->peerMaxPacketSize = conn->peerMaxPacketSize;
|
||||
newConn->currentPMTU = conn->currentPMTU;
|
||||
newConn->supportedVersions = conn->supportedVersions;
|
||||
newConn->transportSettings = conn->transportSettings;
|
||||
newConn->initialWriteCipher = std::move(conn->initialWriteCipher);
|
||||
@@ -153,13 +151,12 @@ void processServerInitialParams(
|
||||
}
|
||||
conn.peerAckDelayExponent =
|
||||
ackDelayExponent.value_or(kDefaultAckDelayExponent);
|
||||
|
||||
// TODO: udpSendPacketLen should also be limited by PMTU
|
||||
if (conn.transportSettings.canIgnorePathMTU) {
|
||||
if (*packetSize > kDefaultMaxUDPPayload) {
|
||||
*packetSize = kDefaultUDPSendPacketLen;
|
||||
}
|
||||
updateUdpSendPacketLen(conn, *packetSize);
|
||||
conn.udpSendPacketLen = *packetSize;
|
||||
}
|
||||
|
||||
// Currently no-op for a client; it doesn't issue connection ids
|
||||
@@ -238,7 +235,7 @@ void updateTransportParamsFromCachedEarlyParams(
|
||||
const CachedServerTransportParameters& transportParams) {
|
||||
conn.peerIdleTimeout = std::chrono::milliseconds(transportParams.idleTimeout);
|
||||
if (conn.transportSettings.canIgnorePathMTU) {
|
||||
updateUdpSendPacketLen(conn, transportParams.maxRecvPacketSize);
|
||||
conn.udpSendPacketLen = transportParams.maxRecvPacketSize;
|
||||
}
|
||||
conn.flowControlState.peerAdvertisedMaxOffset =
|
||||
transportParams.initialMaxData;
|
||||
|
@@ -286,94 +286,6 @@ Buf StatelessResetPacketBuilder::buildPacket() && {
|
||||
return std::move(data_);
|
||||
}
|
||||
|
||||
RegularSizeEnforcedPacketBuilder::RegularSizeEnforcedPacketBuilder(
|
||||
Packet packet,
|
||||
uint64_t enforcedSize,
|
||||
uint32_t cipherOverhead)
|
||||
: packet_(std::move(packet.packet)),
|
||||
header_(std::move(packet.header)),
|
||||
body_(std::move(packet.body)),
|
||||
bodyAppender_(body_.get(), kAppenderGrowthSize),
|
||||
enforcedSize_(enforcedSize),
|
||||
cipherOverhead_(cipherOverhead) {}
|
||||
|
||||
bool RegularSizeEnforcedPacketBuilder::canBuildPacket() const noexcept {
|
||||
// We only force size of packets with short header, because d6d probes always
|
||||
// have short headers and there's no other situations for this type of builder
|
||||
const ShortHeader* shortHeader = packet_.header.asShort();
|
||||
// We also don't want to send packets longer than kDefaultMaxUDPPayload
|
||||
return shortHeader && enforcedSize_ <= kDefaultMaxUDPPayload &&
|
||||
(body_->computeChainDataLength() + header_->computeChainDataLength() +
|
||||
cipherOverhead_ <
|
||||
enforcedSize_);
|
||||
}
|
||||
|
||||
PacketBuilderInterface::Packet
|
||||
RegularSizeEnforcedPacketBuilder::buildPacket() && {
|
||||
// Store counters on the stack to overhead from function calls
|
||||
size_t extraDataWritten = 0;
|
||||
size_t bodyLength = body_->computeChainDataLength();
|
||||
size_t headerLength = header_->computeChainDataLength();
|
||||
while (extraDataWritten + bodyLength + headerLength + cipherOverhead_ <
|
||||
enforcedSize_) {
|
||||
QuicInteger paddingType(static_cast<uint8_t>(FrameType::PADDING));
|
||||
paddingType.encode([&](auto val) { bodyAppender_.writeBE(val); });
|
||||
extraDataWritten++;
|
||||
}
|
||||
return Packet(std::move(packet_), std::move(header_), std::move(body_));
|
||||
}
|
||||
|
||||
InplaceSizeEnforcedPacketBuilder::InplaceSizeEnforcedPacketBuilder(
|
||||
BufAccessor& bufAccessor,
|
||||
Packet packet,
|
||||
uint64_t enforcedSize,
|
||||
uint32_t cipherOverhead)
|
||||
: bufAccessor_(bufAccessor),
|
||||
iobuf_(bufAccessor_.obtain()),
|
||||
packet_(std::move(packet.packet)),
|
||||
header_(std::move(packet.header)),
|
||||
body_(std::move(packet.body)),
|
||||
enforcedSize_(enforcedSize),
|
||||
cipherOverhead_(cipherOverhead) {}
|
||||
|
||||
bool InplaceSizeEnforcedPacketBuilder::canBuildPacket() const noexcept {
|
||||
const ShortHeader* shortHeader = packet_.header.asShort();
|
||||
size_t encryptedPacketSize =
|
||||
header_->length() + body_->length() + cipherOverhead_;
|
||||
size_t delta = enforcedSize_ - encryptedPacketSize;
|
||||
return shortHeader && enforcedSize_ <= kDefaultMaxUDPPayload &&
|
||||
encryptedPacketSize < enforcedSize_ && iobuf_->tailroom() >= delta;
|
||||
}
|
||||
|
||||
PacketBuilderInterface::Packet
|
||||
InplaceSizeEnforcedPacketBuilder::buildPacket() && {
|
||||
// Create bodyWriter
|
||||
size_t encryptedPacketSize =
|
||||
header_->length() + body_->length() + cipherOverhead_;
|
||||
size_t paddingSize = enforcedSize_ - encryptedPacketSize;
|
||||
BufWriter bodyWriter(*iobuf_, paddingSize);
|
||||
|
||||
// Store counters on the stack to overhead from function calls
|
||||
size_t extraDataWritten = 0;
|
||||
size_t bodyLength = body_->computeChainDataLength();
|
||||
size_t headerLength = header_->computeChainDataLength();
|
||||
while (extraDataWritten + bodyLength + headerLength + cipherOverhead_ <
|
||||
enforcedSize_) {
|
||||
QuicInteger paddingType(static_cast<uint8_t>(FrameType::PADDING));
|
||||
paddingType.encode([&](auto val) { bodyWriter.writeBE(val); });
|
||||
extraDataWritten++;
|
||||
}
|
||||
|
||||
PacketBuilderInterface::Packet builtPacket(
|
||||
std::move(packet_),
|
||||
std::move(header_),
|
||||
folly::IOBuf::wrapBuffer(body_->data(), iobuf_->tail() - body_->data()));
|
||||
|
||||
// Release internal iobuf
|
||||
bufAccessor_.release(std::move(iobuf_));
|
||||
return builtPacket;
|
||||
}
|
||||
|
||||
VersionNegotiationPacketBuilder::VersionNegotiationPacketBuilder(
|
||||
ConnectionId sourceConnectionId,
|
||||
ConnectionId destinationConnectionId,
|
||||
|
@@ -255,88 +255,6 @@ class RegularQuicPacketBuilder final : public PacketBuilderInterface {
|
||||
folly::Optional<PacketNumEncodingResult> packetNumberEncoding_;
|
||||
};
|
||||
|
||||
/**
|
||||
* A less involving interface for packet builder, this enables polymorphism
|
||||
* for wrapper-like packet builders (e.g. RegularSizeEnforcedPacketBuilder).
|
||||
*/
|
||||
class WrapperPacketBuilderInterface {
|
||||
public:
|
||||
using Packet = PacketBuilderInterface::Packet;
|
||||
|
||||
virtual ~WrapperPacketBuilderInterface() = default;
|
||||
|
||||
FOLLY_NODISCARD virtual bool canBuildPacket() const noexcept = 0;
|
||||
|
||||
virtual Packet buildPacket() && = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* This builder will enforce the packet size by appending padding frames for
|
||||
* chained memory. This means appending IOBuf at the end of the chain. The
|
||||
* caller should ensure canBuildPacket() returns true before constructing the
|
||||
* builder.
|
||||
*/
|
||||
class RegularSizeEnforcedPacketBuilder : public WrapperPacketBuilderInterface {
|
||||
public:
|
||||
using Packet = PacketBuilderInterface::Packet;
|
||||
|
||||
explicit RegularSizeEnforcedPacketBuilder(
|
||||
Packet packet,
|
||||
uint64_t enforcedSize,
|
||||
uint32_t cipherOverhead);
|
||||
|
||||
/**
|
||||
* Returns true when packet has short header, and that enforced size >
|
||||
* current packet size + cipher overhead, otherwise false
|
||||
*/
|
||||
FOLLY_NODISCARD bool canBuildPacket() const noexcept override;
|
||||
|
||||
Packet buildPacket() && override;
|
||||
|
||||
private:
|
||||
RegularQuicWritePacket packet_;
|
||||
Buf header_;
|
||||
Buf body_;
|
||||
BufAppender bodyAppender_;
|
||||
uint64_t enforcedSize_;
|
||||
uint32_t cipherOverhead_;
|
||||
};
|
||||
|
||||
/**
|
||||
* This builder will enforce the packet size by appending padding frames for
|
||||
* continuous memory. This means pushing padding frame directly to the current
|
||||
* tail offset. The caller should ensure canBuildPacket() returns true before
|
||||
* constructing the builder.
|
||||
*/
|
||||
class InplaceSizeEnforcedPacketBuilder : public WrapperPacketBuilderInterface {
|
||||
public:
|
||||
using Packet = PacketBuilderInterface::Packet;
|
||||
|
||||
explicit InplaceSizeEnforcedPacketBuilder(
|
||||
BufAccessor& bufAccessor,
|
||||
Packet packet,
|
||||
uint64_t enforcedSize,
|
||||
uint32_t cipherOverhead);
|
||||
|
||||
/**
|
||||
* Returns true when packet has short header, and that enforced size> current
|
||||
* packet size + cipher oveahead and that iobuf has enough tailroom,
|
||||
* otherwise false
|
||||
*/
|
||||
FOLLY_NODISCARD bool canBuildPacket() const noexcept override;
|
||||
|
||||
Packet buildPacket() && override;
|
||||
|
||||
private:
|
||||
BufAccessor& bufAccessor_;
|
||||
Buf iobuf_;
|
||||
RegularQuicWritePacket packet_;
|
||||
Buf header_;
|
||||
Buf body_;
|
||||
uint64_t enforcedSize_;
|
||||
uint32_t cipherOverhead_;
|
||||
};
|
||||
|
||||
class VersionNegotiationPacketBuilder {
|
||||
public:
|
||||
explicit VersionNegotiationPacketBuilder(
|
||||
|
@@ -109,7 +109,7 @@ class QuicPacketBuilderTest : public TestWithParam<TestFlavor> {
|
||||
folly::assume_unreachable();
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
std::unique_ptr<BufAccessor> simpleBufAccessor_;
|
||||
};
|
||||
|
||||
@@ -277,67 +277,6 @@ TEST_P(QuicPacketBuilderTest, ShortHeaderRegularPacket) {
|
||||
EXPECT_EQ(pktNum, decodedHeader.getPacketSequenceNum());
|
||||
}
|
||||
|
||||
TEST_P(QuicPacketBuilderTest, EnforcePacketSizeWithCipherOverhead) {
|
||||
auto connId = getTestConnectionId();
|
||||
PacketNum pktNum = 222;
|
||||
|
||||
PacketNum largestAckedPacketNum = 0;
|
||||
size_t cipherOverhead = 2;
|
||||
uint64_t enforcedSize = 1400;
|
||||
auto aead = std::make_unique<NiceMock<MockAead>>();
|
||||
auto aead_ = aead.get();
|
||||
EXPECT_CALL(*aead_, _inplaceEncrypt(_, _, _))
|
||||
.WillRepeatedly(Invoke([&](auto& buf, auto, auto) {
|
||||
auto overhead = folly::IOBuf::create(1000);
|
||||
overhead->append(cipherOverhead);
|
||||
auto clone = buf->clone();
|
||||
clone->prependChain(std::move(overhead));
|
||||
return std::move(clone);
|
||||
}));
|
||||
|
||||
auto builder = testBuilderProvider(
|
||||
GetParam(),
|
||||
kDefaultUDPSendPacketLen,
|
||||
ShortHeader(ProtectionType::KeyPhaseZero, connId, pktNum),
|
||||
largestAckedPacketNum,
|
||||
2000);
|
||||
builder->accountForCipherOverhead(cipherOverhead);
|
||||
builder->encodePacketHeader();
|
||||
|
||||
// write out at least one frame
|
||||
writeFrame(PaddingFrame(), *builder);
|
||||
EXPECT_TRUE(builder->canBuildPacket());
|
||||
auto builtOut = std::move(*builder).buildPacket();
|
||||
|
||||
auto param = GetParam();
|
||||
if (param == TestFlavor::Regular) {
|
||||
EXPECT_EQ(builtOut.body->isManagedOne(), true);
|
||||
RegularSizeEnforcedPacketBuilder sizeEnforcedBuilder(
|
||||
std::move(builtOut), enforcedSize, cipherOverhead);
|
||||
EXPECT_TRUE(sizeEnforcedBuilder.canBuildPacket());
|
||||
auto out = std::move(sizeEnforcedBuilder).buildPacket();
|
||||
EXPECT_EQ(
|
||||
out.header->computeChainDataLength() +
|
||||
out.body->computeChainDataLength(),
|
||||
enforcedSize - cipherOverhead);
|
||||
auto buf = packetToBuf(out, aead_);
|
||||
EXPECT_EQ(buf->computeChainDataLength(), enforcedSize);
|
||||
|
||||
} else {
|
||||
EXPECT_EQ(builtOut.body->isManagedOne(), false);
|
||||
InplaceSizeEnforcedPacketBuilder sizeEnforcedBuilder(
|
||||
*simpleBufAccessor_, std::move(builtOut), enforcedSize, cipherOverhead);
|
||||
EXPECT_TRUE(sizeEnforcedBuilder.canBuildPacket());
|
||||
auto out = std::move(sizeEnforcedBuilder).buildPacket();
|
||||
EXPECT_EQ(
|
||||
out.header->computeChainDataLength() +
|
||||
out.body->computeChainDataLength(),
|
||||
enforcedSize - cipherOverhead);
|
||||
auto buf = packetToBuf(out, aead_);
|
||||
EXPECT_EQ(buf->computeChainDataLength(), enforcedSize);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(QuicPacketBuilderTest, ShortHeaderWithNoFrames) {
|
||||
auto connId = getTestConnectionId();
|
||||
PacketNum pktNum = 222;
|
||||
|
@@ -25,7 +25,7 @@ class BbrTest : public Test {};
|
||||
|
||||
TEST_F(BbrTest, InitStates) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 1000);
|
||||
conn.udpSendPacketLen = 1000;
|
||||
BbrCongestionController bbr(conn);
|
||||
EXPECT_EQ(CongestionControlType::BBR, bbr.type());
|
||||
EXPECT_FALSE(bbr.inRecovery());
|
||||
@@ -39,7 +39,7 @@ TEST_F(BbrTest, Recovery) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Client);
|
||||
conn.qLogger = qLogger;
|
||||
updateUdpSendPacketLen(conn, 1000);
|
||||
conn.udpSendPacketLen = 1000;
|
||||
conn.transportSettings.initCwndInMss = 500; // Make a really large initCwnd
|
||||
BbrCongestionController bbr(conn);
|
||||
// Make a huge inflight so we don't underflow anything
|
||||
@@ -121,7 +121,7 @@ TEST_F(BbrTest, Recovery) {
|
||||
|
||||
TEST_F(BbrTest, StartupCwnd) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 1000);
|
||||
conn.udpSendPacketLen = 1000;
|
||||
BbrCongestionController bbr(conn);
|
||||
auto mockRttSampler = std::make_unique<MockMinRttSampler>();
|
||||
auto mockBandwidthSampler = std::make_unique<MockBandwidthSampler>();
|
||||
@@ -147,7 +147,7 @@ TEST_F(BbrTest, StartupCwnd) {
|
||||
|
||||
TEST_F(BbrTest, LeaveStartup) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 1000);
|
||||
conn.udpSendPacketLen = 1000;
|
||||
BbrCongestionController bbr(conn);
|
||||
auto mockBandwidthSampler = std::make_unique<MockBandwidthSampler>();
|
||||
auto rawBandwidthSampler = mockBandwidthSampler.get();
|
||||
@@ -203,7 +203,7 @@ TEST_F(BbrTest, LeaveStartup) {
|
||||
|
||||
TEST_F(BbrTest, RemoveInflightBytes) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 1000);
|
||||
conn.udpSendPacketLen = 1000;
|
||||
BbrCongestionController bbr(conn);
|
||||
auto writableBytesAfterInit = bbr.getWritableBytes();
|
||||
bbr.onPacketSent(makeTestingWritePacket(0, 1000, 1000));
|
||||
@@ -214,7 +214,7 @@ TEST_F(BbrTest, RemoveInflightBytes) {
|
||||
|
||||
TEST_F(BbrTest, ProbeRtt) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 1000);
|
||||
conn.udpSendPacketLen = 1000;
|
||||
BbrCongestionController bbr(conn);
|
||||
auto mockBandwidthSampler = std::make_unique<MockBandwidthSampler>();
|
||||
auto rawBandwidthSampler = mockBandwidthSampler.get();
|
||||
@@ -376,7 +376,7 @@ TEST_F(BbrTest, AckAggregation) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Client);
|
||||
conn.qLogger = qLogger;
|
||||
updateUdpSendPacketLen(conn, 1000);
|
||||
conn.udpSendPacketLen = 1000;
|
||||
BbrCongestionController bbr(conn);
|
||||
auto mockBandwidthSampler = std::make_unique<MockBandwidthSampler>();
|
||||
auto mockRttSampler = std::make_unique<MockMinRttSampler>();
|
||||
|
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <folly/portability/GTest.h>
|
||||
#include <quic/QuicConstants.h>
|
||||
#include <quic/state/QuicStateFunctions.h>
|
||||
#include <quic/state/StateData.h>
|
||||
|
||||
using namespace testing;
|
||||
@@ -22,7 +21,7 @@ class CongestionControlFunctionsTest : public Test {};
|
||||
|
||||
TEST_F(CongestionControlFunctionsTest, CalculatePacingRate) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 1);
|
||||
conn.udpSendPacketLen = 1;
|
||||
conn.transportSettings.minBurstPackets = 1;
|
||||
conn.transportSettings.pacingTimerTickInterval = 10ms;
|
||||
std::chrono::microseconds rtt(1000 * 100);
|
||||
@@ -40,7 +39,7 @@ TEST_F(CongestionControlFunctionsTest, CalculatePacingRate) {
|
||||
|
||||
TEST_F(CongestionControlFunctionsTest, MinPacingRate) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 1);
|
||||
conn.udpSendPacketLen = 1;
|
||||
conn.transportSettings.pacingTimerTickInterval = 1ms;
|
||||
auto result = calculatePacingRate(
|
||||
conn, 100, conn.transportSettings.minCwndInMss, 100ms);
|
||||
@@ -52,7 +51,7 @@ TEST_F(CongestionControlFunctionsTest, MinPacingRate) {
|
||||
|
||||
TEST_F(CongestionControlFunctionsTest, SmallCwnd) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 1);
|
||||
conn.udpSendPacketLen = 1;
|
||||
conn.transportSettings.minBurstPackets = 1;
|
||||
conn.transportSettings.pacingTimerTickInterval = 1ms;
|
||||
auto result = calculatePacingRate(
|
||||
@@ -63,7 +62,7 @@ TEST_F(CongestionControlFunctionsTest, SmallCwnd) {
|
||||
|
||||
TEST_F(CongestionControlFunctionsTest, RttSmallerThanInterval) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 1);
|
||||
conn.udpSendPacketLen = 1;
|
||||
conn.transportSettings.minBurstPackets = 1;
|
||||
conn.transportSettings.pacingTimerTickInterval = 10ms;
|
||||
auto result =
|
||||
|
@@ -19,7 +19,7 @@ class CubicHystartTest : public Test {};
|
||||
|
||||
TEST_F(CubicHystartTest, SendAndAck) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 100);
|
||||
conn.udpSendPacketLen = 100;
|
||||
Cubic cubic(conn);
|
||||
auto initCwnd = cubic.getWritableBytes();
|
||||
// Packet 0 is sent:
|
||||
@@ -54,7 +54,7 @@ TEST_F(CubicHystartTest, CwndLargerThanSSThresh) {
|
||||
|
||||
TEST_F(CubicHystartTest, NoDelayIncrease) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
updateUdpSendPacketLen(conn, 100);
|
||||
conn.udpSendPacketLen = 100;
|
||||
Cubic cubic(conn);
|
||||
auto initCwnd = cubic.getWritableBytes();
|
||||
// Packet 0 is sent:
|
||||
|
@@ -20,7 +20,7 @@ TEST_F(CubicSteadyTest, CubicReduction) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
// initCwnd > initSsthresh: an ack will immediately make the state machine
|
||||
// transit to Steady state:
|
||||
updateUdpSendPacketLen(conn, 200); // initCwnd = 2000, minCwnd = 400
|
||||
conn.udpSendPacketLen = 200; // initCwnd = 2000, minCwnd = 400
|
||||
Cubic cubic(conn, 1000);
|
||||
|
||||
// Send one and get acked, this moves the state machine to steady. Cwnd will
|
||||
|
@@ -115,7 +115,7 @@ TEST_F(CubicTest, CwndIncreaseAfterReduction) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Client);
|
||||
conn.qLogger = qLogger;
|
||||
updateUdpSendPacketLen(conn, 200);
|
||||
conn.udpSendPacketLen = 200;
|
||||
// initCwnd > initSsthresh: an ack will immediately make the state machine
|
||||
// transit to Steady state:
|
||||
Cubic cubic(conn, 1000);
|
||||
@@ -178,7 +178,7 @@ TEST_F(CubicTest, AppIdle) {
|
||||
QuicConnectionStateBase conn(QuicNodeType::Client);
|
||||
auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Client);
|
||||
conn.qLogger = qLogger;
|
||||
updateUdpSendPacketLen(conn, 1500);
|
||||
conn.udpSendPacketLen = 1500;
|
||||
TestingCubic cubic(conn);
|
||||
cubic.setStateForTest(CubicStates::Steady);
|
||||
|
||||
@@ -244,7 +244,7 @@ TEST_F(CubicTest, PacingGain) {
|
||||
conn.pacer = std::move(mockPacer);
|
||||
auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Client);
|
||||
conn.qLogger = qLogger;
|
||||
updateUdpSendPacketLen(conn, 1500);
|
||||
conn.udpSendPacketLen = 1500;
|
||||
Cubic cubic(conn);
|
||||
|
||||
conn.lossState.srtt = 3000us;
|
||||
|
@@ -1811,12 +1811,12 @@ TEST_F(QuicClientTransportTest, AddNewPeerAddressSetsPacketSize) {
|
||||
folly::SocketAddress v4Address("0.0.0.0", 0);
|
||||
ASSERT_TRUE(v4Address.getFamily() == AF_INET);
|
||||
client->addNewPeerAddress(v4Address);
|
||||
EXPECT_EQ(kDefaultV4UDPSendPacketLen, client->getConn().currentPMTU);
|
||||
EXPECT_EQ(kDefaultV4UDPSendPacketLen, client->getConn().udpSendPacketLen);
|
||||
|
||||
folly::SocketAddress v6Address("::", 0);
|
||||
ASSERT_TRUE(v6Address.getFamily() == AF_INET6);
|
||||
client->addNewPeerAddress(v6Address);
|
||||
EXPECT_EQ(kDefaultV6UDPSendPacketLen, client->getConn().currentPMTU);
|
||||
EXPECT_EQ(kDefaultV6UDPSendPacketLen, client->getConn().udpSendPacketLen);
|
||||
|
||||
client->closeNow(folly::none);
|
||||
}
|
||||
|
@@ -61,10 +61,9 @@ void QuicServerTransport::setRoutingCallback(
|
||||
void QuicServerTransport::setOriginalPeerAddress(
|
||||
const folly::SocketAddress& addr) {
|
||||
conn_->originalPeerAddress = addr;
|
||||
updateUdpSendPacketLen(
|
||||
*conn_,
|
||||
addr.getFamily() == AF_INET6 ? kDefaultV6UDPSendPacketLen
|
||||
: kDefaultV4UDPSendPacketLen);
|
||||
conn_->udpSendPacketLen = addr.getFamily() == AF_INET6
|
||||
? kDefaultV6UDPSendPacketLen
|
||||
: kDefaultV4UDPSendPacketLen;
|
||||
}
|
||||
|
||||
void QuicServerTransport::setServerConnectionIdParams(
|
||||
|
@@ -181,7 +181,7 @@ void processClientInitialParams(
|
||||
if (*packetSize > kDefaultMaxUDPPayload) {
|
||||
*packetSize = kDefaultUDPSendPacketLen;
|
||||
}
|
||||
updateUdpSendPacketLen(conn, *packetSize);
|
||||
conn.udpSendPacketLen = *packetSize;
|
||||
}
|
||||
|
||||
conn.peerActiveConnectionIdLimit =
|
||||
|
@@ -3783,11 +3783,11 @@ TEST_F(
|
||||
|
||||
TEST_F(QuicUnencryptedServerTransportTest, MaxReceivePacketSizeTooLarge) {
|
||||
getFakeHandshakeLayer()->allowZeroRttKeys();
|
||||
auto originalPeerMaxPacketSize = server->getConn().udpSendPacketLen;
|
||||
auto originalUdpSize = server->getConn().udpSendPacketLen;
|
||||
fakeHandshake->maxRecvPacketSize = 4096;
|
||||
setupClientReadCodec();
|
||||
recvClientHello();
|
||||
EXPECT_NE(originalPeerMaxPacketSize, server->getConn().udpSendPacketLen);
|
||||
EXPECT_NE(originalUdpSize, server->getConn().udpSendPacketLen);
|
||||
EXPECT_EQ(server->getConn().udpSendPacketLen, kDefaultUDPSendPacketLen);
|
||||
}
|
||||
|
||||
|
@@ -208,22 +208,6 @@ void increaseNextPacketNum(
|
||||
}
|
||||
}
|
||||
|
||||
void updatePeerMaxPacketSize(QuicConnectionStateBase& conn, uint64_t size) {
|
||||
conn.peerMaxPacketSize = size;
|
||||
conn.udpSendPacketLen = std::min(conn.peerMaxPacketSize, conn.currentPMTU);
|
||||
}
|
||||
|
||||
void updateCurrentPMTU(QuicConnectionStateBase& conn, uint64_t size) {
|
||||
conn.currentPMTU = size;
|
||||
conn.udpSendPacketLen = std::min(conn.peerMaxPacketSize, conn.currentPMTU);
|
||||
}
|
||||
|
||||
void updateUdpSendPacketLen(QuicConnectionStateBase& conn, uint64_t size) {
|
||||
conn.peerMaxPacketSize = size;
|
||||
conn.currentPMTU = size;
|
||||
conn.udpSendPacketLen = size;
|
||||
}
|
||||
|
||||
std::deque<OutstandingPacket>::iterator getFirstOutstandingPacket(
|
||||
QuicConnectionStateBase& conn,
|
||||
PacketNumberSpace packetNumberSpace) {
|
||||
|
@@ -55,24 +55,6 @@ void increaseNextPacketNum(
|
||||
QuicConnectionStateBase& conn,
|
||||
PacketNumberSpace pnSpace) noexcept;
|
||||
|
||||
/**
|
||||
* Update peerMaxPacketSize, will re-calculate udpSendPacketLen
|
||||
*/
|
||||
void updatePeerMaxPacketSize(QuicConnectionStateBase& conn, uint64_t size);
|
||||
|
||||
/**
|
||||
* Update currPMTU, will re-calculate udpSendPacketLen
|
||||
*/
|
||||
void updateCurrentPMTU(QuicConnectionStateBase& conn, uint64_t size);
|
||||
|
||||
/**
|
||||
* Update the actual maximum udp packet length, this will set both
|
||||
* peerMaxPacketSize and PMTU to the same value.
|
||||
* This is useful for initialization when setting peer socket address and
|
||||
* testing.
|
||||
*/
|
||||
void updateUdpSendPacketLen(QuicConnectionStateBase& conn, uint64_t size);
|
||||
|
||||
/**
|
||||
* Update largestReceivedPacketNum in ackState with packetNum. Return if the
|
||||
* current packetNum is received out of order.
|
||||
|
@@ -728,15 +728,8 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction {
|
||||
// until the handshake sets the timeout.
|
||||
std::chrono::milliseconds peerIdleTimeout{kMaxIdleTimeout};
|
||||
|
||||
// The max_packet_size Transport Parameters
|
||||
uint64_t peerMaxPacketSize{kDefaultUDPSendPacketLen};
|
||||
|
||||
// Current PMTU, which may change as d6d discovers new PMTU on the path
|
||||
uint64_t currentPMTU{kDefaultUDPSendPacketLen};
|
||||
|
||||
// The effective max UDP packet size we will be sending, limited by both the
|
||||
// received max_packet_size in Transport Parameters and PMTU. Should not be
|
||||
// set directly, use setUDPSendPacketLen()
|
||||
// The max UDP packet size we will be sending, limited by both the received
|
||||
// max_packet_size in Transport Parameters and PMTU
|
||||
uint64_t udpSendPacketLen{kDefaultUDPSendPacketLen};
|
||||
|
||||
struct PacketSchedulingState {
|
||||
|
@@ -87,7 +87,7 @@ TEST_F(PendingPathRateLimiterTest, TestSetInitialCredit) {
|
||||
EXPECT_EQ(
|
||||
limiter_.currentCredit(now, std::chrono::microseconds{kRtt}),
|
||||
maxWindowBytes);
|
||||
updateUdpSendPacketLen(conn_, 2000);
|
||||
conn_.udpSendPacketLen = 2000;
|
||||
PendingPathRateLimiter limiter2{conn_.udpSendPacketLen};
|
||||
EXPECT_EQ(
|
||||
limiter2.currentCredit(now, std::chrono::microseconds{kRtt}),
|
||||
|
Reference in New Issue
Block a user