pub enum Message {
Setup {
version: u32,
protocol: String,
duration: u64,
bandwidth: Option<u64>,
buffer_size: usize,
parallel: usize,
reverse: bool,
},
SetupAck {
port: u16,
cookie: String,
},
Start {
timestamp: u64,
},
Interval {
stream_id: usize,
start: f64,
end: f64,
bytes: u64,
bits_per_second: f64,
},
Result {
stream_id: usize,
bytes_sent: u64,
bytes_received: u64,
duration: f64,
bits_per_second: f64,
retransmits: Option<u64>,
},
Done,
Error {
message: String,
},
}Expand description
Message types in the rperf3 protocol.
These messages are exchanged between the client and server during test execution.
All messages are serialized as JSON with a type field discriminator.
§Protocol Flow
- Client sends
Setupwith test parameters - Server responds with
SetupAck - Server sends
Startto begin test Intervalmessages are sent periodically during testResultmessage contains final statisticsDonesignals test completionErrorcan be sent at any point to indicate failure
§Examples
use rperf3::protocol::Message;
use std::time::Duration;
// Create a setup message
let setup = Message::setup(
"TCP".to_string(),
Duration::from_secs(10),
None,
128 * 1024,
1,
false,
);Variants§
Setup
Initial handshake from client with test parameters
Fields
SetupAck
Server acknowledgment of setup
Start
Test start signal
Interval
Interval results
Result
Final results
Fields
Done
Test completion signal
Error
Error message
Implementations§
Source§impl Message
impl Message
Sourcepub fn setup(
protocol: String,
duration: Duration,
bandwidth: Option<u64>,
buffer_size: usize,
parallel: usize,
reverse: bool,
) -> Self
pub fn setup( protocol: String, duration: Duration, bandwidth: Option<u64>, buffer_size: usize, parallel: usize, reverse: bool, ) -> Self
Creates a Setup message for test initialization.
§Arguments
protocol- Protocol name (“TCP” or “UDP”)duration- Test durationbandwidth- Target bandwidth for UDP (None for TCP)buffer_size- Buffer size in bytesparallel- Number of parallel streamsreverse- Whether to use reverse mode
Sourcepub fn interval(
stream_id: usize,
start: f64,
end: f64,
bytes: u64,
bits_per_second: f64,
) -> Self
pub fn interval( stream_id: usize, start: f64, end: f64, bytes: u64, bits_per_second: f64, ) -> Self
Creates an Interval message with periodic statistics.
§Arguments
stream_id- Stream identifierstart- Interval start time in secondsend- Interval end time in secondsbytes- Bytes transferred during intervalbits_per_second- Throughput during interval
Sourcepub fn result(
stream_id: usize,
bytes_sent: u64,
bytes_received: u64,
duration: f64,
bits_per_second: f64,
retransmits: Option<u64>,
) -> Self
pub fn result( stream_id: usize, bytes_sent: u64, bytes_received: u64, duration: f64, bits_per_second: f64, retransmits: Option<u64>, ) -> Self
Creates a Result message with final test statistics.
§Arguments
stream_id- Stream identifierbytes_sent- Total bytes sentbytes_received- Total bytes receivedduration- Test duration in secondsbits_per_second- Average throughputretransmits- TCP retransmit count (None for UDP)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more