pub struct BufferedReassembler { /* private fields */ }reassembler only.Expand description
Built-in: drop OOO segments, accumulate in-order bytes into a
Vec<u8> per direction. Drain via take.
Sync, no channel dep. Users who want a channel send via
std::sync::mpsc themselves, or use netring’s
TokioChannelReassembler for tokio integration.
Optionally bounded via with_max_buffer.
When the cap is reached the OverflowPolicy decides whether to
rotate bytes out (sliding window) or poison the reassembler so
the driver can tear the flow down on the next tick.
Implementations§
Source§impl BufferedReassembler
impl BufferedReassembler
pub fn new() -> Self
Sourcepub fn with_max_buffer(self, max_bytes: usize) -> Self
pub fn with_max_buffer(self, max_bytes: usize) -> Self
Set a maximum in-flight buffer size in bytes. When new
in-order segments would push buffered_len() past this cap,
the configured OverflowPolicy kicks in.
Default policy is OverflowPolicy::SlidingWindow. Pair with
with_overflow_policy to switch
to OverflowPolicy::DropFlow for framed binary protocols.
Sourcepub fn with_overflow_policy(self, policy: OverflowPolicy) -> Self
pub fn with_overflow_policy(self, policy: OverflowPolicy) -> Self
Override the overflow policy. Has no effect unless
with_max_buffer is also called.
Sourcepub fn with_high_watermark_threshold(self, percent: u8) -> Self
pub fn with_high_watermark_threshold(self, percent: u8) -> Self
Fire a crate::AnomalyKind::ReassemblerHighWatermark
anomaly when buffer occupancy crosses percent % of
max_buffer from below — once per crossing (debounced;
occupancy must drop back below before the next event
re-arms). Default: off.
No effect unless with_max_buffer
is also set. Values outside 1..=100 are clamped.
Sourcepub fn take(&mut self) -> Vec<u8> ⓘ
pub fn take(&mut self) -> Vec<u8> ⓘ
Drain accumulated in-order bytes, leaving the buffer empty.
expected_seq is preserved so subsequent in-order segments
keep accumulating. Also re-arms the high-watermark threshold
(if configured): once drained, the next time occupancy
climbs back above the threshold counts as a fresh crossing.
Sourcepub fn dropped_segments(&self) -> u64
pub fn dropped_segments(&self) -> u64
Number of segments dropped because they were out of order.
Sourcepub fn bytes_dropped_oversize(&self) -> u64
pub fn bytes_dropped_oversize(&self) -> u64
Number of payload bytes dropped because the per-side buffer cap was exceeded. Zero when no cap is set or when the cap has not yet been hit.
Sourcepub fn buffered_len(&self) -> usize
pub fn buffered_len(&self) -> usize
Bytes currently buffered (not yet drained).
Sourcepub fn is_poisoned(&self) -> bool
pub fn is_poisoned(&self) -> bool
True after an OverflowPolicy::DropFlow overflow. The
driver checks this once per tick; true triggers an
Ended { reason: BufferOverflow } event for the flow.
Sourcepub fn high_watermark(&self) -> u64
pub fn high_watermark(&self) -> u64
Peak buffer occupancy ever observed for this reassembler.
Updated on every append_with_cap call, reflecting
post-rotation state under OverflowPolicy::SlidingWindow.
Survives take — useful for tuning
crate::FlowTrackerConfig::max_reassembler_buffer.
Sourcepub fn retransmits(&self) -> u64
pub fn retransmits(&self) -> u64
Number of TCP segments classified as retransmits on this
side — seq + len <= expected_seq. Distinct from
dropped_segments, which counts
strictly-out-of-order segments ahead of expected_seq.
New in 0.5.0.
Source§impl BufferedReassembler
impl BufferedReassembler
Sourcepub fn high_watermark_crossings(&self) -> u64
pub fn high_watermark_crossings(&self) -> u64
Running count of below→above transitions of the configured high-watermark threshold. Zero when no threshold is set.
Trait Implementations§
Source§impl Debug for BufferedReassembler
impl Debug for BufferedReassembler
Source§impl Default for BufferedReassembler
impl Default for BufferedReassembler
Source§fn default() -> BufferedReassembler
fn default() -> BufferedReassembler
Source§impl Reassembler for BufferedReassembler
impl Reassembler for BufferedReassembler
Source§fn segment(&mut self, seq: u32, payload: &[u8], ts: Timestamp)
fn segment(&mut self, seq: u32, payload: &[u8], ts: Timestamp)
Source§fn dropped_segments(&self) -> u64
fn dropped_segments(&self) -> u64
Source§fn bytes_dropped_oversize(&self) -> u64
fn bytes_dropped_oversize(&self) -> u64
Source§fn is_poisoned(&self) -> bool
fn is_poisoned(&self) -> bool
crate::OverflowPolicy::DropFlow). The driver checks this
once per tick; true triggers synthesis of an
Ended { reason: BufferOverflow } event for the flow.
Default: false.Source§fn high_watermark(&self) -> u64
fn high_watermark(&self) -> u64
0 (custom reassemblers may not track this). Read moreSource§fn bytes_in_flight(&self) -> u64
fn bytes_in_flight(&self) -> u64
0. Mirrors the contract of Self::high_watermark
— only meaningful for impls that actually buffer bytes.Source§fn high_watermark_crossings(&self) -> u64
fn high_watermark_crossings(&self) -> u64
BufferedReassembler:: with_high_watermark_threshold]). Default: 0. The driver
uses per-tick deltas of this counter to emit
crate::AnomalyKind::ReassemblerHighWatermark events
without spamming on repeated above-threshold ticks.Source§fn high_watermark_threshold(&self) -> Option<(u64, u8)>
fn high_watermark_threshold(&self) -> Option<(u64, u8)>
Some((cap, percent)) when a high-watermark threshold is
configured; None otherwise. Lets the driver enrich
crate::AnomalyKind::ReassemblerHighWatermark events with
the cap and threshold percent at emission time. Default:
None.Source§fn retransmits(&self) -> u64
fn retransmits(&self) -> u64
seq + len <= expected_seq). New in 0.5.0; default 0. Read moreSource§fn current_bytes(&self) -> u64
fn current_bytes(&self) -> u64
crate::FlowTrackerConfig::reassembly_memcap)
reads to sum cross-flow usage. Read moreSource§fn on_duplicate(&mut self, _seq: u32, _payload: &[u8], _ts: Timestamp)
fn on_duplicate(&mut self, _seq: u32, _payload: &[u8], _ts: Timestamp)
BufferedReassembler for each classified retransmit; not
called for fresh or OOO segments.Source§fn rexmit_inconsistencies(&self) -> u64
fn rexmit_inconsistencies(&self) -> u64
rexmit_inconsistency). Default
0 for implementations that don’t retain enough history
to detect the divergence. Read more