Skip to main content

Crate rtc_sctp

Crate rtc_sctp 

Source
Expand description

SCTP for the Sans-I/O WebRTC stack.

The Stream Control Transmission Protocol (RFC 4960) with the extensions WebRTC data channels need: partial reliability (RFC 3758) and stream reset / reconfiguration (RFC 6525). In WebRTC, SCTP runs over DTLS rather than over IP, and carries the data channels described by rtc-datachannel.

This is a fully deterministic implementation of the protocol logic. It contains no networking code and reads no clock of its own: you feed it datagrams and time, and poll it for the datagrams and events it produces. That is what makes it testable without a network and reusable under any executor.

§Structure

  • Endpoint — the protocol state for one socket. It holds configuration and dispatches inbound datagrams to the right association.
  • Association — the bulk of the logic for a single association: handshake, congestion control, retransmission, and its streams.
  • Stream — one stream’s reads, writes and reliability settings.
  • Chunks — a reassembled inbound message, delivered once every fragment has arrived.

§Example

Configuration is plain data, and the association is driven entirely by the caller — feed it datagrams and time, poll it for output:

use rtc_sctp::{EndpointConfig, TransportConfig};
use std::sync::Arc;

let transport = TransportConfig::default()
    .with_max_message_size(65_536)
    .with_max_num_outbound_streams(1024);

let endpoint_config = Arc::new(EndpointConfig::new());
assert_eq!(transport.max_message_size(), 65_536);

Most applications do not depend on this crate directly — the rtc crate drives it as one layer of the peer-connection pipeline and exposes data channels, and webrtc wraps that in an async API.

Structs§

Association
Association represents an SCTP association
AssociationEvent
Events sent from an Endpoint to an Association
AssociationHandle
Internal identifier for an Association currently associated with an endpoint
AssociationStats
Association statistics
Chunk
A chunk of data from the stream
ChunkPayloadData
ChunkPayloadData represents an SCTP Chunk of type DATA
Chunks
Chunks is a set of chunks that share the same SSN
ClientConfig
Configuration for outgoing associations
Endpoint
The main entry point to the library
EndpointConfig
Global configuration for the endpoint, affecting all associations
EndpointEvent
Events sent from an Association to an Endpoint
ErrorCauseCode
ErrorCauseCode is a cause code that appears in either a ERROR or ABORT chunk
ServerConfig
Parameters governing incoming associations
Stream
Stream represents an SCTP stream
StreamState
StreamState represents the state of an SCTP stream
TimerConfig
Retransmission limits for the association’s timers.
TransportConfig
Config collects the arguments to create_association construction into a single structure

Enums§

AssociationError
Reasons why an association might be lost
ConnectError
Errors in the parameters being used to create a new association
DatagramEvent
Event resulting from processing a single datagram
Event
Events of interest to the application
Payload
Payload in Incoming/outgoing Transmit
PayloadProtocolIdentifier
PayloadProtocolIdentifier is an enum for DataChannel payload types PayloadProtocolIdentifier enums https://www.iana.org/assignments/sctp-parameters/sctp-parameters.xhtml#sctp-parameters-25
ReliabilityType
Reliability type for stream
Side
Whether an endpoint was the initiator of an association
StreamEvent
Application events about streams

Constants§

MIN_DATA_PACKET_MTU
Floor for max_payload_size_for_mtu: the smallest representable padded DATA packet — the 12-byte common header, the 16-byte DATA chunk header, and a 1..=4-byte payload padded to the 4-byte chunk boundary.

Functions§

max_payload_size_for_mtu
Derive an EndpointConfig::max_payload_size value from an outbound DATA-packet budget: the largest DATA packet (common header plus bundled DATA chunks) associations may emit, in bytes. Control packets (INIT, INIT ACK, SACK, RECONFIG, FORWARD TSN, shutdown) marshal without consulting this value.

Type Aliases§

AssociationId
Protocol-level identifier for an Association.
StreamId
Identifier for a stream within a particular association