Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions neqo-transport/src/connection/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ pub struct ConnectionParameters {
max_streams_bidi: u64,
/// Initial limit on unidirectional streams that this endpoint creates.
max_streams_uni: u64,
/// > The maximum UDP payload size parameter is an integer value that limits
/// > the size of UDP payloads that the endpoint is willing to receive. UDP
/// > datagrams with payloads larger than this limit are not likely to be
/// > processed by the receiver.
///
/// <https://www.rfc-editor.org/rfc/rfc9000.html#section-18.2>
max_udp_payload_size: Option<u64>,
Comment thread
larseggert marked this conversation as resolved.
/// The ACK ratio determines how many acknowledgements we will request as a
/// fraction of both the current congestion window (expressed in packets) and
/// as a fraction of the current round trip time. This value is scaled by
Expand Down Expand Up @@ -166,6 +173,7 @@ impl Default for ConnectionParameters {
.expect("usize fits in u64"),
max_streams_bidi: LOCAL_STREAM_LIMIT_BIDI,
max_streams_uni: LOCAL_STREAM_LIMIT_UNI,
max_udp_payload_size: None,
ack_ratio: Self::DEFAULT_ACK_RATIO,
idle_timeout: Self::DEFAULT_IDLE_TIMEOUT,
preferred_address: PreferredAddressConfig::Default,
Expand Down Expand Up @@ -287,6 +295,18 @@ impl ConnectionParameters {
self
}

/// > The maximum UDP payload size parameter is an integer value that limits
/// > the size of UDP payloads that the endpoint is willing to receive. UDP
/// > datagrams with payloads larger than this limit are not likely to be
/// > processed by the receiver.
///
/// <https://www.rfc-editor.org/rfc/rfc9000.html#section-18.2>
#[must_use]
pub const fn max_udp_payload_size(mut self, v: u64) -> Self {
self.max_udp_payload_size = Some(v);
self
}

/// Set a preferred address (which only has an effect for a server).
#[must_use]
pub const fn preferred_address(mut self, preferred: PreferredAddress) -> Self {
Expand Down Expand Up @@ -532,6 +552,12 @@ impl ConnectionParameters {
.set_integer(InitialMaxStreamsBidi, self.max_streams_bidi);
tps.local_mut()
.set_integer(InitialMaxStreamsUni, self.max_streams_uni);
if let Some(max_udp_payload_size) = self.max_udp_payload_size {
tps.local_mut().set_integer(
TransportParameterId::MaxUdpPayloadSize,
max_udp_payload_size,
);
}
tps.local_mut().set_integer(
TransportParameterId::IdleTimeout,
u64::try_from(self.idle_timeout.as_millis()).unwrap_or(0),
Expand Down
Loading