-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
216 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/// rperf, validates network throughput capacity and reliability, | ||
/// https://github.com/opensource-3d-p/rperf | ||
#[derive(clap::Parser, Debug, Clone)] | ||
#[command(author, version, about, long_about = None)] | ||
pub struct Args { | ||
/// the port used for client-server interactions | ||
#[arg(short, long, value_name = "number", default_value_t = 5199)] | ||
pub port: u16, | ||
|
||
/// specify logical CPUs, delimited by commas, across which to round-robin affinity; | ||
/// not supported on all systems | ||
#[arg(short = 'A', long, value_name = "number", default_value = "1")] | ||
pub affinity: String, | ||
|
||
/// bind to the interface associated with the address <host> | ||
#[arg( | ||
short = 'B', | ||
long, | ||
conflicts_with = "client", | ||
default_value_if("version6", "true", Some("::")), | ||
default_value = "0.0.0.0", | ||
value_name = "host" | ||
)] | ||
pub bind: std::net::IpAddr, | ||
|
||
/// emit debug-level logging on stderr; default is info and above | ||
#[arg(short, long)] | ||
pub debug: bool, | ||
|
||
/// run in server mode | ||
#[arg(short, long, conflicts_with = "client")] | ||
pub server: bool, | ||
|
||
/// enable IPv6 on the server (on most hosts, this will allow both IPv4 and IPv6, | ||
/// but it might limit to just IPv6 on some) | ||
#[arg(short = '6', long)] | ||
pub version6: bool, | ||
|
||
/// limit the number of concurrent clients that can be processed by a server; | ||
/// any over this count will be immediately disconnected | ||
#[arg(long, value_name = "number", default_value = "0")] | ||
pub client_limit: usize, | ||
|
||
/// run in client mode; value is the server's address | ||
#[arg(short, long, value_name = "host", conflicts_with = "server")] | ||
pub client: Option<std::net::IpAddr>, | ||
|
||
/// run in reverse-mode (server sends, client receives) | ||
#[arg(short = 'R', long)] | ||
pub reverse: bool, | ||
|
||
/// the format in which to deplay information (json, megabit/sec, megabyte/sec) | ||
#[arg( | ||
short, | ||
long, | ||
value_enum, | ||
value_name = "format", | ||
default_value = "megabit" | ||
)] | ||
pub format: Format, | ||
|
||
/// use UDP rather than TCP | ||
#[arg(short, long)] | ||
pub udp: bool, | ||
|
||
/// target bandwidth in bytes/sec; this value is applied to each stream, | ||
/// with a default target of 1 megabit/second for all protocols (note: megabit, not mebibit); | ||
/// the suffixes kKmMgG can also be used for xbit and xbyte, respectively | ||
#[arg(short, long, default_value = "125000", value_name = "bytes/sec")] | ||
pub bandwidth: String, | ||
|
||
/// the time in seconds for which to transmit | ||
#[arg(short, long, default_value = "10.0", value_name = "seconds")] | ||
pub time: f64, | ||
|
||
/// the interval at which to send batches of data, in seconds, between [0.0 and 1.0); | ||
/// this is used to evenly spread packets out over time | ||
#[arg(long, default_value = "0.05", value_name = "seconds")] | ||
pub send_interval: f64, | ||
|
||
/// length of the buffer to exchange; for TCP, this defaults to 32 kibibytes; for UDP, it's 1024 bytes | ||
#[arg(short, long, default_value = "32768", value_name = "bytes")] | ||
pub length: usize, | ||
|
||
/// send buffer, in bytes (only supported on some platforms; | ||
/// if set too small, a 'resource unavailable' error may occur; | ||
/// affects TCP window-size) | ||
#[arg(long, default_value = "0", value_name = "bytes")] | ||
pub send_buffer: usize, | ||
|
||
/// receive buffer, in bytes (only supported on some platforms; | ||
/// if set too small, a 'resource unavailable' error may occur; affects TCP window-size) | ||
#[arg(long, default_value = "0", value_name = "bytes")] | ||
pub receive_buffer: usize, | ||
|
||
/// the number of parallel data-streams to use | ||
#[arg(short = 'P', long, value_name = "number", default_value = "1")] | ||
pub parallel: usize, | ||
|
||
/// omit a number of seconds from the start of calculations, | ||
/// primarily to avoid including TCP ramp-up in averages; | ||
/// using this option may result in disagreement between bytes sent and received, | ||
/// since data can be in-flight across time-boundaries | ||
#[arg(short, long, default_value = "0", value_name = "seconds")] | ||
pub omit: usize, | ||
|
||
/// use no-delay mode for TCP tests, disabling Nagle's Algorithm | ||
#[arg(short = 'N', long)] | ||
pub no_delay: bool, | ||
|
||
/// an optional pool of IPv4 TCP ports over which data will be accepted; | ||
/// if omitted, any OS-assignable port is used; format: 1-10,19,21 | ||
#[arg(long, value_name = "ports", default_value = "")] | ||
pub tcp_port_pool: String, | ||
|
||
/// an optional pool of IPv6 TCP ports over which data will be accepted; | ||
/// if omitted, any OS-assignable port is used; format: 1-10,19,21 | ||
#[arg(long, value_name = "ports", default_value = "")] | ||
pub tcp6_port_pool: String, | ||
|
||
/// an optional pool of IPv4 UDP ports over which data will be accepted; | ||
/// if omitted, any OS-assignable port is used; format: 1-10,19,21 | ||
#[arg(long, value_name = "ports", default_value = "")] | ||
pub udp_port_pool: String, | ||
|
||
/// an optional pool of IPv6 UDP ports over which data will be accepted; | ||
/// if omitted, any OS-assignable port is used; format: 1-10,19,21 | ||
#[arg(long, value_name = "ports", default_value = "")] | ||
pub udp6_port_pool: String, | ||
} | ||
|
||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum, Default)] | ||
pub enum Format { | ||
#[default] | ||
Json, | ||
Megabit, | ||
Megabyte, | ||
} | ||
|
||
impl std::fmt::Display for Format { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Format::Json => write!(f, "json"), | ||
Format::Megabit => write!(f, "megabit/sec"), | ||
Format::Megabyte => write!(f, "megabyte/sec"), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.