mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-06 22:22:38 +03:00
Round up Quic congestion control writable bytes to nearest multiple of packet
Summary: Currently we return the exact writable bytes number from a real congestion controller or Path Challenger. This diff round the number up to the nearest multiple of packet length. Doing so can greatly reduce weird bytes counting/checking bugs we have around packet writing. Reviewed By: mjoras Differential Revision: D20265678 fbshipit-source-id: 2973dde3acc4b2008337127482185f34e16efb43
This commit is contained in:
committed by
Facebook Github Bot
parent
bbb8cb8218
commit
df865c4e34
@@ -971,6 +971,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionConnWindowUpdate) {
|
||||
|
||||
TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketWithCC) {
|
||||
auto conn = createConn();
|
||||
conn->udpSendPacketLen = 30;
|
||||
auto mockCongestionController =
|
||||
std::make_unique<NiceMock<MockCongestionController>>();
|
||||
auto rawCongestionController = mockCongestionController.get();
|
||||
@@ -1199,7 +1200,7 @@ TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketWithNoBytesForHeader) {
|
||||
writeDataToQuicStream(*stream1, buf->clone(), true);
|
||||
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillRepeatedly(Return(10));
|
||||
.WillRepeatedly(Return(0));
|
||||
EXPECT_CALL(*rawCongestionController, onPacketSent(_)).Times(0);
|
||||
writeQuicDataToSocket(
|
||||
*rawSocket,
|
||||
@@ -1719,42 +1720,30 @@ TEST_F(QuicTransportFunctionsTest, ShouldWriteDataTestDuringPathValidation) {
|
||||
auto buf = IOBuf::copyBuffer("0123456789");
|
||||
writeDataToQuicStream(*stream1, buf->clone(), false);
|
||||
|
||||
// shouldWriteData checks this first
|
||||
const size_t minimumDataSize = std::max(
|
||||
kLongHeaderHeaderSize + kCipherOverheadHeuristic, sizeof(Sample));
|
||||
|
||||
// Only case that we allow the write; both CC / PathLimiter have writablebytes
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(minimumDataSize + 1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _))
|
||||
.WillOnce(Return(minimumDataSize + 1));
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes()).WillOnce(Return(1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _)).WillOnce(Return(1));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked()).Times(0);
|
||||
EXPECT_NE(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
// CC has writableBytes, but PathLimiter doesn't.
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(minimumDataSize + 1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _))
|
||||
.WillOnce(Return(minimumDataSize - 2));
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes()).WillOnce(Return(1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _)).WillOnce(Return(0));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
// PathLimiter has writableBytes, CC doesn't
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(minimumDataSize - 1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _))
|
||||
.WillOnce(Return(minimumDataSize + 1));
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes()).WillOnce(Return(0));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _)).WillOnce(Return(1));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
// Neither PathLimiter or CC have writablebytes
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(minimumDataSize - 1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _))
|
||||
.WillOnce(Return(minimumDataSize - 1));
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes()).WillOnce(Return(0));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _)).WillOnce(Return(0));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
@@ -2051,5 +2040,32 @@ TEST_F(QuicTransportFunctionsTest, WriteLimitBytRttFraction) {
|
||||
500 /* packetLimit */));
|
||||
}
|
||||
|
||||
TEST_F(QuicTransportFunctionsTest, CongestionControlWritableBytesRoundUp) {
|
||||
auto conn = createConn();
|
||||
conn->udpSendPacketLen = 2000;
|
||||
auto mockCongestionController =
|
||||
std::make_unique<NiceMock<MockCongestionController>>();
|
||||
auto rawCongestionController = mockCongestionController.get();
|
||||
conn->congestionController = std::move(mockCongestionController);
|
||||
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes()).WillOnce(Return(1));
|
||||
EXPECT_EQ(conn->udpSendPacketLen, congestionControlWritableBytes(*conn));
|
||||
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(1000));
|
||||
EXPECT_EQ(conn->udpSendPacketLen, congestionControlWritableBytes(*conn));
|
||||
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes()).WillOnce(Return(0));
|
||||
EXPECT_EQ(0, congestionControlWritableBytes(*conn));
|
||||
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(2000));
|
||||
EXPECT_EQ(conn->udpSendPacketLen, congestionControlWritableBytes(*conn));
|
||||
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(2001));
|
||||
EXPECT_EQ(conn->udpSendPacketLen * 2, congestionControlWritableBytes(*conn));
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace quic
|
||||
|
Reference in New Issue
Block a user