SCTP (RFC 9260, RFC 3758, RFC 6525, RFC 8260, RFC 8261, RFC 9653)

View Source

SCTP runs over DTLS application data (RFC 8261) and is implemented by the sans-IO engine webrtc_sctp_assoc with its internal modules: webrtc_sctp_handshake (setup, cookies, OOTB), webrtc_sctp_send and webrtc_sctp_pr (queues, scheduler, PR-SCTP), webrtc_sctp_ack (SACK processing, RTO, congestion control), webrtc_sctp_recv (TSN tracking, SACK generation, reassembly), webrtc_sctp_reconfig (RFC 6525), webrtc_sctp_cookie, webrtc_sctp_out (bundling). The codec is webrtc_sctp_chunk, webrtc_sctp_param and webrtc_sctp_crc32c. Engine tests run two engines over the seeded lossy in-memory network of test/webrtc_sctp_net.erl; "assoc" below means webrtc_sctp_assoc_tests, "prop" means prop_webrtc_sctp.

RFC 9260 (base protocol)

IDSectionRequirementModuleTestStatus
SCTP-13.1, 6.8, App. ACommon header; CRC32c over the packet with the checksum field zeroed, stored little endian; bad checksum discardedwebrtc_sctp_chunk, webrtc_sctp_crc32cwebrtc_sctp_crc32c_tests, assoc:bad_checksum_testUnit tested
SCTP-23.1Packets with other source or destination ports are discardedwebrtc_sctp_assocImplemented, untested
SCTP-33.2Chunk length >= 4, padding to 4 bytes, no more than 3 pad bytes; truncated or inconsistent chunks rejectedwebrtc_sctp_chunkwebrtc_sctp_chunk_tests (all truncations), prop:prop_decode_never_crashesUnit tested
SCTP-43.2Unrecognized chunk types handled by the upper two bits (stop, stop and report, skip, skip and report)webrtc_sctp_assocassoc:unknown_chunk_testUnit tested
SCTP-53.2.1, 3.2.2Unrecognized INIT parameters handled by the upper two bits and reported in INIT ACKwebrtc_sctp_handshakeassoc:init_validation_testUnit tested
SCTP-63.2.2Unrecognized INIT ACK parameters reported in an ERROR chunk bundled with COOKIE ECHOwebrtc_sctp_handshakeImplemented, untested
SCTP-73.3.2, 3.3.3INIT with Initiate Tag 0 silently discarded; OS or MIS 0 answered with ABORT (Invalid Mandatory Parameter); INIT ACK without State Cookie aborted (Missing Mandatory Parameter)webrtc_sctp_handshakeassoc:init_validation_testUnit tested
SCTP-83.3.10All ERROR causes encoded and decodedwebrtc_sctp_paramwebrtc_sctp_chunk_tests, prop:prop_tlv_roundtripUnit tested
SCTP-95.1Four-way handshake, T1-init and T1-cookie with Max.Init.Retransmitswebrtc_sctp_handshakeassoc:handshake_test, assoc:handshake_timeout_testUnit tested
SCTP-105.1.3, 5.1.5State Cookie with HMAC-SHA256 and lifetime; responder keeps no state until COOKIE ECHO; forged cookies discardedwebrtc_sctp_cookieassoc:init_validation_test, assoc:bad_cookie_testUnit tested
SCTP-115.2.1INIT in COOKIE-WAIT / COOKIE-ECHOED answered with the original tag (simultaneous open as used by WebRTC)webrtc_sctp_handshakeassoc:simultaneous_init_test, prop:prop_reliable_deliveryUnit tested
SCTP-125.2.2Unexpected INIT in an established association: new tag, tie-tags in cookie, TCB unchangedwebrtc_sctp_handshakeassoc:peer_restart_testUnit tested
SCTP-135.2.4COOKIE ECHO with an existing TCB, Table 12 actions A (restart), B, Dwebrtc_sctp_handshakeassoc:peer_restart_test, assoc:simultaneous_init_testUnit tested
SCTP-145.2.4Table 12 action C (late cookie discarded)webrtc_sctp_handshakeImplemented, untested
SCTP-155.2.4Restart while in SHUTDOWN-ACK-SENT: resend SHUTDOWN ACK and ERROR "Cookie Received While Shutting Down"webrtc_sctp_handshakeImplemented, untested
SCTP-165.2.6Stale Cookie ERROR, retried with a Cookie Preservative (alternative 3)webrtc_sctp_handshakeassoc:stale_cookie_testUnit tested
SCTP-175.3.1Verification tags and initial TSNs random (crypto:strong_rand_bytes/1, seedable for tests)webrtc_sctp_handshakeImplemented, untested
SCTP-186.1 APeer rwnd respected; with the window closed and nothing in flight the first zero window probe goes at once (one DATA chunk may always be in flight), T3 retransmits it with backoff, later probes while the window stays closed back offwebrtc_sctp_sendassoc:zero_window_test, assoc:receive_window_test, ETSI sctp-d-o-8-7, sctp-d-o-8-8Unit tested
SCTP-196.1 B, Dcwnd with one packet of overbooking; Max.Burstwebrtc_sctp_sendassoc:loss10_test, assoc:loss30_testUnit tested
SCTP-206.1 CRetransmissions sent before new datawebrtc_sctp_sendassoc:loss30_testUnit tested
SCTP-216.1SACK bundled with outgoing DATA when an acknowledgement is pendingwebrtc_sctp_outImplemented, untested
SCTP-226.2, 6.7Delayed SACK within SACK.Delay (200 ms, at most 500), at least every second packet, immediately on gaps, duplicates or the I bit (RFC 7053); also immediately for the first DATA of the association (which covers DATA bundled with COOKIE ECHO, §5.1.5) and for the packet that closes a gap, as FreeBSD doeswebrtc_sctp_recvassoc:delayed_sack_test, ETSI sctp-a-v-9-1, sctp-a-o-9-3, sctp-bdc-v-7-4, sctp-d-o-8-6Unit tested
SCTP-236.2Receive window: data beyond the highest TSN dropped when the window is closed; a_rwnd advertised from buffered byteswebrtc_sctp_recvassoc:receive_window_testUnit tested
SCTP-246.2DATA without user data answered with ABORT (No User Data)webrtc_sctp_recvassoc:no_user_data_testUnit tested
SCTP-256.2.1SACK processing: out of order SACK dropped, gap blocks, reneging, rwnd updatewebrtc_sctp_ackassoc:loss30_test, prop:prop_reliable_deliveryUnit tested
SCTP-266.3.1RTO from SRTT/RTTVAR, Karn's rule, one measurement per round trip, RTO.Min / RTO.Maxwebrtc_sctp_ackassoc:heartbeat_failure_test (SRTT from heartbeats)Unit tested
SCTP-576.3.3 E2, 6.3.1 C7, 5.1Timer back off on expiry of T3-rtx, T1-init, T1-cookie and T2-shutdown: RTO doubled, bounded by RTO.Max and by the max_backoff ceiling, which never brings the timer under an RTO the measurements gave; Max.Init.Retransmits still ends the handshakewebrtc_sctp_ack, webrtc_sctp_handshake, webrtc_sctp_assocassoc:backofftest, assoc:retransmissionbackoff_cap_test, assoc:handshake_backoff_cap_test, assoc:backoff_options_testUnit tested
SCTP-276.3.2, 6.3.3T3-rtx rules R1 to R4, backoff, retransmission of the earliest chunkswebrtc_sctp_ack, webrtc_sctp_sendassoc:retransmissionlimit_test, assoc:loss_30_testUnit tested
SCTP-286.5DATA on an invalid stream acknowledged at once and reported with "Invalid Stream Identifier", the ERROR after the SACKwebrtc_sctp_recvassoc:invalid_stream_testUnit tested
SCTP-296.6Ordered and unordered delivery per streamwebrtc_sctp_recvassoc:ordered_delivery_with_reordering_test, assoc:unordered_delivery_testUnit tested
SCTP-306.7Gap Ack Blocks and Duplicate TSNs reported, bounded by the MTUwebrtc_sctp_recvassoc:fastretransmit_test, assoc:loss_30_testUnit tested
SCTP-316.9Fragmentation to the configured MTU and reassembly (TSN based for DATA)webrtc_sctp_send, webrtc_sctp_recvassoc:large_message_test, assoc:large_message_small_mtu_test, assoc:unordered_fragmented_testUnit tested
SCTP-326.10Bundling of control and data chunks up to the MTUwebrtc_sctp_outassoc:manystreams_test (no MTU violation)Unit tested
SCTP-337.2.1, 7.2.2Slow start (initial cwnd per §7.2.1, L = 1) and congestion avoidance with partial_bytes_ackedwebrtc_sctp_ackassoc:loss10_testUnit tested
SCTP-347.2.3, 7.2.4Fast retransmit on three miss indications (HTNA), fast recovery, one packet ignoring cwndwebrtc_sctp_ack, webrtc_sctp_sendassoc:fast_retransmit_testUnit tested
SCTP-357.2.1cwnd decay while the sender is idle: halved per RTO without data, not below 4 MTUs, applied when data starts againwebrtc_sctp_sendwebrtc_sctp_assoc_tests:idle_cwnd_decay_testUnit tested
SCTP-367.3, RFC 8899 §4, §5, §6.2Path MTU discovery (PLPMTUD): from the base size (mtu), once established, HEARTBEAT and PAD probes of three sizes up to max_mtu, three unanswered probes end the search below that size, probe loss does not count toward Association.Max.Retrans, a retransmission timeout above the base goes back to it, the search is repeated every 600 swebrtc_sctp_pmtuwebrtc_sctp_assoc_tests:pmtu_search_test, pmtu_no_limit_test, pmtu_off_test, pmtu_black_hole_test (a large message across the fall back), pmtu_chunks_stay_base_test, webrtc_impairment_SUITE:path_mtu_1400E2E tested; DATA chunks are always cut for the base size, so a fall back never strands one (a chunk keeps its size once sent): larger packets bundle more chunks
SCTP-376.4, 8.2Multi-homing and path failoverNon-compliant / known limitation: one path only; SCTP over DTLS is single-homed (RFC 8261 §6.1)
SCTP-388.1Association.Max.Retrans: association closed after too many consecutive errors (T3, heartbeats, T2, RE-CONFIG); infinity leaves it to the owner (DT-10)webrtc_sctp_assocassoc:retransmission_limit_test, assoc:unlimited_retransmissions_testUnit tested
SCTP-398.3HEARTBEAT on an idle path, HEARTBEAT ACK echoes the info, RTT sample, configurable or disabledwebrtc_sctp_assocassoc:heartbeat_failure_testUnit tested
SCTP-408.4Out of the blue packets: ABORT and SHUTDOWN COMPLETE with T bit, silent caseswebrtc_sctp_handshakeassoc:ootb_testUnit tested
SCTP-418.5, 8.5.1Verification tag checks, INIT alone with tag 0, ABORT / SHUTDOWN COMPLETE T bit ruleswebrtc_sctp_assocassoc:bad_vtag_test, assoc:init_validation_testUnit tested
SCTP-429.1ABORT with User-Initiated Abort causewebrtc_sctp_assocassoc:abort_testUnit tested
SCTP-439.2Graceful shutdown: queued data delivered, T2-shutdown, SHUTDOWN in reply to DATA in SHUTDOWN-SENT, SHUTDOWN COMPLETEwebrtc_sctp_assocassoc:shutdown_test, assoc:shutdown_lossy_testUnit tested
SCTP-449.2T5-shutdown-guard: 5 times RTO.Max after our SHUTDOWN, the association is aborted with an ABORT (event shutdown_timeout)webrtc_sctp_assocETSI sctp-at-i-2-5Unit tested
SCTP-4512.2.4.2SACK acknowledging a TSN never sent aborts the associationwebrtc_sctp_ackassoc:sack_unsent_tsn_testUnit tested
SCTP-466.1Sender silly window avoidance: no DATA chunk is sent into a window smaller than itwebrtc_sctp_sendImplemented, untested
SCTP-476.2Receiver window update SACKs when the application consumes dataNon-compliant / known limitation: complete messages are handed to the owner on arrival, so the window only depends on fragments and out of order messages and no separate window update is needed
SCTP-48RFC 7053Sender sets the I bitNot implemented (receive side honours it)
SCTP-49ECN, AUTH (RFC 4895), ASCONF (RFC 5061 beyond Supported Extensions)Not implemented (not required by RFC 8831)
SCTP-50Robustness: random chunks with a valid tag never crash an established associationwebrtc_sctp_assocprop:prop_engine_never_crashesUnit tested
SCTP-516.10A packet bundling INIT ACK or SHUTDOWN COMPLETE with other chunks is discardedwebrtc_sctp_assocETSI sctp-bdc-i-7-2, sctp-bdc-i-7-3Unit tested
SCTP-525.1.2, 3.3.2.1An INIT or INIT ACK with a Host Name Address is answered with an ABORT carrying "Unresolvable Address"webrtc_sctp_handshakeETSI sctp-as-v-1-12-1, sctp-as-i-1-12-2Unit tested
SCTP-533.3.3An INIT ACK with initiate tag 0 or zero streams destroys the association, with an ABORT carrying "Invalid Mandatory Parameter"webrtc_sctp_handshakeETSI sctp-as-i-1-14-2, sctp-as-i-1-7-4Unit tested
SCTP-545.1.1The INIT ACK advertises the outbound streams the association will use, no more than the INIT's inbound streamswebrtc_sctp_handshakeETSI sctp-as-v-1-7-1Unit tested
SCTP-558.1, 5.1 CGiving up after Association.Max.Retrans or Max.Init.Retransmits of a COOKIE ECHO sends an ABORT, in case only the other direction is brokenwebrtc_sctp_assoc, webrtc_sctp_handshakeETSI sctp-as-i-1-3-2, sctp-at-i-2-12, sctp-fh-i-5-1-1, sctp-fh-i-5-1-2Unit tested
SCTP-56ETSI TS 102 369The ETSI SCTP conformance test purposes, as the packetdrill scripts of the nplab suite (FreeBSD lines where the platforms differ): 108 of 115 pass; the 7 others differ on purpose or do not apply over DTLS, listed with their reason in webrtc_sctp_etsi_testswebrtc_sctp_assocwebrtc_sctp_etsi_testsUnit tested

RFC 3758 and RFC 7496 (partial reliability)

IDSectionRequirementModuleTestStatus
PR-13.1, 3.3Forward-TSN-Supported parameter and FORWARD TSN in Supported Extensionswebrtc_sctp_handshakeassoc:handshake_testUnit tested
PR-23.2FORWARD TSN chunk formatwebrtc_sctp_chunkwebrtc_sctp_chunk_testsUnit tested
PR-33.5 A1 to A3Abandoned chunks are no longer outstanding, not credited to cwnd, all fragments of the message abandoned (including unsent ones)webrtc_sctp_prassoc:pr_ordered_max_retransmits_test, assoc:pr_lifetime_loss_testUnit tested
PR-43.5 C1 to C5, A5Advanced.Peer.Ack.Point, FORWARD TSN with the highest SSN per ordered stream, T3 kept running until the FORWARD TSN is acknowledged (also when a SACK leaves nothing in flight), repeated at most once per RTOwebrtc_sctp_pr, webrtc_sctp_ackassoc:pr_max_retransmits_test, assoc:pr_forward_tsn_lost_test, webrtc_impairment_SUITE:unreliable_channel_under_lossE2E tested
PR-53.5 C4Lower the Advanced.Peer.Ack.Point when the FORWARD TSN does not fit one MTUNot implemented (only reachable with more than about 290 streams abandoning messages at once)
PR-63.6Receiver: cumulative TSN moved, stranded fragments removed, ordered streams skipped and waiting messages deliveredwebrtc_sctp_recvassoc:pr_ordered_max_retransmits_test (window fully restored)Unit tested
PR-74Timed reliability (lifetime in ms from the send call), checked before first transmission and before retransmissionwebrtc_sctp_sendassoc:pr_lifetime_test, assoc:pr_lifetime_loss_testUnit tested
PR-8RFC 7496 §3.1Limited retransmissions policy, including 0 retransmissionswebrtc_sctp_sendassoc:pr_max_retransmits_testUnit tested

RFC 6525 (stream reconfiguration)

IDSectionRequirementModuleTestStatus
RC-13, 4RE-CONFIG chunk and parameters 13 to 18webrtc_sctp_paramwebrtc_sctp_chunk_testsUnit tested
RC-25.1.1Support negotiated through Supported Extensions; one request in flight; timer with RTO backoff counted in the error counterwebrtc_sctp_reconfigassoc:streamreset_lossy_testUnit tested
RC-35.1.2Outgoing SSN Reset Request: new messages held, Sender's Last Assigned TSN, request sent once queued messages have TSNs, stream ids limited to one packetwebrtc_sctp_reconfig, webrtc_sctp_sendassoc:streamreset_test, assoc:many_streams_testUnit tested
RC-45.2.1Request sequence numbers, retransmitted request answered again, bad sequence numberwebrtc_sctp_reconfigassoc:reconf_requests_testUnit tested
RC-55.2.2Incoming Outgoing SSN Reset: deferred until the last TSN arrives ("In progress"), held chunks replayed, success responsewebrtc_sctp_reconfig, webrtc_sctp_recvassoc:stream_reset_deferred_test, assoc:reconf_deferred_requests_testUnit tested
RC-65.2.3Incoming SSN Reset Request answered with an Outgoing SSN Reset Requestwebrtc_sctp_reconfigassoc:reconf_requests_testUnit tested
RC-75.2.4SSN/TSN Reset Requestwebrtc_sctp_reconfigassoc:reconf_requests_testNon-compliant / known limitation: always answered "Denied" (allowed by §5.2.1)
RC-85.2.5Add Outgoing Streams accepted up to 65535 incoming streamswebrtc_sctp_reconfigassoc:reconf_requests_testUnit tested
RC-95.2.6Add Incoming Streamswebrtc_sctp_reconfigassoc:reconf_requests_testNon-compliant / known limitation: always answered "Denied"
RC-105.2.7Responses: success resets the streams, "In progress" restarts the timer without counting an error, failures release held datawebrtc_sctp_reconfigassoc:stream_reset_deferred_testUnit tested
RC-115.1.3Sending Incoming SSN Reset, SSN/TSN Reset and Add Streams requestsNot implemented (WebRTC only needs outgoing resets)
RC-125.2.2 E3An Outgoing SSN Reset Request with no stream numbers resets every incoming stream, including when no stream has statewebrtc_sctp_recvwebrtcsctp_recv_tests:reset_all_without_state_test, assoc:reconfreset_all_streams_empty_test, reconfreset_all_streams_with_state_testUnit tested

RFC 8260 (message interleaving)

IDSectionRequirementModuleTestStatus
ID-12.1I-DATA chunk format (MID, PPID or FSN)webrtc_sctp_chunkwebrtc_sctp_chunk_testsUnit tested
ID-22.2.1Used only when both sides list I-DATA (and I-FORWARD-TSN); offered only with the interleaving optionwebrtc_sctp_handshakeassoc:interleaving_test, assoc:no_interleaving_testUnit tested
ID-32.2.2Late TSN assignment, one message per stream at a time, separate ordered and unordered MID counterswebrtc_sctp_sendassoc:interleavinglossy_test, assoc:stream_reset_interleaving_testUnit tested
ID-42.2.3Reassembly by stream, U bit, MID and FSN; DATA and I-DATA mixed abort the associationwebrtc_sctp_recvassoc:interleavinglossy_test, assoc:idata_without_negotiation_testUnit tested
ID-52.3.1I-FORWARD-TSN for ordered and unordered messages; FORWARD TSN with I-DATA abortswebrtc_sctp_pr, webrtc_sctp_recvassoc:interleaving_pr_test, assoc:forward_tsn_with_idata_testUnit tested
ID-62.3.2Stream reset resets both MID counterswebrtc_sctp_sendassoc:stream_reset_interleaving_testUnit tested
ID-73.2, 3.6Weighted fair queueing between streams (per fragment with I-DATA, per message with DATA); equal weights share by byteswebrtc_sctp_sendassoc:wfq_interleaved_test, wfq_data_test, wfq_equal_test, interleaving_testUnit tested
ID-83.1, 3.3 to 3.5First come first served, strict priority and fair bandwidth schedulersNot implemented: weighted fair queueing (3.6) is the one used

RFC 8261 (SCTP over DTLS)

IDSectionRequirementModuleTestStatus
DT-13Each SCTP packet is one DTLS application data record ({send, Bin} action, handle_packet/3 input)webrtc_sctp_assocall engine testsUnit tested
DT-25Safe SCTP packet size: the base is 1200 bytes minus the DTLS record overhead of the negotiated version, suite and CID; larger only once PLPMTUD confirmed itwebrtc_sctp_assocassoc:large_message_test, assoc:large_message_small_mtu_test (MTU checked on every packet)Unit tested
DT-36.1Single-homed association, no reliance on ICMPwebrtc_sctp_assocImplemented, untested
DT-46.1INIT and INIT ACK carry no IPv4 / IPv6 Address and no Supported Address Types parameterswebrtc_sctp_handshakeassoc:init_validation_testUnit tested
DT-56.1Associations multiplexed over one DTLS connection by SCTP port; packets for other ports discardedwebrtc_sctp_assocImplemented, untested (one engine per association, the owner demultiplexes)
DT-66.1On a lower layer path change (ICE selects another pair, or restarts), back to the base path MTU and a new search, initial cwnd and ssthresh, initial RTO and a new RTT estimatewebrtc_sctp_assoc, webrtc_dcep, webrtc_transport_securewebrtc_sctp_assoc_tests:path_changed_testUnit tested
DT-76.2PAD chunk for PMTU probes: a HEARTBEAT and a PAD chunk make each probe exactly the probed sizewebrtc_sctp_pmtu, webrtc_sctp_chunkwebrtc_sctp_chunk_tests, webrtc_sctp_assoc_tests:pmtu_search_testUnit tested
DT-86.5, 6.6, 6.7Partial reliability, stream reset and interleaving extensions over DTLSwebrtc_sctp_assocsee the RFC 3758, RFC 6525 and RFC 8260 tablesUnit tested
DT-9RFC 9260 §6.3.3 E2, §16WebRTC timers: the back off stops at 3 s (max_backoff, as libwebrtc), so after an outage the path is used again within seconds; Max.Init.Retransmits kept at 8 (about 25 s of setup attempts). The peer connection's sctp option changes themwebrtc_transport_securewebrtc_impairment_SUITE:long_outage_recovery (a message queued during a 20 s outage arrives within 4.5 s of the path coming back)E2E tested
DT-10RFC 9260 §8.1Association.Max.Retrans not applied by default (a SHOULD): the transport sets max_retransmissions => infinity, so a long outage that ICE consent survives does not close the data channels; the association ends when ICE consent or DTLS ends, as in libwebrtc, Firefox and Pion. The sctp option sets a limitwebrtc_transport_secure, webrtc_sctp_assocassoc:unlimited_retransmissions_test, webrtc_impairment_SUITE:long_outage_recoveryNon-compliant / known limitation (deliberate, configurable)

RFC 9653 (zero checksum)

IDSectionRequirementModuleTestStatus
ZC-14Zero Checksum Acceptable parameter (EDMID 1, SCTP over DTLS)webrtc_sctp_paramwebrtc_sctp_chunk_testsUnit tested
ZC-25.1Announced only when the upper layer allows it (zero_checksum option); the WebRTC transport, always over DTLS, enables itwebrtc_sctp_handshake, webrtc_transportassoc:zero_checksum_one_side_test, the E2E and interop data channel suitesInteroperability tested
ZC-35.2Zero checksum sent only after the peer announced DTLS; INIT, INIT ACK, COOKIE ECHO and OOTB responses keep a correct CRC32cwebrtc_sctp_out, webrtc_sctp_handshakeassoc:zero_checksum_testUnit tested
ZC-45.3Zero checksum accepted only after announcing it, correct CRC32c always acceptedwebrtc_sctp_assocassoc:bad_checksum_test, assoc:zero_checksum_testUnit tested