QuinnTransportConfig

Struct QuinnTransportConfig 

pub struct QuinnTransportConfig { /* private fields */ }
Expand description

Parameters governing the core QUIC state machine

Default values should be suitable for most internet applications. Applications protocols which forbid remotely-initiated streams should set max_concurrent_bidi_streams and max_concurrent_uni_streams to zero.

In some cases, performance or resource requirements can be improved by tuning these values to suit a particular application and/or network connection. In particular, data window sizes can be tuned for a particular expected round trip time, link capacity, and memory availability. Tuning for higher bandwidths and latencies increases worst-case memory consumption, but does not impair performance at lower bandwidths and latencies. The default configuration is tuned for a 100Mbps link with a 100ms round trip time.

Implementations§

§

impl TransportConfig

pub fn max_concurrent_bidi_streams( &mut self, value: VarInt, ) -> &mut TransportConfig

Maximum number of incoming bidirectional streams that may be open concurrently

Must be nonzero for the peer to open any bidirectional streams.

Worst-case memory use is directly proportional to max_concurrent_bidi_streams * stream_receive_window, with an upper bound proportional to receive_window.

pub fn max_concurrent_uni_streams( &mut self, value: VarInt, ) -> &mut TransportConfig

Variant of max_concurrent_bidi_streams affecting unidirectional streams

pub fn max_idle_timeout( &mut self, value: Option<IdleTimeout>, ) -> &mut TransportConfig

Maximum duration of inactivity to accept before timing out the connection.

The true idle timeout is the minimum of this and the peer’s own max idle timeout. None represents an infinite timeout. Defaults to 30 seconds.

WARNING: If a peer or its network path malfunctions or acts maliciously, an infinite idle timeout can result in permanently hung futures!

let mut config = TransportConfig::default();

// Set the idle timeout as `VarInt`-encoded milliseconds
config.max_idle_timeout(Some(VarInt::from_u32(10_000).into()));

// Set the idle timeout as a `Duration`
config.max_idle_timeout(Some(Duration::from_secs(10).try_into()?));

pub fn stream_receive_window(&mut self, value: VarInt) -> &mut TransportConfig

Maximum number of bytes the peer may transmit without acknowledgement on any one stream before becoming blocked.

This should be set to at least the expected connection latency multiplied by the maximum desired throughput. Setting this smaller than receive_window helps ensure that a single stream doesn’t monopolize receive buffers, which may otherwise occur if the application chooses not to read from a large stream for a time while still requiring data on other streams.

pub fn receive_window(&mut self, value: VarInt) -> &mut TransportConfig

Maximum number of bytes the peer may transmit across all streams of a connection before becoming blocked.

This should be set to at least the expected connection latency multiplied by the maximum desired throughput. Larger values can be useful to allow maximum throughput within a stream while another is blocked.

pub fn send_window(&mut self, value: u64) -> &mut TransportConfig

Maximum number of bytes to transmit to a peer without acknowledgment

Provides an upper bound on memory when communicating with peers that issue large amounts of flow control credit. Endpoints that wish to handle large numbers of connections robustly should take care to set this low enough to guarantee memory exhaustion does not occur if every connection uses the entire window.

pub fn send_fairness(&mut self, value: bool) -> &mut TransportConfig

Whether to implement fair queuing for send streams having the same priority.

When enabled, connections schedule data from outgoing streams having the same priority in a round-robin fashion. When disabled, streams are scheduled in the order they are written to.

Note that this only affects streams with the same priority. Higher priority streams always take precedence over lower priority streams.

Disabling fairness can reduce fragmentation and protocol overhead for workloads that use many small streams.

pub fn packet_threshold(&mut self, value: u32) -> &mut TransportConfig

Maximum reordering in packet number space before FACK style loss detection considers a packet lost. Should not be less than 3, per RFC5681.

pub fn time_threshold(&mut self, value: f32) -> &mut TransportConfig

Maximum reordering in time space before time based loss detection considers a packet lost, as a factor of RTT

pub fn initial_rtt(&mut self, value: Duration) -> &mut TransportConfig

The RTT used before an RTT sample is taken

pub fn initial_mtu(&mut self, value: u16) -> &mut TransportConfig

The initial value to be used as the maximum UDP payload size before running MTU discovery (see TransportConfig::mtu_discovery_config).

Must be at least 1200, which is the default, and known to be safe for typical internet applications. Larger values are more efficient, but increase the risk of packet loss due to exceeding the network path’s IP MTU. If the provided value is higher than what the network path actually supports, packet loss will eventually trigger black hole detection and bring it down to TransportConfig::min_mtu.

pub fn min_mtu(&mut self, value: u16) -> &mut TransportConfig

The maximum UDP payload size guaranteed to be supported by the network.

Must be at least 1200, which is the default, and lower than or equal to TransportConfig::initial_mtu.

Real-world MTUs can vary according to ISP, VPN, and properties of intermediate network links outside of either endpoint’s control. Extreme care should be used when raising this value outside of private networks where these factors are fully controlled. If the provided value is higher than what the network path actually supports, the result will be unpredictable and catastrophic packet loss, without a possibility of repair. Prefer TransportConfig::initial_mtu together with TransportConfig::mtu_discovery_config to set a maximum UDP payload size that robustly adapts to the network.

pub fn mtu_discovery_config( &mut self, value: Option<MtuDiscoveryConfig>, ) -> &mut TransportConfig

Specifies the MTU discovery config (see MtuDiscoveryConfig for details).

Enabled by default.

pub fn pad_to_mtu(&mut self, value: bool) -> &mut TransportConfig

Pad UDP datagrams carrying application data to current maximum UDP payload size

Disabled by default. UDP datagrams containing loss probes are exempt from padding.

Enabling this helps mitigate traffic analysis by network observers, but it increases bandwidth usage. Without this mitigation precise plain text size of application datagrams as well as the total size of stream write bursts can be inferred by observers under certain conditions. This analysis requires either an uncongested connection or application datagrams too large to be coalesced.

pub fn ack_frequency_config( &mut self, value: Option<AckFrequencyConfig>, ) -> &mut TransportConfig

Specifies the ACK frequency config (see AckFrequencyConfig for details)

The provided configuration will be ignored if the peer does not support the acknowledgement frequency QUIC extension.

Defaults to None, which disables controlling the peer’s acknowledgement frequency. Even if set to None, the local side still supports the acknowledgement frequency QUIC extension and may use it in other ways.

pub fn persistent_congestion_threshold( &mut self, value: u32, ) -> &mut TransportConfig

Number of consecutive PTOs after which network is considered to be experiencing persistent congestion.

pub fn keep_alive_interval( &mut self, value: Option<Duration>, ) -> &mut TransportConfig

Period of inactivity before sending a keep-alive packet

Keep-alive packets prevent an inactive but otherwise healthy connection from timing out.

None to disable, which is the default. Only one side of any given connection needs keep-alive enabled for the connection to be preserved. Must be set lower than the idle_timeout of both peers to be effective.

pub fn crypto_buffer_size(&mut self, value: usize) -> &mut TransportConfig

Maximum quantity of out-of-order crypto layer data to buffer

pub fn allow_spin(&mut self, value: bool) -> &mut TransportConfig

Whether the implementation is permitted to set the spin bit on this connection

This allows passive observers to easily judge the round trip time of a connection, which can be useful for network administration but sacrifices a small amount of privacy.

pub fn datagram_receive_buffer_size( &mut self, value: Option<usize>, ) -> &mut TransportConfig

Maximum number of incoming application datagram bytes to buffer, or None to disable incoming datagrams

The peer is forbidden to send single datagrams larger than this size. If the aggregate size of all datagrams that have been received from the peer but not consumed by the application exceeds this value, old datagrams are dropped until it is no longer exceeded.

pub fn datagram_send_buffer_size( &mut self, value: usize, ) -> &mut TransportConfig

Maximum number of outgoing application datagram bytes to buffer

While datagrams are sent ASAP, it is possible for an application to generate data faster than the link, or even the underlying hardware, can transmit them. This limits the amount of memory that may be consumed in that case. When the send buffer is full and a new datagram is sent, older datagrams are dropped until sufficient space is available.

pub fn congestion_controller_factory( &mut self, factory: Arc<dyn ControllerFactory + Send + Sync>, ) -> &mut TransportConfig

How to construct new congestion::Controllers

Typically the refcounted configuration of a congestion::Controller, e.g. a congestion::NewRenoConfig.

§Example
let mut config = TransportConfig::default();
config.congestion_controller_factory(Arc::new(congestion::NewRenoConfig::default()));

pub fn enable_segmentation_offload( &mut self, enabled: bool, ) -> &mut TransportConfig

Whether to use “Generic Segmentation Offload” to accelerate transmits, when supported by the environment

Defaults to true.

GSO dramatically reduces CPU consumption when sending large numbers of packets with the same headers, such as when transmitting bulk data on a connection. However, it is not supported by all network interface drivers or packet inspection tools. quinn-udp will attempt to disable GSO automatically when unavailable, but this can lead to spurious packet loss at startup, temporarily degrading performance.

pub fn send_observed_address_reports( &mut self, enabled: bool, ) -> &mut TransportConfig

Whether to send observed address reports to peers.

This will aid peers in inferring their reachable address, which in most NATd networks will not be easily available to them.

pub fn receive_observed_address_reports( &mut self, enabled: bool, ) -> &mut TransportConfig

Whether to receive observed address reports from other peers.

Peers with the address discovery extension enabled that are willing to provide observed address reports will do so if this transport parameter is set. In general, observed address reports cannot be trusted. This, however, can aid the current endpoint in inferring its reachable address, which in most NATd networks will not be easily available.

pub fn max_concurrent_multipath_paths( &mut self, max_concurrent: u32, ) -> &mut TransportConfig

Enables the Multipath Extension for QUIC.

Setting this to any nonzero value will enable the Multipath Extension for QUIC, https://datatracker.ietf.org/doc/draft-ietf-quic-multipath/.

The value provided specifies the number maximum number of paths this endpoint may open concurrently when multipath is negotiated. For any path to be opened, the remote must enable multipath as well.

pub fn default_path_max_idle_timeout( &mut self, timeout: Option<Duration>, ) -> &mut TransportConfig

Sets a default per-path maximum idle timeout

If the path is idle for this long the path will be abandoned. Bear in mind this will interact with the TransportConfig::max_idle_timeout, if the last path is abandoned the entire connection will be closed.

You can also change this using Connection::set_path_max_idle_timeout for existing paths.

pub fn default_path_keep_alive_interval( &mut self, interval: Option<Duration>, ) -> &mut TransportConfig

Sets a default per-path keep alive interval

Note that this does not interact with the connection-wide TransportConfig::keep_alive_interval. This setting will keep this path active, TransportConfig::keep_alive_interval will keep the connection active, with no control over which path is used for this.

You can also change this using Connection::set_path_keep_alive_interval for existing path.

pub fn set_max_nat_traversal_concurrent_attempts( &mut self, max_concurrent: u32, ) -> &mut TransportConfig

Sets the maximum number of concurrent nat traversal attempts to initiate as a client, or to allow as a server.

Setting this to any nonzero value will enable the Nat Traversal Extension for QUIC, see https://www.ietf.org/archive/id/draft-seemann-quic-nat-traversal-02.html

This implementation expects the multipath extension to be enabled as well. if not yet enabled via Self::max_concurrent_multipath_paths, a default value of [DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED] will be used.

pub fn get_nat_traversal_concurrency_limit(&self) -> Option<VarInt>

Gets the maximum number of concurrent attempts for nat traversal

If this is Some, the value is guaranteed to be non zero.

Trait Implementations§

§

impl Debug for TransportConfig

§

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

Formats the value using the given formatter. Read more
§

impl Default for TransportConfig

§

fn default() -> TransportConfig

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more