pub struct SenderState { /* private fields */ }Expand description
Per-peer sender-side MMP state.
Records cumulative and interval counters for every frame transmitted
to this peer. Produces SenderReport snapshots on demand.
Implementations§
Source§impl SenderState
impl SenderState
pub fn new() -> Self
Sourcepub fn new_with_cold_start(cold_start_ms: u64) -> Self
pub fn new_with_cold_start(cold_start_ms: u64) -> Self
Create with a custom cold-start interval (ms).
Used by session-layer MMP which needs a longer initial interval since reports consume bandwidth on every transit link.
Sourcepub fn record_sent(&mut self, counter: u64, timestamp: u32, bytes: usize)
pub fn record_sent(&mut self, counter: u64, timestamp: u32, bytes: usize)
Record a frame sent to this peer.
Called on the TX path for every encrypted link message.
counter is the AEAD nonce/counter, timestamp is the inner header
session-relative timestamp (ms), bytes is the wire payload size.
Sourcepub fn build_report(&mut self, now: Instant) -> Option<SenderReport>
pub fn build_report(&mut self, now: Instant) -> Option<SenderReport>
Build a SenderReport from current state and reset the interval.
Returns None if no frames have been sent since the last report.
Sourcepub fn should_send_report(&self, now: Instant) -> bool
pub fn should_send_report(&self, now: Instant) -> bool
Check if it’s time to send a report.
When consecutive send failures have occurred, the effective interval is multiplied by an exponential backoff factor (2^failures, capped at 32×).
Sourcepub fn record_send_failure(&mut self) -> u32
pub fn record_send_failure(&mut self) -> u32
Record a send failure. Returns the new consecutive failure count.
Sourcepub fn record_send_success(&mut self) -> u32
pub fn record_send_success(&mut self) -> u32
Record a successful send. Returns the previous failure count (for summary logging).
Sourcepub fn send_failure_backoff_multiplier(&self) -> f64
pub fn send_failure_backoff_multiplier(&self) -> f64
Get the backoff multiplier based on consecutive failures.
Returns 1.0 for no failures, 2.0 for 1 failure, 4.0 for 2, … capped at 32.0 (5 failures).
Sourcepub fn update_report_interval_from_srtt(&mut self, srtt_us: i64)
pub fn update_report_interval_from_srtt(&mut self, srtt_us: i64)
Update the report interval based on SRTT (link-layer defaults).
Sender reports at 2× SRTT clamped to [floor, MAX]. During cold-start
(first COLD_START_SAMPLES updates), the floor is the cold-start
interval (200ms) for fast SRTT convergence. After that, it rises to
MIN_REPORT_INTERVAL_MS (1000ms) for steady-state efficiency.
Sourcepub fn update_report_interval_with_bounds(
&mut self,
srtt_us: i64,
min_ms: u64,
max_ms: u64,
)
pub fn update_report_interval_with_bounds( &mut self, srtt_us: i64, min_ms: u64, max_ms: u64, )
Update the report interval based on SRTT with custom bounds.
Used by session-layer MMP which needs higher clamp values since each report consumes bandwidth on every transit link.
pub fn cumulative_packets_sent(&self) -> u64
pub fn cumulative_bytes_sent(&self) -> u64
pub fn report_interval(&self) -> Duration
pub fn consecutive_send_failures(&self) -> u32
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SenderState
impl RefUnwindSafe for SenderState
impl Send for SenderState
impl Sync for SenderState
impl Unpin for SenderState
impl UnsafeUnpin for SenderState
impl UnwindSafe for SenderState
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more