pub struct TransportConfig { /* 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§
Source§impl TransportConfig
impl TransportConfig
Sourcepub fn max_concurrent_bidi_streams(&mut self, value: VarInt) -> &mut Self
pub fn max_concurrent_bidi_streams(&mut self, value: VarInt) -> &mut Self
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
.
Sourcepub fn max_concurrent_uni_streams(&mut self, value: VarInt) -> &mut Self
pub fn max_concurrent_uni_streams(&mut self, value: VarInt) -> &mut Self
Variant of max_concurrent_bidi_streams
affecting unidirectional streams
Sourcepub fn max_idle_timeout(&mut self, value: Option<IdleTimeout>) -> &mut Self
pub fn max_idle_timeout(&mut self, value: Option<IdleTimeout>) -> &mut Self
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()?));
Sourcepub fn stream_receive_window(&mut self, value: VarInt) -> &mut Self
pub fn stream_receive_window(&mut self, value: VarInt) -> &mut Self
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.
Sourcepub fn receive_window(&mut self, value: VarInt) -> &mut Self
pub fn receive_window(&mut self, value: VarInt) -> &mut Self
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.
Sourcepub fn send_window(&mut self, value: u64) -> &mut Self
pub fn send_window(&mut self, value: u64) -> &mut Self
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.
Sourcepub fn send_fairness(&mut self, value: bool) -> &mut Self
pub fn send_fairness(&mut self, value: bool) -> &mut Self
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.
Sourcepub fn packet_threshold(&mut self, value: u32) -> &mut Self
pub fn packet_threshold(&mut self, value: u32) -> &mut Self
Maximum reordering in packet number space before FACK style loss detection considers a packet lost. Should not be less than 3, per RFC5681.
Sourcepub fn time_threshold(&mut self, value: f32) -> &mut Self
pub fn time_threshold(&mut self, value: f32) -> &mut Self
Maximum reordering in time space before time based loss detection considers a packet lost, as a factor of RTT
Sourcepub fn initial_rtt(&mut self, value: Duration) -> &mut Self
pub fn initial_rtt(&mut self, value: Duration) -> &mut Self
The RTT used before an RTT sample is taken
Sourcepub fn initial_mtu(&mut self, value: u16) -> &mut Self
pub fn initial_mtu(&mut self, value: u16) -> &mut Self
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
.
Sourcepub fn min_mtu(&mut self, value: u16) -> &mut Self
pub fn min_mtu(&mut self, value: u16) -> &mut Self
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.
Sourcepub fn mtu_discovery_config(
&mut self,
value: Option<MtuDiscoveryConfig>,
) -> &mut Self
pub fn mtu_discovery_config( &mut self, value: Option<MtuDiscoveryConfig>, ) -> &mut Self
Specifies the MTU discovery config (see MtuDiscoveryConfig
for details).
Enabled by default.
Sourcepub fn pad_to_mtu(&mut self, value: bool) -> &mut Self
pub fn pad_to_mtu(&mut self, value: bool) -> &mut Self
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.
Sourcepub fn ack_frequency_config(
&mut self,
value: Option<AckFrequencyConfig>,
) -> &mut Self
pub fn ack_frequency_config( &mut self, value: Option<AckFrequencyConfig>, ) -> &mut Self
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.
Sourcepub fn persistent_congestion_threshold(&mut self, value: u32) -> &mut Self
pub fn persistent_congestion_threshold(&mut self, value: u32) -> &mut Self
Number of consecutive PTOs after which network is considered to be experiencing persistent congestion.
Sourcepub fn keep_alive_interval(&mut self, value: Option<Duration>) -> &mut Self
pub fn keep_alive_interval(&mut self, value: Option<Duration>) -> &mut Self
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.
Sourcepub fn crypto_buffer_size(&mut self, value: usize) -> &mut Self
pub fn crypto_buffer_size(&mut self, value: usize) -> &mut Self
Maximum quantity of out-of-order crypto layer data to buffer
Sourcepub fn allow_spin(&mut self, value: bool) -> &mut Self
pub fn allow_spin(&mut self, value: bool) -> &mut Self
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.
Sourcepub fn datagram_receive_buffer_size(
&mut self,
value: Option<usize>,
) -> &mut Self
pub fn datagram_receive_buffer_size( &mut self, value: Option<usize>, ) -> &mut Self
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.
Sourcepub fn datagram_send_buffer_size(&mut self, value: usize) -> &mut Self
pub fn datagram_send_buffer_size(&mut self, value: usize) -> &mut Self
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.
Sourcepub fn congestion_controller_factory(
&mut self,
factory: Arc<dyn ControllerFactory + Send + Sync + 'static>,
) -> &mut Self
pub fn congestion_controller_factory( &mut self, factory: Arc<dyn ControllerFactory + Send + Sync + 'static>, ) -> &mut Self
How to construct new congestion::Controller
s
Typically the refcounted configuration of a congestion::Controller
,
e.g. a congestion::NewRenoConfig
.
§Example
use ant_quic::config::TransportConfig;
let mut config = TransportConfig::default();
// The default uses CubicConfig, but custom implementations can be provided
// by implementing the congestion::ControllerFactory trait
Sourcepub fn enable_segmentation_offload(&mut self, enabled: bool) -> &mut Self
pub fn enable_segmentation_offload(&mut self, enabled: bool) -> &mut Self
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.
Sourcepub fn nat_traversal_config(
&mut self,
config: Option<NatTraversalConfig>,
) -> &mut Self
pub fn nat_traversal_config( &mut self, config: Option<NatTraversalConfig>, ) -> &mut Self
Configure NAT traversal capabilities for this connection
When enabled, this connection will support QUIC NAT traversal extensions including:
- Address candidate advertisement and validation
- Coordinated hole punching through bootstrap nodes
- Multi-path connectivity testing
- Automatic path migration for NAT rebinding
This is required for P2P connections through NATs in Autonomi networks.
Pass None
to disable NAT traversal or use the high-level NAT traversal API
to create appropriate configurations.
Sourcepub fn enable_nat_traversal(&mut self, enabled: bool) -> &mut Self
pub fn enable_nat_traversal(&mut self, enabled: bool) -> &mut Self
Enable NAT traversal with default client configuration
This is a convenience method that enables NAT traversal with sensible defaults
for a client endpoint. Use nat_traversal_config()
for more control.
Sourcepub fn address_discovery_config(
&mut self,
config: Option<AddressDiscoveryConfig>,
) -> &mut Self
pub fn address_discovery_config( &mut self, config: Option<AddressDiscoveryConfig>, ) -> &mut Self
Set the address discovery configuration
This enables the QUIC Address Discovery extension (draft-ietf-quic-address-discovery-00) which allows endpoints to share observed addresses with each other.
Sourcepub fn enable_address_discovery(&mut self, enabled: bool) -> &mut Self
pub fn enable_address_discovery(&mut self, enabled: bool) -> &mut Self
Enable address discovery with default configuration
This is a convenience method that enables address discovery with sensible defaults.
Use address_discovery_config()
for more control.
Sourcepub fn pqc_algorithms(&mut self, algorithms: Option<PqcAlgorithms>) -> &mut Self
pub fn pqc_algorithms(&mut self, algorithms: Option<PqcAlgorithms>) -> &mut Self
Set the Post-Quantum Cryptography algorithms configuration
This advertises which PQC algorithms are supported by this endpoint. When both endpoints support PQC, they can negotiate the use of quantum-resistant algorithms.
Sourcepub fn enable_pqc(&mut self, enabled: bool) -> &mut Self
pub fn enable_pqc(&mut self, enabled: bool) -> &mut Self
Enable Post-Quantum Cryptography with default algorithms
This is a convenience method that enables all standard PQC algorithms.
Use pqc_algorithms()
for more control over which algorithms to support.
Sourcepub fn get_address_discovery_config(&self) -> Option<&AddressDiscoveryConfig>
pub fn get_address_discovery_config(&self) -> Option<&AddressDiscoveryConfig>
Get the address discovery configuration (read-only)
Sourcepub fn get_pqc_algorithms(&self) -> Option<&PqcAlgorithms>
pub fn get_pqc_algorithms(&self) -> Option<&PqcAlgorithms>
Get the PQC algorithms configuration (read-only)
Sourcepub fn get_nat_traversal_config(&self) -> Option<&NatTraversalConfig>
pub fn get_nat_traversal_config(&self) -> Option<&NatTraversalConfig>
Get the NAT traversal configuration (read-only)
Trait Implementations§
Source§impl Clone for TransportConfig
impl Clone for TransportConfig
Source§fn clone(&self) -> TransportConfig
fn clone(&self) -> TransportConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more