Struct yamux::Config

source ·
pub struct Config { /* private fields */ }
Expand description

Yamux configuration.

The default configuration values are as follows:

  • max. for the total receive window size across all streams of a connection = 1 GiB
  • max. number of streams = 512
  • read after close = true
  • split send size = 16 KiB

Implementations§

source§

impl Config

source

pub fn set_max_connection_receive_window( &mut self, n: Option<usize> ) -> &mut Self

Set the upper limit for the total receive window size across all streams of a connection.

Must be >= 256 KiB * max_num_streams to allow each stream at least the Yamux default window size.

The window of a stream starts at 256 KiB and is increased (auto-tuned) based on the connection’s round-trip time and the stream’s bandwidth (striving for the bandwidth-delay-product).

Set to None to disable limit, i.e. allow each stream to grow receive window based on connection’s round-trip time and stream’s bandwidth without limit.

DOS attack mitigation

A remote node (attacker) might trick the local node (target) into allocating large stream receive windows, trying to make the local node run out of memory.

This attack is difficult, as the local node only increases the stream receive window up to 2x the bandwidth-delay-product, where bandwidth is the amount of bytes read, not just received. In other words, the attacker has to send (and have the local node read) significant amount of bytes on a stream over a long period of time to increase the stream receive window. E.g. on a 60ms 10Gbit/s connection the bandwidth-delay-product is ~75 MiB and thus the local node will at most allocate ~150 MiB (2x bandwidth-delay-product) per stream.

Despite the difficulty of the attack one should choose a reasonable max_connection_receive_window to protect against this attack, especially since an attacker might use more than one stream per connection.

source

pub fn set_max_num_streams(&mut self, n: usize) -> &mut Self

Set the max. number of streams per connection.

source

pub fn set_read_after_close(&mut self, b: bool) -> &mut Self

Allow or disallow streams to read from buffered data after the connection has been closed.

source

pub fn set_split_send_size(&mut self, n: usize) -> &mut Self

Set the max. payload size used when sending data frames. Payloads larger than the configured max. will be split.

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Config

source§

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

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

impl Default for Config

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> 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,

§

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>,

§

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>,

§

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