Skip to content
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d29e073
[SCTP] Socket part 2
ibc May 6, 2025
a2e9f4b
more
ibc May 7, 2025
86f55b4
more
ibc May 7, 2025
908b1d1
more
ibc May 9, 2025
01feb43
add StateCookie::IsMediasoupStateCookie() static method
ibc May 9, 2025
04f0758
more
ibc May 9, 2025
6e87917
add StateCookie::DetermineSctpImplementation()
ibc May 9, 2025
76222cf
fix fuzzer
ibc May 9, 2025
c5eda5f
add BackoffTimerHandle
ibc May 9, 2025
932c843
Improve TestStateCookie.cpp
ibc May 10, 2025
bb2fa4e
cosmetic
ibc May 11, 2025
494113d
more
ibc May 11, 2025
e0bece2
cosmetic
ibc May 12, 2025
0f42e64
add SocketMetrics
ibc May 12, 2025
44c537b
minimal
ibc May 12, 2025
27af7f1
rename my => local, peer => remote
ibc May 12, 2025
8cd7451
more
ibc May 12, 2025
0259ecb
more
ibc May 12, 2025
afffe96
more
ibc May 12, 2025
953fc56
cosmetic
ibc May 12, 2025
8a03da5
fix fuzzer
ibc May 12, 2025
17c3cc2
more
ibc May 14, 2025
c66d453
more
ibc May 14, 2025
a0af838
more
ibc May 14, 2025
ccaabf1
Merge branch 'v3' into sctp-socket-part-2
ibc May 15, 2025
5f589c8
more
ibc May 15, 2025
67e3e6a
more
ibc May 16, 2025
4e1148e
Merge branch 'v3' into sctp-socket-part-2
ibc May 16, 2025
c7c47cc
improve C++ random number generator and add GetRandomUInt64()
ibc May 16, 2025
d0d314a
apply changes in classes
ibc May 16, 2025
70091d6
SCTP Socket: handle INIT_ACK
ibc May 16, 2025
97054cb
improve
ibc May 16, 2025
7e58bd0
fix fuzzer
ibc May 18, 2025
7f2a2ba
Merge branch 'v3' into sctp-socket-part-2
ibc May 21, 2025
859e178
not much
ibc May 21, 2025
f8a7bde
add ErrorCause::ToString() method
ibc May 21, 2025
8862887
Merge branch 'v3' into sctp-socket-part-2
ibc Jun 14, 2025
aaaf77a
Merge branch 'v3' into sctp-socket-part-2
ibc Jun 27, 2025
2f4b36a
Merge branch 'v3' into sctp-socket-part-2
ibc Jul 30, 2025
1dd6624
Merge branch 'v3' into sctp-socket-part-2
ibc Sep 1, 2025
6b704df
Merge branch 'v3' into sctp-socket-part-2
ibc Sep 7, 2025
4fce777
Merge branch 'v3' into sctp-socket-part-2
ibc Sep 9, 2025
6075d66
Merge branch 'v3' into sctp-socket-part-2
ibc Sep 10, 2025
9c6d8e2
fix
ibc Sep 10, 2025
d3672a3
fix https://github.com/versatica/mediasoup/pull/1533/#issuecomment-32…
ibc Sep 11, 2025
88ded0c
Merge branch 'v3' into sctp-socket-part-2
ibc Sep 11, 2025
5ee722d
Merge branch 'v3' into sctp-socket-part-2
ibc Feb 17, 2026
2076b9c
cosmetic
ibc Feb 17, 2026
0a6cbd4
fix
ibc Feb 17, 2026
63f8029
cosmetic
ibc Feb 17, 2026
a9fd491
fix and "cosmetic"
ibc Feb 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion worker/fuzzer/src/FuzzerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void Fuzzer::Utils::Fuzz(const uint8_t* data, size_t len)

/* Crypto class. */

::Utils::Crypto::GetRandomUInt(static_cast<uint32_t>(len), static_cast<uint32_t>(len + 1000000));
::Utils::Crypto::GetRandomUInt32(static_cast<uint32_t>(len), static_cast<uint32_t>(len + 1000000));
::Utils::Crypto::GetRandomString(len);
::Utils::Crypto::GetCRC32(data2.get(), len);

Expand Down
6 changes: 3 additions & 3 deletions worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ void Fuzzer::RTC::DtlsTransport::Fuzz(const uint8_t* data, size_t len)
// Remote DTLS fingerprint random generation.
// NOTE: Use a random integer in range 1..5 since FingerprintAlgorithm enum
// has 5 possible values starting with value 1.
dtlsRemoteFingerprint.algorithm =
static_cast<::RTC::DtlsTransport::FingerprintAlgorithm>(::Utils::Crypto::GetRandomUInt(1u, 5u));
dtlsRemoteFingerprint.algorithm = static_cast<::RTC::DtlsTransport::FingerprintAlgorithm>(
::Utils::Crypto::GetRandomUInt32(1u, 5u));

dtlsRemoteFingerprint.value =
::Utils::Crypto::GetRandomString(::Utils::Crypto::GetRandomUInt(3u, 20u));
::Utils::Crypto::GetRandomString(::Utils::Crypto::GetRandomUInt32(3u, 20u));

dtlsTransportSingleton->Run(localRole);
dtlsTransportSingleton->SetRemoteFingerprint(dtlsRemoteFingerprint);
Expand Down
4 changes: 2 additions & 2 deletions worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ void Fuzzer::RTC::RateCalculator::Fuzz(const uint8_t* data, size_t len)
}

auto size = static_cast<size_t>(
Utils::Crypto::GetRandomUInt(0u, static_cast<uint32_t>(::RTC::Consts::MtuSize)));
Utils::Crypto::GetRandomUInt32(0u, static_cast<uint32_t>(::RTC::Consts::MtuSize)));

nowMs += Utils::Crypto::GetRandomUInt(0u, 1000u);
nowMs += Utils::Crypto::GetRandomUInt32(0u, 1000u);

rateCalculator.Update(size, nowMs);

Expand Down
39 changes: 21 additions & 18 deletions worker/fuzzer/src/RTC/SCTP/association/FuzzerStateCookie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ void Fuzzer::RTC::SCTP::StateCookie::Fuzz(const uint8_t* data, size_t len)
// data matches it.
if (len > ::RTC::SCTP::StateCookie::StateCookieLength)
{
len = ::Utils::Crypto::GetRandomUInt(
len = ::Utils::Crypto::GetRandomUInt32(
::RTC::SCTP::StateCookie::StateCookieLength, ::RTC::SCTP::StateCookie::StateCookieLength + 10);

if (len < ::RTC::SCTP::StateCookie::StateCookieLength + 5)
{
::Utils::Byte::Set4Bytes(clonedData, 0, ::RTC::SCTP::StateCookie::MagicValue1);
::Utils::Byte::Set2Bytes(clonedData, 34, ::RTC::SCTP::StateCookie::MagicValue2);
::Utils::Byte::Set8Bytes(clonedData, 0, ::RTC::SCTP::StateCookie::Magic1);
::Utils::Byte::Set2Bytes(
clonedData,
::RTC::SCTP::StateCookie::NegotiatedCapabilitiesOffset,
::RTC::SCTP::StateCookie::Magic2);
}
}

Expand All @@ -36,33 +39,33 @@ void Fuzzer::RTC::SCTP::StateCookie::Fuzz(const uint8_t* data, size_t len)
return;
}

stateCookie->GetMyVerificationTag();
stateCookie->GetPeerVerificationTag();
stateCookie->GetMyInitialTsn();
stateCookie->GetPeerInitialTsn();
stateCookie->GetMyAdvertisedReceiverWindowCredit();
stateCookie->GetLocalVerificationTag();
stateCookie->GetRemoteVerificationTag();
stateCookie->GetLocalInitialTsn();
stateCookie->GetRemoteInitialTsn();
stateCookie->GetRemoteAdvertisedReceiverWindowCredit();
stateCookie->GetTieTag();
stateCookie->GetNegotiatedCapabilities();

stateCookie->Serialize(StateCookieSerializeBuffer, len);

stateCookie->GetMyVerificationTag();
stateCookie->GetPeerVerificationTag();
stateCookie->GetMyInitialTsn();
stateCookie->GetPeerInitialTsn();
stateCookie->GetMyAdvertisedReceiverWindowCredit();
stateCookie->GetLocalVerificationTag();
stateCookie->GetRemoteVerificationTag();
stateCookie->GetLocalInitialTsn();
stateCookie->GetRemoteInitialTsn();
stateCookie->GetRemoteAdvertisedReceiverWindowCredit();
stateCookie->GetTieTag();
stateCookie->GetNegotiatedCapabilities();

auto* clonedStateCookie = stateCookie->Clone(StateCookieCloneBuffer, len);

delete stateCookie;

clonedStateCookie->GetMyVerificationTag();
clonedStateCookie->GetPeerVerificationTag();
clonedStateCookie->GetMyInitialTsn();
clonedStateCookie->GetPeerInitialTsn();
clonedStateCookie->GetMyAdvertisedReceiverWindowCredit();
clonedStateCookie->GetLocalVerificationTag();
clonedStateCookie->GetRemoteVerificationTag();
clonedStateCookie->GetLocalInitialTsn();
clonedStateCookie->GetRemoteInitialTsn();
clonedStateCookie->GetRemoteAdvertisedReceiverWindowCredit();
clonedStateCookie->GetTieTag();
clonedStateCookie->GetNegotiatedCapabilities();

Expand Down
4 changes: 2 additions & 2 deletions worker/fuzzer/src/RTC/SCTP/packet/FuzzerPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void Fuzzer::RTC::SCTP::Packet::Fuzz(const uint8_t* data, size_t len)
packet->GetChecksum();
packet->ValidateCRC32cChecksum();
packet->SetChecksum(999999);
packet->SetCRC32cChecksum();
packet->WriteCRC32cChecksum();
packet->ValidateCRC32cChecksum();
packet->HasChunks();
packet->GetChunksCount();
Expand All @@ -58,7 +58,7 @@ void Fuzzer::RTC::SCTP::Packet::Fuzz(const uint8_t* data, size_t len)
clonedPacket->GetChecksum();
clonedPacket->ValidateCRC32cChecksum();
clonedPacket->SetChecksum(999999);
clonedPacket->SetCRC32cChecksum();
clonedPacket->WriteCRC32cChecksum();
clonedPacket->ValidateCRC32cChecksum();
clonedPacket->HasChunks();
clonedPacket->GetChunksCount();
Expand Down
6 changes: 0 additions & 6 deletions worker/include/RTC/SCTP/TODO_SCTP.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,3 @@ Here some notes about our future SCTP implementation.
However, in step 4 `WebRtcTransport::OnDtlsTransportApplicationDataReceived()` should instead call `RTC::SCTP::Packet::parse()` and `Transport::ReceiveSctpPacket()` with a `SCTP::Packet` instance instead than `data` and `len`. In fact it should be named `Transport::ReceiveSctpPacket()` instead of the current `Transport::ReceiveSctpData()`.

Same in `PipeTransport` and `PlainTransport`.

## TODO

- Try to remove all `friend class`.

- In `HeartbeatChunk` the `HeartbeatInfoParameter` should be mandatory when parsing. Or should we add some `Validate()` method?
17 changes: 17 additions & 0 deletions worker/include/RTC/SCTP/association/NegotiatedCapabilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#define MS_RTC_SCTP_NEGOTIATED_CAPABILITIES_HPP

#include "common.hpp"
#include "RTC/SCTP/association/SocketOptions.hpp"
#include "RTC/SCTP/packet/chunks/InitAckChunk.hpp"
#include "RTC/SCTP/packet/chunks/InitChunk.hpp"
#include <variant> // std::variant, std::visit()

namespace RTC
{
Expand All @@ -14,6 +18,19 @@ namespace RTC
*/
struct NegotiatedCapabilities
{
using InitOrInitAckChunkVariant = std::variant<const InitChunk*, const InitAckChunk*>;

/**
* Create a NegotiatedCapabilities struct. Intended to be used during
* the SCTP association handshake flow.
*
* @remarks
* Given `remoteChunk` must be an INIT or an INIT_ACK Chunk. Otherwise
* it will fail in compilation time.
*/
static NegotiatedCapabilities Factory(
SocketOptions socketOptions, InitOrInitAckChunkVariant remoteChunk);

/**
* Negotiated maximum number of outbound streams (OS).
*/
Expand Down
Loading
Loading