Skip to main content

TransportConfig

Struct TransportConfig 

Source
pub struct TransportConfig { /* private fields */ }
Expand description

Config collects the arguments to create_association construction into a single structure

Implementations§

Source§

impl TransportConfig

Source

pub fn with_zero_window_overcommit(self, value: bool) -> Self

Whether a receiver that advertised a closed window (a_rwnd 0) still takes the next in-sequence DATA chunk when nothing is readable: the chunk that would complete a message the full buffer holds the start of (webrtc-rs/webrtc#822), up to one message beyond the buffer. Off by default: RFC 9260 section 6.2, “When the receiver’s advertised window is 0, the receiver MUST drop any new incoming DATA chunk with a TSN larger than the largest TSN received so far”. While the advertised window is open, a full buffer takes that chunk either way (the RFC rule binds a closed advertised window only).

An application that reads with Stream::read_part does not need it: partial delivery (RFC 9260 6.9) empties a buffer full of incomplete messages, so the window opens again and the drop never stops a message. It is for an application that reads whole messages only (read_sctp) and accepts messages larger than its receive buffer, or negotiates user message interleaving (RFC 8260), where several part-received messages, each smaller than the buffer, can fill it together with none of them complete. Without it such a reader can deadlock: nothing is readable, so the application frees nothing, and the chunk that would complete a message is dropped on every retransmission.

Source

pub fn zero_window_overcommit(&self) -> bool

Source

pub fn with_zero_window_renege(self, value: bool) -> Self

Whether a receiver that advertised a closed window (a_rwnd 0) and receives a DATA chunk filling a gap below the largest TSN it holds makes room for it by dropping the largest TSN held for reordering: RFC 9260 section 6.2, “if the new incoming DATA chunk holds a TSN value less than the largest TSN received so far, then the receiver SHOULD drop the largest TSN held for reordering and accept the new incoming DATA chunk”. Off by default: the gap filler is then taken with nothing dropped, up to one message beyond the buffer.

The chunk dropped was reported in a Gap Ack Block, so dropping it is a renege (RFC 9260 6.2.1 D iii): it is no longer reported (6.2: “MUST NOT include” it), and the sender has to send it again. libwebrtc’s dcSCTP sender never sends again a chunk a Gap Ack Block acknowledged (net/dcsctp/tx/outstanding_data.cc @ a222406d, NackItem returns for an acknowledged item and NackAll skips them), so a reliable channel from a browser stops for good at the dropped chunk: dcSCTP is the SCTP stack of Chromium, of WebKit’s libwebrtc and, since Firefox 146 (Mozilla bug 1997590), of Firefox. This crate sends it again. A chunk is dropped only when its message is still held for reordering: not readable whole, and not in partial delivery (RFC 9260 6.9). When no held chunk is such, the gap filler is taken as without the setting.

Source

pub fn zero_window_renege(&self) -> bool

Source

pub fn with_send_buffer_size(self, value: Option<u32>) -> Self

The size of the association’s send buffer: the bytes of user data written and not yet acknowledged (queued, or sent and outstanding), over every stream. A write that would take the buffer past it fails with Error::ErrBufferFull and queues nothing, unless the priority policy makes room for it (below). None, the default, sets no limit.

The priority policy of RFC 7496 section 3.2: “When storing a user message in the send buffer while there is not enough available space, the SCTP stack at the sender side MAY abandon other user message(s) of the same SCTP association (with the same or a different stream) with a priority lower than the provided one. User messages sent reliably are considered to have a priority higher than all messages sent with the Priority Policy.” A stream sends with the policy after Stream::set_reliability_params with ReliabilityType::Priority and the priority (section 4.2: 0 is the highest, a larger value a lower priority). When a write does not fit, the messages of that policy with a lower priority than the one written are abandoned, the lowest priority first and, among equal ones, the one written first, until it fits; a message written without the policy (reliable, or with a lifetime or a retransmission limit) ranks above all of them. Only messages none of which has been sent are abandoned: that takes no TSN and needs no FORWARD TSN, so the peer sees nothing of it. Each is reported as StreamEvent::MessageAbandoned with transmitted: false. When abandoning every such message would not make room, none is abandoned and the write fails. A message of the policy that has been sent is retransmitted as a reliable one is.

WebRTC has no use for it: a data channel’s priority (RFC 8831 section 6.4, RFC 8832 section 5.1) is the weight of the stream scheduler (Stream::set_priority), and neither the Data Channel Establishment Protocol nor RTCDataChannelInit has a way to ask for this policy.

Source

pub fn send_buffer_size(&self) -> Option<u32>

Whether DATA goes in the packet of the COOKIE ECHO: RFC 9260 section 5.1 C, “The COOKIE ECHO chunk MAY be bundled with any pending outbound DATA chunks, but it MUST be the first chunk in the packet and, until the COOKIE ACK chunk is returned, the sender MUST NOT send any other packets to the peer” (and 3.3.11: the COOKIE ECHO “MAY be bundled with one or more DATA chunks in the same packet”). Off by default.

On, a stream takes writes in COOKIE-ECHOED (the INIT ACK has told what the peer accepts; in COOKIE-WAIT writes are refused as before), and the packet of each COOKIE ECHO, the first and every T1-cookie retransmission, carries after it the DATA that fits the path MTU: the DATA sent with an earlier COOKIE ECHO again first (counted as retransmissions, no round trip measured with them, RFC 9260 6.3.1 C5), then DATA written since, as far as the peer’s a_rwnd and the congestion window allow. DATA written after a COOKIE ECHO has left waits for the COOKIE ACK, or for the next retransmission. The first DATA then reaches the peer one round trip earlier. The receiver takes the COOKIE ECHO first (RFC 9260 5.1 D), so the DATA arrives on an ESTABLISHED association. libwebrtc’s dcSCTP, the SCTP stack of the browsers, sends its own DATA so (TransmissionControlBlock::SendBufferedPackets in net/dcsctp/socket/transmission_control_block.cc puts the COOKIE ECHO first in a packet of DATA and sends no other packet until the COOKIE ACK).

Off by default because WebRTC never has DATA to bundle: the data channel layer writes nothing before the association is up (Event::Connected, which follows the COOKIE ACK), so the setting would not change what a peer connection sends.

Source

pub fn with_forward_tsn_delay(self, value: Option<Duration>) -> Self

How long a FORWARD TSN (RFC 3758) or I-FORWARD-TSN (RFC 8260) that finds no DATA to go with may wait for some. RFC 3758 3.5 F2: “The data sender SHOULD always attempt to bundle an outgoing FORWARD TSN with outbound DATA chunks for efficiency. A sender MAY even choose to delay the sending of the FORWARD TSN in the hope of bundling it with an outbound DATA chunk.” F3: “Any delay applied to the sending of FORWARD TSN chunk SHOULD NOT exceed 200ms and MUST NOT exceed 500ms”, so a longer value is taken as 200 ms.

None, the default, does not wait: a FORWARD TSN goes with DATA sent at the same time when a packet has room for it, and alone otherwise, at the instant the Advanced.Peer.Ack.Point moves. With a delay, a FORWARD TSN that would go alone is held: the first DATA sent in the delay carries it, and at the end of the delay, counted from when it was first due, it goes alone. A SACK that catches up with the Advanced.Peer.Ack.Point in the meantime makes it unnecessary, and it is not sent. The T3-rtx timer runs throughout (RFC 3758 3.5 C5). The delay holds back the receiver’s delivery of what it keeps for reordering behind the abandoned message (F3’s NOTE).

Source

pub fn forward_tsn_delay(&self) -> Option<Duration>

Source

pub fn with_partial_delivery_point(self, value: u32) -> Self

The partial delivery point (RFC 6458 section 8.1.21, SCTP_PARTIAL_DELIVERY_POINT): once the fragments of a message held from its first one on, without a gap, come to this many bytes, Stream::read_part gives them out before the message is complete (RFC 9260 section 6.9). A message no larger than this is read whole, unless the receive buffer runs out of space with nothing readable whole: then RFC 9260 6.9’s “it SHOULD dispatch part of its inbound message” applies to a message of any size. Taken as at least 1 and at most the receive buffer size (RFC 6458: the point may not be set “larger than the socket receive buffer size”).

The default is half the receive buffer (with_max_receive_buffer_size); the RFCs give none. From there a single message never closes the window by itself: when it starts partial delivery at least half the buffer is free, which is at or above the window silly window avoidance advertises as closed (min(buffer / 2, one full chunk), RFC 9260 6.2), so RFC 9260 6.2’s drop never meets it. And every message up to half the buffer (512 KiB with the default 1 MiB, above any max-message-size a data channel offers by default) is still read whole.

read_sctp reads whole messages only; an application that reads with it alone does not use partial delivery.

Source

pub fn with_fragmentation(self, enabled: bool) -> Self

Turns fragmentation of user messages off (RFC 9260 6.9: “An implementation MAY allow the upper layer to disable fragmentation”). The association then acts “just like an implementation that does NOT support fragmentation”: a message that does not fit in one DATA chunk of a full-sized packet (the PMDCS less the chunk header) is refused with Error::ErrOutboundPacketTooLarge instead of being sent in fragments. Off by default.

Source

pub fn fragmentation(&self) -> bool

Whether user messages are fragmented: see with_fragmentation.

Source

pub fn partial_delivery_point(&self) -> u32

The partial delivery point in effect: see with_partial_delivery_point.

Source

pub fn with_path_mtu_discovery( self, value: Option<PathMtuDiscoveryConfig>, ) -> Self

Path MTU discovery (DPLPMTUD, RFC 8899 section 6.2, with the PAD chunk of RFC 4820): once established, the association confirms its packet size (what Association::set_path_mtu set, else the default) with a probe, searches for a larger one up to PathMtuDiscoveryConfig::with_max_path_mtu, and falls back to it when the path stops carrying the larger size (RFC 9260 section 7.3; RFC 8261 section 4: SCTP over DTLS “MUST implement and use” a discovery method that works without ICMP). None, the crate’s default, keeps the packet size where the transport sets it: the transport knows the largest packet worth probing for, so it turns discovery on. The rtci peer connection does, by default (SettingEngineBuilder::with_sctp_path_mtu_discovery).

Source

pub fn path_mtu_discovery(&self) -> Option<PathMtuDiscoveryConfig>

The path MTU discovery settings, see with_path_mtu_discovery.

Source

pub fn with_slow_start_growth_limit(self, value: u32) -> Self

Sets L of RFC 9260 section 7.2.1: in slow start one SACK grows the congestion window by at most the bytes it acknowledges and at most L packets (L x PMDCS). The RFC says L SHOULD be 1 and MAY be larger (RFC 3465 discusses the choice): 1 is the default. A receiver that acknowledges many packets with one SACK, as one that reads its socket in batches does, makes a sender with L = 1 leave slow start slowly; a larger L restores the faster ramp at the price the RFC names (a burst after such a SACK, and trust in the receiver not to split its acknowledgements). Zero counts as one.

Source

pub fn slow_start_growth_limit(&self) -> u32

Source

pub fn with_partial_reliability(self, value: bool) -> Self

Whether PR-SCTP (RFC 3758) is announced to the peer and used. On by default, as WebRTC data channels need it (RFC 8831 section 6.1). Off, neither chunk 192 nor the Forward-TSN-Supported parameter is announced, no message is ever abandoned, and a FORWARD TSN from the peer is answered as an unrecognized chunk.

Source

pub fn partial_reliability(&self) -> bool

Source

pub fn with_message_interleaving(self, value: bool) -> Self

Whether user message interleaving (RFC 8260) is announced to the peer. When the peer announces it too, user data travels in I-DATA chunks: the fragments of messages on different streams may be interleaved, so a large message on one stream no longer holds up the others, and the stream scheduler chooses the stream for every chunk. RFC 8831 section 6.1 says WebRTC data channels SHOULD use it. Off by default; an application reads whole messages either way, so it needs no change to turn it on.

Source

pub fn message_interleaving(&self) -> bool

Source

pub fn with_zero_checksum(self, value: bool) -> Self

Says that the association runs over DTLS (RFC 8261), which detects errors better than SCTP’s CRC32c does, and so allows the zero checksum of RFC 9653 with the “SCTP over DTLS” error detection method (section 6):

  • the INIT or INIT ACK carries the Zero Checksum Acceptable parameter, and packets that arrive with a checksum of zero are taken, their CRC32c not computed;
  • when the peer announces the same, packets are sent with a checksum of zero and their CRC32c is not computed either. The packets RFC 9653 section 5.2 excepts keep a correct one: an INIT, a COOKIE ECHO, an answer to an out-of-the-blue packet.

Off by default: every packet carries its CRC32c and one without is dropped. It MUST NOT be turned on for an association that does not run over DTLS; a WebRTC data channel transport always does.

Source

pub fn zero_checksum(&self) -> bool

Source

pub fn with_sack_delay(self, value: Duration) -> Self

Sets SACK.Delay (RFC 9260 sections 6.2 and 16): how long the acknowledgement of a DATA chunk may wait for a second one. Defaults to 200 ms. The RFC forbids more than 500 ms, so a longer delay is taken as 500 ms.

Source

pub fn sack_delay(&self) -> Duration

SACK.Delay, see with_sack_delay.

Source

pub fn with_max_burst(self, value: Option<u32>) -> Self

Sets Max.Burst (RFC 9260 sections 6.1 D and 16): before DATA is sent the congestion window is brought down to what is outstanding plus this many packets, so that one SACK for many packets does not release as many at once. Defaults to 4, the value the RFC recommends. None applies no limit: a peer that acknowledges in batches (one that reads its socket in bursts) otherwise has this side’s window cut back on every SACK.

Source

pub fn max_burst(&self) -> Option<u32>

Max.Burst, see with_max_burst.

Source

pub fn with_heartbeat_interval(self, value: Option<Duration>) -> Self

Sets HB.interval (RFC 9260 8.3, 16): an association whose path has been idle for an RTO plus this long sends a HEARTBEAT, which measures the round trip and shows that the peer is still there. One left unanswered counts toward TimerConfig::max_t3_rtx_retrans. Defaults to 30 seconds; None sends no HEARTBEAT.

Source

pub fn heartbeat_interval(&self) -> Option<Duration>

HB.interval, see with_heartbeat_interval.

Sets Valid.Cookie.Life: how long after an INIT ACK its State Cookie is accepted in a COOKIE ECHO (RFC 9260 5.1.3, 16). Later it is refused with a “Stale Cookie” error and the peer starts again. Defaults to 60 seconds.

Valid.Cookie.Life, see with_valid_cookie_life.

Source

pub fn with_sctp_port(self, value: u16) -> Self

Sets this endpoint’s SCTP port, the source port of what it sends (RFC 8841 5: its own a=sctp-port). Defaults to 5000. Port 0 MUST NOT be used (RFC 9260 section 3.1): Endpoint::connect refuses a configuration with it (ConnectError::ZeroSctpPort), and an accepting endpoint answers on the INIT’s ports.

Source

pub fn with_remote_sctp_port(self, value: u16) -> Self

Sets the peer’s SCTP port, the destination port of the INIT this endpoint sends when it initiates (RFC 8841 5: the remote a=sctp-port). Defaults to 5000. An endpoint that accepts an association answers on the ports of the INIT it received. Port 0 is refused by Endpoint::connect (RFC 9260 section 3.1).

Source

pub fn with_max_receive_buffer_size(self, value: u32) -> Self

Sets the advertised receive window (a_rwnd), bounding how much unacknowledged data a peer may have in flight toward this endpoint. At least 1500: RFC 9260 3.3.2 and 3.3.3 forbid a smaller a_rwnd in the INIT and INIT ACK, so a smaller value is raised to it.

Source

pub fn with_max_message_size(self, value: u32) -> Self

Sets the largest message this endpoint will send, which is the peer’s limit (RFC 8841 6.1: the remote max-message-size). Also the largest it will accept unless with_max_receive_message_size sets that apart.

Source

pub fn with_max_receive_message_size(self, value: u32) -> Self

Sets the largest message this endpoint will accept, which is the limit it advertised itself (RFC 8841 6.1: the local max-message-size). Each direction has its own limit; the receive buffer keeps room for one message of this size beyond its bound, so a message larger than the buffer can still be reassembled.

Source

pub fn with_max_num_outbound_streams(self, value: u16) -> Self

Sets how many outbound streams to request during the handshake. At least 1: RFC 9260 3.3.2 and 3.3.3 forbid 0 in the INIT and INIT ACK.

Source

pub fn with_max_num_inbound_streams(self, value: u16) -> Self

Sets how many inbound streams this endpoint will accept. At least 1, as for the outbound streams.

Source

pub fn with_handshake_timers_back_off_rto(self, value: bool) -> Self

Whether an expiry of T1-init or T1-cookie backs off the RTO of the path, as a T3-rtx expiry does. On by default: RFC 9260 section 5.1, “The T1-init timer and T1-cookie timer SHOULD follow the same rules given in Section 6.3”, whose rule E2 (6.3.3) is “set RTO = RTO * 2 (‘back off the timer’)” for the destination, bounded by RTO.Max. Each timer is started with the path’s RTO, so T1-cookie starts where T1-init’s backoff left the RTO, and the first DATA after the handshake does too, until a round trip is measured (6.3.1 C2).

false is what libwebrtc’s dcSCTP does (t1_init_ and t1_cookie_ in net/dcsctp/socket/dcsctp_socket.cc: each timer starts at its own 1 s and doubles by itself): each timer starts at RTO.Initial and doubles on its own expiries, and the RTO the data transfer uses is left alone, so the first DATA after a handshake that lost packets is retransmitted an RTO.Initial after it is sent.

Source

pub fn handshake_timers_back_off_rto(&self) -> bool

Source

pub fn with_timer_config(self, value: TimerConfig) -> Self

Overrides the retransmission limits; see TimerConfig.

Source

pub fn with_rto_config(self, value: RtoConfig) -> Self

Sets RTO.Initial, RTO.Min and RTO.Max (RFC 9260 sections 6.3.1 and 16); see RtoConfig. The defaults are the RFC’s: 1, 1 and 60 seconds. With TimerConfig::max_t3_rtx_retrans (Association.Max.Retrans) they bound how long an unanswered peer is retransmitted to before the association fails.

Source

pub fn with_stream_scheduler(self, value: StreamScheduler) -> Self

Chooses how the next message to send is picked among the streams.

Source

pub fn sctp_port(&self) -> u16

The configured SCTP port.

Source

pub fn remote_sctp_port(&self) -> u16

The configured SCTP port of the peer.

Source

pub fn max_receive_buffer_size(&self) -> u32

The configured receive window in bytes.

Source

pub fn max_message_size(&self) -> u32

The configured maximum message size to send, in bytes.

Source

pub fn max_receive_message_size(&self) -> u32

The configured maximum message size to accept, in bytes: the send limit unless set apart with with_max_receive_message_size.

Source

pub fn max_num_outbound_streams(&self) -> u16

The configured outbound stream count.

Source

pub fn max_num_inbound_streams(&self) -> u16

The configured inbound stream count.

Source

pub fn timer_config(&self) -> TimerConfig

The configured retransmission limits.

Source

pub fn rto_config(&self) -> RtoConfig

The configured RTO bounds.

Source

pub fn stream_scheduler(&self) -> StreamScheduler

The configured stream scheduler.

Trait Implementations§

Source§

impl Clone for TransportConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TransportConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TransportConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.