udp load test: fix ipv6 issues, improve documentation

This commit is contained in:
Joakim Frostegård 2021-11-14 02:47:37 +01:00
parent 18635bf26c
commit 5a34bd4b81
2 changed files with 17 additions and 26 deletions

View file

@ -17,12 +17,12 @@ pub struct ThreadId(pub u8);
#[serde(default)] #[serde(default)]
pub struct Config { pub struct Config {
/// Server address /// Server address
///
/// If you want to send IPv4 requests to a IPv4+IPv6 tracker, put an IPv4
/// address here.
pub server_address: SocketAddr, pub server_address: SocketAddr,
pub log_level: LogLevel, pub log_level: LogLevel,
/// Number of sockets and socket worker threads /// 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, pub num_socket_workers: u8,
/// Number of workers generating requests from responses, as well as /// Number of workers generating requests from responses, as well as
/// requests not connected to previous ones. /// requests not connected to previous ones.
@ -38,15 +38,14 @@ pub struct Config {
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)] #[serde(default)]
pub struct NetworkConfig { pub struct NetworkConfig {
/// True means bind to one localhost IP per socket. On macOS, this by /// True means bind to one localhost IP per socket.
/// default causes all server responses to go to one socket worker.
/// Default option ("true") can cause issues on macOS.
/// ///
/// The point of multiple IPs is to possibly cause a better distribution /// The point of multiple IPs is to possibly cause a better distribution
/// of requests to servers with SO_REUSEPORT option. /// of requests to servers with SO_REUSEPORT option, but it doesn't
pub multiple_client_ips: bool, /// necessarily help.
/// Use Ipv6 only ///
pub ipv6_client: bool, /// Setting this to true can cause issues on macOS.
pub multiple_client_ipv4s: bool,
/// Number of first client port /// Number of first client port
pub first_port: u16, pub first_port: u16,
/// Socket worker poll timeout in microseconds /// Socket worker poll timeout in microseconds
@ -121,8 +120,7 @@ impl Default for Config {
impl Default for NetworkConfig { impl Default for NetworkConfig {
fn default() -> Self { fn default() -> Self {
Self { Self {
multiple_client_ips: true, multiple_client_ipv4s: false,
ipv6_client: false,
first_port: 45_000, first_port: 45_000,
poll_timeout: 276, poll_timeout: 276,
poll_event_capacity: 2_877, poll_event_capacity: 2_877,

View file

@ -72,25 +72,18 @@ fn run(config: Config) -> ::anyhow::Result<()> {
let (sender, receiver) = unbounded(); let (sender, receiver) = unbounded();
let port = config.network.first_port + (i as u16); let port = config.network.first_port + (i as u16);
let addr = if config.network.multiple_client_ips { let ip = if config.server_address.is_ipv6() {
let ip = if config.network.ipv6_client { Ipv6Addr::LOCALHOST.into()
// 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)
} else { } else {
let ip = if config.network.ipv6_client { if config.network.multiple_client_ipv4s {
Ipv6Addr::LOCALHOST.into() Ipv4Addr::new(127, 0, 0, 1 + i).into()
} else { } else {
Ipv4Addr::LOCALHOST.into() Ipv4Addr::LOCALHOST.into()
}; }
SocketAddr::new(ip, port)
}; };
let addr = SocketAddr::new(ip, port);
request_senders.push(sender); request_senders.push(sender);
let config = config.clone(); let config = config.clone();