CoolrfulDARkness/moonsctp/association does not have a README file

    AssocError

    pub suberror AssocError {
    InvalidState(String)
    InvalidStream(UInt)
    MessageTooLarge(Int)
    PacketError(String)
    SecurityViolation(String)
    InvalidConfig(String)
    } derive(Eq,
    Debug
    )

    Errors raised by association configuration, framing, or security checks.

    AssocState

    pub(all) enum AssocState {
    Closed
    CookieWait
    CookieEchoed
    Established
    ShutdownPending
    ShutdownSent
    ShutdownReceived
    ShutdownAckSent
    } derive(Eq,
    Debug
    )

    RFC 9260 Section 4 SCTP association states.

    AssocStats

    pub(all) struct AssocStats {
    cwnd : Int
    rto_ms : UInt64
    packets_sent : Int
    packets_recv : Int
    retransmissions : Int
    forward_tsn_sent : Int
    messages_delivered : Int
    } derive(Eq,
    Debug
    )

    Runtime observability statistics for an SCTP association.

    Association

    pub struct Association {
    // private fields
    }

    Sans-I/O RFC 9260 SCTP + RFC 3758 PR-SCTP Association State Machine. All internal state and cryptographic secrets are strictly private.

    Association::abort

    fn Association::abort(self : Association, reason : Bytes) -> Unit

    Immediately aborts the association by queueing an ABORT chunk and transitioning to Closed.

    Association::connect

    fn Association::connect(self : Association, now_ms : UInt64) -> Array[Bytes] raise AssocError

    Initiates the 4-way handshake by emitting an INIT packet and transitioning Closed -> CookieWait.

    Association::handle_packet

    fn Association::handle_packet(self : Association, raw : BytesView, now_ms : UInt64) -> Array[Event] raise AssocError

    Processes an incoming wire SCTP packet, verifying CRC-32C, Verification Tag, HMAC cookies, state transitions, multi-stream reassembly, SACK, and PR-SCTP.

    Association::new_client

    fn Association::new_client(cfg : Config) -> Association raise AssocError

    Creates a new client-side SCTP association in the Closed state.

    Association::new_server

    fn Association::new_server(cfg : Config) -> Association raise AssocError

    Creates a new server-side SCTP association in the Closed state.

    Association::poll_outbound

    fn Association::poll_outbound(self : Association) -> Array[Bytes]

    Drains and returns all pending outbound wire SCTP packets.

    Association::process_stateless_init

    fn Association::process_stateless_init(cfg : Config, raw_pkt : BytesView, now_ms : UInt64) -> Bytes raise AssocError

    Stateless SYN-flood resistant INIT responder (RFC 9260 Section 5.1.3). Allocates zero per-client session state and signs a 64-byte HMAC-SHA256 cookie.

    Association::send

    fn Association::send(self : Association, payload : Bytes, opts : SendOptions, now_ms : UInt64) -> Unit raise AssocError

    Enqueues a user message on the specified stream, automatically fragmenting by max_payload_size with B/E flags and transmitting eligible chunks.

    Association::send_heartbeat

    fn Association::send_heartbeat(self : Association, info : Bytes, _now_ms : UInt64) -> Unit raise AssocError

    Sends an RFC 9260 HEARTBEAT chunk carrying caller-provided opaque info.

    Association::shutdown

    fn Association::shutdown(self : Association, now_ms : UInt64) -> Unit raise AssocError

    Initiates a graceful RFC 9260 3-way shutdown (SHUTDOWN -> SHUTDOWN_ACK -> SHUTDOWN_COMPLETE), draining any queued outbound data first.

    Association::state

    fn Association::state(self : Association) -> AssocState

    Returns the current RFC 9260 association state.

    Association::stats

    fn Association::stats(self : Association) -> AssocStats

    Returns a snapshot of congestion, timing, and traffic statistics.

    Association::tick

    fn Association::tick(self : Association, now_ms : UInt64) -> Array[Event]

    Advances protocol timers: T1-init/T1-cookie, T3-rtx timeout with exponential RTO backoff, PR-SCTP timed/max-retransmit abandonment + FORWARD_TSN, and T2-shutdown retransmissions.

    Config

    pub(all) struct Config {
    local_port : UInt
    remote_port : UInt
    local_vtag : UInt
    initial_tsn : UInt
    num_outbound_streams : UInt
    num_inbound_streams : UInt
    a_rwnd : UInt
    max_payload_size : Int
    cookie_secret : Bytes
    cookie_lifetime_ms : UInt64
    rto_initial_ms : UInt64
    rto_max_ms : UInt64
    max_message_size : Int
    } derive(Eq,
    Debug
    )

    Endpoint configuration for a Sans-I/O SCTP association.

    Config::default_client

    fn Config::default_client(local_port : UInt, remote_port : UInt, local_vtag : UInt, initial_tsn : UInt, num_outbound_streams? : UInt, num_inbound_streams? : UInt) -> Config

    Constructs a client configuration with sensible RFC 9260 defaults.

    Config::default_server

    fn Config::default_server(local_port : UInt, remote_port : UInt, local_vtag : UInt, initial_tsn : UInt, cookie_secret : Bytes, num_outbound_streams? : UInt, num_inbound_streams? : UInt) -> Config

    Constructs a server configuration with sensible RFC 9260 defaults.

    DeliveredMessage

    pub(all) struct DeliveredMessage {
    stream_id : UInt
    ppid : UInt
    unordered : Bool
    payload : Bytes
    } derive(Eq,
    Debug
    )

    A fully reassembled user message delivered by the association.

    Event

    pub(all) enum Event {
    Connected
    Message(DeliveredMessage)
    HeartbeatAcked(Bytes)
    PeerShutdown
    Closed
    Aborted(String)
    } derive(Eq,
    Debug
    )

    High-level events produced by the Sans-I/O SCTP association.

    ReliabilityPolicy

    pub(all) enum ReliabilityPolicy {
    Reliable
    MaxRetransmits(Int)
    TimedMs(UInt64)
    } derive(Eq,
    Debug
    )

    RFC 3758 PR-SCTP per-message reliability policy.

    SendOptions

    pub(all) struct SendOptions {
    stream_id : UInt
    ppid : UInt
    unordered : Bool
    reliability : ReliabilityPolicy
    } derive(Eq,
    Debug
    )

    Per-message send options.

    SendOptions::reliable

    fn SendOptions::reliable(stream_id : UInt, ppid? : UInt) -> SendOptions

    Creates default reliable ordered send options on the given stream.

    SendOptions::unordered

    fn SendOptions::unordered(stream_id : UInt, ppid? : UInt, reliability? : ReliabilityPolicy) -> SendOptions

    Creates unordered send options on the given stream.

    DEFAULT_A_RWND

    let DEFAULT_A_RWND : UInt

    Default advertised receiver window (64 KiB).
    let DEFAULT_COOKIE_LIFETIME_MS : UInt64

    Default state cookie lifetime in milliseconds (60 seconds).

    DEFAULT_MAX_MESSAGE_SIZE

    let DEFAULT_MAX_MESSAGE_SIZE : Int

    Default maximum single user message size (64 KiB, anti-OOM bound).

    DEFAULT_MAX_PAYLOAD_SIZE

    let DEFAULT_MAX_PAYLOAD_SIZE : Int

    Default maximum DATA chunk payload size (1200 bytes for safe UDP/IP MTU).

    DEFAULT_RTO_INITIAL_MS

    let DEFAULT_RTO_INITIAL_MS : UInt64

    Default initial retransmission timeout in milliseconds (RFC 9260: 1s).

    DEFAULT_RTO_MAX_MS

    let DEFAULT_RTO_MAX_MS : UInt64

    Default maximum retransmission timeout in milliseconds (RFC 9260: 60s).

    DEFAULT_RTO_MIN_MS

    let DEFAULT_RTO_MIN_MS : UInt64

    Default minimum retransmission timeout in milliseconds.