Skip to content

Commit 51ef00c

Browse files
committed
fix(udp/bench): enforce max 64k UDP datagram limit
Linux drops UDP datagrams larger than 64k, even when segmented. In other words, 64k - headers is the maximum GSO payload size.
1 parent f753220 commit 51ef00c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

quinn-udp/benches/throughput.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::{
2+
cmp::min,
23
io::{ErrorKind, IoSliceMut},
34
net::{Ipv4Addr, Ipv6Addr, UdpSocket},
45
};
@@ -51,7 +52,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
5152
} else {
5253
1
5354
};
54-
let msg = vec![0xAB; SEGMENT_SIZE * gso_segments];
55+
let msg = vec![0xAB; min(MAX_DATAGRAM_SIZE, SEGMENT_SIZE * gso_segments)];
5556
let transmit = Transmit {
5657
destination: dst_addr,
5758
ecn: None,
@@ -116,3 +117,6 @@ fn new_socket() -> (tokio::net::UdpSocket, UdpSocketState) {
116117

117118
criterion_group!(benches, criterion_benchmark);
118119
criterion_main!(benches);
120+
121+
const MAX_IP_UDP_HEADER_SIZE: usize = 48;
122+
const MAX_DATAGRAM_SIZE: usize = u16::MAX as usize - MAX_IP_UDP_HEADER_SIZE;

0 commit comments

Comments
 (0)