pub struct QuicTransportConfigBuilder(/* private fields */);Expand description
Builder for a QuicTransportConfig.
Implementations§
Source§impl QuicTransportConfigBuilder
impl QuicTransportConfigBuilder
Sourcepub fn build(self) -> QuicTransportConfig
pub fn build(self) -> QuicTransportConfig
Builds a QuicTransportConfig from the builder.
Sourcepub fn max_concurrent_bidi_streams(self, value: VarInt) -> Self
pub fn max_concurrent_bidi_streams(self, value: VarInt) -> 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(self, value: VarInt) -> Self
pub fn max_concurrent_uni_streams(self, value: VarInt) -> Self
Variant of max_concurrent_bidi_streams affecting unidirectional streams.
Sourcepub fn max_idle_timeout(self, value: Option<IdleTimeout>) -> Self
pub fn max_idle_timeout(self, value: Option<IdleTimeout>) -> 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 builder = QuicTransportConfig::builder()
// Set the idle timeout as `VarInt`-encoded milliseconds
.max_idle_timeout(Some(VarInt::from_u32(10_000).into()));
// Set the idle timeout as a `Duration`
builder = builder.max_idle_timeout(Some(Duration::from_secs(10).try_into()?));
let _cfg = builder.build();
Sourcepub fn stream_receive_window(self, value: VarInt) -> Self
pub fn stream_receive_window(self, value: VarInt) -> 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(self, value: VarInt) -> Self
pub fn receive_window(self, value: VarInt) -> 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(self, value: u64) -> Self
pub fn send_window(self, value: u64) -> 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(self, value: bool) -> Self
👎Deprecated: Send fairness is now always enabled. Neither enabling nor disabling it has no effect.
pub fn send_fairness(self, value: bool) -> 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(self, value: u32) -> Self
pub fn packet_threshold(self, value: u32) -> 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(self, value: f32) -> Self
pub fn time_threshold(self, value: f32) -> Self
Maximum reordering in time space before time based loss detection considers a packet lost, as a factor of RTT.
Sourcepub fn initial_rtt(self, value: Duration) -> Self
pub fn initial_rtt(self, value: Duration) -> Self
The RTT used before an RTT sample is taken.
Sourcepub fn initial_mtu(self, value: u16) -> Self
pub fn initial_mtu(self, value: u16) -> Self
The initial value to be used as the maximum UDP payload size before running MTU discovery
(see QuicTransportConfigBuilder::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 QuicTransportConfigBuilder::min_mtu.
Sourcepub fn min_mtu(self, value: u16) -> Self
pub fn min_mtu(self, value: u16) -> 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
QuicTransportConfigBuilder::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
QuicTransportConfigBuilder::initial_mtu together with
QuicTransportConfigBuilder::mtu_discovery_config to set a maximum UDP payload size that robustly
adapts to the network.
Sourcepub fn mtu_discovery_config(self, value: Option<MtuDiscoveryConfig>) -> Self
pub fn mtu_discovery_config(self, value: Option<MtuDiscoveryConfig>) -> Self
Specifies the MTU discovery config (see MtuDiscoveryConfig for details).
Enabled by default.
Sourcepub fn pad_to_mtu(self, value: bool) -> Self
pub fn pad_to_mtu(self, value: bool) -> 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(self, value: Option<AckFrequencyConfig>) -> Self
pub fn ack_frequency_config(self, value: Option<AckFrequencyConfig>) -> 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(self, value: u32) -> Self
pub fn persistent_congestion_threshold(self, value: u32) -> Self
Number of consecutive PTOs after which network is considered to be experiencing persistent congestion.
Sourcepub fn keep_alive_interval(self, value: Duration) -> Self
pub fn keep_alive_interval(self, value: Duration) -> Self
Period of inactivity before sending a keep-alive packet.
Keep-alive packets prevent an inactive but otherwise healthy connection from timing out. They are important to keep NAT bindings alive and firewalls open.
The default is 5s, please be careful when modifying this as it may affect connection stability. Must be set lower than the idle_timeout of both peers to be effective.
Sourcepub fn crypto_buffer_size(self, value: usize) -> Self
pub fn crypto_buffer_size(self, value: usize) -> Self
Maximum quantity of out-of-order crypto layer data to buffer.
Sourcepub fn allow_spin(self, value: bool) -> Self
pub fn allow_spin(self, value: bool) -> 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(self, value: Option<usize>) -> Self
pub fn datagram_receive_buffer_size(self, value: Option<usize>) -> 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(self, value: usize) -> Self
pub fn datagram_send_buffer_size(self, value: usize) -> 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(
self,
factory: Arc<dyn ControllerFactory + Send + Sync + 'static>,
) -> Self
pub fn congestion_controller_factory( self, factory: Arc<dyn ControllerFactory + Send + Sync + 'static>, ) -> Self
How to construct new congestion::Controllers.
Typically the refcounted configuration of a congestion::Controller,
e.g. a congestion::NewRenoConfig.
§Example
let config = QuicTransportConfig::builder()
.congestion_controller_factory(Arc::new(congestion::NewRenoConfig::default()))
.build();Sourcepub fn enable_segmentation_offload(self, enabled: bool) -> Self
pub fn enable_segmentation_offload(self, enabled: bool) -> 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. noq-udp will attempt to
disable GSO automatically when unavailable, but this can lead to spurious packet loss at
startup, temporarily degrading performance.
Sourcepub fn send_observed_address_reports(self, enabled: bool) -> Self
pub fn send_observed_address_reports(self, enabled: bool) -> Self
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.
Sourcepub fn receive_observed_address_reports(self, enabled: bool) -> Self
pub fn receive_observed_address_reports(self, enabled: bool) -> Self
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.
Sourcepub fn max_concurrent_multipath_paths(self, max_concurrent: u32) -> Self
pub fn max_concurrent_multipath_paths(self, max_concurrent: u32) -> Self
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.
Note: this method will ignore values less than the recommended 13 and will log a warning.
Sourcepub fn default_path_max_idle_timeout(self, timeout: Duration) -> Self
pub fn default_path_max_idle_timeout(self, timeout: Duration) -> Self
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 QuicTransportConfigBuilder::max_idle_timeout, if the last path is
abandoned the entire connection will be closed.
Note: values higher than PATH_MAX_IDLE_TIMEOUT (15 seconds) are clamped and a warning is logged.
Sourcepub fn default_path_keep_alive_interval(self, interval: Duration) -> Self
pub fn default_path_keep_alive_interval(self, interval: Duration) -> Self
Sets a default per-path keep alive interval.
Note that this does not interact with the connection-wide
QuicTransportConfigBuilder::keep_alive_interval. This setting will keep this path active,
QuicTransportConfigBuilder::keep_alive_interval will keep the connection active, with no
control over which path is used for this.
Note: this method will ignore values higher than the recommended 5 seconds and will log a warning.
Sourcepub fn max_remote_nat_traversal_addresses(self, max_addresses: u8) -> Self
pub fn max_remote_nat_traversal_addresses(self, max_addresses: u8) -> Self
Sets the maximum number of nat traversal addresses this endpoint allows the remote to advertise.
Setting this to any nonzero value will enable Iroh’s holepunching, loosely based in 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
8 will be used.
Note: this method will ignore values less than the recommended 8 and will log a warning.
Sourcepub fn qlog_factory(self, factory: Arc<dyn QlogFactory>) -> Self
Available on crate feature qlog only.
pub fn qlog_factory(self, factory: Arc<dyn QlogFactory>) -> Self
qlog only.Configures qlog capturing by setting a QlogFactory.
This assigns a QlogFactory that produces qlog capture configurations for
individual connections.
Sourcepub fn qlog_from_env(self, prefix: &str) -> Self
Available on crate feature qlog only.
pub fn qlog_from_env(self, prefix: &str) -> Self
qlog only.Configures qlog capturing through the QLOGDIR environment variable.
This uses QlogFileFactory::from_env to create a factory to write qlog traces
into the directory set through the QLOGDIR environment variable.
If QLOGDIR is not set, no traces will be written. If QLOGDIR is set to a path
that does not exist, it will be created.
The files will be prefixed with prefix.
Sourcepub fn qlog_from_path(self, path: impl AsRef<Path>, prefix: &str) -> Self
Available on crate feature qlog only.
pub fn qlog_from_path(self, path: impl AsRef<Path>, prefix: &str) -> Self
qlog only.Configures qlog capturing into a directory.
This uses QlogFileFactory to create a factory to write qlog traces into
the specified directory. The files will be prefixed with prefix.
Trait Implementations§
Source§impl Clone for QuicTransportConfigBuilder
impl Clone for QuicTransportConfigBuilder
Source§fn clone(&self) -> QuicTransportConfigBuilder
fn clone(&self) -> QuicTransportConfigBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for QuicTransportConfigBuilder
impl !RefUnwindSafe for QuicTransportConfigBuilder
impl Send for QuicTransportConfigBuilder
impl Sync for QuicTransportConfigBuilder
impl Unpin for QuicTransportConfigBuilder
impl !UnwindSafe for QuicTransportConfigBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more