From 99fbbb9c32170d4e9fd9d2ff284d47b26549d461 Mon Sep 17 00:00:00 2001 From: Nils Andreas Svee Date: Tue, 28 Apr 2026 18:23:28 +0700 Subject: [PATCH] feat(client): define new event types and error variants for echo probes --- crates/irtt-client/src/error.rs | 4 +- crates/irtt-client/src/event.rs | 81 ++++++++++++++++++++++++++++++++- 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/crates/irtt-client/src/error.rs b/crates/irtt-client/src/error.rs index aaffab9..d5faf76 100644 --- a/crates/irtt-client/src/error.rs +++ b/crates/irtt-client/src/error.rs @@ -39,8 +39,8 @@ pub enum ClientError { AlreadyCompleted, #[error("client session is already closed")] AlreadyClosed, - #[error("operation is not implemented for this milestone")] - NotImplementedForMilestone, #[error("duration is too large to encode as nanoseconds")] DurationOverflow, + #[error("pending probe limit exceeded ({limit})")] + PendingLimitExceeded { limit: usize }, } diff --git a/crates/irtt-client/src/event.rs b/crates/irtt-client/src/event.rs index 7e3c458..023653f 100644 --- a/crates/irtt-client/src/event.rs +++ b/crates/irtt-client/src/event.rs @@ -1,4 +1,4 @@ -use std::net::SocketAddr; +use std::{net::SocketAddr, time::Duration}; use crate::{session::NegotiatedParams, timing::ClientTimestamp}; @@ -35,7 +35,86 @@ pub enum ClientEvent { token: u64, at: ClientTimestamp, }, + + EchoReply { + seq: u32, + logical_seq: u64, + remote: SocketAddr, + sent_at: ClientTimestamp, + received_at: ClientTimestamp, + rtt: RttSample, + server_timing: Option, + one_way: Option, + received_stats: Option, + packet_meta: PacketMeta, + }, + + EchoLoss { + seq: u32, + logical_seq: u64, + sent_at: ClientTimestamp, + timeout_at: std::time::Instant, + }, + + DuplicateReply { + seq: u32, + remote: SocketAddr, + received_at: ClientTimestamp, + }, + + LateReply { + seq: u32, + logical_seq: Option, + highest_seen: u32, + remote: SocketAddr, + sent_at: Option, + received_at: ClientTimestamp, + rtt: Option, + server_timing: Option, + one_way: Option, + received_stats: Option, + packet_meta: PacketMeta, + }, + Warning { message: String, }, } + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct RttSample { + pub raw: Duration, + pub adjusted: Option, + pub effective: Duration, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ServerTiming { + pub receive_wall_ns: Option, + pub receive_mono_ns: Option, + pub send_wall_ns: Option, + pub send_mono_ns: Option, + pub midpoint_wall_ns: Option, + pub midpoint_mono_ns: Option, + pub processing: Option, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct OneWayDelaySample { + pub client_to_server: Option, + pub server_to_client: Option, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ReceivedStatsSample { + pub count: Option, + pub window: Option, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +pub struct PacketMeta { + pub traffic_class: Option, + pub dscp: Option, + pub ecn: Option, + pub kernel_rx_timestamp: Option, +}