Skip to content

Commit

Permalink
Reduce default maximum UDP payload size to the ethernet MTU
Browse files Browse the repository at this point in the history
Drastically reduces the size and sparsity of the quinn receive buffer
for no performance cost in typical applications.
  • Loading branch information
Ralith committed Jul 26, 2023
1 parent 4973c4a commit 89ff085
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions quinn-proto/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ impl EndpointConfig {
|| Box::<RandomConnectionIdGenerator>::default();
Self {
reset_key,
max_udp_payload_size: MAX_UDP_PAYLOAD.into(), // See RFC 9000 (https://www.rfc-editor.org/rfc/rfc9000.html#section-18.2-4.10.1)
max_udp_payload_size: (1500u32 - 28).into(), // Ethernet MTU minus IP + UDP headers
connection_id_generator_factory: Arc::new(cid_factory),
supported_versions: DEFAULT_SUPPORTED_VERSIONS.to_vec(),
grease_quic_bit: true,
Expand Down Expand Up @@ -603,7 +603,10 @@ impl EndpointConfig {
///
/// Must be greater or equal than 1200.
///
/// Defaults to 65527, which is the maximum permitted UDP payload.
/// Defaults to 1472, which is the largest UDP payload that can be transmitted in the typical
/// 1500 byte Ethernet MTU. Deployments on links with larger MTUs (e.g. loopback or Ethernet
/// with jumbo frames) can raise this to improve performance at the cost of a linear increase in
/// datagram receive buffer size.
pub fn max_udp_payload_size(&mut self, value: u16) -> Result<&mut Self, ConfigError> {
if !(1200..=65_527).contains(&value) {
return Err(ConfigError::OutOfBounds);
Expand Down

0 comments on commit 89ff085

Please sign in to comment.