From 5a34bd4b814865c24e624b40a1b24a73f7a9c6d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 14 Nov 2021 02:47:37 +0100 Subject: [PATCH] udp load test: fix ipv6 issues, improve documentation --- aquatic_udp_load_test/src/common.rs | 22 ++++++++++------------ aquatic_udp_load_test/src/main.rs | 21 +++++++-------------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/aquatic_udp_load_test/src/common.rs b/aquatic_udp_load_test/src/common.rs index 681bec9..98ef435 100644 --- a/aquatic_udp_load_test/src/common.rs +++ b/aquatic_udp_load_test/src/common.rs @@ -17,12 +17,12 @@ pub struct ThreadId(pub u8); #[serde(default)] pub struct Config { /// Server address + /// + /// If you want to send IPv4 requests to a IPv4+IPv6 tracker, put an IPv4 + /// address here. pub server_address: SocketAddr, pub log_level: LogLevel, /// Number of sockets and socket worker threads - /// - /// Sockets will bind to one port each, and with - /// multiple_client_ips = true, additionally to one IP each. pub num_socket_workers: u8, /// Number of workers generating requests from responses, as well as /// requests not connected to previous ones. @@ -38,15 +38,14 @@ pub struct Config { #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(default)] pub struct NetworkConfig { - /// True means bind to one localhost IP per socket. On macOS, this by - /// default causes all server responses to go to one socket worker. - /// Default option ("true") can cause issues on macOS. + /// True means bind to one localhost IP per socket. /// /// The point of multiple IPs is to possibly cause a better distribution - /// of requests to servers with SO_REUSEPORT option. - pub multiple_client_ips: bool, - /// Use Ipv6 only - pub ipv6_client: bool, + /// of requests to servers with SO_REUSEPORT option, but it doesn't + /// necessarily help. + /// + /// Setting this to true can cause issues on macOS. + pub multiple_client_ipv4s: bool, /// Number of first client port pub first_port: u16, /// Socket worker poll timeout in microseconds @@ -121,8 +120,7 @@ impl Default for Config { impl Default for NetworkConfig { fn default() -> Self { Self { - multiple_client_ips: true, - ipv6_client: false, + multiple_client_ipv4s: false, first_port: 45_000, poll_timeout: 276, poll_event_capacity: 2_877, diff --git a/aquatic_udp_load_test/src/main.rs b/aquatic_udp_load_test/src/main.rs index a65ee35..0b34bb2 100644 --- a/aquatic_udp_load_test/src/main.rs +++ b/aquatic_udp_load_test/src/main.rs @@ -72,25 +72,18 @@ fn run(config: Config) -> ::anyhow::Result<()> { let (sender, receiver) = unbounded(); let port = config.network.first_port + (i as u16); - let addr = if config.network.multiple_client_ips { - let ip = if config.network.ipv6_client { - // FIXME: test ipv6 - Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1 + i as u16).into() - } else { - Ipv4Addr::new(127, 0, 0, 1 + i).into() - }; - - SocketAddr::new(ip, port) + let ip = if config.server_address.is_ipv6() { + Ipv6Addr::LOCALHOST.into() } else { - let ip = if config.network.ipv6_client { - Ipv6Addr::LOCALHOST.into() + if config.network.multiple_client_ipv4s { + Ipv4Addr::new(127, 0, 0, 1 + i).into() } else { Ipv4Addr::LOCALHOST.into() - }; - - SocketAddr::new(ip, port) + } }; + let addr = SocketAddr::new(ip, port); + request_senders.push(sender); let config = config.clone();