2个版本
0.1.1 | 2024年1月22日 |
---|---|
0.1.0 | 2023年12月20日 |
#4 在 #s2n-netbench
210KB
6K SLoC
netbench-scenarios
可执行文件包含三个默认场景
request response
向服务器发送N
个字节的请求,服务器以M
个字节的响应。ping
将“ping-pong”数据负载从客户端到服务器,然后再返回connect
将打开多个连接,然后交换一个字节。这对于评估连接设置时间很有用。
提供了多种配置选项
$ cargo run --bin netbench-scenarios -- --help
netbench scenarios
USAGE:
netbench-scenarios [FLAGS] [OPTIONS] [OUT_DIR]
FLAGS:
-h, --help
Prints help information
--request_response.parallel
Specifies if the requests should be performed in parallel
-V, --version
Prints version information
OPTIONS:
--connect.connections <COUNT>
The number of separate connections to create [default: 1000]
--ping.connections <COUNT>
The number of concurrent connections to create [default: 1]
--ping.size <BYTES>
The amount of data to send in each ping [default: 1KB,10KB,100KB,1MB]
--ping.streams <COUNT>
The number of concurrent streams to ping on [default: 1]
--ping.time <TIME>
The amount of time to spend pinging for each size [default: 15s]
--request_response.client_receive_rate <RATE>
The rate at which the client receives data [default: NONE]
--request_response.client_send_rate <RATE>
The rate at which the client sends data [default: NONE]
--request_response.connections <COUNT>
The number of separate connections to create [default: 1]
--request_response.count <COUNT>
The number of requests to make [default: 1]
--request_response.request_size <BYTES>
The size of the client's request to the server [default: 1KB]
--request_response.response_delay <TIME>
How long the server will take to respond to the request [default: 0s]
--request_response.response_size <BYTES>
The size of the server's response to the client [default: 10MB]
--request_response.response_unblock <BYTES>
The number of bytes that must be received before the next request [default: 0B]
--request_response.server_receive_rate <RATE>
The rate at which the server receives data [default: NONE]
--request_response.server_send_rate <RATE>
The rate at which the server sends data [default: NONE]
ARGS:
<OUT_DIR>
[default: target/netbench]
FORMATS:
BYTES
42b -> 42 bits
42 -> 42 bytes
42B -> 42 bytes
42K -> 42000 bytes
42Kb -> 42000 bits
42KB -> 42000 bytes
42KiB -> 43008 bytes
COUNT
42 -> 42 units
RATE
42bps -> 42 bits per second
42Mbps -> 42 megabits per second
42MBps -> 42 megabytes per second
42MiBps -> 42 mebibytes per second
42MB/50ms -> 42 megabytes per 50 milliseconds
TIME
42ms -> 42 milliseconds
42s -> 42 seconds
1s42ms -> 1 second + 42 milliseconds
未来,我们可以将任何有用的场景添加到这个列表中。
库
对于想要构建自己的场景的工作流程,它可以根据库并按照以下方式设置他们的 main.rs
netbench_scenario::scenarios!(my_scenario_a, my_scenario_b);
然后,他们会创建一个 my_scenario_a.rs
和 my_scenario_b.rs
// my_scenario_a.rs
use netbench_scenario::prelude::*;
config!({
/// The size of the client's request to the server
let request_size: Byte = 1.kilobytes();
/// The size of the server's response to the client
let response_size: Byte = 10.megabytes();
});
pub fn scenario(config: Config) -> Scenario {
let Config {
request_size,
response_size,
} = config;
Scenario::build(|scenario| {
let server = scenario.create_server();
scenario.create_client(|client| {
client.connect_to(server, |conn| {
conn.open_bidirectional_stream(
|local| {
local.send(request_size);
local.receive(response_size);
},
|remote| {
remote.receive(request_size);
remote.send(response_size);
},
);
});
});
})
}
然后,他们可以运行他们的场景生成器
$ cargo run -- --help
netbench scenarios
USAGE:
netbench-scenarios [FLAGS] [OPTIONS] [OUT_DIR]
FLAGS:
-h, --help
Prints help information
-V, --version
Prints version information
OPTIONS:
--my_scenario_a.request_size <BYTES>
The size of the client's request to the server [default: 1KB]
--my_scenario_a.response_size <BYTES>
The size of the server's response to the client [default: 10MB]
ARGS:
<OUT_DIR>
[default: target/netbench]
$ cargo run
created: target/netbench/my_scenario_a.json
created: target/netbench/my_scenario_b.json
依赖项
~17–29MB
~537K SLoC