Increase maximum RTP padding length to 255 bytes

which is the maximum allowed in RFC 3550:
  The last octet of the padding contains a count of how
  many padding octets should be ignored, including itself

SRTP encryption does not need to be taken into account since none of
the cipher suites used by WebRTC require padding:
https://www.rfc-editor.org/rfc/rfc3711#section-3.1
https://www.rfc-editor.org/rfc/rfc7714#section-7.2

BUG=webrtc:15182

Change-Id: Ife3d264af389509733699f2dd4d32ba63793e9de
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/305642
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#40101}
This commit is contained in:
Philipp Hancke 2023-05-18 11:03:21 +02:00 committed by WebRTC LUCI CQ
parent 194f657b51
commit 15feded162
4 changed files with 7 additions and 8 deletions

View File

@ -103,7 +103,7 @@ TEST(PccNetworkControllerTest, UpdatesTargetSendRate) {
c->bandwidth = DataRate::KilobitsPerSec(800);
c->delay = TimeDelta::Millis(100);
});
s.RunFor(TimeDelta::Seconds(20));
s.RunFor(TimeDelta::Seconds(40));
EXPECT_NEAR(client->target_rate().kbps(), 750, 150);
send_net->UpdateConfig([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::KilobitsPerSec(200);

View File

@ -38,8 +38,6 @@
namespace webrtc {
namespace {
// Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP.
constexpr size_t kMaxPaddingLength = 224;
constexpr size_t kMinAudioPaddingLength = 50;
constexpr size_t kRtpHeaderLength = 12;

View File

@ -41,6 +41,9 @@ class RateLimiter;
class RtcEventLog;
class RtpPacketToSend;
// Maximum amount of padding in RFC 3550 is 255 bytes.
constexpr size_t kMaxPaddingLength = 255;
class RTPSender {
public:
RTPSender(const RtpRtcpInterface::Configuration& config,

View File

@ -65,10 +65,8 @@ const uint32_t kSsrc = 725242;
const uint32_t kRtxSsrc = 12345;
const uint32_t kFlexFecSsrc = 45678;
const uint64_t kStartTime = 123456789;
const size_t kMaxPaddingSize = 224u;
const uint8_t kPayloadData[] = {47, 11, 32, 93, 89};
const int64_t kDefaultExpectedRetransmissionTimeMs = 125;
const size_t kMaxPaddingLength = 224; // Value taken from rtp_sender.cc.
const uint32_t kTimestampTicksPerMs = 90; // 90kHz clock.
constexpr absl::string_view kMid = "mid";
constexpr absl::string_view kRid = "f";
@ -1115,7 +1113,7 @@ TEST_F(RtpSenderTest, GeneratePaddingResendsOldPacketsWithRtx) {
padding_bytes_generated += packet->padding_size();
}
EXPECT_EQ(padding_bytes_generated, kMaxPaddingSize);
EXPECT_EQ(padding_bytes_generated, kMaxPaddingLength);
}
TEST_F(RtpSenderTest, LimitsPayloadPaddingSize) {
@ -1187,7 +1185,7 @@ TEST_F(RtpSenderTest, GeneratePaddingCreatesPurePaddingWithoutRtx) {
// maximum size.
const size_t kPaddingBytesRequested = kPayloadPacketSize + kRtxHeaderSize;
const size_t kExpectedNumPaddingPackets =
(kPaddingBytesRequested + kMaxPaddingSize - 1) / kMaxPaddingSize;
(kPaddingBytesRequested + kMaxPaddingLength - 1) / kMaxPaddingLength;
size_t padding_bytes_generated = 0;
std::vector<std::unique_ptr<RtpPacketToSend>> padding_packets =
GeneratePadding(kPaddingBytesRequested);
@ -1204,7 +1202,7 @@ TEST_F(RtpSenderTest, GeneratePaddingCreatesPurePaddingWithoutRtx) {
}
EXPECT_EQ(padding_bytes_generated,
kExpectedNumPaddingPackets * kMaxPaddingSize);
kExpectedNumPaddingPackets * kMaxPaddingLength);
}
TEST_F(RtpSenderTest, SupportsPadding) {