ReplayWindow

Struct ReplayWindow 

pub struct ReplayWindow {
    pub last_accepted: u32,
    pub last_accepted_time_ms: u64,
    pub backward_bitmap: u8,
    pub recent_mics: Deque<RecentMic, umsh_crypto::::replay::ReplayWindow::{constant#0}>,
    pub last_dup_ack_counter: u32,
    pub last_dup_ack_ms: u64,
}
Expand description

Replay-detection window for secure traffic from one sender.

Fields§

§last_accepted: u32

Highest accepted frame counter.

§last_accepted_time_ms: u64

Timestamp of the highest accepted frame.

§backward_bitmap: u8

Occupancy bitmap for the backward counter window.

§recent_mics: Deque<RecentMic, umsh_crypto::::replay::ReplayWindow::{constant#0}>

Accepted MICs retained for duplicate late-arrival checks.

§last_dup_ack_counter: u32

Counter of the last duplicate re-acknowledged, paired with last_dup_ack_ms.

One pair for the whole window, not a stamp per retained MIC: duplicate re-acks pace one packet’s copies, and windows are replicated widely enough (per channel, per tracked sender) that per-entry state is real RAM on the embedded targets — spent, for channel traffic, on packets that are never acknowledged at all.

§last_dup_ack_ms: u64

When the duplicate carrying last_dup_ack_counter was last re-acknowledged, in milliseconds.

Implementations§

§

impl ReplayWindow

pub fn new() -> ReplayWindow

Create a fresh replay window.

pub fn check(&self, counter: u32, mic: &[u8], now_ms: u64) -> ReplayVerdict

Evaluate whether counter and mic are acceptable at now_ms.

pub fn note_acknowledgeable_duplicate( &mut self, counter: u32, mic: &[u8], now_ms: u64, holdoff_ms: u64, ) -> bool

Return whether this is an exact, recently accepted packet eligible for an idempotent duplicate acknowledgement, and record the acknowledgement when it is.

This deliberately requires both the bounded counter distance and a matching retained MIC. Merely reusing an occupied counter does not prove that the receiver previously accepted this logical packet.

A duplicate is re-acknowledged at most once per holdoff_ms. The duplicate-acknowledgement window exists so a sender whose ack was lost can recover by retransmitting — but most duplicates are not retransmissions, they are flood copies of a single transmission arriving over different paths, and each already-sent ack covers all of them. A sender cannot retransmit before its confirmation window lapses, so a duplicate arriving inside that window proves nothing was lost yet and earns no fresh ack. Callers pass their forwarding-confirmation window (or the closest equivalent their radio timing offers) as holdoff_ms.

Two clocks pace this. Copies of the accepted transmission are caught by the entry’s acceptance time — the acceptance already queued their ack. Copies of a retransmission are caught by the re-ack stamp the first copy leaves behind. A true return stamps: the caller is expected to queue the acknowledgement it just asked about.

pub fn accept(&mut self, counter: u32, mic: &[u8], now_ms: u64)

Record an accepted counter and mic at now_ms.

pub fn reset(&mut self, baseline: u32, now_ms: u64)

Reset the replay window to a known baseline.

Trait Implementations§

§

impl Clone for ReplayWindow

§

fn clone(&self) -> ReplayWindow

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for ReplayWindow

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for ReplayWindow

§

fn default() -> ReplayWindow

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.