Skip to content

Conversation

@jordanvrtanoski
Copy link

Implement full SCTP (Stream Control Transmission Protocol) layer with support for:

Core Protocol (RFC 9260):

  • All standard chunk types (DATA, INIT, INIT-ACK, SACK, HEARTBEAT, ABORT, SHUTDOWN, ERROR, COOKIE-ECHO, COOKIE-ACK, ECNE, CWR, SHUTDOWN-COMPLETE)
  • CRC32c checksum calculation and validation
  • Chunk and parameter action bits helpers
  • Bundling validation per RFC 9260
  • Host Name Address deprecation detection

Extensions:

  • AUTH chunk with HMAC-SHA1/SHA256 computation and verification (RFC 4895)
  • ASCONF/ASCONF-ACK for dynamic address reconfiguration (RFC 5061)
  • RE-CONFIG for stream reconfiguration (RFC 6525)
  • FORWARD-TSN for partial reliability (RFC 3758)
  • I-DATA and I-FORWARD-TSN for message interleaving (RFC 8260)
  • PAD chunk (RFC 4820)
  • NR-SACK experimental support (IANA registered, draft-based)
  • Zero Checksum Acceptable parameter (RFC 9653)

Additional features:

  • Parameter iterators for INIT, RE-CONFIG, and ASCONF chunks
  • Error cause iterator for ABORT/ERROR chunks
  • Extended PPID enum with 70+ protocol identifiers from IANA registry
  • Chunk creation APIs for building SCTP packets

Includes 72 test cases covering parsing, creation, and validation.

Copy link
Collaborator

@Dimi1010 Dimi1010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the submission. :)

/// @class SctpChunk
/// A wrapper class for SCTP chunks. This class does not create or modify chunk records,
/// but rather serves as a wrapper and provides useful methods for retrieving data from them
class SctpChunk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is essentially a view class right?

Somewhat thinking out loud but can we split this class into several view subclasses for each chunk type?
Currently the class seems a bit unwieldy with all the different chunk type methods?

Can we instead have:

  • SctpChunk - Common Methods (getChunkType(), etc)
    • SctpDataChunk - A data chunk.
    • SctpInitChunk - Init/InitAck chunk.
    • ScptSackChunk - Sack chunk.
    • ...

Since the chunk objects only hold a pointer, they can be treated as value objects, similar to std::string_view.

class SctpChunk
{
  /* Generic chunk methods */
  SctpChunkType getChunkType() const;
}

class SctpDataChunk : public SctpChunk {
  SctpDataChunk(SctpChunk chunk) { /* validate correct chunk type */ }

  /* Data specific chunk accessors */
}

// Other chunk types.

The inheritance in the above example is mostly for code reuse of the common methods, not for polymorphism, therefor the lack of any virtual methods.

Do you think that would work or is there something I am missing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good observation, let me see what it takes to refactor it to be more aligned to OO principles.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason the SctpChunk is designed as a monolith class in the first pace is to avoid the heap overhead that inheritance would create, as well as it's impact on the cache as the objects in the hierarchy have bad locality.

Having the chunks as views classes on the SctpChunk will address my original performance concerns, so I will refactor the code based on the suggestion.

@jordanvrtanoski jordanvrtanoski marked this pull request as draft December 1, 2025 03:08
@jordanvrtanoski
Copy link
Author

Converted the PR to draft to address the proposed refactoring.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add the original pcap file used for these .dat files?

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 99.39394% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.45%. Comparing base (08d661c) to head (7fcaf10).

Files with missing lines Patch % Lines
Packet++/src/IPv4Layer.cpp 50.00% 3 Missing ⚠️
Packet++/src/IPv6Layer.cpp 57.14% 3 Missing ⚠️
Tests/Packet++Test/Tests/SctpTests.cpp 99.82% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2031      +/-   ##
==========================================
- Coverage   83.47%   83.45%   -0.02%     
==========================================
  Files         311      314       +3     
  Lines       54574    58524    +3950     
  Branches    11516    12677    +1161     
==========================================
+ Hits        45555    48842    +3287     
- Misses       7777     8481     +704     
+ Partials     1242     1201      -41     
Flag Coverage Δ
alpine320 75.59% <98.93%> (-0.31%) ⬇️
fedora42 75.19% <98.71%> (-0.26%) ⬇️
macos-14 81.08% <99.37%> (-0.50%) ⬇️
macos-15 81.07% <99.37%> (-0.51%) ⬇️
mingw32 68.89% <50.00%> (-1.12%) ⬇️
mingw64 68.89% <66.66%> (-0.98%) ⬇️
npcap ?
rhel94 75.24% <98.94%> (-0.22%) ⬇️
ubuntu2004 59.33% <45.66%> (-0.14%) ⬇️
ubuntu2004-zstd 59.41% <45.66%> (-0.18%) ⬇️
ubuntu2204 75.17% <98.93%> (-0.23%) ⬇️
ubuntu2204-icpx 57.13% <88.13%> (-0.76%) ⬇️
ubuntu2404 75.25% <98.93%> (-0.27%) ⬇️
ubuntu2404-arm64 75.26% <98.88%> (-0.32%) ⬇️
unittest 83.45% <99.39%> (-0.02%) ⬇️
windows-2022 84.41% <93.93%> (-0.86%) ⬇️
windows-2025 84.44% <93.93%> (-0.90%) ⬇️
winpcap 84.44% <93.93%> (-1.10%) ⬇️
xdp 54.16% <98.93%> (+1.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Implement full SCTP (Stream Control Transmission Protocol) layer with support for:

Core Protocol (RFC 9260):
- All standard chunk types (DATA, INIT, INIT-ACK, SACK, HEARTBEAT, ABORT,
  SHUTDOWN, ERROR, COOKIE-ECHO, COOKIE-ACK, ECNE, CWR, SHUTDOWN-COMPLETE)
- CRC32c checksum calculation and validation
- Chunk and parameter action bits helpers
- Bundling validation per RFC 9260
- Host Name Address deprecation detection

Extensions:
- AUTH chunk with HMAC-SHA1/SHA256 computation and verification (RFC 4895)
- ASCONF/ASCONF-ACK for dynamic address reconfiguration (RFC 5061)
- RE-CONFIG for stream reconfiguration (RFC 6525)
- FORWARD-TSN for partial reliability (RFC 3758)
- I-DATA and I-FORWARD-TSN for message interleaving (RFC 8260)
- PAD chunk (RFC 4820)
- NR-SACK experimental support (IANA registered, draft-based)
- Zero Checksum Acceptable parameter (RFC 9653)

Additional features:
- Parameter iterators for INIT, RE-CONFIG, and ASCONF chunks
- Error cause iterator for ABORT/ERROR chunks
- Extended PPID enum with 70+ protocol identifiers from IANA registry
- Chunk creation APIs for building SCTP packets

Includes 72 test cases covering parsing, creation, and validation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants