1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//! Client benchmark configuration and presets.
use std::time::Duration;
/// Parameters for one complete benchmark run.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NetBenchConfig {
/// Hard wall-clock limit for the complete benchmark, including connection setup and cleanup.
pub overall_timeout: Duration,
/// Maximum time to wait for a direct path before measurements begin.
pub path_stabilization_timeout: Duration,
/// Idle RTT measurement duration.
pub latency_duration: Duration,
/// Delay between idle RTT probes.
pub latency_interval: Duration,
/// Datagram timeout measurement duration.
pub loss_duration: Duration,
/// Number of datagram probes sent per second.
pub loss_rate_per_second: u32,
/// Time after the last probe before outstanding probes time out.
pub probe_timeout: Duration,
/// Warm-up before download accounting starts.
pub download_warmup: Duration,
/// Accounted download duration.
pub download_duration: Duration,
/// Warm-up before upload accounting starts.
pub upload_warmup: Duration,
/// Accounted upload duration.
pub upload_duration: Duration,
/// Number of parallel unidirectional streams per throughput direction.
pub parallel_streams: u16,
/// Payload size written at a time.
pub chunk_size: u32,
/// Interval between progress samples.
pub sample_interval: Duration,
}
/// Parameters for a low-bandwidth latency and loss probe run.
///
/// Probe runs never open throughput streams and remain available when the peer denies
/// bandwidth-saturating measurements.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NetBenchProbeConfig {
/// Hard wall-clock limit for the complete low-bandwidth probe run.
pub overall_timeout: Duration,
/// Maximum time to wait for a direct path before measurements begin.
pub path_stabilization_timeout: Duration,
/// Idle RTT measurement duration.
pub latency_duration: Duration,
/// Delay between idle RTT probes.
pub latency_interval: Duration,
/// Datagram timeout measurement duration.
pub loss_duration: Duration,
/// Number of datagram probes sent per second.
pub loss_rate_per_second: u32,
/// Time after the last probe before outstanding probes time out.
pub probe_timeout: Duration,
}
impl NetBenchConfig {
/// A roughly 15-second interactive preset.
#[must_use]
pub fn quick() -> Self {
Self {
overall_timeout: Duration::from_secs(45),
path_stabilization_timeout: Duration::from_secs(3),
latency_duration: Duration::from_secs(2),
latency_interval: Duration::from_millis(100),
loss_duration: Duration::from_secs(2),
loss_rate_per_second: 100,
probe_timeout: Duration::from_secs(2),
download_warmup: Duration::from_secs(1),
download_duration: Duration::from_secs(5),
upload_warmup: Duration::from_secs(2),
upload_duration: Duration::from_secs(5),
parallel_streams: 4,
chunk_size: 64 * 1024,
sample_interval: Duration::from_millis(250),
}
}
/// A roughly 32-second default preset.
#[must_use]
pub fn standard() -> Self {
Self {
overall_timeout: Duration::from_secs(75),
latency_duration: Duration::from_secs(3),
loss_duration: Duration::from_secs(5),
download_warmup: Duration::from_secs(2),
download_duration: Duration::from_secs(10),
upload_warmup: Duration::from_secs(2),
upload_duration: Duration::from_secs(10),
..Self::quick()
}
}
}
impl Default for NetBenchConfig {
fn default() -> Self {
Self::standard()
}
}
impl NetBenchProbeConfig {
/// A short low-bandwidth diagnostic preset.
#[must_use]
pub fn quick() -> Self {
let full = NetBenchConfig::quick();
Self {
overall_timeout: Duration::from_secs(15),
..Self::from(&full)
}
}
/// A longer low-bandwidth diagnostic preset.
#[must_use]
pub fn standard() -> Self {
let full = NetBenchConfig::standard();
Self {
overall_timeout: Duration::from_secs(25),
..Self::from(&full)
}
}
}
impl From<&NetBenchConfig> for NetBenchProbeConfig {
fn from(config: &NetBenchConfig) -> Self {
Self {
overall_timeout: config.overall_timeout,
path_stabilization_timeout: config.path_stabilization_timeout,
latency_duration: config.latency_duration,
latency_interval: config.latency_interval,
loss_duration: config.loss_duration,
loss_rate_per_second: config.loss_rate_per_second,
probe_timeout: config.probe_timeout,
}
}
}
impl Default for NetBenchProbeConfig {
fn default() -> Self {
Self::standard()
}
}