-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code formating and refine #4
Open
ssrlive
wants to merge
20
commits into
opensource-3d-p:master
Choose a base branch
from
ssrlive:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
bfbbd1d
cargo fmt && cargo clippy
ssrlive 6fbd736
bind argument
ssrlive 7721e0f
upgrade to clap 4.4.x
ssrlive a80178b
refine code
ssrlive 508d4a7
rustfmt max_width = 140
ssrlive 3d0f1e9
temp result
ssrlive 6262199
socket2 imported
ssrlive 94568ba
refactor BoxResult
ssrlive bdc9b10
tcp_stream_try_clone function
ssrlive b33c1f2
make rperf as a lib
ssrlive 59471a5
verbosity
ssrlive 5365d90
fix mio poll issues
ssrlive 4cbf40b
windows issues
ssrlive eb084fe
Merge pull request #1 from ssrlive/mio
ssrlive f5778a4
Complete adjustments as recommended.
ssrlive ec65bb9
fix issues that always timeout in windows
ssrlive e988f5d
Merge pull request #2 from ssrlive/mywin
ssrlive db7106b
refine code
ssrlive 5c7fa18
unit-tests issues fixing
ssrlive fb68b59
UDP-receive logic grouped all packets into a single interval, which b…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,154 @@ | ||
/// 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 = "numbers", default_value = "")] | ||
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", | ||
default_value_if("udp", "true", Some("1024")), | ||
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")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The unit-tests, and existing real-world code, are broken without it, so this seems like a (minor) refactoring regression. |
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get what you're going for here, but this breaks compatibility with hostname-based resolution.
Not everything will, or should, be specified as an IP address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, specifically a hostname as defined in https://datatracker.ietf.org/doc/html/rfc952 or an IP address, v4 or v6, per https://datatracker.ietf.org/doc/html/rfc1123#page-13, but I'm perfectly content for it to just be a string and for the user to figure it out if they enter something nonsensical, rather than having the tool try to hold their hand on something basic like this.